:root {
  --ink: #241816;
  --muted: #6f6258;
  --paper: #f3eee6;
  --card: #fffdf8;
  --line: #e4d8c8;
  --wine: #7a2433;
  --wine-deep: #3c141c;
  --sidebar: #2a1618;
  --gold: #8d6b32;
  --good: #1f6b45;
  --good-bg: #e7f2e4;
  --bad: #8a2e24;
  --bad-bg: #f8e6e1;
  --shadow: 0 12px 40px rgba(36, 24, 22, 0.06);
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Figtree", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}
img { max-width: 100%; height: auto; }
a { color: var(--wine); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 560;
  line-height: 1.15;
  margin: 0;
}
h1 { font-size: clamp(2rem, 4vw, 3.1rem); letter-spacing: -0.03em; }
h2 { font-size: 1.45rem; }
p { margin: 0; }

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: white;
  padding: 0.4rem 0.7rem;
  z-index: 5;
}
.skip:focus { top: 0.75rem; }

.shell { min-height: 100vh; }
.sidebar {
  display: none;
  background: var(--sidebar);
  color: #f6efe6;
  padding: 1.4rem 1rem 1.2rem;
  flex-direction: column;
  gap: 1.2rem;
}
.sidebar a { color: inherit; text-decoration: none; }
.brand {
  font-family: var(--serif);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: inherit;
}
.household-name { color: #e4c9a2; margin-top: 0.2rem; }
.side-nav, .tabbar { display: flex; }
.side-nav { flex-direction: column; gap: 0.25rem; }
.side-nav a, .tabbar a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  text-decoration: none;
}
.side-nav a.is-current { background: rgba(232, 196, 138, 0.16); color: #f3ddb4; }
.side-foot { margin-top: auto; display: grid; gap: 0.35rem; }
.side-foot a, .linkish {
  color: #f0e2d4;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.nav-icon { width: 1.15rem; height: 1.15rem; fill: currentColor; flex: none; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.1rem;
  background: var(--sidebar);
  color: #f6efe6;
}
.topbar a { color: inherit; text-decoration: none; }
.content, .guest { width: min(52rem, 100%); margin: 0 auto; }
.content { padding: 1.2rem 1.05rem 6.2rem; }
.guest {
  min-height: 100vh;
  display: grid;
  align-content: center;
  padding: 1.5rem 1.05rem 2rem;
}
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--sidebar);
  color: #f6efe6;
  z-index: 4;
  padding: 0.2rem 0.2rem calc(0.2rem + env(safe-area-inset-bottom));
}
.tabbar a {
  flex-direction: column;
  gap: 0.1rem;
  justify-content: center;
  font-size: 0.68rem;
  color: #f6efe6;
  border-radius: 0.7rem;
  padding: 0.35rem 0.1rem;
}
.tabbar a.is-current { background: rgba(232, 196, 138, 0.16); color: #f3ddb4; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 15.5rem 1fr; }
  .sidebar { display: flex; position: sticky; top: 0; height: 100vh; }
  .topbar, .tabbar { display: none; }
  .content { padding: 2.2rem 2rem 3rem; }
}

.page-head, .stack, .panel, .form-section { display: grid; gap: 0.75rem; }
.page-head { margin-bottom: 1.25rem; }
.eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 600;
}
.lede { color: var(--muted); font-size: 1.05rem; max-width: 38rem; }
.hint, .muted { color: var(--muted); }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.login-card, .panel, .recommend-card, .place {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.login-card { display: grid; gap: 0.8rem; }
.panel + .panel, .form-section, .fold, form.stack, .panel { margin-top: 1rem; }
.page-head + .note, .page-head + .panel, .page-head + form { margin-top: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 1rem 0;
}
.stats article, .scores article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
}
.stat {
  font-family: var(--serif);
  font-size: 2rem;
  letter-spacing: -0.03em;
  color: var(--wine-deep);
}
.scores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}
.scores h3 { font-family: var(--sans); font-size: 0.82rem; font-weight: 600; color: var(--muted); }

