:root {
  color-scheme: light;

  /* paper family */
  --paper: #faf6ee;
  --paper-2: #f2ead9;
  --paper-3: #e8decc;
  --paper-glass: rgba(250, 246, 238, 0.78);

  /* ink family */
  --ink: #1b1712;
  --ink-2: #322b23;
  --muted: #6c6255;
  --soft: #8d8172;
  --line: rgba(27, 23, 18, 0.12);
  --line-strong: rgba(27, 23, 18, 0.22);

  /* cellar accents */
  --wine: #7a2e3c;
  --wine-2: #a34255;
  --whiskey: #c68e4e;
  --whiskey-2: #d9a443;
  --clay: #b45a36;
  --sage: #5e7c5f;
  --gold: #c9a227;

  /* status */
  --status-open: #eaf3e6;
  --status-open-text: #2f5a2a;
  --status-unopened: #e8f0f4;
  --status-unopened-text: #2b4d5a;
  --status-low: #f9e8e3;
  --status-low-text: #7a2e3c;
  --status-finished: #f1eeea;
  --status-finished-text: var(--muted);

  /* shadows */
  --shadow-sm: 0 2px 8px rgba(27, 23, 18, 0.06);
  --shadow: 0 12px 32px rgba(27, 23, 18, 0.10), 0 4px 12px rgba(27, 23, 18, 0.06);
  --shadow-lg: 0 24px 60px rgba(27, 23, 18, 0.14), 0 8px 20px rgba(27, 23, 18, 0.08);
  --shadow-inset: inset 0 2px 4px rgba(27, 23, 18, 0.06);

  /* radius */
  --radius-xl: 28px;
  --radius: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;

  /* motion */
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* type */
  --font-display: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  font-family: var(--font-ui);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 8%, rgba(198, 142, 78, 0.14), transparent 24rem),
    radial-gradient(circle at 94% 4%, rgba(122, 46, 60, 0.12), transparent 26rem),
    linear-gradient(135deg, rgba(255,255,255,.4), transparent 40%),
    var(--paper);
  overflow-x: hidden;
}

/* paper grain overlay */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; background: transparent; border: none; color: inherit; }

/* ===== SHELL ===== */
.shell {
  width: min(1100px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 80px;
  position: relative;
  z-index: 1;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: clamp(28px, 5vw, 52px); flex-wrap: wrap;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: -.02em;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 13px;
  display: grid; place-items: center; color: #fffdf8; font-size: 1.1rem;
  background: linear-gradient(135deg, var(--wine), #4a1b25);
  box-shadow: 0 6px 18px rgba(74, 27, 37, .18);
}

.navlinks {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--muted); font-size: .95rem;
}
.navlinks .text-btn {
  border: 1px solid transparent; background: transparent;
  color: var(--muted); padding: 7px 14px; font-size: .94rem; border-radius: 999px;
  transition: color .2s var(--ease-smooth), background .2s var(--ease-smooth), border-color .2s var(--ease-smooth);
}
.navlinks .text-btn:hover,
.navlinks .text-btn.active { color: var(--ink); background: var(--paper-glass); border-color: var(--line); }

/* ===== HERO ===== */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, .8fr);
  gap: clamp(20px, 4vw, 48px); align-items: center; margin-bottom: 34px;
}
.eyebrow {
  margin: 0 0 10px; color: var(--clay); font-size: .72rem;
  font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
}
h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -.045em; color: var(--ink);
}
h1 { max-width: 720px; margin: 0; font-size: clamp(2.8rem, 8vw, 4.8rem); line-height: 1.02; }
.lede { max-width: 560px; margin: 18px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.55; }

/* counts strip */
.counts {
  display: flex; flex-direction: column; gap: 0;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper-glass); box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.count { display: flex; flex-direction: column; gap: 2px; }
.count-number { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; color: var(--ink); line-height: 1; }
.count-label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

/* counts row (compact original counts inside hero aside) */
.counts-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.counts-row .count-number { font-size: 1.35rem; }
.counts-row .count-label { font-size: .66rem; }

