/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f1eff8;
  --text: #1d1a2b;
  --muted: #6b6880;
  --border: #e3e0ee;
  --accent: #6d4aff;
  --accent-hover: #5a37f0;
  --accent-ink: #ffffff;
  --accent-soft: #eee9ff;
  --danger: #c43d3d;
  --warn-bg: #fff6df;
  --warn-text: #7a5200;
  --warn-border: #f1d58f;
  --fastest: #c26a00;
  --fastest-soft: #fff1de;
  --cheapest: #0f8a5f;
  --cheapest-soft: #e2f6ee;
  --balanced: #2f6bd8;
  --balanced-soft: #e5eefe;
  --pin-on: #16a34a;
  /* Board sections: Active is green, Planned is amber (kept apart from the --warn-* colours). */
  --active: #15803d;
  --active-soft: #f1faf4;
  --active-ink: #ffffff;
  --planned: #a16207;
  --planned-soft: #fefaef;
  --planned-ink: #ffffff;
  --planned-pin: #ca8a04;
  --tag-bg: #ecebf3;
  --tag-text: #4d4a5e;
  --tag-border: #dcd9e8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(20 16 40 / 0.05), 0 4px 16px rgb(20 16 40 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme. The head script in index.html sets data-theme before the page draws: the saved
   choice from the header button, otherwise the system's. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121019;
  --surface: #1b1824;
  --surface-2: #25212f;
  --text: #ece9f6;
  --muted: #a29db6;
  --border: #322d42;
  --accent: #9b85ff;
  --accent-hover: #ae9bff;
  --accent-ink: #130f1f;
  --accent-soft: #2a2347;
  --danger: #ff7b7b;
  --warn-bg: #2e2510;
  --warn-text: #f5d58a;
  --warn-border: #5a4818;
  --fastest: #ffb35c;
  --fastest-soft: #3a2a12;
  --cheapest: #4fd6a2;
  --cheapest-soft: #123228;
  --balanced: #82adff;
  --balanced-soft: #182a4a;
  --active: #4ade80;
  --active-soft: #15201b;
  --active-ink: #0b1f12;
  --planned: #f2c063;
  --planned-soft: #221d15;
  --planned-ink: #261c06;
  --tag-bg: #3a3550;
  --tag-text: #e6e2f3;
  --tag-border: #4d4766;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
/* Affection / currency icon in place of the word next to a number. */
.unit-icon { display: inline-block; width: 1.15em; height: 1.15em; margin: 0 1px; vertical-align: -0.22em; object-fit: contain; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .wrap { padding-inline: 24px; } }

