/* ============================================================
   theme.css: Phase 4 shared theme. Loaded after main.css.
   Tokens, fonts, navigation, sheets, chips, charts, dashboard
   and the phone list all live here: no one-off styles in pages.
   ============================================================ */

@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/figtree-400.ttf') format('truetype'); }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/static/fonts/figtree-500.ttf') format('truetype'); }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/static/fonts/figtree-600.ttf') format('truetype'); }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/static/fonts/figtree-700.ttf') format('truetype'); }

:root {
  --bg:        #140f12;
  --surface:   #1a1317;
  --surface2:  #231a1f;
  --card:      #1a1317;
  --hair:      #261c21;
  --hair2:     #3a2c32;
  --border:    #261c21;
  --text:      #efe6e4;
  --muted:     #b3a4a8;
  --gold:      #d9b97a;
  --accent:    #e2557a;
  --primary:   #b8365b;
  --primary-h: #cf4569;
  --ready:     #8fd3a8;
  --young:     #b9aef5;
  --past:      #8a7d82;
  --pos:       #8fd3a8;
  --neg:       #e2557a;

  --t-red:       #c0405e;
  --t-white:     #e8d99a;
  --t-sparkling: #8fc9d6;
  --t-rose:      #f2a7bd;
  --t-dessert:   #d9893a;
  --t-fortified: #8c6b52;
  --t-orange:    #c9a27a;

  --font:       'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;

  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

body { font-family: var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); }
.serif { font-family: var(--font-serif); }
.at-cost { font-style: italic; opacity: .78; }

.show-phone-only { display: none; }
@media (max-width: 759px) {
  .show-phone-only { display: flex; }
  .desktop-only { display: none !important; }
}

/* ---------- Top bar (desktop) ---------- */
.nav { background: var(--bg); border-bottom: 1px solid var(--hair2); }
.nav-inner { min-height: 52px; padding: 0 1rem; }
.nav-logo { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; }
.nav-logo-text { letter-spacing: .02em; }
.nav-link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 .85rem;
  border-radius: 0; background: none !important; border-bottom: 2px solid transparent; }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); border-bottom-color: var(--accent); }
.nav-user { color: var(--muted); }
@media (max-width: 759px) {
  .nav { display: none; }
  body { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
  .main { padding-bottom: 1.5rem; }
}

/* ---------- Bottom tab bar (phone) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--hair2);
  align-items: stretch; justify-content: space-around;
}
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 44px; color: var(--muted); font: 500 .7rem/1.1 var(--font);
  background: none; border: 0; cursor: pointer; text-decoration: none; position: relative;
}
.tabbar .tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
.tabbar .tab.active { color: var(--text); }
.tabbar .tab.active::before { content: ''; position: absolute; top: 0; width: 28px; height: 2px;
  background: var(--accent); }
.tabbar .tab--scan { color: var(--text); }
.tabbar .scan-circle {
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #140f12;
  display: flex; align-items: center; justify-content: center;
  margin-top: -26px; box-shadow: 0 4px 14px rgba(0,0,0,.55), 0 0 0 4px var(--surface);
}
.tabbar .scan-circle svg { width: 26px; height: 26px; }
.tabbar .tab--scan span.lbl { margin-top: 1px; }

/* ---------- Sheets (bottom sheet on phone, centred panel on desktop) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--hair2); border-radius: 18px 18px 0 0;
  padding: 1.1rem 1.1rem calc(1.1rem + var(--safe-b));
}
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .8rem; }
.sheet-title { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 600; }
.sheet-link { color: var(--accent); background: none; border: 0; font: 500 .95rem var(--font);
  min-height: 44px; padding: 0 .25rem; cursor: pointer; }
.sheet-list a { display: flex; align-items: center; justify-content: space-between; min-height: 52px; color: var(--text);
  border-top: 1px solid var(--hair); font-size: 1.05rem; padding: .35rem 0; }
.sheet-list a::after { content: ''; width: .5rem; height: .5rem; border: solid var(--muted); border-width: 2px 2px 0 0; transform: rotate(45deg); margin-right: .25rem; flex: none; }
.sheet-list a small { display: block; color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.sheet-list a.on { color: var(--accent); }
.sheet-group { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .15rem; }
.sheet-group:first-child { margin-top: 0; }
@media (min-width: 760px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 14px; }
}

/* ---------- Chips and segments ---------- */
.chip { display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 1rem; border-radius: 22px; border: 1px solid var(--hair2); background: transparent;
  color: var(--muted); font: 500 .9rem var(--font); cursor: pointer; text-decoration: none; }
.chip:hover { color: var(--text); }
.chip.on, .chip[aria-pressed="true"] { background: rgba(226,85,122,.16); border-color: var(--accent); color: var(--text); }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg { display: flex; border: 1px solid var(--hair2); border-radius: 10px; overflow: hidden; }
.seg > a, .seg > button { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 0 .5rem; color: var(--muted); background: none; border: 0;
  border-right: 1px solid var(--hair2); font: 500 .9rem var(--font); text-decoration: none; cursor: pointer; }
.seg > :last-child { border-right: 0; }
.seg > .on { background: rgba(226,85,122,.16); color: var(--text); }

/* ---------- Placeholder / empty states ---------- */
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty-state p { margin-bottom: 1rem; }

/* ============================================================
   My Cellar list: phone layout, filters sheet, active-filter chips
   ============================================================ */
@media (max-width: 759px) {
  .totals-strip, .cellar-table-wrap { display: none; }
}
.fchips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.fchip { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .85rem;
  border-radius: 22px; background: rgba(226,85,122,.14); border: 1px solid var(--accent);
  color: var(--text); font-size: .88rem; text-decoration: none; }
@media (min-width: 760px) { .fchip { min-height: 32px; } }
.resume-line { margin-bottom: .75rem; }

.plist-title { display: flex; align-items: center; justify-content: space-between; padding-top: .35rem; }
.plist-title h1 { font-family: var(--font-serif); font-weight: 600; font-size: 2.3rem; line-height: 1.1; }
.icon-btn { position: relative; width: 44px; height: 44px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 12px; border: 1px solid var(--hair2); background: var(--surface);
  color: var(--text); cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
.badge-n { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--accent); color: #140f12; font: 700 .72rem/20px var(--font);
  text-align: center; }

.plist-search { position: sticky; top: 0; z-index: 40; background: var(--bg); padding: .55rem 0;
  margin-top: .35rem; }
.plist-search input { width: 100%; height: 44px; padding: 0 .9rem 0 2.6rem; border-radius: 12px;
  border: 1px solid var(--hair2); background: var(--surface); color: var(--text); font: 400 1rem var(--font); }
.plist-search svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); width: 20px; height: 20px;
  stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.ploc { margin: .35rem 0 .2rem; }