/* ===== HERO CAROUSEL ===== */
.hero-left { min-width: 0; overflow: hidden; }
.hero-carousel {
  position: relative; margin-top: 24px;
  min-height: 0;
}
.hero-slides { position: relative; min-height: 132px; }
.hero-slide {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--paper-glass); box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0; transition: opacity .55s var(--ease-smooth);
  pointer-events: none;
}
.hero-slide.active { opacity: 1; pointer-events: auto; }
.hero-slide:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.hero-slide:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }

.hero-slide-thumb {
  flex: 0 0 64px; width: 64px; height: 86px; position: relative;
  border-radius: 8px; background: var(--paper-2); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.hero-slide-thumb .bottle-thumb { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.hero-slide-thumb .bottle-thumb.placeholder { display: grid; place-items: center; font-size: .85rem; font-weight: 800; color: var(--soft); text-align: center; line-height: 1.1; }

.hero-slide-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.hero-slide-name {
  margin: 0; font-family: var(--font-display);
  font-size: 1.25rem; line-height: 1.16; letter-spacing: -.02em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-slide-meta {
  margin: 0; color: var(--muted); font-size: .82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-slide-score { display: flex; flex-wrap: wrap; gap: 6px; }
.hero-slide-note {
  margin: 0; color: var(--soft); font-size: .84rem; line-height: 1.4;
  font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.hero-dots {
  display: flex; gap: 8px; justify-content: center; margin-top: 12px;
}
.hero-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper-3); border: 1px solid var(--line);
  transition: background .2s var(--ease-smooth), transform .2s var(--ease-smooth);
  padding: 0;
}
.hero-dot:hover { transform: scale(1.18); }
.hero-dot.active { background: var(--clay); border-color: var(--clay); }

/* ===== VITALS STRIP ===== */
.vitals-strip {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.vital {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink);
  font-size: .82rem; font-weight: 700; text-align: left;
  transition: transform .15s var(--ease-smooth), background .2s var(--ease-smooth), border-color .2s var(--ease-smooth), box-shadow .2s var(--ease-smooth);
}
.vital:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.vital.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.vital.active .vital-label { color: var(--paper); }
.vital-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.55);
}
.vital-dot.dot-green { background: var(--sage); }
.vital-dot.dot-amber { background: var(--whiskey); }
.vital-dot.dot-blue { background: #3b6c8a; }
.vital-dot.dot-red { background: var(--wine); }
.vital-count { font-weight: 800; font-size: .9rem; }
.vital-label { color: var(--muted); }
.vital.active .vital-dot { box-shadow: 0 0 0 2px rgba(255,255,255,.3); }

/* ===== CONTROLS ===== */
.controls { margin-bottom: 22px; }
.search-row { margin-bottom: 14px; position: relative; }
.search-row::before {
  content: "⌕";
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  font-size: 1.15rem; color: var(--soft); pointer-events: none;
}
#search {
  width: 100%; padding: 15px 16px 15px 44px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--paper-glass); color: var(--ink);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  backdrop-filter: blur(8px);
}
#search::placeholder { color: var(--soft); }
#search:focus { outline: 2px solid var(--clay); outline-offset: 2px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper-glass); color: var(--muted); font-size: .9rem;
  transition: transform .15s var(--ease-smooth), background .2s var(--ease-smooth), color .2s var(--ease-smooth), border-color .2s var(--ease-smooth), box-shadow .2s var(--ease-smooth);
  backdrop-filter: blur(6px);
}
.chip:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: var(--shadow-sm); }
.chip .chip-icon { font-size: .95em; }