/* ---------- Header + tabs ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding-block: 12px;
}
.brand { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); }

.tabs { margin-left: auto; display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab-count {
  min-width: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.75rem; line-height: 20px; text-align: center;
}

main.wrap { padding-block: 20px 32px; }
.site-footer { padding-block: 0 28px; font-size: 0.85rem; }
.site-footer p { margin: 0; }
.site-footer .footer-legal { margin-top: 4px; font-size: 0.78rem; }

/* ---------- Generic UI ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.empty { text-align: center; padding: 40px 20px; display: grid; gap: 10px; justify-items: center; }
.empty p { margin: 0; max-width: 46ch; }
.note { font-size: 0.85rem; margin: 12px 0 0; }
.section-title { margin: 22px 0 10px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 22px 0 10px; }
.section-head .section-title { margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.banner { border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 16px; }
.banner ul { margin: 6px 0 0; padding-left: 20px; }
.banner-warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-small { padding: 5px 10px; font-size: 0.85rem; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.08); }
/* Yes/no pop-up (confirmDialog). */
.confirm-dialog {
  max-width: min(400px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}
.confirm-dialog::backdrop { background: rgb(15 12 30 / 0.45); }
.confirm-message { margin: 0 0 18px; line-height: 1.45; }
.confirm-message p { margin: 0; }
.confirm-message p + p, .confirm-message ul { margin-top: 10px; }
.confirm-message ul { padding-left: 20px; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.btn.is-done, .btn:disabled { cursor: default; background: var(--surface-2); border-color: transparent; color: var(--muted); }

.icon-btn {
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }
.link-btn {
  border: 0; padding: 0; background: none;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.link-btn:hover { color: var(--accent); text-decoration: underline; }

.field { display: grid; align-content: start; gap: 4px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.field small { font-weight: 400; }
input, select {
  font: inherit; font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
  width: 100%;
}
input:disabled { opacity: 0.55; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.avatar {
  --hue: 260;
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
  color: hsl(var(--hue) 55% 32%);
  background: hsl(var(--hue) 75% 88%);
  position: relative;
  overflow: hidden;
}
.avatar-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--surface-2);
}
[data-theme="dark"] .avatar { color: hsl(var(--hue) 80% 85%); background: hsl(var(--hue) 35% 26%); }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

/* Gift tile: rarity colour at the bottom fading to black at the top, image on top. */
.gift-tile {
  position: relative;
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700; font-size: 1rem;
}
.gift-tile.has-rarity {
  background: linear-gradient(to top, var(--rarity), #000);
  color: rgb(255 255 255 / 0.85);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
}
/* The letter is only a fallback: hide it while an image is present (missing images are removed),
   so it can't show through transparent parts of the image. */
.gift-tile:has(.gift-tile-img) .tile-letter,
.avatar:has(.avatar-img) .tile-letter { visibility: hidden; }
.gift-tile-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.gift-tile-md { width: 52px; height: 52px; border-radius: 10px; font-size: 1.15rem; }
.gift-tile-lg { width: 68px; height: 68px; border-radius: 12px; font-size: 1.4rem; }

.stat-label { display: block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}
.badge-fastest { background: var(--fastest-soft); color: var(--fastest); }
.badge-cheapest { background: var(--cheapest-soft); color: var(--cheapest); }
.badge-balanced { background: var(--balanced-soft); color: var(--balanced); }
.badge-source { background: var(--tag-bg); color: var(--tag-text); box-shadow: inset 0 0 0 1px var(--tag-border); }

/* ---------- Characters tab ---------- */
.chars-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) {
  .chars-layout { grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
  .char-picker { position: sticky; top: 84px; max-height: calc(100vh - 104px); display: flex; flex-direction: column; }
}
.char-picker { padding: 12px; }
.char-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.char-detail .card + .card { margin-top: 0; }
.hide-maxed { margin-top: 8px; font-size: 0.82rem; }
.char-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; overflow-y: auto; }
@media (max-width: 899px) {
  .char-list { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 4px; }
}
.list-empty { padding: 8px; font-size: 0.9rem; }
.char-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.char-item:hover { background: var(--surface-2); }
.char-item.is-active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.char-item .avatar { width: 32px; height: 32px; font-size: 0.75rem; }
.char-item-name { flex: 1; font-weight: 600; }
.char-item.is-maxed .char-item-name { color: var(--muted); font-weight: 500; }
/* Which board the character is on: green pin for Active, yellow for Planned. */
.board-pin { display: inline-grid; place-items: center; flex: none; opacity: 0.6; }
.board-pin.is-active { color: var(--active); }
.board-pin.is-planned { color: var(--planned-pin); }

.detail-body { min-width: 0; display: grid; gap: 14px; }
/* The full-body image is a fixed size pinned to the top right, the same for everyone. The card's height comes
   from its content alone: a short card cuts the image off at the bottom, a tall one shows the strip below it. */
.detail-card { position: relative; padding: 0; overflow: hidden; }
/* Top part: the bond level and XP; bottom part: the daily plan. */
.bond-top { padding: 18px; }
.bond-plan { border-top: 1px solid var(--border); background: var(--surface-2); }
.bond-plan .plan-card { margin: 0; border: 0; border-radius: 0; background: transparent; padding: 14px 18px; }
.detail-card.has-full-body { --figure-w: 200px; --figure-h: 600px; padding-right: var(--figure-w); }
.detail-card.has-full-body::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: var(--figure-w);
  background: linear-gradient(180deg, var(--accent-soft), var(--surface-2));
}
.full-body {
  position: absolute; top: 0; right: 0; z-index: 1;
  width: var(--figure-w); height: var(--figure-h);
  object-fit: cover; object-position: var(--focus-x, 50%) top;
}
/* On phones the image stays beside the bond part only, and the daily plan below gets the full width. */
@media (max-width: 640px) {
  .detail-card.has-full-body { --figure-w: 80px; --figure-h: 240px; padding-right: 0; }
  .detail-card.has-full-body::after { content: none; }
  .has-full-body .bond-top { position: relative; overflow: hidden; padding-right: calc(var(--figure-w) + 18px); }
  .has-full-body .bond-top::after {
    content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: var(--figure-w);
    background: linear-gradient(180deg, var(--accent-soft), var(--surface-2));
  }
}
.detail-body h2 { font-size: 1.4rem; }
.level-line .reset-btn { width: 30px; height: 30px; }
.level-line .reset-btn svg { width: 15px; height: 15px; }

/* "Bond Lv 3 + [xp]/2,000 XP → Lv 8" */
.level-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; min-height: 34px; font-size: 1rem; color: var(--muted); }
.level-line strong { color: var(--text); font-variant-numeric: tabular-nums; }
.level-xp { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.level-xp[hidden] { display: none; }
.level-xp input { width: calc(6ch + 40px); padding: 4px 8px; text-align: right; font-weight: 700; }
.level-arrow { color: var(--accent); font-weight: 700; }

/* Bond level slider: two range inputs stacked on one thin track (current level and target level). */
.level-field { --thumb: 16px; }
/* The whole track takes clicks (they move the current level); pan-y keeps vertical page scrolling on touch. */
.level-slider { --from: 1; --to: 10; position: relative; height: 20px; cursor: pointer; touch-action: pan-y; }
.level-track {
  position: absolute; left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); top: 50%;
  height: 4px; transform: translateY(-50%);
  border-radius: 999px; background: var(--border);
}
.level-fill {
  position: absolute; top: 0; bottom: 0; border-radius: inherit; background: var(--accent);
  left: calc((var(--from) - var(--lo)) / (var(--hi) - var(--lo)) * 100%);
  right: calc((var(--hi) - var(--to)) / (var(--hi) - var(--lo)) * 100%);
}
.level-slider input[type="range"] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0;
  background: none; border: 0; box-shadow: none;
  -webkit-appearance: none; appearance: none;
  pointer-events: none; /* only the thumbs take clicks, so both handles can be grabbed */
}
.level-slider input[type="range"]:focus { box-shadow: none; }
.level-slider input[type="range"]::-webkit-slider-runnable-track { background: none; border: 0; }
.level-slider input[type="range"]::-moz-range-track { background: none; border: 0; }
.level-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto; cursor: grab;
  width: var(--thumb); height: var(--thumb); border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgb(20 16 40 / 0.25);
  transition: transform 0.12s;
}
.level-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto; cursor: grab;
  width: var(--thumb); height: var(--thumb); border-radius: 50%; box-sizing: border-box;
  background: var(--surface); border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgb(20 16 40 / 0.25);
}
.level-slider input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.15); }
/* The target handle is filled in so the two are easy to tell apart. */
.level-slider input[type="range"][data-field="target"]::-webkit-slider-thumb { background: var(--accent); }
.level-slider input[type="range"][data-field="target"]::-moz-range-thumb { background: var(--accent); }
.level-slider input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
/* At max level both handles overlap; keep the current-level handle on top so it can still be moved down. */
.level-slider.is-at-max [data-field="level"] { z-index: 1; }
.level-ticks {
  display: flex; justify-content: space-between;
  padding: 0 calc(var(--thumb) / 2 - 0.35em);
  font-size: 0.68rem; font-weight: 600; color: var(--muted);
}
.level-ticks span { width: 0.7em; text-align: center; }