.ptabs { display: flex; align-items: flex-end; border-bottom: 1px solid var(--hair2); margin-top: .4rem; }
.ptabs a { padding: .75rem 0 .5rem; margin-right: 1.1rem; min-height: 44px; display: inline-flex; align-items: flex-end;
  color: var(--muted); font: 600 .72rem var(--font); letter-spacing: .12em; text-transform: uppercase;
  border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.ptabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.psum { margin-left: auto; padding-bottom: .55rem; color: var(--muted); font-size: .85rem; white-space: nowrap; }

.pbodywrap { margin-top: .6rem; }
.pband { width: calc(100% + 2rem); margin: .9rem -1rem 0; padding: .55rem 1rem; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; text-align: left; cursor: pointer;
  background: var(--surface); border: 0; border-bottom: 2px solid var(--accent); color: var(--text); }
.pband-text { display: flex; flex-direction: column; }
.pband-name { font-family: var(--font-serif); font-weight: 600; font-size: 28px; line-height: 1.15; }
.pband-meta { color: var(--muted); font-size: .8rem; margin-top: 1px; }
.chev { width: 24px; height: 24px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; transition: transform .15s; flex-shrink: 0; }
.pband[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.pcountry.collapsed .pcountry-body { display: none; }
.preg { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: 1rem 0 .25rem; }
.preg-name { color: var(--gold); font: 600 .78rem var(--font); letter-spacing: .14em; text-transform: uppercase; }
.preg-sub { color: var(--muted); font-size: .8rem; }
.papp { font-family: var(--font-serif); font-style: italic; font-size: 21px; line-height: 1.2; padding: .6rem 0 .1rem; }
.prow { display: grid; grid-template-columns: 3.3rem 1fr auto; gap: .6rem; align-items: start; min-height: 56px;
  padding: .55rem 0; border-bottom: 1px solid var(--hair); color: var(--text); text-decoration: none; }
.prow:active { background: var(--surface); }
.prow-vin { font-family: var(--font-serif); font-weight: 600; font-size: 25px; line-height: 1.1; color: var(--gold); }
.prow-mid { min-width: 0; display: flex; flex-direction: column; }
.prow-prod { font-weight: 600; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.prow-sub { color: var(--muted); font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.prow-right { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.prow-price { font-weight: 600; font-size: 16px; }
.prow-qty { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; white-space: nowrap; }
.prow-score { font-family: var(--font-serif); font-weight: 600; font-size: 22px; color: var(--gold); line-height: 1.1; }
.mk { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }
.mk--ready { background: var(--ready); }
.mk--peak  { background: var(--gold); }
.mk--young { border: 2px solid var(--young); }
.mk--past  { border: 2px solid var(--past); }
.pkey { color: var(--muted); font-size: .78rem; margin: 1.2rem 0 .5rem; }

/* filters sheet */
.fset { border: 0; margin: 0 0 1rem; min-width: 0; }
.fset legend, .fset > label { color: var(--gold); font: 600 .74rem var(--font); letter-spacing: .13em;
  text-transform: uppercase; margin-bottom: .45rem; display: block; padding: 0; }
.fset > label, .fset--2 > label { color: var(--muted); letter-spacing: .06em; text-transform: none; font-size: .82rem; }
.fset--2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.sheet .filter-select { width: 100%; min-height: 44px; margin-top: .3rem; background: var(--bg);
  border: 1px solid var(--hair2); color: var(--text); border-radius: 10px; padding: 0 .7rem; font-size: 1rem; }
.chipbox { position: relative; }
.chipbox input { position: absolute; opacity: 0; pointer-events: none; }
.chipbox input:checked + .chip { background: rgba(226,85,122,.16); border-color: var(--accent); color: var(--text); }
.chipbox input:focus-visible + .chip { outline: 2px solid var(--gold); outline-offset: 2px; }
.segbox label { flex: 1; position: relative; border-right: 1px solid var(--hair2); }
.segbox label:last-child { border-right: 0; }
.segbox input { position: absolute; opacity: 0; pointer-events: none; }
.segbox span { display: flex; align-items: center; justify-content: center; min-height: 44px; color: var(--muted);
  font: 500 .9rem var(--font); cursor: pointer; text-align: center; padding: 0 .4rem; }
.segbox input:checked + span { background: rgba(226,85,122,.16); color: var(--text); }
.segbox input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: -2px; }
.btn-wide { width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--accent);
  color: #140f12; font: 700 1rem var(--font); cursor: pointer; margin-top: .4rem; }
.sheet .btn-wide { position: sticky; bottom: 0; box-shadow: 0 -14px 12px -2px var(--surface); }

/* ============================================================
   Dashboard
   ============================================================ */
.dash { max-width: 1100px; margin: 0 auto; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.dash-title { font-family: var(--font-serif); font-weight: 600; font-size: 3rem; line-height: 1.05; }
.dash-sub { color: var(--muted); margin-top: .25rem; }
.dash-controls { display: flex; flex-wrap: wrap; gap: .6rem; }
.dash-controls .seg { min-width: 0; }
.dash-controls .seg button { padding: 0 .9rem; white-space: nowrap; }
.dash-tabs { display: flex; gap: 1.4rem; border-bottom: 1px solid var(--hair2); margin-bottom: 1.2rem; }
.dash-tabs a { padding: .8rem 0 .55rem; min-height: 44px; color: var(--muted); font: 600 .78rem var(--font);
  letter-spacing: .13em; text-transform: uppercase; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.dash-tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.dash-loading, .chart-empty { color: var(--muted); padding: 1rem 0; }
.panel[hidden] { display: none; }
@media (max-width: 759px) {
  .dash-title { font-size: 2.4rem; }
  .dash-controls { width: 100%; }
  .dash-controls .seg { width: 100%; }
}

/* headline numbers */
.heads { margin-bottom: 1.2rem; }
.big3, .small3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.big3 { border-top: 1px solid var(--hair2); border-bottom: 1px solid var(--hair2); }
.small3 { border-bottom: 1px solid var(--hair2); }
.tile { display: flex; flex-direction: column; padding: 1rem 1rem 1rem 0; color: var(--text); text-decoration: none; min-width: 0; }
.tile + .tile { padding-left: 1.2rem; border-left: 1px solid var(--hair); }
.tile-label { color: var(--gold); font: 600 .72rem var(--font); letter-spacing: .13em; text-transform: uppercase; }
.tile-num { font-family: var(--font-serif); font-weight: 500; font-size: 3.75rem; line-height: 1.05; margin-top: .2rem; overflow-wrap: anywhere; }
.small3 .tile-num { font-size: 2.3rem; }
.tile-sub { color: var(--muted); font-size: .88rem; margin-top: .2rem; }
.tile.pos .tile-num, .tile.pos .tile-sub { color: var(--pos); }
.tile.neg .tile-num, .tile.neg .tile-sub { color: var(--neg); }
@media (max-width: 759px) {
  .heads { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
  .big3, .small3 { display: contents; }
  .tile, .tile + .tile { background: var(--surface); border: 1px solid var(--hair2); border-radius: 12px; padding: .8rem .9rem; }
  .tile-num, .small3 .tile-num { font-size: 2rem; }
  .tile-sub { font-size: .8rem; }
}

/* ruled sections */
.sec { border-top: 2px solid var(--accent); padding-top: .8rem; margin-top: 1.8rem; }
.sec-h { color: var(--gold); font: 600 .78rem var(--font); letter-spacing: .14em; text-transform: uppercase; margin-bottom: .9rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.two > .sec { min-width: 0; }
@media (max-width: 759px) {
  .two { grid-template-columns: 1fr; gap: 0; }
  .sec--style { background: var(--surface); border: 1px solid var(--hair2); border-top: 2px solid var(--accent); border-radius: 12px; padding: .9rem; }
}
.note { color: var(--muted); font-size: .82rem; margin-top: .6rem; }
.dash-foot { color: var(--muted); font-size: .8rem; margin: 2rem 0 1rem; border-top: 1px solid var(--hair2); padding-top: .8rem; }

/* phone-only breakdown card */
.pcard { display: none; }
@media (max-width: 759px) {
  .pcard { display: block; background: var(--surface); border: 1px solid var(--hair2); border-radius: 12px; padding: .9rem; margin-top: .8rem; }
  .chip-scroll { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: .7rem; padding-bottom: .2rem; }
  .chip-scroll .chip { flex-shrink: 0; }
}

/* stacked bar and legend */
.stack { display: flex; height: 30px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--hair); }
.stack-seg { display: block; min-width: 3px; }
.legend { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; margin-top: .9rem; }
.legend a { display: flex; align-items: center; gap: .6rem; min-height: 44px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--hair); }
.sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.lg-l { flex: 1; }
.lg-v { color: var(--muted); font-size: .9rem; white-space: nowrap; }
@media (max-width: 759px) { .legend { grid-template-columns: 1fr; } }

/* geography */
.geo { column-count: 2; column-gap: 2.5rem; }
.geo-c { break-inside: avoid; margin-bottom: 1.4rem; }
.geo-ch { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; min-height: 44px; border-bottom: 1px solid var(--hair2); color: var(--text); text-decoration: none; }
.geo-name { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 600; }
.geo-stat { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.geo-r { display: flex; justify-content: space-between; gap: .8rem; min-height: 44px; align-items: center; padding-left: 1.1rem; color: var(--muted); border-bottom: 1px solid var(--hair); text-decoration: none; }
.geo-r:hover, .geo-ch:hover { color: var(--text); }
@media (max-width: 759px) { .geo { column-count: 1; } .geo-name { font-size: 1.5rem; } .geo-stat { white-space: normal; text-align: right; } }

/* horizontal bars */
.hb { list-style: none; }
.hb-row { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr auto; gap: .8rem; align-items: center; min-height: 44px; color: var(--text); text-decoration: none; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 14px; background: var(--hair); border-radius: 3px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.hb-val { color: var(--muted); font-size: .9rem; min-width: 2.2rem; text-align: right; }
@media (max-width: 759px) { .hb-row { grid-template-columns: minmax(5rem, 8rem) 1fr auto; gap: .5rem; } }

/* columns */
.cols { display: flex; align-items: flex-end; gap: 4px; }
.cols--scroll { overflow-x: auto; padding-bottom: .3rem; }
.col { flex: 1 1 0; min-width: 34px; display: flex; flex-direction: column; align-items: center; color: var(--muted); text-decoration: none; font-size: .72rem; }
.col-val { height: 1.3em; font-size: .72rem; color: var(--text); white-space: nowrap; }
.col-wrap { height: 150px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col-bar { display: flex; flex-direction: column; width: 70%; max-width: 40px; min-height: 0; background: var(--accent); border-radius: 3px 3px 0 0; overflow: hidden; }
.col-bar--gold { background: var(--gold); }
.col-bar:has(.part) { background: none; }
.part { display: block; background: var(--accent); min-height: 0; }
.part--cost { background: color-mix(in srgb, var(--accent) 40%, var(--bg)); }
.col-lab { margin-top: .35rem; min-height: 2.4em; text-align: center; line-height: 1.2; }
.col:hover .col-lab { color: var(--text); }

/* classification */
.klass-row { margin-bottom: 1.2rem; }
.klass-name { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; margin-bottom: .4rem; }
.klass-key { color: var(--muted); font-size: .82rem; margin-top: .45rem; }
.klass-key a { color: var(--muted); }

.edit-buckets { margin-top: .6rem; font-size: .85rem; color: var(--muted); }
.edit-buckets summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.edit-buckets label { display: block; margin-bottom: .4rem; }
.edit-buckets input { display: block; width: 100%; min-height: 44px; margin-top: .3rem; background: var(--bg); border: 1px solid var(--hair2); color: var(--text); border-radius: 8px; padding: 0 .7rem; }

.dash .tile-num { color: var(--text); }
.dash .tile.pos .tile-num { color: var(--pos); }
.dash .tile.neg .tile-num { color: var(--neg); }

/* drinking history */
.year-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; margin-bottom: 1rem; }
.recent { list-style: none; }
.recent a { display: grid; grid-template-columns: 3.6rem 1fr auto; gap: .7rem; align-items: start; min-height: 56px; padding: .6rem 0; border-bottom: 1px solid var(--hair); color: var(--text); text-decoration: none; }
.rc-date { color: var(--muted); font-size: .85rem; padding-top: .15rem; }
.rc-mid { display: flex; flex-direction: column; min-width: 0; }
.rc-name { font-weight: 600; overflow-wrap: anywhere; }
.rc-sub { color: var(--muted); font-size: .85rem; }
.rc-score { font-family: var(--font-serif); font-weight: 600; font-size: 1.5rem; color: var(--gold); line-height: 1.1; }
@media (max-width: 759px) {
  .year-chips { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: .3rem; }
  .year-chips .chip { flex-shrink: 0; }
}

.backlink { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 500; text-decoration: none; }

.lab-short { display: none; }
@media (max-width: 759px) { .lab-full { display: none; } .lab-short { display: inline; } }
.sortdir { margin-top: .6rem; }

/* ============================================================
   Import (Phase 5): upload, column mapping, preview
   ============================================================ */

.imp-form { display: flex; flex-direction: column; gap: 1rem; max-width: 40rem; }
.imp-note { margin-top: .75rem; }
.imp-h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
.imp-drafts { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.imp-drafts li { display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
.imp-map-row { display: grid; grid-template-columns: 1fr; gap: .25rem; padding: .5rem 0; border-top: 1px solid var(--hair); }
.imp-sample { color: var(--muted); font-size: .8rem; min-height: 1.1em; overflow-wrap: anywhere; }
.imp-check { display: flex; gap: .5rem; align-items: flex-start; margin-top: .75rem; }
.imp-bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + .5rem); padding: .5rem 0; }
.imp-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
.imp-stat { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: .6rem .8rem; display: flex; flex-direction: column; }
.imp-stat strong { font-size: 1.4rem; }
.imp-stat span { color: var(--muted); font-size: .8rem; }
.imp-stat--bad strong { color: var(--neg); }
.imp-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.imp-rows { display: grid; grid-template-columns: 1fr; gap: .75rem; margin-bottom: 1.5rem; }
.imp-row { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--ready); border-radius: 12px; padding: .75rem .9rem; min-width: 0; }
.imp-row--warn { border-left-color: var(--gold); }
.imp-row--err { border-left-color: var(--neg); }
.imp-row-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .3rem; }
.imp-row-num { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.imp-row-name { font-weight: 600; overflow-wrap: anywhere; }
.imp-facts { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin: .5rem 0 0; }
.imp-facts dt { color: var(--muted); font-size: .72rem; }
.imp-facts dd { margin: 0; }
.imp-problems { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.imp-problem { font-size: .85rem; }
.imp-problem--error { color: var(--neg); }
.imp-problem--warning { color: var(--gold); }
@media (min-width: 760px) {
  .imp-map-row { grid-template-columns: 16rem 1fr 1fr; align-items: center; gap: .75rem; }
  .imp-stats { grid-template-columns: repeat(4, 1fr); }
  .imp-bar { position: static; }
}

.imp-edit { margin-left: auto; }
.imp-bulk { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: .6rem .9rem; margin: .75rem 0 1rem; }
.imp-bulk summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.imp-bulk form { margin-top: .75rem; }
.imp-edit-problems { margin-bottom: 1rem; }

.imp-h3 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--gold); }
.imp-diff { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: .75rem .9rem; margin: .75rem 0 1rem; }
.imp-diff .imp-h2 { margin-top: 0; }
.imp-diff-counts { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.imp-diff-item { border-top: 1px solid var(--hair); padding: .6rem 0; }
.imp-changes { margin: .3rem 0 0 1.6rem; padding: 0; font-size: .9rem; }
.chip--warn { color: var(--gold); }

/* Wine page lots: one stacked card per lot on phones, so a due-in lot with an ETA and the
   action buttons never push the table wider than the screen. */
@media (max-width: 759px) {
  .lots-table, .lots-table tbody { display: block; width: 100%; }
  .lots-table thead { display: none; }
  .lots-table tr { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; padding: .65rem .85rem;
    border-top: 1px solid var(--hair); }
  .lots-table td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .lots-table td[data-label]::before { content: attr(data-label); display: block;
    color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
  .lots-table td:last-child { flex-basis: 100%; }
  .lots-table tr.lot-origin-row { padding-top: 0; border-top: 0; }
  .lots-table tr:hover td { background: none; }
}

/* Delete / restore */
.danger-zone { margin: 2rem 0 1rem; padding: 1rem; border: 1px solid var(--hair2); border-radius: 12px; }
.danger-title { font-size: 1rem; color: var(--neg); margin-bottom: .4rem; }
.danger-zone form { margin-top: .75rem; }
.delete-banner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.delete-banner form { margin: 0; }
.trash-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.5rem; }
.trash-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: .6rem .8rem; }
.trash-list form { margin: 0; }

.imp-more { margin-top: .75rem; border-top: 1px solid var(--hair); padding-top: .6rem; }
.imp-more summary { cursor: pointer; font-weight: 600; min-height: 32px; line-height: 1.3; }

.viewer-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.viewer-actions form { margin: 0; }

/* Check stock */
.chk-bar { display: flex; flex-direction: column; gap: .75rem; margin: 1rem 0; max-width: 32rem; }
.chk-tally { color: var(--muted); margin: .5rem 0; }
.chk-results { display: flex; flex-direction: column; gap: .9rem; margin-bottom: 4rem; }
.chk-card { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--gold);
  border-radius: 12px; padding: .8rem .9rem; min-width: 0; }
.chk-card--done { border-left-color: var(--ready); }
.chk-head { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .6rem; }
.chk-thumb { width: 64px; max-height: 88px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.chk-title { min-width: 0; }
.chk-name { font-weight: 600; overflow-wrap: anywhere; }
.chk-here { margin: .25rem 0 .6rem; }
.chk-qty { max-width: 8rem; font-size: 1.2rem; }
.chk-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.chk-summary { margin: .4rem 0 0; padding-left: 1.2rem; }
.chk-more { margin-top: .75rem; border-top: 1px solid var(--hair); padding-top: .5rem; }
.chk-more summary { cursor: pointer; min-height: 32px; }
.chk-others { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .5rem; }
.chk-pick { background: var(--surface2); color: var(--text); border: 1px solid var(--hair2); border-radius: 999px;
  padding: .25rem .7rem; margin: .15rem .2rem .15rem 0; min-height: 36px; cursor: pointer; }
.chk-search { display: flex; gap: .5rem; margin-top: .5rem; }
.chk-search .form-input { flex: 1; min-width: 0; }
.chk-hint { margin-top: .6rem; }

.chk-status { position: sticky; top: .5rem; z-index: 5; background: var(--surface2); border: 1px solid var(--hair2);
  border-radius: 999px; padding: .35rem .9rem; margin: .5rem 0; width: fit-content; font-size: .9rem; }
.chk-card--reading { border-left-color: var(--hair2); opacity: .85; }
.chk-card--reading .chk-name::after { content: ''; display: inline-block; width: .9em; height: .9em; margin-left: .5em;
  border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; vertical-align: -.1em;
  animation: chk-spin .8s linear infinite; }
@keyframes chk-spin { to { transform: rotate(360deg); } }

.imp-missing { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin: .5rem 0 .75rem; }
.imp-missing form { margin: 0; }

/* Stocktake */
.st-progress { margin: .5rem 0 1rem; }
.st-bar { height: 10px; border-radius: 999px; background: var(--surface2); overflow: hidden; margin-bottom: .4rem; }
.st-bar span { display: block; height: 100%; background: var(--ready); border-radius: 999px; }
.st-round { margin: 0 0 1rem; }
.st-round summary { cursor: pointer; color: var(--muted); min-height: 32px; }
.st-form { display: flex; gap: .5rem; align-items: center; margin-top: .4rem; }
.st-qty { max-width: 6.5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chk-modes { display: flex; gap: .5rem; margin: .25rem 0 1rem; }
.chk-mode { padding: .45rem 1rem; border-radius: 999px; border: 1px solid var(--hair2); color: var(--muted);
  text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
.chk-mode--on { background: var(--primary); color: var(--text); border-color: var(--primary); }
.chk-undo-form { margin-top: .5rem; }

/* Tasting history: its own look (gold, not the cellar's pink) so it reads as a separate place */
.tasting { --primary: #8f7430; --primary-h: #a8893a; --accent: var(--gold); }
.tasting .page-title { color: var(--gold); }
.tst-banner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--gold); padding-bottom: .6rem; margin-bottom: .8rem; }
.tst-banner .page-title { margin: 0; }
.tst-sub { margin: .15rem 0 0; color: var(--muted); }
.tst-note { max-width: 40rem; }
.tst-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0; }
.tst-chip { padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--hair2); color: var(--muted);
  text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
.tst-chip--on { background: var(--primary); border-color: var(--primary); color: var(--text); }
.tst-more { margin: .25rem 0 1rem; }
.tst-more summary { cursor: pointer; color: var(--muted); min-height: 32px; }
.tst-h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; color: var(--gold); }
.tst-h3 { font-size: .95rem; margin: 0 0 .5rem; }
.tst-grid { display: grid; grid-template-columns: 1fr; gap: .75rem; margin: 1rem 0; }
.tst-box { background: var(--surface); border: 1px solid var(--hair); border-top: 2px solid var(--gold); border-radius: 12px; padding: .7rem .9rem; min-width: 0; }
.tst-rank { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; }
ul.tst-rank { list-style: none; padding-left: 0; }
.tst-bar-row { display: grid; grid-template-columns: 6.5rem 1fr 2rem; gap: .5rem; align-items: center; font-size: .9rem; margin: .25rem 0; }
.tst-bar-row .st-bar { margin: 0; }
.tst-bar-row .st-bar span { background: var(--gold); }
.tst-score { display: inline-block; min-width: 2.2rem; text-align: center; font-weight: 700; color: var(--bg);
  background: var(--gold); border-radius: 999px; padding: .05rem .5rem; }
.tst-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.tst-list li { display: flex; flex-wrap: wrap; gap: .1rem .75rem; }
.tst-rows { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .6rem; margin-bottom: 4rem; }
.tst-row { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--gold); border-radius: 12px; padding: .6rem .8rem; }
.tst-row--cellar { border-left-color: var(--primary); opacity: .92; }
.tst-row-head { display: flex; gap: .6rem; align-items: center; }
.tst-row-head .tst-score { margin-left: auto; }
.tst-row-name { font-weight: 600; overflow-wrap: anywhere; }
.tst-row-meta { font-size: .85rem; }
.tst-row-note { margin-top: .3rem; font-size: .9rem; }
.tst-tag { display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; border-radius: 999px; padding: .1rem .55rem; border: 1px solid var(--gold); color: var(--gold); }
.tst-tag--cellar { border-color: #b8365b; color: #e2557a; }
.tst-tag--todo { border-color: var(--gold); background: rgba(217, 185, 122, .12); }
.tst-todo { background: var(--surface); border: 1px dashed var(--gold); border-radius: 12px; padding: .6rem .9rem; margin: 1rem 0; }
.tst-bar { margin: .5rem 0 1rem; }
.tst-cards { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 3rem; }
.tst-card { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--gold); border-radius: 12px; padding: .75rem .85rem; min-width: 0; }
.tst-card--reading { opacity: .85; border-left-color: var(--hair2); }
.tst-card--unread { border-left-color: var(--neg); }
.tst-card-head { display: flex; gap: .75rem; align-items: flex-start; }
.tst-card-title { min-width: 0; }
.tst-hint { color: var(--gold); font-size: .88rem; margin: .25rem 0; }
.tst-quick { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.tst-quick form { margin: 0; }
.tst-score-input { max-width: 6.5rem; }
.tst-saved { color: var(--ready); font-size: .85rem; min-width: 4rem; }
.tst-photo { max-width: 100%; max-height: 22rem; border-radius: 10px; margin-bottom: 1rem; display: block; }
.tst-facts { margin-bottom: 1rem; }
@media (min-width: 760px) { .tst-grid { grid-template-columns: repeat(2, 1fr); } }

/* Wishlist: lilac, so it reads as neither the cellar (pink) nor the tasting history (gold) */
.wishlist { --primary: #6f62b8; --primary-h: #8276cc; --accent: var(--young); }
.wishlist .page-title { color: var(--young); }
.wsh-banner { border-bottom: 2px solid var(--young); padding-bottom: .6rem; margin-bottom: .8rem; }
.wsh-banner .page-title { margin: 0; }
.wsh-sub { margin: .15rem 0 0; color: var(--muted); }
.wsh-bar { margin: .75rem 0; }
.wsh-h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; color: var(--young); }
.wsh-cards { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 3rem; }
.wsh-card { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--young); border-radius: 12px; padding: .75rem .85rem; min-width: 0; }
.wsh-card--reading { opacity: .85; border-left-color: var(--hair2); }
.wsh-card--bought { opacity: .75; border-left-color: var(--ready); }
.wsh-note { margin: .25rem 0; overflow-wrap: anywhere; }
.wsh-hint { color: var(--young); font-size: .88rem; margin: .2rem 0; }

/* On a phone nothing may be pinned over the bottom tab bar (z-index 120): a pinned "Save all"
   was hidden behind it. The review page has a Save all at the top and an ordinary one at the end
   of the list; the undo toast is lifted above the tab bar. */
.review-top { margin: .5rem 0 1rem; }
@media (max-width: 759px) {
  .review-bar { position: static; padding: 0; background: none; border-top: 0; margin: 1.25rem 0 1.5rem; }
  .review-bar .btn--primary { max-width: none; }
  .bcards { margin-bottom: 0; }
  .undo-toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + .75rem); z-index: 130; }
}
@media (min-width: 760px) { .review-top { display: none; } }

/* Wine menu: green, so it reads as separate from the cellar (pink), tasting (gold) and wishlist (lilac) */
.menuapp { --primary: #2f7d5b; --primary-h: #3b9970; --accent: var(--ready); }
.menuapp .page-title { color: var(--ready); }
.mnu-banner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--ready); padding-bottom: .6rem; margin-bottom: .8rem; }
.mnu-banner .page-title { margin: 0; }
.mnu-sub { margin: .15rem 0 0; color: var(--muted); }
.mnu-h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; color: var(--ready); }
.mnu-wait { display: flex; gap: 1rem; align-items: center; background: var(--surface); border: 1px solid var(--hair);
  border-left: 3px solid var(--ready); border-radius: 12px; padding: 1rem; margin: 1rem 0; }