.status { margin: 12px 0 0; min-height: 1.4em; color: var(--muted); font-size: .9rem; }
.status.error { color: #a33; }
.status.pending { color: var(--soft); }

[hidden] { display: none !important; }

/* ===== CARD SHELVES ===== */
.cards-view { display: block; }
.shelves { display: flex; flex-direction: column; gap: 34px; }

.shelf {
  position: relative;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.shelf::after { display: none; }
.shelf-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding: 4px 0;
  background: transparent; border: 0;
}
.shelf-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  align-self: center;
}
.shelf-label-text {
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink);
}
.shelf-count {
  font-size: .82rem;
  font-weight: 700;
  color: var(--soft);
}
.shelf-sep {
  color: var(--soft);
  font-weight: 400;
}
.shelf-subtitle {
  font-size: .78rem;
  font-weight: 500;
  color: var(--soft);
  font-style: italic;
}
.shelf-subtitle::before { content: "· "; }
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* bottle cards */
.bottle-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--paper-glass);
  box-shadow: var(--shadow-sm);
  cursor: pointer; text-align: left; width: 100%;
  transition: transform .25s var(--ease-out-expo), box-shadow .25s var(--ease-out-expo), border-color .25s var(--ease-out-expo);
  backdrop-filter: blur(8px);
  transform-style: preserve-3d;
}
.bottle-card:hover,
.bottle-card:focus-visible {
  transform: perspective(900px) rotateX(2deg) translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
  outline: none;
}
.bottle-card:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }

