  :root {
    color-scheme: light;
    --page: #f2eef0;
    --surface: #fbf9f9;
    --surface-2: #ffffff;
    --border: rgba(29,20,23,0.12);
    --border-strong: rgba(29,20,23,0.20);
    --text-primary: #1d1417;
    --text-secondary: #6b5a5f;
    --text-muted: #958289;
    --accent: #7c2245;
    --accent-text: #7c2245;
    --accent-strong: #5c1834;
    --accent-soft: #f3dde6;
    --accent-ink: #ffffff;
    --gold: #93690f;
    --danger: #b3261e;
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
    --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #5598e7; --seq-4: #2a78d6; --seq-5: #1c5cab; --seq-6: #0d366b;
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --land: #e2d5da;
    --land-line: #bda6ae;
    --shadow: 0 1px 2px rgba(29,20,23,0.06), 0 6px 20px -10px rgba(29,20,23,0.25);
  }
  /* DARK TOKENS — keep byte-identical with the :root[data-theme="dark"] block below.
     Both are generated from one source; a verification step asserts they match. */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --page: #130d0f;
      --surface: #1c1315;
      --surface-2: #241a1d;
      --border: rgba(247,238,240,0.14);
      --border-strong: rgba(247,238,240,0.24);
      --text-primary: #f7eef0;
      --text-secondary: #c7b2b8;
      --text-muted: #94838a;
      --accent: #7c2245;
      --accent-text: #cfa15c;
      --accent-strong: #e8c07a;
      --accent-soft: rgba(124,34,69,0.45);
      --accent-ink: #ffffff;
      --gold: #d4a53c;
      --danger: #ff8a80;
      --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
      --series-5: #c4667f; --series-6: #4bbf4b; --series-7: #9085e9; --series-8: #e66767;
      --seq-1: #17273b; --seq-2: #1c3c62; --seq-3: #234f85; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #9ec5f4;
      --grid: #2c2c2a;
      --axis: #40393b;
      --land: #3d2f34;
      --land-line: #5c474d;
      --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -10px rgba(0,0,0,0.6);
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --page: #130d0f;
    --surface: #1c1315;
    --surface-2: #241a1d;
    --border: rgba(247,238,240,0.14);
    --border-strong: rgba(247,238,240,0.24);
    --text-primary: #f7eef0;
    --text-secondary: #c7b2b8;
    --text-muted: #94838a;
    --accent: #7c2245;
    --accent-text: #cfa15c;
    --accent-strong: #e8c07a;
    --accent-soft: rgba(124,34,69,0.45);
    --accent-ink: #ffffff;
    --gold: #d4a53c;
    --danger: #ff8a80;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #c4667f; --series-6: #4bbf4b; --series-7: #9085e9; --series-8: #e66767;
    --seq-1: #17273b; --seq-2: #1c3c62; --seq-3: #234f85; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #9ec5f4;
    --grid: #2c2c2a;
    --axis: #40393b;
    --land: #3d2f34;
    --land-line: #5c474d;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -10px rgba(0,0,0,0.6);
  }

  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--page);
    color: var(--text-primary);
    font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
  }
  .wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 64px; }

  /* header */
  .top {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; padding: 22px 0 14px; border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
  }
  .brand {
    display: flex; align-items: center; gap: 11px;
    background: none; border: none; padding: 0; cursor: pointer; text-align: left;
    font: inherit; color: inherit; border-radius: 6px;
  }
  .brand:hover .wm-main { color: var(--accent-text); }
  .brand:active { transform: translateY(1px); }
  .crest { width: 30px; height: 35px; flex-shrink: 0; }
  .crest svg { display: block; width: 100%; height: 100%; overflow: visible; }
  .crest-edge { fill: none; stroke: var(--accent-text); stroke-width: 1.5; }
  .crest-inner { fill: none; stroke: var(--accent-text); stroke-width: 0.6; opacity: 0.5; }
  .crest-mono {
    fill: var(--accent-text); font-family: Fraunces, Georgia, serif; font-weight: 600;
    font-size: 12.5px; letter-spacing: 0.08em;
  }
  .crest-dot { fill: var(--accent-text); opacity: 0.75; }

  .wordmark { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1; }
  .wm-top {
    font-family: Fraunces, Georgia, serif; font-style: italic; font-weight: 400;
    font-size: 12px; letter-spacing: 0.06em; color: var(--text-secondary);
  }
  .wm-rule { display: block; width: 100%; height: 1px; background: var(--border-strong); margin: 1px 0 2px; }
  .auth-brand .wm-top { font-size: 15px; }
  .auth-brand .wm-main { font-size: 22px; letter-spacing: 0.3em; }
  .wm-main {
    font-family: Fraunces, Georgia, serif; font-weight: 400; font-size: 16px;
    text-transform: uppercase; letter-spacing: 0.26em; color: var(--text-primary);
    white-space: nowrap; font-optical-sizing: auto;
  }
  @media (max-width: 380px){
    .wm-main { font-size: 14px; letter-spacing: 0.2em; }
    .wm-top { font-size: 11px; }
    .crest { width: 27px; height: 32px; }
  }

  .top-stat { font-size: 12px; }
  }
  .top-stat { font-size: 13px; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .top-stat b { color: var(--text-primary); font-weight: 700; }

  /* tabs */
  .tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; margin-bottom: 18px; }
  .tab-btn {
    flex: 1; border: none; background: transparent; color: var(--text-secondary);
    font: inherit; font-weight: 700; font-size: 13.5px; padding: 9px 10px; border-radius: 9px; cursor: pointer;
    letter-spacing: 0.01em;
  }
  .tab-btn[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
  .tab-panel[hidden] { display: none; }

  /* buttons & inputs */
  button { font: inherit; }
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2);
    color: var(--text-primary); font-weight: 700; font-size: 14px; padding: 10px 16px; cursor: pointer;
  }
  .btn:active { transform: translateY(1px); }
  .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
  .btn-block { width: 100%; }
  .btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
  .btn:focus-visible, .tab-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
  }

  .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
  .field-row { display: flex; gap: 10px; }
  .field-row > .field { flex: 1; min-width: 0; }
  label { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
  input[type="text"], input[type="number"], input[type="date"], select, textarea {
    font: inherit; font-size: 15px; padding: 10px 11px; border-radius: 9px;
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-primary); width: 100%;
  }
  textarea { resize: vertical; min-height: 56px; font-family: inherit; }
  .hint { font-size: 12px; color: var(--text-muted); margin: -8px 0 13px; line-height: 1.5; }
  .hint b { color: var(--text-secondary); }

  .card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
  .form-card { padding: 16px 16px 8px; margin-bottom: 20px; }
  .form-card .form-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
  .form-card .form-header .lbl { font-weight: 800; font-size: 15.5px; font-family: Fraunces, serif; }
  .form-card .form-body { padding-top: 12px; }
  .icon-btn {
    border: none; background: transparent; color: var(--text-muted); font-size: 20px; line-height: 1;
    cursor: pointer; padding: 4px 6px; border-radius: 8px;
  }
  .icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }

  .rating-row { display: flex; align-items: center; gap: 12px; }
  .rating-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 28px; }
  .rating-num {
    flex: 0 0 68px; width: 68px; text-align: center; font-family: Fraunces, serif; font-weight: 600;
    font-size: 18px; font-variant-numeric: tabular-nums; padding: 6px 4px;
  }

  /* search + quick add */
  .search-add-row { display: flex; gap: 8px; margin-bottom: 12px; }
  .search-add-row .searchbar { flex: 1; min-width: 0; position: relative; }
  .search-add-row .searchbar input { padding-right: 38px; }
  .search-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--border); color: var(--text-secondary); font-size: 18px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
  }
  .search-clear:hover { background: var(--border-strong); color: var(--text-primary); }
  .search-add-row .searchbar input { padding: 12px 14px; font-size: 15px; border-radius: 12px; }
  .btn-add {
    flex-shrink: 0; width: 46px; height: 46px; padding: 0; border-radius: 12px;
    font-size: 24px; font-weight: 600; line-height: 1;
  }
  .year-input { flex: 0 0 84px; width: 84px; text-align: center; font-size: 16px; }
  .search-tools { display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; }
  .dot-sep { color: var(--text-muted); font-size: 12px; }
  .section-head {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin: 16px 0 2px;
  }
  .results-section { margin-bottom: 4px; }
  .qa-card { padding: 16px 14px; margin-bottom: 14px; }
  .qa-row { display: flex; gap: 8px; margin-top: 4px; }
  .qa-row input { flex: 1; font-size: 16px; }
  #qaPaste { width: 100%; margin-top: 9px; min-height: 60px; resize: vertical; font-family: inherit; font-size: 14px; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-primary); }

  .qa-results { display: flex; flex-direction: column; margin-top: 4px; }
  .qa-result {
    display: flex; align-items: center; gap: 10px; padding: 10px 2px;
    border-bottom: 1px solid var(--border);
  }
  .qa-result:last-child { border-bottom: none; }
  .qa-result-info { flex: 1; min-width: 0; }
  .qa-result-name { font-family: Fraunces, serif; font-weight: 600; font-size: 15px; color: var(--text-primary); line-height: 1.25; }
  .qa-result-name .yr { color: var(--text-muted); font-weight: 500; }
  .qa-result-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.45; }
  .qa-result-producer { font-size: 12.5px; color: var(--text-secondary); font-weight: 700; }
  .qa-result-plain .qa-result-meta { color: var(--text-muted); font-style: italic; }
  .qa-result.in-log .qa-result-name { color: var(--accent-text); }
  .qa-result.in-log .qa-result-producer { color: var(--accent-text); opacity: 0.85; }
  .qa-result.in-log .qa-result-meta { opacity: 0.8; }
  .qa-result-check {
    flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
    background: transparent; border: 1.5px solid var(--accent-text); color: var(--accent-text);
    font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  }
  .verified { display: inline-flex; vertical-align: -2px; width: 15px; height: 15px; margin-left: 5px; }
  .verified svg { width: 100%; height: 100%; }
  .verified svg path { fill: var(--accent-text); }
  .verified svg polyline { fill: none; stroke: var(--surface); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

  /* inline rating on a log card */
  .inline-rate {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 14px 12px 17px; border-top: 1px solid var(--border); background: var(--surface-2);
  }
  .inline-rate .ir-slider { flex: 1 1 120px; min-width: 100px; accent-color: var(--accent); height: 26px; }
  .inline-rate .ir-num {
    flex: 0 0 64px; width: 64px; text-align: center; font-family: Fraunces, serif; font-weight: 600;
    font-size: 16px; font-variant-numeric: tabular-nums; padding: 5px 4px;
  }
  button.entry-score { border: none; cursor: pointer; font-family: inherit; }
  button.entry-score.untasted { padding: 4px 9px; }
  button.entry-score:hover { filter: brightness(1.08); }

  .qa-vintage-hint { font-size: 10.5px; color: var(--text-muted); text-align: right; max-width: 74px; line-height: 1.3; margin-right: 2px; }
  .qa-guess-tag {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 800;
    color: var(--accent-text); border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 6px; white-space: nowrap;
  }
  .qa-result-add {
    flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; border: none;
    background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 600; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
  }
  .qa-result-add:active { transform: translateY(1px); }
  .qa-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; gap: 10px; flex-wrap: wrap; }
  .link-btn {
    background: none; border: none; color: var(--accent-text); font-weight: 700; font-size: 12.5px;
    padding: 4px 0; cursor: pointer; text-align: left;
  }
  .qa-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 9px; line-height: 1.5; }

  .tasted-toggle {
    display: flex; align-items: center; gap: 8px; margin: 2px 0 15px; font-size: 13.5px;
    font-weight: 700; color: var(--text-primary); cursor: pointer;
  }
  .tasted-toggle input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }

  /* toolbar */
  .toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
  .search { flex: 1 1 140px; }
  .search input { padding: 8px 11px; font-size: 14px; }
  .chip-row { display: flex; gap: 6px; flex-wrap: wrap; overflow-x: auto; padding-bottom: 2px; }
  .chip {
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-secondary);
    border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
  }
  .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
  select.sortsel { width: auto; padding: 7px 10px; font-size: 13px; font-weight: 700; }

  /* entries */
  .entry-list { display: flex; flex-direction: column; gap: 10px; }
  .entry { border: 1px solid var(--border); background: var(--surface); border-radius: 14px; overflow: hidden; }
  .entry-head { display: flex; align-items: stretch; cursor: pointer; }
  .entry-bar { width: 5px; flex-shrink: 0; }
  .entry-main { flex: 1; min-width: 0; padding: 12px 12px 12px 11px; display: flex; flex-direction: column; gap: 4px; }
  .entry-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .entry-name { font-family: Fraunces, serif; font-weight: 600; font-size: 16.5px; line-height: 1.25; }
  .entry-name .yr { color: var(--text-muted); font-weight: 500; }
  .entry-score {
    font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px; flex-shrink: 0;
    background: var(--accent-soft); color: var(--accent-text); border-radius: 7px; padding: 2px 7px;
  }
  .entry-score.untasted {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 800;
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-strong);
  }
  .type-pill.pill-unknown { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-strong); }
  .entry-meta { font-size: 12.5px; color: var(--text-secondary); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .type-pill { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; }
  .entry-notes-preview { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .entry-detail { padding: 0 14px 16px 17px; display: none; border-top: 1px solid var(--border); }
  .entry.open .entry-detail { display: block; }
  .entry.open .entry-head { border-bottom: none; }
  .detail-block { margin-top: 12px; }
  .detail-block h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 800; }
  .detail-block p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-primary); white-space: pre-wrap; }
  .detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 11px 14px; margin-top: 12px; }
  .detail-grid h4 { margin: 0 0 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 800; }
  .detail-grid p { margin: 0; font-size: 13.5px; line-height: 1.35; color: var(--text-primary); }
  .detail-actions { display: flex; gap: 8px; margin-top: 16px; }

  .empty { text-align: center; padding: 46px 16px; color: var(--text-secondary); }
  .empty .mark { font-size: 34px; display: block; margin-bottom: 10px; }
  .empty h3 { font-family: Fraunces, serif; font-size: 18px; margin: 0 0 6px; color: var(--text-primary); }
  .empty p { margin: 0 auto 16px; max-width: 34ch; font-size: 13.5px; line-height: 1.6; }

  /* insights */
  .stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
  .stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 14px; }
  .stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
  .stat-value { font-family: Fraunces, serif; font-size: 26px; font-weight: 600; margin-top: 4px; }
  .stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

  .chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 14px 12px; margin-bottom: 18px; }
  .chart-card h3 { font-family: Fraunces, serif; font-weight: 600; font-size: 16px; margin: 0 0 2px; }
  .chart-card .chart-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
  .chart-card svg { display: block; width: 100%; height: auto; overflow: visible; }
  .legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; }
  .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); font-weight: 600; }
  .legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .axis-label { fill: var(--axis); font-size: 9.5px; font-family: Manrope, sans-serif; }
  .grid-line { stroke: var(--grid); stroke-width: 1; }
  .tick-label { fill: var(--text-muted); font-size: 9.5px; font-family: Manrope, sans-serif; }
  .bar-label { fill: var(--text-secondary); font-size: 10.5px; font-weight: 700; font-family: Manrope, sans-serif; }

  /* ranked region list */
  .rank-list { list-style: none; margin: 6px 0 0; padding: 0; }
  .rank-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); }
  .rank-row:last-child { border-bottom: none; }
  .rank-num { flex: 0 0 20px; font-size: 11.5px; font-weight: 800; color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .rank-name { flex: 1; min-width: 0; font-family: Fraunces, serif; font-weight: 600; font-size: 14.5px; color: var(--text-primary); }
  .rank-sub { font-family: Manrope, sans-serif; font-weight: 500; font-size: 12px; color: var(--text-muted); }
  .rank-count { flex: 0 0 auto; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
  .rank-score {
    flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 13px;
    background: var(--accent-soft); color: var(--accent-text); border-radius: 7px; padding: 2px 8px;
  }

  /* grape bars */
  .gbar-wrap { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
  .gbar-row { display: flex; flex-direction: column; gap: 4px; }
  .gbar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .gbar-label {
    min-width: 0; font-size: 13px; font-weight: 700; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .gbar-track { width: 100%; height: 12px; background: var(--grid); border-radius: 4px; overflow: hidden; }
  .gbar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
  .gbar-meta { flex: 0 0 auto; display: flex; gap: 9px; align-items: baseline; }
  .gbar-n { font-size: 12px; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
  .gbar-avg { font-size: 12.5px; font-weight: 800; color: var(--accent-text); font-variant-numeric: tabular-nums; }
  .gbar-untasted { color: var(--text-muted); font-weight: 600; }
  .chart-note { font-size: 11.5px; color: var(--text-muted); margin-top: 10px; }

  /* map */
  .map-wrap { position: relative; border-radius: 12px; overflow: hidden; background: var(--page); border: 1px solid var(--border); touch-action: none; }
  #mapSvg { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; }
  #mapSvg.grabbing { cursor: grabbing; }
  .map-pin { cursor: pointer; }
  .map-controls { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 5px; }
  .map-btn {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-primary); font-size: 15px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1;
  }
  .map-btn:hover { background: var(--surface-2); }

  .chart-empty { font-size: 13px; color: var(--text-muted); padding: 18px 4px; text-align: center; }

  .map-tip {
    position: relative; opacity: 0; pointer-events: none; transition: opacity .12s ease;
    background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 9px; padding: 7px 10px;
    font-size: 12px; box-shadow: var(--shadow); max-width: 190px; line-height: 1.4;
  }
  .map-tip b { display: block; font-size: 12.5px; margin-bottom: 1px; }
  .map-wrap { position: relative; }
  .map-tip-anchor { position: absolute; transform: translate(-50%, -100%); z-index: 5; }

  details.table-toggle { margin-top: 4px; }
  details.table-toggle summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--accent-text); padding: 6px 2px; }
  .table-scroll { overflow-x: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; }
  table.data-table { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
  table.data-table th, table.data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
  table.data-table th { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); }
  table.data-table tr:last-child td { border-bottom: none; }

  .banner { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 9px 12px; border-radius: 10px; margin-bottom: 14px; }
  .banner-info { background: var(--accent-soft); color: var(--accent-strong); }
  .banner-error { background: rgba(179,38,30,0.12); color: var(--danger); }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  .toast {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
    background: var(--accent); color: var(--accent-ink); font-size: 13.5px; font-weight: 700;
    padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 60;
    max-width: calc(100% - 32px); text-align: center;
  }
  .empty-inline { font-size: 13px; color: var(--text-muted); padding: 14px 2px; }

  .modal-overlay {
    position: fixed; inset: 0; background: rgba(11,7,8,0.5); display: flex; align-items: center;
    justify-content: center; padding: 20px; z-index: 50;
  }
  .modal-overlay[hidden] { display: none; }
  .modal-card {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
    padding: 20px; max-width: 340px; width: 100%;
  }
  .modal-card p { margin: 0 0 18px; font-size: 14.5px; line-height: 1.5; color: var(--text-primary); }
  .modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

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

  /* ── auth ───────────────────────────────────────────── */
  .auth-wrap { max-width: 340px; margin: 0 auto; padding: 12vh 20px 40px; }
  .auth-brand { display: flex; flex-direction: column; align-items: center; gap: 20px; margin-bottom: 44px; }
  .auth-brand .crest { width: 86px; height: 101px; }
  .auth-card { background: none; border: none; border-radius: 0; padding: 0; box-shadow: none; }
  .auth-eyebrow {
    font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.34em; font-weight: 700;
    color: var(--accent-text); margin: 0 0 10px; text-align: center;
  }
  .auth-card h2 {
    font-family: Fraunces, serif; font-weight: 400; font-size: 17px; margin: 0 0 6px;
    text-align: center; letter-spacing: 0.04em;
  }
  .auth-card .sub { font-size: 12px; color: var(--text-muted); margin: 0 0 26px; line-height: 1.6; text-align: center; }
  .auth-card label { font-size: 9.5px; letter-spacing: 0.16em; color: var(--text-muted); }
  .auth-card input {
    background: transparent; border: none; border-bottom: 1px solid var(--border-strong);
    border-radius: 0; padding: 9px 2px; font-size: 15px;
  }
  .auth-card input:focus { outline: none; border-bottom-color: var(--accent-text); }
  .auth-card .field { margin-bottom: 20px; gap: 3px; }
  .auth-card .btn-primary {
    border-radius: 999px; padding: 12px 16px; letter-spacing: 0.1em;
    text-transform: uppercase; font-size: 12px; margin-top: 6px;
  }
  .auth-switch { text-align: center; margin-top: 22px; font-size: 12px; color: var(--text-muted); }
  .auth-msg { font-size: 13px; padding: 10px 12px; border-radius: 9px; margin-bottom: 14px; line-height: 1.5; }
  .auth-msg.err { background: rgba(179,38,30,0.12); color: var(--danger); }
  .auth-msg.ok { background: var(--accent-soft); color: var(--accent-text); }

  /* ── account / friends ──────────────────────────────── */
  .acct-row { display: flex; align-items: center; gap: 10px; }
  .acct-btn {
    display: flex; align-items: center; gap: 5px; cursor: pointer;
    background: none; border: none; padding: 2px; border-radius: 999px;
  }
  .acct-btn .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent); color: var(--accent-ink);
    font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 12.5px;
    letter-spacing: 0.03em; border: 1px solid var(--accent);
  }
  .acct-btn .caret { color: var(--text-muted); font-size: 11px; line-height: 1; }
  .acct-btn[aria-expanded="true"] .avatar { box-shadow: 0 0 0 2px var(--accent-soft); }
  .acct-btn:hover .caret { color: var(--text-primary); }
  .icon-link { background: none; border: none; color: var(--accent-text); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 4px 2px; }
  .share-box { display: flex; gap: 8px; margin-top: 10px; }
  .share-box input { font-size: 13px; }
  .toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 13.5px; font-weight: 600; }
  .toggle-row input { width: 17px; height: 17px; accent-color: var(--accent); }

  .friend-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
  .friend-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .friend-name { font-family: Fraunces, serif; font-weight: 600; font-size: 16px; }
  .match-pct { font-family: Fraunces, serif; font-weight: 600; font-size: 22px; color: var(--accent-text); font-variant-numeric: tabular-nums; }
  .match-bar { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; margin: 10px 0 8px; }
  .match-fill { height: 100%; background: var(--accent); border-radius: 4px; }
  .match-note { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
  .shared-list { margin-top: 12px; }
  .shared-item { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 6px 0; border-top: 1px solid var(--border); }
  .shared-item .sn { color: var(--text-secondary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .shared-item .sr { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 700; white-space: nowrap; }

  /* ── AI lookup row ──────────────────────────────────── */
  .ai-row { border-top: 1px dashed var(--border-strong); }
  .ai-tag {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 800;
    color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px 7px; margin-left: 6px;
  }
  .ai-conf { font-size: 11px; color: var(--text-muted); }
  .ai-status { font-size: 12.5px; color: var(--text-muted); padding: 10px 2px; display: flex; align-items: center; gap: 8px; }
  .spinner {
    width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong);
    border-top-color: var(--accent-text); animation: spin .7s linear infinite; flex-shrink: 0;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .ai-warn { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }

  /* ── invites ────────────────────────────────────────── */
  .invite-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 2px; border-bottom: 1px solid var(--border);
  }
  .invite-row:last-child { border-bottom: none; }
  .invite-code {
    font-family: Fraunces, serif; font-weight: 600; font-size: 15px; letter-spacing: 0.08em;
    color: var(--accent-text);
  }
  .invite-meta { font-size: 11.5px; color: var(--text-muted); }
  .invite-used { opacity: 0.55; }
  .invite-used .invite-code { color: var(--text-muted); text-decoration: line-through; }

  /* ── ask-claude footer ──────────────────────────────── */
  .ask-foot { padding: 14px 2px 4px; border-top: 1px dashed var(--border-strong); margin-top: 4px; }
  .ask-foot p { margin: 0 0 9px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
