/* Shared light/dark tokens for ui-mock. Light values match the original mocks. */
:root, html[data-theme="light"] {
  --canvas: #f7f2ec;
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --surface-muted: #fbf7f1;
  --ink: #342f38;
  --ink-soft: #756d78;
  --line: #e2dad2;
  --line-strong: #75666f;
  --pink: #d98396;
  --pink-soft: #f8e6ea;
  --pink-strong: #9d4d61;
  --mint: #88afa0;
  --mint-soft: #e7f1ec;
  --mint-strong: #547c6f;
  --blue: #789ebd;
  --blue-soft: #e7eef4;
  --yellow-soft: #fbefcf;
  --warn-border: #c9a94a;
  --shadow: rgba(117, 102, 111, 0.32);
  --overlay: rgba(30, 25, 35, 0.3);
  --radius-small: 8px;
  --radius-medium: 12px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --canvas: #161318;
  --surface: #221e25;
  --surface-strong: #2b262e;
  --surface-muted: #1b171e;
  --ink: #f3ece7;
  --ink-soft: #b9aeb8;
  --line: #3f3846;
  --line-strong: #9a8e98;
  --pink: #e39aab;
  --pink-soft: #3a2830;
  --pink-strong: #f2b8c4;
  --mint: #8eb5a7;
  --mint-soft: #22332d;
  --mint-strong: #b0d4c5;
  --blue: #8fb2cb;
  --blue-soft: #22303a;
  --yellow-soft: #3a3420;
  --warn-border: #d2b45a;
  --shadow: rgba(0, 0, 0, 0.45);
  --overlay: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

:root {
  --color-canvas: var(--canvas);
  --color-surface: var(--surface);
  --color-surface-muted: var(--surface-muted);
  --color-text: var(--ink);
  --color-text-muted: var(--ink-soft);
  --color-border: var(--line);
  --color-border-strong: var(--line-strong);
  --color-accent: var(--pink);
  --color-accent-soft: var(--pink-soft);
  --color-accent-strong: var(--pink-strong);
  --color-success: var(--mint-strong);
  --color-success-base: var(--mint);
  --color-success-soft: var(--mint-soft);
  --color-info: var(--blue);
  --color-info-soft: var(--blue-soft);
  --color-warning-soft: var(--yellow-soft);
}

/* Dark-mode helpers for assets that stay colorful */
html[data-theme="dark"] img[src*="assets/res/"],
html[data-theme="dark"] img[src*="assets/items/"],
html[data-theme="dark"] img[src*="assets/icon_"] {
  background: #f7f2ec;
  border-radius: 6px;
  padding: 2px;
  box-sizing: content-box;
}
html[data-theme="dark"] .mapbox .base,
html[data-theme="dark"] img.map,
html[data-theme="dark"] .place .map {
  filter: brightness(0.92) contrast(1.05);
}
html[data-theme="dark"] .mapframe,
html[data-theme="dark"] .mapbox {
  background: #0e0c10;
}

/* Theme menu (injected) */
.theme-menu {
  position: absolute;
  right: 10px;
  top: 48px;
  width: min(260px, calc(100vw - 20px));
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 10px;
  z-index: 40;
  display: none;
}
.theme-menu.open { display: block; }
.theme-menu h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-soft);
}
.theme-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding: 8px 10px;
  margin: 0 0 4px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
}
.theme-menu button.on {
  background: var(--pink-soft);
  border-color: var(--pink-strong);
  color: var(--pink-strong);
}
.theme-menu .hint {
  margin: 6px 2px 0;
  font-size: 11px;
  color: var(--ink-soft);
}
header { position: relative; }

/* Warning chips: readable in both themes */
.badge.warn,
.chip.warn,
.tag.warn {
  border-color: var(--warn-border) !important;
  color: var(--ink) !important;
  background: var(--yellow-soft) !important;
}
html[data-theme="dark"] .badge.warn,
html[data-theme="dark"] .chip.warn {
  color: #f0e2a8 !important;
}

/* Menu hamburger bars follow ink */
header .menu i {
  background: var(--ink);
  box-shadow: 0 5px 0 var(--ink), 0 -5px 0 var(--ink);
}

/* Inputs / selects that still used white */
input, select, textarea, .inp, .ta, .sel, .filebtn {
  color: var(--ink);
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .inp,
html[data-theme="dark"] .ta,
html[data-theme="dark"] .sel {
  background: var(--surface-strong);
  border-color: var(--line-strong);
}

/* Bottom tabs / sample note */
.sample {
  background: var(--surface) !important;
  color: var(--ink-soft) !important;
  border-color: var(--line) !important;
}

/* Account block inside theme menu */
.theme-menu-sep {
  height: 1px;
  background: var(--line);
  margin: 8px 0 10px;
}
.theme-menu .auth-box {
  margin: 0 0 2px;
}
.theme-menu .auth-user {
  font-size: 13px;
  color: var(--ink);
  padding: 4px 2px 8px;
  word-break: break-all;
  line-height: 1.4;
}
.theme-menu .auth-msg {
  min-height: 0;
}
.theme-menu .auth-msg.auth-error {
  color: var(--pink-strong);
}
.theme-menu button[data-auth-login],
.theme-menu button[data-auth-logout] {
  margin-bottom: 4px;
}
.theme-menu button[disabled] {
  opacity: 0.55;
  cursor: default;
}