.thumb-wrap {
  flex: 0 0 72px; width: 72px; height: 96px;
  position: relative;
  border-radius: 10px;
  background: var(--paper-2); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.bottle-thumb {
  width: 100%; height: 100%; object-fit: contain; padding: 6px;
}
.bottle-thumb.placeholder {
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 800; color: var(--soft);
  text-align: center; line-height: 1.1;
}
.status-lozenge {
  position: absolute; top: -6px; right: -6px;
  padding: 3px 7px; border-radius: 999px;
  font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid var(--paper); box-shadow: var(--shadow-sm);
}
.status-lozenge.open { background: var(--status-open); color: var(--status-open-text); }
.status-lozenge.unopened { background: var(--status-unopened); color: var(--status-unopened-text); }
.status-lozenge.low { background: var(--status-low); color: var(--status-low-text); }
.status-lozenge.finished { background: var(--status-finished); color: var(--status-finished-text); }

.bottle-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bottle-name {
  margin: 0; font-family: var(--font-display);
  font-size: 1.15rem; line-height: 1.16; letter-spacing: -.02em;
}
.bottle-kind {
  margin: 0; color: var(--muted); font-size: .84rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bottle-note {
  margin: 0;
  color: var(--soft);
  font-size: .84rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bottle-signals {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.signal {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 800; letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.score-signal { background: #eaf3e6; color: #2f5a2a; border-color: rgba(47,90,42,.12); }
.price-everyday { background: #f1eeea; color: var(--muted); border-color: var(--line); }
.price-standard { background: #e8dfd3; color: var(--ink); border-color: var(--line); }
.price-premium { background: #f3e6e2; color: #7a2e3c; border-color: rgba(122,46,60,.15); }
.price-special { background: #fbf2d9; color: #7a5a1a; border-color: rgba(122,90,26,.15); }
.window-now { background: #eaf3e6; color: #2f5a2a; border-color: rgba(47,90,42,.12); }
.window-soon { background: #fff4db; color: #7a5a1a; border-color: rgba(122,90,26,.15); }
.window-later { background: #f1eeea; color: var(--muted); border-color: var(--line); }
.saved-signal { background: var(--ink); color: var(--paper); }

.bottle-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 2px;
}
.tag {
  padding: 2px 7px; border-radius: 999px;
  background: transparent; color: var(--soft); font-size: .72rem;
  border: 1px solid var(--line);
}

.empty {
  text-align: center; color: var(--muted); margin: 60px 0;
  padding: 28px; border: 1px dashed var(--line); border-radius: var(--radius);
  background: var(--paper-glass); backdrop-filter: blur(8px);
}
.empty strong { color: var(--ink); display: block; margin-bottom: 8px; font-family: var(--font-display); font-size: 1.3rem; }

/* card entrance animation */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.bottle-card { animation: card-enter .45s var(--ease-out-expo) both; }

/* shelf label entrance — fades in before its cards */
@keyframes shelf-label-enter {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== TIERED CARDS ===== */
/* Spotlight: 2-column span, larger image, warm gradient, note always visible */
.bottle-card.spotlight {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(198,142,78,0.08), var(--paper-glass));
}
.bottle-card.spotlight .thumb-wrap {
  flex: 0 0 100px; width: 100px; height: 130px;
}
.bottle-card.spotlight .bottle-name {
  font-size: 1.25rem;
}
.bottle-card.spotlight .bottle-note {
  display: -webkit-box;
}

/* Compact: vertical, minimal, smaller image, no note/signals/meta */
.bottle-card.compact {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 12px;
}
.bottle-card.compact .thumb-wrap {
  flex: 0 0 60px; width: 60px; height: 80px;
}
.bottle-card.compact .bottle-text {
  align-items: center;
}
.bottle-card.compact .bottle-name {
  font-size: 0.95rem;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%;
}

/* Tier-specific hover effects (override the default card hover).
   The entrance animation uses `both` fill-mode so the final resting state
   is `opacity:1; transform: translateY(0) scale(1)`. These :hover rules
   apply on top of that final state. */
.bottle-card.spotlight:hover,
.bottle-card.spotlight:focus-visible {
  transform: scale(1.02);
  box-shadow: 0 12px 32px rgba(198, 142, 78, 0.22), 0 4px 12px rgba(198, 142, 78, 0.14);
  border-color: var(--line-strong);
  outline: none;
}
.bottle-card.compact:hover,
.bottle-card.compact:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
  outline: none;
}
/* Standard cards keep the default tilt from .bottle-card:hover above. */

/* ===== MAP ===== */
.map-view { display: block; }
.cards-view, .map-view {
  transition: opacity 0.3s var(--ease-smooth);
}
.cards-view[hidden], .map-view[hidden] { display: none !important; }
.map-wrap {
  position: relative; width: 100%;
  aspect-ratio: 2 / 1; min-height: 420px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: #e6ded3;
  box-shadow: var(--shadow);
}
.cellar-map { width: 100%; height: 100%; z-index: 1; background: #e6ded3; }

/* sepia muted tiles */
.leaflet-container { background: #e6ded3 !important; }
.leaflet-tile { filter: sepia(0.22) saturate(0.78) contrast(0.95) brightness(1.04); }

/* clusters */
.marker-cluster { background: transparent !important; }
.map-cluster {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wine); color: #fff;
  font-weight: 800; font-size: .95rem;
  border: 2px solid var(--paper); box-shadow: var(--shadow);
  transition: transform .2s var(--ease-spring);
}
.map-cluster.whiskey { background: var(--whiskey); }
.map-cluster.mixed { background: var(--clay); }
.marker-cluster:hover .map-cluster { transform: scale(1.08); }

/* pins */
.cellar-pin { background: transparent !important; border: none !important; }
.map-pin {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
}
.map-pin .mp-icon {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wine); color: #fff;
  border: 2px solid #fff; box-shadow: var(--shadow);
}
.map-pin.whiskey .mp-icon { background: var(--whiskey); }
.map-pin.mixed .mp-icon { background: var(--clay); }
.map-pin .mp-icon svg { width: 18px; height: 18px; fill: currentColor; }
.map-pin .mp-label {
  padding: 3px 10px; border-radius: 999px;
  background: var(--paper-glass); color: var(--ink);
  font-size: .74rem; font-weight: 700;
  border: 1px solid var(--line); white-space: nowrap;
  box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
}

.leaflet-control-attribution {
  font-size: .65rem !important;
  background: var(--paper-glass) !important;
  color: var(--muted) !important;
  padding: 3px 7px !important;
  border-top-left-radius: 8px;
  backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* region panel */
.region-panel {
  position: absolute; right: 16px; top: 16px;
  width: min(340px, 42%); max-height: calc(100% - 32px); overflow-y: auto;
  padding: 18px; border-radius: var(--radius-md);
  background: var(--paper-glass); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); z-index: 1000;
  backdrop-filter: blur(16px);
}
.region-panel h3 { margin: 0 0 14px; font-size: 1.15rem; }
.region-panel .region-meta { font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.region-panel .region-bottle {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line); cursor: pointer;
  transition: transform .15s var(--ease-smooth);
}
.region-panel .region-bottle:hover { transform: translateX(4px); }
.region-panel .region-bottle:last-child { border-bottom: 0; }
.region-panel .region-bottle img { width: 36px; height: 60px; object-fit: contain; border-radius: 5px; background: var(--paper-2); }
.region-panel .region-bottle .ph { width: 36px; height: 60px; border-radius: 5px; background: linear-gradient(90deg, rgba(57,42,27,.18), rgba(57,42,27,.06)); }
.region-panel .region-bottle .name { font-size: .87rem; font-weight: 700; }
.region-panel .region-bottle .kind { font-size: .75rem; color: var(--muted); }
.region-close {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px;
  border-radius: 50%; background: var(--paper); border: 1px solid var(--line);
  color: var(--muted); display: grid; place-items: center; font-size: 1.1rem;
}

/* map reset button */
.map-reset {
  position: absolute; left: 16px; bottom: 16px; z-index: 1000;
  padding: 9px 14px; border-radius: 999px;
  background: var(--paper-glass); color: var(--ink); font-size: .85rem; font-weight: 700;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

/* ===== SHEETS ===== */
.detail-sheet, .history-sheet {
  position: fixed; inset: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: transparent; overflow: hidden;
}
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(27, 23, 18, .42);
  opacity: 0;
  backdrop-filter: blur(0px);
  transition: opacity 0.3s var(--ease-smooth), backdrop-filter 0.3s var(--ease-smooth);
}
.detail-sheet[open] .sheet-backdrop, .history-sheet[open] .sheet-backdrop {
  opacity: 1;
  backdrop-filter: blur(4px);
}
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 90vh; overflow-y: auto;
  padding: 26px 22px 30px;
  border-top-left-radius: var(--radius-xl); border-top-right-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 80% 0%, rgba(198,142,78,.08), transparent 35%),
    var(--paper);
  box-shadow: var(--shadow-lg); scrollbar-width: thin;
  transform: translateY(100%);
  transition: transform .35s var(--ease-out-expo);
}
.detail-sheet[open] .sheet-panel, .history-sheet[open] .sheet-panel { transform: translateY(0); }
.sheet-panel::-webkit-scrollbar { width: 6px; }
.sheet-panel::-webkit-scrollbar-thumb { background: var(--paper-3); border-radius: 999px; }
.sheet-panel h2 { margin: 0 0 18px; font-size: 1.8rem; }
.sheet-close {
  position: absolute; top: 16px; right: 18px; width: 38px; height: 38px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--paper-glass);
  color: var(--muted); font-size: 1.4rem; line-height: 1; display: grid; place-items: center;
  backdrop-filter: blur(6px); z-index: 2;
}

/* detail content */
.detail-image {
  width: 100%; max-width: 220px; height: auto;
  border-radius: var(--radius-md); margin: 0 auto 22px; display: block;
  background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow);
}

/* animated drink gauge */
.drink-gauge {
  width: 110px; height: 110px; margin: 0 auto 26px;
  border-radius: 50%;
  background: conic-gradient(var(--sage) 0deg var(--leaf-end, 0deg), var(--paper-3) 0deg);
  position: relative;
  transition: background 1.2s var(--ease-out-expo);
}
.drink-gauge::before {
  content: "";
  position: absolute; inset: 7px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.drink-gauge::after {
  content: attr(data-label); position: absolute; inset: 7px;
  display: grid; place-items: center; border-radius: 50%;
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); text-align: center;
  padding: 8px;
}
.drink-gauge.cellar { background: conic-gradient(var(--clay) 0deg var(--leaf-end, 0deg), var(--paper-3) 0deg); }
.drink-gauge.drink { background: conic-gradient(var(--sage) 0deg var(--leaf-end, 0deg), var(--paper-3) 0deg); }
.drink-gauge.approach { background: conic-gradient(var(--gold) 0deg var(--leaf-end, 0deg), var(--paper-3) 0deg); }

/* featured tasting note */
.detail-feature-note {
  padding: 16px 20px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--wine);
  background: rgba(122, 46, 60, 0.04);
}
.detail-feature-note.whiskey {
  border-left-color: var(--whiskey);
  background: rgba(198, 142, 78, 0.06);
}
.feature-note-text {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink);
}
.feature-note-text.muted { color: var(--muted); font-style: italic; }

/* quick fact chips */
.quick-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.fact-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-glass);
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
}
.fact-chip.score { background: rgba(94, 124, 95, 0.12); border-color: rgba(94, 124, 95, 0.4); color: var(--sage); }
.fact-chip.price-everyday { background: rgba(94, 124, 95, 0.10); border-color: rgba(94, 124, 95, 0.3); }
.fact-chip.price-standard { background: rgba(201, 162, 39, 0.10); border-color: rgba(201, 162, 39, 0.3); }
.fact-chip.price-premium { background: rgba(180, 90, 54, 0.10); border-color: rgba(180, 90, 54, 0.3); }
.fact-chip.price-special { background: rgba(122, 46, 60, 0.10); border-color: rgba(122, 46, 60, 0.3); color: var(--wine); }
.fact-chip.window { background: rgba(201, 162, 39, 0.10); border-color: rgba(201, 162, 39, 0.3); color: var(--ink-2); }
.fact-chip.tier { background: var(--paper-2); border-color: var(--line-strong); }
.fact-chip.region { background: var(--paper-glass); color: var(--muted); }

/* detail section headings */
.detail-section { margin-bottom: 18px; }
.detail-section h3 {
  margin: 0 0 10px;
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.detail-section p { margin: 0 0 6px; line-height: 1.5; }
.detail-section ul { margin: 0; padding-left: 1.2rem; }
.detail-section li + li { margin-top: 6px; }

/* tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .2s var(--ease-smooth), border-color .2s var(--ease-smooth);
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab-content { animation: fadeIn .2s var(--ease-smooth); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.note-list { display: grid; gap: 10px; padding: 0; }
.note-list div { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(255,252,246,.62); }
.note-list dt { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.note-list dd { margin: 0; line-height: 1.45; }
.source-note { margin-top: 8px !important; font-size: .9rem; color: var(--soft); }
.muted { color: var(--muted); }

/* fill slider */
.fill-control { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.fill-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fill-label { font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fill-value { font-size: 1.1rem; font-weight: 800; color: var(--ink); }
.fill-bar { flex: 1; height: 12px; border-radius: 999px; background: var(--paper-3); overflow: hidden; }
.fill-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--wine), var(--whiskey)); transition: width .25s var(--ease-smooth); }
.fill-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 999px; background: var(--paper-3); outline: none;
}
.fill-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 3px solid var(--paper); box-shadow: var(--shadow); cursor: pointer; }
.fill-slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 3px solid var(--paper); box-shadow: var(--shadow); cursor: pointer; }
.fill-steps { display: flex; gap: 6px; }
.fill-step { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: .8rem; font-weight: 700; }