.xp-summary { display: grid; gap: 6px; }
.xp-total { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.xp-total strong { color: var(--text); font-size: 1.05rem; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #ff7ac6)); transition: width 0.25s; }

.mode-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); padding: 3px; border-radius: var(--radius-sm); gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 0.9rem;
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.best-card {
  --mode: var(--accent); --mode-soft: var(--accent-soft);
  margin-top: 14px;
  display: grid; gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--mode-soft);
  border-left: 4px solid var(--mode);
}
.best-card.mode-fastest { --mode: var(--fastest); --mode-soft: var(--fastest-soft); }
.best-card.mode-cheapest { --mode: var(--cheapest); --mode-soft: var(--cheapest-soft); }
.best-card.mode-balanced { --mode: var(--balanced); --mode-soft: var(--balanced-soft); }
.best-card .stat-label { color: var(--mode); }
.best-card h3 { font-size: 1.15rem; }
.best-gifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.best-gifts li { display: flex; align-items: center; gap: 12px; min-width: 0; }
.best-gifts h3 { flex: 1; min-width: 0; }
.best-cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
.maxed-note { margin-top: 14px; }
.best-cards .best-card { margin-top: 0; align-content: start; }
.other-options > summary { display: inline-block; list-style: none; cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.other-options > summary::before { content: "▸ "; }
.other-options[open] > summary::before { content: "▾ "; }
.other-options > summary:hover { color: var(--mode, var(--accent)); }
.best-gifts li.tie-row { display: block; margin-top: -4px; }
.tie-list { display: grid; gap: 3px; margin-top: 4px; }
.tie-option {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 3px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: inherit; font: inherit; font-weight: 600; cursor: pointer;
}
.tie-option:hover { border-color: var(--mode, var(--accent)); }
.tie-option .gift-tile { width: 28px; height: 28px; }
.best-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.best-count { font-size: 1.05rem; color: var(--mode); font-variant-numeric: tabular-nums; }
.best-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 0.92rem; }
.best-stats strong { font-variant-numeric: tabular-nums; }
.best-note { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Daily plan: the character's mix of gifts, shown above the gift picks. */
.plan-card {
  display: grid; gap: 8px;
  padding: 14px 16px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.plan-card .stat-label { color: var(--accent); }
.plan-card p { margin: 0; }
.plan-card.is-empty .muted { font-size: 0.9rem; }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-gifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plan-gifts li { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 34px; }
.plan-gifts .plan-name { flex: 1; min-width: 0; }
.plan-stats { gap: 4px 6px; align-items: center; }
.plan-gifts .gift-tile { width: 32px; height: 32px; }
.plan-gifts strong { color: var(--accent); font-variant-numeric: tabular-nums; }

/* City hangout: one date a day, shown in the Daily plan and on Board cards. */
.hangout-tile { background: linear-gradient(to top, #c2417a, #3a0f24); color: #ffd6e7; display: inline-grid; place-items: center; }
.hangout-row { display: flex; align-items: center; gap: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.hangout-row .gift-tile { width: 40px; height: 40px; }
.hangout-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.hangout-text .gift-name { font-weight: 600; }
.hangout-text .muted { font-size: 0.82rem; }
.hangout-text .badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
/* Spot tags: green when the character's level has unlocked the spot, grey and dashed when not. */
.spot-tag.is-open { background: var(--cheapest-soft); color: var(--cheapest); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cheapest) 35%, transparent); }
.spot-tag.is-locked { background: transparent; color: var(--muted); border: 1px dashed var(--tag-border); padding: 0 7px; }
.hangout-row.is-locked .hangout-tile { filter: grayscale(0.8); opacity: 0.6; }

/* Results: the picks card, then the Daily extras card. */
.results { display: grid; gap: 16px; }
.daily-extras { display: grid; gap: 10px; }
.daily-extras .section-title { margin: 0; }
.daily-extras .hangout-row:first-of-type { padding-top: 0; border-top: 0; }

/* Full gift table, closed until opened. */
.all-gifts { margin-top: 16px; }
.all-gifts > summary {
  display: inline-block; list-style: none; cursor: pointer;
  font-size: 0.9rem; font-weight: 600; color: var(--muted);
}
.all-gifts > summary::-webkit-details-marker { display: none; }
.all-gifts > summary::before { content: "▸ "; }
.all-gifts[open] > summary::before { content: "▾ "; }
.all-gifts > summary:hover { color: var(--accent); }
.all-gifts > .section-head { margin-top: 12px; }

/* − count + for how many of a gift a character gets each day. */
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.step-btn {
  width: 30px; height: 30px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 1.05rem; font-weight: 700; line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.step-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.step-btn:disabled { opacity: 0.35; cursor: default; }
.step-btn.is-full, .pin-btn.is-full { opacity: 0.45; }
.step-count { min-width: 1.6em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.step-count.is-set { color: var(--accent); }

/* Square icon button (reset, and the daily gift's check mark: green when given). */
.pin-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pin-btn:hover { border-color: var(--accent); color: var(--accent); }
.pin-btn.is-pinned { background: var(--pin-on); border-color: var(--pin-on); color: #fff; }
.pin-btn.is-pinned svg { fill: currentColor; }
.pin-btn.is-pinned:hover { filter: brightness(1.08); }
.check-btn.is-pinned svg { fill: none; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.gift-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.gift-table th, .gift-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.gift-table tbody tr:last-child > * { border-bottom: 0; }
.gift-table thead th { background: var(--surface-2); padding: 0; vertical-align: bottom; }
.gift-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sort-btn {
  width: 100%;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px; border: 0; background: none;
  font: inherit; font-size: 0.74rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.03em;
  cursor: pointer; text-align: left; line-height: 1.25;
}
th.num .sort-btn { justify-content: flex-end; text-align: right; }
.sort-btn:hover { color: var(--text); }
.sort-arrow { font-size: 0.65rem; color: var(--accent); }
.gift-cell { font-weight: 600; min-width: 120px; }
.gift-cell-inner { display: flex; align-items: center; gap: 10px; }
/* Name on top, tags (pick badges, source) always on the line below. */
.gift-cell-inner > div { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.gift-table tr.is-best > * { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.gift-table tr.is-unbuyable td.num { color: var(--muted); }
.gift-table .empty-row { padding: 18px 12px; text-align: center; }
.gift-table .group-row th {
  padding: 6px 8px; border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.action-cell { text-align: right; white-space: nowrap; }

/* ---------- Board tab ---------- */
.summary { display: grid; gap: 18px; }
@media (min-width: 760px) { .summary { grid-template-columns: minmax(0, 1fr) auto; align-items: center; } }
.summary-main { display: grid; gap: 2px; }
.stat-hero { font-size: clamp(2.2rem, 7vw, 3rem); font-weight: 800; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.summary-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.summary-stats:has(.summary-select) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* On phones the life skill select takes its own row above the two stats. */
@media (max-width: 600px) {
  .summary-stats:has(.summary-select) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-stats .summary-select { grid-column: 1 / -1; }
}
.summary-select select { margin-top: 2px; padding: 3px 8px; font-weight: 700; font-size: 1rem; }
.summary-stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 0; }
.summary-stats dt { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.summary-stats dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-stats .of-limit { font-size: 0.85em; font-weight: 600; color: var(--muted); }
.summary-stats .is-over { background: var(--warn-bg); box-shadow: inset 0 0 0 1px var(--warn-border); }
.summary-stats .is-over dd, .summary-stats .is-over .of-limit { color: var(--warn-text); }
.summary .banner { grid-column: 1 / -1; margin: 0; }
@media (max-width: 480px) {
  .summary-stats div { padding: 8px 10px; }
  .summary-stats dd { font-size: 1rem; }
}
@media (max-width: 340px) { .summary-stats { grid-template-columns: 1fr; } }

.board-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 24px; }
.board-toolbar h2 { font-size: 1.1rem; }
.board-section { margin-top: 24px; }
/* Active and Planned each sit on a tinted panel so a card's board shows at a glance. */
.board-section[data-section="active"] { --section: var(--active); --section-soft: var(--active-soft); --section-ink: var(--active-ink); }
.board-section[data-section="planned"] { --section: var(--planned); --section-soft: var(--planned-soft); --section-ink: var(--planned-ink); }
.board-section[data-section="active"], .board-section[data-section="planned"] {
  padding: 14px; border-radius: var(--radius);
  background: var(--section-soft); border: 1px solid color-mix(in srgb, var(--section) 25%, transparent);
}
.board-section .board-toolbar { margin-top: 0; }
/* Planned and Completed titles hide or show their cards. */
.section-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; cursor: pointer;
}
.section-toggle:hover { color: var(--section, var(--accent)); }
.section-chevron { display: inline-block; width: 1em; font-size: 0.85em; color: var(--muted); }
/* Completed sits on a light grey panel. */
.board-section[data-section="completed"] {
  padding: 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--muted) 10%, var(--surface)); border: 1px solid var(--border);
}
@media (max-width: 480px) { .board-section[data-section="completed"] { padding: 12px; } }
/* Recommended: suggested plans for characters who don't have one yet. */
.rec-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.section-note { margin: 6px 0 0; font-size: 0.88rem; }
.rec-card { display: grid; gap: 12px; align-content: start; }
.rec-gifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rec-gifts li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.rec-gifts .gift-tile { width: 32px; height: 32px; }
.rec-gifts .gift-name { flex: 1; min-width: 0; }
.board-section[data-section] .section-count { background: var(--section, var(--surface-2)); color: var(--section-ink, var(--muted)); }
@media (max-width: 480px) {
  .board-section[data-section="active"], .board-section[data-section="planned"] { padding: 12px; }
}

.entries { display: grid; gap: 14px; margin-top: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.entries .card { margin: 0; }
.entry { display: grid; gap: 14px; align-content: start; }
.entry.is-maxed { opacity: 0.75; }
.entry-head { display: flex; align-items: center; gap: 12px; }
/* Drag, move and delete sit together in the card's top-right corner. */
.entry-actions { display: flex; align-self: flex-start; margin: -8px -10px 0 auto; }
.entry-actions .icon-btn { width: 30px; height: 30px; }
.entry-title { flex: 1; min-width: 0; }
.entry-title .muted { font-size: 0.85rem; }
.entry-title h3 { display: flex; align-items: center; gap: 4px; }
/* The name and its pencil are one button, so they highlight together. */
.name-link {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.name-link .edit-icon { display: inline-grid; place-items: center; flex: none; color: var(--muted); }
.name-link:hover, .name-link:hover .edit-icon { color: var(--accent); }
.name-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.drag-handle { cursor: grab; touch-action: none; }
.move-btn:hover { color: var(--accent); }
.entry-days { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.per-day { white-space: nowrap; }
.per-day .calendar-icon { margin-left: 0; }
.done-group { display: inline-flex; align-items: stretch; gap: 6px; }
/* Undo: a square bordered icon button, the same height as the button beside it. */
.btn.undo-btn { padding: 0; border: 1.5px solid var(--muted); color: var(--text); background: var(--surface); align-self: stretch; }
.btn.undo-btn.btn-small { width: 32px; min-height: 32px; }
.btn.undo-btn:not(.btn-small) { width: 43px; min-height: 43px; }
.btn.undo-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Light/dark switch in the header: shows the theme it switches to. */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; flex: none; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
/* Account (cloud sync): a guest icon or the Google avatar with a status dot, opening a small menu. */
.account { position: relative; flex: none; }
.account-btn {
  position: relative; display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.account-btn:hover { border-color: var(--accent); }
.account-btn.is-guest { background: var(--surface); color: var(--muted); }
.account-btn.is-guest:hover { color: var(--accent); }
.account-btn img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.account-dot {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg); background: var(--muted);
}
.account-btn.is-synced .account-dot { background: var(--active); }
.account-btn.is-error .account-dot { background: var(--danger); }
.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  width: max-content; max-width: min(280px, calc(100vw - 32px)); padding: 12px; display: grid; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.18);
}
.account-menu[hidden] { display: none; }
.account-menu p { margin: 0; }
.account-name { font-weight: 600; overflow-wrap: anywhere; }
.account-note { width: 240px; max-width: 100%; font-size: 0.85rem; line-height: 1.4; color: var(--muted); }
/* Google's neutral sign-in button style: G logo, plain surface, grey border. */
.google-signin {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.google-signin:hover { background: var(--surface-2); }
.google-signin svg { width: 18px; height: 18px; flex: none; }
.account-status { font-size: 0.85rem; color: var(--muted); }
.account-status.is-error { color: var(--danger); }
.account-menu .btn { justify-self: start; }
.region-select select:disabled { opacity: 0.6; cursor: not-allowed; }
.calendar-icon { color: var(--accent); }
.section-count { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: 0.8rem; color: var(--muted); vertical-align: 2px; }
.section-empty { margin: 12px 0 0; }
.region-select { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.region-select select { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.reset-timer { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.reset-timer strong { color: var(--text); }
.drag-handle:hover { color: var(--accent); }
.entry.is-dragging { opacity: 0.6; outline: 2px dashed var(--accent); outline-offset: 2px; }
.entry.is-dragging .drag-handle { cursor: grabbing; }
.entry-gifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.entry-gift { display: flex; align-items: center; gap: 10px; min-width: 0; }
.entry-gift .gift-tile { width: 44px; height: 44px; flex: none; }
/* The tile is a remove button: hovering shows a bin, and once armed (first click) it turns red. */
.tile-remove { position: relative; flex: none; padding: 0; border: 0; background: none; border-radius: 8px; cursor: pointer; line-height: 0; }
.tile-remove-icon {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 8px;
  background: rgb(20 16 40 / 0.55); color: #fff; opacity: 0; transition: opacity 0.12s, background 0.12s;
}
.tile-remove:hover .tile-remove-icon, .tile-remove:focus-visible .tile-remove-icon { opacity: 1; }
.tile-remove.is-armed .tile-remove-icon { opacity: 1; background: color-mix(in srgb, var(--danger) 88%, transparent); }
.entry-gift-text { flex: 1; display: grid; min-width: 0; }
.entry-gift-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.entry-gift .gift-name { font-weight: 600; min-width: 0; }
.entry-count { color: var(--accent); white-space: nowrap; }
.entry-gift .muted { font-size: 0.82rem; }
.entry-total {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0; padding: 7px 7px 7px 11px; border-radius: 8px; background: var(--accent-soft);
  font-size: 0.88rem; font-variant-numeric: tabular-nums;
}
.entry-total .btn { display: inline-flex; align-items: center; gap: 5px; }
.present-icon { color: var(--accent); }
.board-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.board-actions .btn-primary { display: inline-flex; align-items: center; gap: 6px; }
.entry-total strong { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  opacity: 0;
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--text); color: var(--bg);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.25);
  font-size: 0.92rem;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast-action {
  border: 0; background: none; padding: 0;
  font: inherit; font-weight: 700; color: var(--accent-soft);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.toast-action:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