.flash, .note {
  border-radius: 0.8rem;
  padding: 0.75rem 0.85rem;
  margin: 0 0 0.9rem;
}
.flash.success, .note { background: var(--good-bg); color: #163c28; }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.note { margin-bottom: 1rem; }

.button, .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--wine);
  background: var(--wine);
  color: #fffaf6;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary, .chip {
  background: transparent;
  color: var(--wine-deep);
  border-color: var(--line);
}
.button:disabled { opacity: 0.6; }
.actions, .chips, .cluster { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.actions { margin-top: 1rem; }
.text-link { font-weight: 600; }

.field { display: grid; gap: 0.35rem; }
.field span { font-weight: 600; }
.field small { color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: white;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.form-grid { display: grid; gap: 0.85rem; }
.form-section h2, .fold summary { margin-bottom: 0.2rem; }
.fold {
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.8rem 1rem 1rem;
  background: var(--card);
}
.fold summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-family: var(--serif); font-size: 1.3rem; }
.tags, .tag-list { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0; list-style: none; }
.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
}
.check input { width: auto; min-height: 0; accent-color: var(--wine); }
.rating { display: flex; flex-wrap: wrap; gap: 0.4rem; border: 0; padding: 0; margin: 0; }
.rating legend { font-weight: 600; width: 100%; padding: 0; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; }
.rating span {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: white;
}
.rating input:checked + span { background: var(--wine); color: white; border-color: var(--wine); }
.rating input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

.filters { display: flex; gap: 0.5rem; align-items: end; margin-bottom: 0.5rem; }
.filters .grow { flex: 1; }
.bottle-list { display: grid; }
.bottle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.15rem 0.75rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.bottle .vintage, .vintage-large {
  font-family: var(--serif);
  color: var(--wine-deep);
  margin: 0;
}
.bottle .vintage { font-size: 1.35rem; }
.vintage-large { font-size: clamp(2.4rem, 6vw, 4rem); letter-spacing: -0.04em; }
.bottle h2 { font-size: 1.25rem; }
.bottle h2 a { color: inherit; text-decoration: none; }
.bottle h2 a:hover { color: var(--wine); }
.bottle .where { grid-column: 2; }
.bottle .qty { grid-column: 3; grid-row: 1 / span 2; }
.bottle .row-actions { grid-column: 2 / -1; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
.qty {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--wine);
  border-radius: 50%;
  color: var(--wine);
  font-family: var(--serif);
}
.qty-small { width: 2.1rem; height: 2.1rem; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
.pill-red { background: #f3e2e4; color: #6e2430; }
.pill-white { background: #f7f1d8; color: #6d5a28; }
.pill-sparkling { background: #e7eef2; color: #23404c; }
.pill-rose { background: #f8e6ea; color: #8a3d55; }
.pill-other { background: #eeeae4; color: #4e463f; }

@media (min-width: 800px) {
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
  .bottle {
    grid-template-columns: 4.5rem minmax(0, 1.4fr) auto minmax(8rem, 0.8fr) auto auto;
  }
  .bottle .where, .bottle .row-actions, .bottle .qty { grid-column: auto; grid-row: auto; }
}

.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.plain li, .log li, .place header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  align-items: center;
  justify-content: space-between;
}
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; }
.log-kind { font-weight: 650; }
.log-kind.in { color: var(--good); }
.log-kind.out { color: var(--wine); }
.log-kind.move { color: var(--gold); }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.timeline li { border-left: 2px solid var(--line); padding-left: 0.8rem; display: grid; gap: 0.25rem; }
.pips { display: flex; gap: 0.25rem; align-items: center; }
.pips i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--line);
  display: inline-block;
}
.pips i.on { background: var(--wine); }
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin: 0.5rem 0 1rem;
}
.facts dt { color: var(--muted); font-size: 0.82rem; }
.facts dd { margin: 0; font-family: var(--serif); font-size: 1.15rem; }
.wine-card section { margin-top: 1.4rem; display: grid; gap: 0.55rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.6rem; }
.photos figure, .label-pair figure { margin: 0; }
.photos img, .label-photo {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid var(--line);
  background: white;
  object-fit: cover;
}
.photos figcaption, .label-pair figcaption {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.label-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
.label-photo { max-height: 22rem; object-fit: contain; background: white; margin-bottom: 0.8rem; }
.label-pair .label-photo { margin-bottom: 0; }
fieldset.stack { border: 0; padding: 0; margin: 0; }
fieldset.stack legend { font-weight: 650; }
.empty, .empty-block { color: var(--muted); }
.empty-block { display: grid; gap: 0.6rem; padding: 1rem 0 0.4rem; }
.remain { font-family: var(--serif); font-size: 1.2rem; }
.picks { border: 0; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.picks legend { font-weight: 600; }
.pick {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: white;
}
.pick span { display: grid; gap: 0.1rem; }
.recommend-list { list-style: none; padding: 0; display: grid; gap: 0.8rem; }
.recommend-card h2 { font-size: 1.7rem; }
.recommend-card h2 a { color: inherit; text-decoration: none; }
.place { display: grid; gap: 0.6rem; margin-bottom: 0.7rem; }
.place header { align-items: center; }
.finished-link, .place-link { margin-top: 1rem; }

@media (max-width: 640px) {
  .scores, .stats { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .button { width: 100%; }
  .actions .button, .chips .chip { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