/* tags inside sheet */
.sheet-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* related bottles strip */
.related-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.related-card {
  flex: 0 0 140px; padding: 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper-glass); cursor: pointer;
  transition: transform .2s var(--ease-smooth), box-shadow .2s var(--ease-smooth);
}
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.related-card .ph { width: 100%; height: 72px; border-radius: 6px; background: linear-gradient(90deg, rgba(57,42,27,.18), rgba(57,42,27,.06)); margin-bottom: 8px; }
.related-card img { width: 100%; height: 72px; object-fit: contain; border-radius: 6px; background: var(--paper-2); margin-bottom: 8px; }
.related-card .name { font-size: .82rem; font-weight: 700; line-height: 1.2; }
.related-card .kind { font-size: .7rem; color: var(--muted); }

/* sheet action bar */
.sheet-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line);
}
.action-btn {
  padding: 11px 18px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--paper-glass); color: var(--ink);
  font-size: .95rem; font-weight: 700;
  transition: transform .15s var(--ease-smooth), background .2s var(--ease-smooth), color .2s var(--ease-smooth);
  backdrop-filter: blur(4px);
}
.action-btn:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.action-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.action-btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.action-btn.primary:hover { background: var(--ink-2); }

/* ===== HISTORY TIMELINE ===== */
.history-timeline { position: relative; padding-left: 24px; }
.history-timeline::before {
  content: "";
  position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(to bottom, var(--line), var(--line-strong), var(--line));
  border-radius: 999px;
}
.history-item { position: relative; margin-bottom: 16px; }
.history-item::before {
  content: attr(data-icon);
  position: absolute; left: -24px; top: 2px; width: 16px; height: 16px;
  display: grid; place-items: center; font-size: .75rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: 50%;
}
.history-item time { display: block; font-size: .74rem; color: var(--soft); margin-bottom: 3px; }
.history-item p { margin: 0; color: var(--ink); font-size: .96rem; }
.history-empty { color: var(--muted); }
.history-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history-stat { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--soft); background: var(--paper); padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); }