.mnu-wait p { margin: 0; }
.mnu-flag { background: rgba(217, 185, 122, .12); border: 1px solid var(--gold); border-radius: 10px; padding: .6rem .8rem; }
.mnu-wines { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .6rem; margin: .75rem 0; }
.mnu-wine { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--ready); border-radius: 12px; padding: .55rem .7rem; }
.mnu-wine--noprice { border-left-color: var(--gold); }
.mnu-fields { display: grid; grid-template-columns: 4.5rem 5.5rem 1fr auto; gap: .4rem; align-items: center; margin-top: .4rem; }
.mnu-drop { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.mnu-meta { font-size: .8rem; margin-top: .3rem; }
.mnu-pages { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.mnu-page { max-width: 8rem; border-radius: 8px; border: 1px solid var(--hair2); }

/* Wine menu helper: choosing (results, tabs, preferences sheet) */
.mnu-tabs { display: flex; gap: .4rem; margin: 1rem 0 .75rem; border-bottom: 1px solid var(--hair); }
.mnu-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: .55rem .8rem; color: var(--muted); font: inherit; cursor: pointer; }
.mnu-tab.is-on { color: var(--ready); border-bottom-color: var(--ready); }
.mnu-panel[hidden] { display: none; }
.mnu-top { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.mnu-pick { background: var(--surface); border: 1px solid var(--hair); border-left: 3px solid var(--ready); border-radius: 12px; padding: .7rem .8rem; }
.mnu-pick-head { display: flex; gap: .7rem; align-items: flex-start; }
.mnu-rank { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--ready); color: #0e1511; display: grid; place-items: center; font-weight: 700; }
.mnu-pick-name { font-weight: 600; overflow-wrap: anywhere; }
.mnu-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .6rem 0; }
.mnu-num { display: block; font-size: 1.15rem; font-weight: 600; }
.mnu-lab { display: block; font-size: .75rem; color: var(--muted); }
.mnu-mult--good { color: var(--ready); }
.mnu-mult--bad { color: #d98a7a; }
.mnu-reason { margin: .2rem 0 .4rem; }
.mnu-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--hair); border-radius: 10px; }
.mnu-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.mnu-table th, .mnu-table td { padding: .4rem .5rem; text-align: left; border-bottom: 1px solid var(--hair); vertical-align: top; }
.mnu-table td:first-child { min-width: 11rem; }
.mnu-table td:last-child { min-width: 14rem; }
.mnu-out { opacity: .55; }
.mnu-types { border: 0; padding: 0; margin: 0 0 .75rem; display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.mnu-chk { display: flex; align-items: center; gap: .3rem; }
.mnu-two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