/* ===== RESPONSIVE ===== */
@media (min-width: 720px) {
  .shell { width: min(1080px, calc(100vw - 48px)); }
  .vitals-strip { grid-template-columns: repeat(4, 1fr); }
  .sheet-panel {
    left: auto; right: 0; top: 0; bottom: 0; max-height: 100vh;
    width: min(460px, 42vw); border-radius: 0;
    border-top-left-radius: var(--radius-xl); border-bottom-left-radius: var(--radius-xl);
    padding: 30px 28px 36px;
  }
  .shelf-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 540px) {
  .hero { grid-template-columns: 1fr; overflow-x: hidden; }
  .vitals-strip { grid-template-columns: repeat(2, 1fr); }
  .shelves { gap: 18px; }
  .shelf { padding: 12px 10px 16px; }
  .shelf-label { margin-bottom: 10px; gap: 8px; }
  .shelf-subtitle { display: none; }
  .shelf-count-word { display: none; }
  .shelf-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; width: 100%; max-width: 100%; overflow: hidden; }
  .bottle-card { min-width: 0; max-width: 100%; width: 100%; padding: 12px; gap: 12px; animation: none; transform: none !important; }
  .bottle-card.spotlight { grid-column: span 1; }
  .bottle-card.compact { flex-direction: row; text-align: left; gap: 12px; }
  .bottle-card.compact .bottle-text { align-items: flex-start; }
  .bottle-card.compact .bottle-name { white-space: normal; }
  .bottle-card:hover,
  .bottle-card:focus-visible { transform: none; }
  .bottle-text { min-width: 0; max-width: 100%; overflow: hidden; }
  .bottle-note { display: none; }
  .bottle-card.spotlight .bottle-note { display: -webkit-box; }
  .thumb-wrap { flex: 0 0 60px; width: 60px; height: 80px; }
  .bottle-name { font-size: 1.05rem; overflow-wrap: anywhere; }
  .bottle-kind { font-size: .78rem; max-width: 100%; }
  .bottle-signals { gap: 4px; max-width: 100%; overflow: hidden; }
  .bottle-meta { display: none; }
  .signal { padding: 3px 7px; font-size: .68rem; }
  .chip-row {
    flex-wrap: nowrap; overflow-x: auto; gap: 8px;
    padding-bottom: 6px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }
  .chip-row::-webkit-scrollbar { display: none; }
  .map-wrap { aspect-ratio: 1 / 1.1; min-height: 340px; }
  .region-panel { right: 10px; top: 10px; width: min(300px, calc(100% - 20px)); max-height: calc(100% - 20px); }
  /* mobile: compact featured note, wrapping chips, scrollable tabs */
  .detail-feature-note { padding: 12px 14px; margin-bottom: 16px; }
  .feature-note-text { font-size: 1rem; }
  .quick-facts { gap: 6px; margin-bottom: 16px; }
  .fact-chip { padding: 4px 10px; font-size: .76rem; }
  .tabs { gap: 2px; }
  .tab { padding: 12px 14px; font-size: .82rem; min-height: 44px; display: inline-flex; align-items: center; }

  /* hero carousel mobile: shorter, compact, note hidden, dots tappable */
  .hero-carousel { margin-top: 16px; }
  .hero-slides { min-height: 130px; width: 100%; max-width: 100%; overflow: hidden; }
  .hero-slide { padding: 12px; gap: 12px; max-width: 100%; overflow: hidden; }
  .hero-slide-thumb { flex: 0 0 56px; width: 56px; height: 76px; }
  .hero-slide-name { font-size: 1.2rem; white-space: normal; overflow-wrap: anywhere; }
  .hero-slide-meta { font-size: .76rem; white-space: normal; overflow-wrap: anywhere; }
  .hero-slide-note { display: none; }
  .hero-slide-score .signal { padding: 3px 7px; font-size: .68rem; }
  .hero-dots { gap: 4px; margin-top: 8px; }
  .hero-dot {
    width: 44px; height: 44px; padding: 0;
    background: transparent; border: none;
    position: relative;
  }
  .hero-dot::after {
    content: "";
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--paper-3); border: 1px solid var(--line);
    transition: background .2s var(--ease-smooth);
  }
  .hero-dot:hover { transform: none; }
  .hero-dot.active { background: transparent; border: none; }
  .hero-dot.active::after { background: var(--clay); border-color: var(--clay); }

  /* vitals mobile: smaller numbers/labels, 44px touch targets */
  .vital { min-height: 44px; padding: 10px 12px; font-size: .76rem; }
  .vital-count { font-size: .82rem; }
  .vital-label { font-size: .72rem; }

  /* touch targets ≥ 44px */
  .chip { min-height: 44px; padding: 10px 14px; display: inline-flex; align-items: center; }
  .action-btn { min-height: 44px; padding: 12px 18px; }
  .sheet-close { width: 44px; height: 44px; }
  .fill-step { min-height: 44px; padding: 10px 12px; }
  .fill-slider::-webkit-slider-thumb { width: 28px; height: 28px; }
  .fill-slider::-moz-range-thumb { width: 28px; height: 28px; }

  /* disable backdrop-filter on mobile — major scroll jank with 20+ cards */
  .bottle-card, .hero-slide, .counts, .chip, #search, .empty, .region-panel, .map-reset, .sheet-close, .map-pin .mp-label {
    backdrop-filter: none;
  }
  .bottle-card { background: var(--paper); }
  .hero-slide { background: var(--paper); }
  .counts { background: var(--paper); }
  .chip { background: var(--paper); }
  .chip.active { background: var(--ink); }
  #search { background: var(--paper); }
  .empty { background: var(--paper); }
  .region-panel { background: var(--paper); }
}

/* mobile full-height map */
@media (max-width: 420px) {
  html, body { height: 100%; overflow-x: hidden; }
  body.map-active .hero,
  body.map-active .controls { display: none !important; }
  body.map-active .shell {
    width: 100vw !important; max-width: none !important; padding: 0 !important; margin: 0 !important; min-height: 0 !important;
  }
  body.map-active .map-view {
    position: fixed; inset: 72px 0 0 0; padding: 0; z-index: 2;
    display: flex !important; flex-direction: column;
  }
  body.map-active .map-wrap {
    flex: 1 1 auto; width: 100vw !important; height: auto !important;
    aspect-ratio: auto !important; min-height: 0 !important;
    border-radius: 0; border-left: 0; border-right: 0; border: 0;
  }
  body.map-active .cellar-map { width: 100vw !important; height: 100% !important; }
  body.map-active main { padding-bottom: 0 !important; }
}

@media (min-width: 540px) { .bottle-note { display: -webkit-box; } }

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
