/* Wine Inventory — a deliberately dark, cellar-lit theme, built mobile-first. */

:root {
  --bg: #140a0f;
  --surface: #1e1017;
  --surface-2: #2a1721;
  --surface-3: #351d29;
  --line: #3d2634;
  --text: #f6ecef;
  --muted: #b99daa;
  --wine: #a12448;
  --wine-bright: #c8355f;
  --gold: #d9a94f;

  --good: #4aa877;
  --great: #d9a94f;
  --warn: #e08c3a;
  --bad: #d1495b;
  --cool: #6a95c4;

  --red: #8e1f3f;
  --white: #e8d9a0;
  --rose: #e79aa8;
  --sparkling: #f0d47a;
  --orange: #d98836;
  --dessert: #c8952f;
  --fortified: #7a4230;
  --unknown: #6b5560;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

/* `display` rules below are more specific than the UA's [hidden] default. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(120% 60% at 50% 0%, #2a1019 0%, var(--bg) 60%);
  background-attachment: fixed;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
p { margin: 0 0 .5rem; }
code, .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .1em .4em;
}

.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- shell --------------------------------------------------------------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  align-items: center;
  gap: .25rem;
  padding: max(env(safe-area-inset-top), .35rem) .5rem .5rem;
  background: rgba(20, 10, 15, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.appbar__title {
  grid-column: 2;
  font-family: var(--serif);
  font-size: 1.15rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar__back { grid-column: 1; }
.appbar__add { grid-column: 3; }

.appbar__back, .appbar__add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  font-size: 1.7rem;
  line-height: 1;
  color: var(--muted);
  border-radius: var(--radius-sm);
}
.appbar__add { font-size: 1.6rem; }
.appbar__back:active, .appbar__add:active { background: var(--surface-2); }
.appbar__back[hidden] { display: none; }

.main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem .85rem calc(5.5rem + env(safe-area-inset-bottom));
  outline: none;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .1rem;
  padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom));
  background: rgba(22, 11, 17, .93);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .4rem .1rem .3rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .01em;
}
.tabbar a.is-on { color: var(--text); background: var(--surface-2); }
.tabbar__icon { font-size: 1.25rem; line-height: 1.1; }
.tabbar a.is-primary .tabbar__icon {
  background: linear-gradient(160deg, var(--wine-bright), var(--wine));
  color: #fff;
  border-radius: 50%;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(161, 36, 72, .5);
}

/* --- buttons & inputs ---------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: var(--tap);
  padding: .55rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: linear-gradient(165deg, var(--wine-bright), var(--wine)); border-color: transparent; color: #fff; }
.btn--secondary { background: var(--surface-3); }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn--small { min-height: 34px; padding: .3rem .65rem; font-size: .84rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gold);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linkish--quiet { color: var(--muted); font-size: .78rem; text-decoration: none; }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: .6rem .7rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* keeps iOS from zooming on focus */
  appearance: none;
}
.input:focus { outline: 2px solid var(--wine-bright); outline-offset: 1px; }
.input::placeholder { color: #8d7280; }
textarea.input { min-height: 5rem; line-height: 1.4; resize: vertical; }
select.input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.input--search { background: var(--surface-2); }
.select-wrap { display: block; }

.field { display: block; margin-bottom: .75rem; }
.field__label { display: block; margin-bottom: .25rem; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field__hint { display: block; margin-top: .3rem; font-size: .78rem; color: var(--muted); }

.grid { display: grid; gap: .25rem .7rem; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .grid--4 { grid-template-columns: repeat(4, 1fr); } }

.fieldset {
  margin: 0 0 1rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.fieldset legend { padding: 0 .4rem; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.switch { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); }
.switch input { width: 1.15rem; height: 1.15rem; accent-color: var(--wine-bright); }

/* --- toolbar ------------------------------------------------------------- */

/* minmax(0,1fr) stops the auto column from being widened by nowrap content. */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; margin-bottom: 1rem; }
.toolbar__row { display: flex; align-items: center; gap: .5rem; min-width: 0; }
/* The shelf switch and the sort menu share a row when there is room and
   stack when there is not, rather than pushing the sort off-screen. */
.toolbar__row--split { justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.toolbar__row--split .segmented { flex: 1 1 auto; min-width: 0; }
.toolbar__row--split .segmented button { min-width: 0; padding: .3rem .5rem; overflow: hidden; text-overflow: ellipsis; }
.toolbar__row--split .select-wrap { flex: 0 1 auto; min-width: 9.5rem; margin-left: auto; }

.chips { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .2rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: 0 0 auto;
  padding: .4rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}
.chip-btn.is-on { background: var(--surface-3); color: var(--text); border-color: var(--wine); }

.segmented {
  display: inline-flex;
  padding: .18rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.segmented--wide { display: flex; width: 100%; }
.segmented button {
  flex: 1;
  min-height: 36px;
  padding: .3rem .7rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .84rem;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button.is-on { background: var(--wine); color: #fff; }

/* --- stats & banners ----------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
@media (min-width: 520px) { .stats { grid-template-columns: repeat(4, 1fr); } }

.stat {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .7rem .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat__value { font-family: var(--serif); font-size: 1.5rem; line-height: 1.1; }
.stat__label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat__sub { font-size: .76rem; color: var(--muted); }

.banner {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .75rem .85rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  background: linear-gradient(160deg, rgba(224, 140, 58, .18), rgba(224, 140, 58, .06));
}
.banner span { font-size: .84rem; color: var(--muted); }

.notice {
  padding: .8rem .9rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.notice--warn { border-color: var(--warn); }
.notice p { margin: .3rem 0 0; font-size: .88rem; color: var(--muted); }

/* --- cards --------------------------------------------------------------- */

.list { display: grid; gap: .5rem; }
.list--tight { gap: .35rem; }
.list__month {
  margin: 1.1rem 0 .35rem;
  font-size: .76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .7rem;
  align-items: center;
  padding: .65rem .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: background .15s ease;
}
.card:active { background: var(--surface-2); }
.card__title { font-family: var(--serif); font-size: 1rem; line-height: 1.25; text-wrap: balance; }
.card__sub { margin: .12rem 0 0; font-size: .82rem; color: var(--muted); display: flex; align-items: flex-start; gap: .35rem; }
.card__sub .dot { margin-top: .38em; }
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .3rem; }
.card__count { display: flex; flex-direction: column; align-items: center; min-width: 2.4rem; align-self: center; }
.card__count strong { font-family: var(--serif); font-size: 1.35rem; line-height: 1; }
.card__count span { font-size: .64rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.thumb {
  width: 46px;
  height: 62px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--red { background: linear-gradient(160deg, #6d1730, #3a0c1a); color: #f0c9d4; }
.thumb--white { background: linear-gradient(160deg, #6a5c2c, #35301a); color: #f2e8bf; }
.thumb--rose { background: linear-gradient(160deg, #7d3a49, #3d1d26); color: #f5cdd5; }
.thumb--sparkling { background: linear-gradient(160deg, #6f6231, #35301c); color: #f6e6a8; }
.thumb--orange { background: linear-gradient(160deg, #7d4c1e, #3b2410); color: #f3d3ac; }
.thumb--dessert { background: linear-gradient(160deg, #74561d, #382a11); color: #f0dda6; }
.thumb--fortified { background: linear-gradient(160deg, #532c1f, #2a1610); color: #e6c2ad; }

.dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--unknown); flex: 0 0 auto; }
.dot--red { background: var(--red); }
.dot--white { background: var(--white); }
.dot--rose { background: var(--rose); }
.dot--sparkling { background: var(--sparkling); }
.dot--orange { background: var(--orange); }
.dot--dessert { background: var(--dessert); }
.dot--fortified { background: var(--fortified); }

.pill, .chip, .tag {
  display: inline-flex;
  align-items: center;
  padding: .12rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 550;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill--good { background: rgba(74, 168, 119, .16); color: var(--good); border-color: rgba(74, 168, 119, .4); }
.pill--great { background: rgba(217, 169, 79, .16); color: var(--great); border-color: rgba(217, 169, 79, .45); }
.pill--warn { background: rgba(224, 140, 58, .16); color: var(--warn); border-color: rgba(224, 140, 58, .45); }
.pill--bad { background: rgba(209, 73, 91, .16); color: var(--bad); border-color: rgba(209, 73, 91, .45); }
.pill--cool { background: rgba(106, 149, 196, .16); color: var(--cool); border-color: rgba(106, 149, 196, .4); }
.pill--muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

.chip--restock { background: rgba(74, 168, 119, .18); color: var(--good); }
.chip--repeat { background: rgba(217, 169, 79, .16); color: var(--great); }
.chip--occasional { background: var(--surface-2); color: var(--muted); }
.chip--avoid { background: rgba(209, 73, 91, .16); color: var(--bad); }

.tag--yes { background: rgba(74, 168, 119, .18); color: var(--good); }
.tag--maybe { background: var(--surface-3); color: var(--muted); }
.tag--no { background: rgba(209, 73, 91, .16); color: var(--bad); }

/* --- stars --------------------------------------------------------------- */

.stars { display: inline-flex; gap: .05rem; color: var(--gold); font-size: .95rem; line-height: 1; }
.stars--sm { font-size: .82rem; }
.stars--empty { color: var(--muted); font-size: .8rem; }
.star { color: #4b3540; }
.star.is-full { color: var(--gold); }
.star.is-half { background: linear-gradient(90deg, var(--gold) 50%, #4b3540 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }

.star-input { display: flex; align-items: center; gap: .6rem; }
.star-input__stars { display: flex; gap: .1rem; }
.star-input__star {
  position: relative;
  width: 2.4rem;
  height: 2.6rem;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}
.star-input__glyph { font-size: 1.9rem; color: #4b3540; line-height: 1; pointer-events: none; }
.star-input__star.is-full .star-input__glyph { color: var(--gold); }
.star-input__star.is-half .star-input__glyph {
  background: linear-gradient(90deg, var(--gold) 50%, #4b3540 50%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.star-input__half, .star-input__whole { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 1; }
.star-input__half { left: 0; }
.star-input__whole { right: 0; }
.star-input__label { font-size: .85rem; color: var(--muted); }

/* --- panels & detail ----------------------------------------------------- */

.panel {
  padding: .85rem .9rem;
  margin-bottom: .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel--danger { border-color: rgba(209, 73, 91, .35); }
.panel__title { display: flex; align-items: center; gap: .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .55rem; }
.panel__count { padding: .05rem .45rem; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: .72rem; letter-spacing: 0; }
.panel__sub { margin: -.3rem 0 .6rem; font-size: .84rem; color: var(--muted); }
.panel__note { margin: .5rem 0 0; font-size: .86rem; }
.panel__prose { margin: 0; font-size: .92rem; white-space: pre-wrap; }

.detail__head { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: .9rem; }
.detail__head .thumb { width: 68px; height: 92px; }
.detail__title { font-family: var(--serif); font-size: 1.35rem; line-height: 1.2; }
.detail__sub .dot { margin-top: .38em; }
.detail__sub { margin: .25rem 0 0; align-items: flex-start; font-size: .88rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.detail__meta { margin: .35rem 0 0; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; font-size: .85rem; }
.detail__actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.detail__actions .btn { flex: 1 1 auto; }

/* --- drinking window bar -------------------------------------------------- */

.window-bar { margin: .3rem 0 .2rem; }
.window-bar__track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3a5570, #4b3540 45%, #5d3a2a);
  overflow: visible;
}
.window-bar__peak {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(217, 169, 79, .85), rgba(217, 169, 79, .55));
}
.window-bar__now {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--surface), 0 2px 6px rgba(0, 0, 0, .6);
}
.window-bar__now--bad { background: var(--bad); }
.window-bar__now--warn { background: var(--warn); }
.window-bar__now--cool { background: var(--cool); }
.window-bar__scale { display: flex; justify-content: space-between; margin-top: .35rem; font-size: .72rem; color: var(--muted); }
.window-bar__peak-label { color: var(--gold); }
.window-bar__none { margin: 0; font-size: .88rem; color: var(--muted); }

/* --- score --------------------------------------------------------------- */

.score { display: flex; gap: .9rem; align-items: flex-start; }
.score__ring {
  --pct: 0;
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring, var(--gold)) calc(var(--pct) * 1%), var(--surface-3) 0);
  position: relative;
}
.score__ring::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--surface);
}
.score__ring span { position: relative; z-index: 1; font-family: var(--serif); font-size: 1.35rem; }
.score__ring--restock { --ring: var(--good); }
.score__ring--repeat { --ring: var(--gold); }
.score__ring--occasional { --ring: var(--muted); }
.score__ring--avoid { --ring: var(--bad); }

.score__verdict { margin: 0 0 .3rem; font-size: 1.02rem; font-weight: 600; }
.score__verdict--restock { color: var(--good); }
.score__verdict--repeat { color: var(--gold); }
.score__verdict--avoid { color: var(--bad); }
.score__reasons { margin: 0; padding-left: 1.1rem; font-size: .86rem; color: var(--muted); }
.score__reasons li { margin-bottom: .15rem; }

/* --- bottles & tastings --------------------------------------------------- */

.bottle-list, .tasting-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.bottle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .6rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.bottle-row__info { display: flex; flex-direction: column; min-width: 0; }
.bottle-row__title { font-size: .92rem; }
.bottle-row__sub { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.bottle-row__actions { display: flex; gap: .35rem; flex: 0 0 auto; }

.tasting, .history-item {
  padding: .6rem .7rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.history-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tasting__head, .history-item__head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.history-item__head { justify-content: space-between; }
.history-item__wine { font-family: var(--serif); font-size: 1rem; }
.tasting__date, .history-item__date { font-size: .78rem; color: var(--muted); }
.history-item__row { display: flex; align-items: center; gap: .45rem; margin-top: .3rem; }
.tasting__notes, .history-item__notes { margin: .35rem 0 .2rem; font-size: .88rem; }
.tasting__meta, .history-item__meta { margin: 0; font-size: .78rem; }
.tasting__wine { margin: .2rem 0; font-size: .9rem; }

.insight-row { position: relative; }
.insight-row__note { margin: .15rem 0 .5rem .6rem; font-size: .78rem; color: var(--muted); }

/* --- balance bars --------------------------------------------------------- */

.balance { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.balance__row { display: grid; grid-template-columns: 5.5rem 1fr 2rem; align-items: center; gap: .5rem; font-size: .82rem; }
.balance__track { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.balance__fill { display: block; height: 100%; border-radius: 999px; background: var(--unknown); }
.balance__fill--red { background: var(--red); }
.balance__fill--white { background: var(--white); }
.balance__fill--rose { background: var(--rose); }
.balance__fill--sparkling { background: var(--sparkling); }
.balance__fill--orange { background: var(--orange); }
.balance__fill--dessert { background: var(--dessert); }
.balance__fill--fortified { background: var(--fortified); }
.balance__value { text-align: right; color: var(--muted); }

/* --- scanner -------------------------------------------------------------- */

.scan { display: grid; gap: .7rem; }
.scan__hint { margin: -.2rem 0 0; font-size: .85rem; color: var(--muted); text-align: center; }
.scan__stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  /* Centred for when the height cap makes it narrower than its column. */
  margin: 0 auto;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}
.scan__stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan__reticle { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan__reticle span {
  width: 78%;
  height: 28%;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}
.scan__status {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom, 0px));
  font-size: .84rem;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
}
.scan__torch {
  position: absolute;
  top: .6rem; right: .6rem;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(0, 0, 0, .45);
  font-size: 1.2rem;
  cursor: pointer;
}
.scan__torch.is-on { background: var(--gold); }
.scan__fallbacks { display: flex; gap: .5rem; flex-wrap: wrap; }
.scan__fallbacks .btn { flex: 1 1 30%; }

/* --- form ---------------------------------------------------------------- */

.form__photo { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.form__photo-preview {
  width: 84px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--line);
  overflow: hidden;
  font-size: .72rem;
  text-align: center;
  padding: .3rem;
}
.form__photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.form__photo-actions { display: grid; gap: .4rem; }
.form__actions { display: flex; gap: .6rem; margin-top: 1rem; }
.form__actions .btn { flex: 1; }

/* --- empty states, toasts, sheets ---------------------------------------- */

.empty { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.empty__icon { font-size: 2.4rem; margin-bottom: .4rem; }
.empty h3 { font-family: var(--serif); font-size: 1.1rem; color: var(--text); margin-bottom: .3rem; }
.empty p { font-size: .9rem; margin-bottom: .9rem; }

.footnote { margin: 1.5rem 0 0; text-align: center; font-size: .75rem; color: var(--muted); }

.toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  gap: .4rem;
  justify-items: center;
  padding: 0 .8rem;
  pointer-events: none;
}
.toast {
  max-width: 22rem;
  padding: .6rem .9rem;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: .88rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--good { border-color: rgba(74, 168, 119, .5); }
.toast--warn { border-color: rgba(224, 140, 58, .6); }
.toast--action { display: flex; align-items: center; gap: .7rem; pointer-events: auto; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, .6);
  opacity: 0;
  transition: opacity .18s ease;
}
.sheet-backdrop.is-in { opacity: 1; }
@media (min-width: 560px) { .sheet-backdrop { align-items: center; } }

.sheet {
  width: min(560px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 1rem .9rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  transform: translateY(12px);
  transition: transform .2s ease;
}
.sheet-backdrop.is-in .sheet { transform: none; }
@media (min-width: 560px) { .sheet { border-radius: var(--radius); } }

.sheet__head h2 { font-family: var(--serif); font-size: 1.15rem; margin-bottom: .6rem; }
.sheet__text { font-size: .92rem; margin-bottom: .7rem; }
.sheet__foot { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.sheet__foot .btn { flex: 1 1 auto; }

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

/* --- sign in -------------------------------------------------------------- */

.auth {
  width: min(26rem, 100%);
  margin: 0 auto;
  padding: 3rem 0 2rem;
  text-align: center;
}
.auth__mark { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }
.auth__title { font-family: var(--serif); font-size: 1.6rem; margin-bottom: .3rem; }
.auth__blurb { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth__form { text-align: left; margin-top: .5rem; }
.auth__form .field__label { text-transform: none; letter-spacing: 0; font-size: .82rem; }
.auth__switch { margin-top: 1.2rem; font-size: .86rem; color: var(--muted); }

.btn--block { width: 100%; }

.auth__or {
  position: relative;
  margin: 1.1rem 0 .4rem;
  color: var(--muted);
  font-size: .8rem;
}
.auth__or::before {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  border-top: 1px solid var(--line);
}
.auth__or span { position: relative; background: var(--bg); padding: 0 .7rem; }

/* --- shared-cellar bits --------------------------------------------------- */

.tasting__who {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gold);
}

.raters { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .25rem; }
.rater { display: flex; align-items: center; gap: .5rem; font-size: .84rem; }
.rater__name { min-width: 5rem; color: var(--muted); }
.rater__count { font-size: .74rem; color: var(--muted); }

.people, .passkeys__list, .invites {
  list-style: none;
  margin: .3rem 0 .7rem;
  padding: 0;
  display: grid;
  gap: .35rem;
}
.people__row, .passkeys__row, .invites__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .6rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: .86rem;
  flex-wrap: wrap;
}
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.3rem;
  letter-spacing: .08em;
  text-align: center;
  padding: .8rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  user-select: all;
}

/* --- research ------------------------------------------------------------- */

.research-strip {
  padding: .7rem .8rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: .88rem;
}
.research-strip--busy { border-color: var(--cool); }
.research-strip--good { border-color: rgba(74, 168, 119, .5); }
.research-strip--warn { border-color: var(--warn); }
.research-strip__line { margin: 0; }
.research-strip__meta { margin: .35rem 0 0; font-size: .8rem; color: var(--muted); }

.sources { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .2rem; }
.sources li { font-size: .8rem; }
.sources a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.field.is-filled .input {
  border-color: rgba(74, 168, 119, .55);
  background: rgba(74, 168, 119, .07);
}

/* --- photo gallery -------------------------------------------------------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: .5rem;
}
.gallery__item { margin: 0; }
.gallery__item img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  display: block;
}
.gallery__item.is-primary img { border-color: var(--gold); }
.gallery__item figcaption {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  margin-top: .3rem;
  font-size: .74rem;
}
.gallery__badge { color: var(--gold); }

/* --- offline -------------------------------------------------------------- */

.notice--offline {
  border-color: var(--cool);
  background: linear-gradient(160deg, rgba(106, 149, 196, .16), rgba(106, 149, 196, .05));
}

.scan__aside {
  margin: -.3rem 0 .2rem;
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

/* --- second currency ------------------------------------------------------
   The converted value sits inside the same element as the primary one and is
   revealed for every price at once, so a tap never reflows just one row. */

.money.has-alt {
  cursor: pointer;
  border-bottom: 1px dotted currentColor;
  /* Keeps the dotted hint from crowding the digits. */
  padding-bottom: 1px;
}
.money__alt { display: none; }
.show-alt-currency .money__alt {
  display: inline;
  margin-left: .35em;
  font-size: .85em;
  color: var(--muted);
  opacity: .95;
}
.show-alt-currency .money__alt::before { content: '≈ '; }

/* In the big stat figures the converted value belongs on its own line. */
.stat__value .money__alt {
  display: none;
}
.show-alt-currency .stat__value .money__alt {
  display: block;
  margin-left: 0;
  font-size: .5em;
  line-height: 1.4;
  font-family: var(--font);
}
.stat__value .money.has-alt { border-bottom: 0; }

/* --- label framing and the shutter --------------------------------------- */

/* A tall portrait guide: labels are read best when they fill the frame. */
.scan__frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan__frame span {
  width: 62%;
  height: 66%;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

.btn--shutter { min-height: 52px; font-size: 1.05rem; }
.btn--shutter:disabled { opacity: .5; }

/* --- disambiguation picker ------------------------------------------------ */

.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.pick {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .7rem;
  width: 100%;
  padding: .5rem .6rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pick:active { background: var(--surface-3); }
.pick .thumb { width: 38px; height: 50px; }
.pick__main { display: flex; flex-direction: column; min-width: 0; }
.pick__title { font-family: var(--serif); font-size: .98rem; }
.pick__sub { font-size: .78rem; color: var(--muted); }
.pick__score { font-size: .78rem; color: var(--muted); }
.pick--new { grid-template-columns: 1fr; background: transparent; }

/* An ungrounded answer is still useful — it just must not look verified. */
.warnish { color: var(--warn); }

/* --- staged progress ------------------------------------------------------
   Unknown-length work: name the stage and count the seconds rather than
   pretend to know how far along it is. The bar eases toward the end of each
   stage's slice and only completes when the work actually does. */

.progress { display: grid; gap: .35rem; }
.progress__track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--wine), var(--wine-bright));
  transition: width .4s cubic-bezier(.22, .61, .36, 1);
}
.progress__label { margin: 0; font-size: .88rem; }
.progress__meta { margin: 0; font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.progress.is-done .progress__fill { background: var(--good); }
.progress.is-error .progress__fill { background: var(--bad); }
.progress.is-error .progress__label { color: var(--bad); }

/* Over the camera, progress needs its own legible ground. */
.scan__progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, rgba(0, 0, 0, .82) 35%);
  color: #fff;
}
.scan__progress .progress__meta { color: rgba(255, 255, 255, .72); }
.scan__progress .progress__track { background: rgba(255, 255, 255, .22); }

/* --- fridge header --------------------------------------------------------
   Two tiles, both answering "what shall I open": how much is in there, and
   what is nearest the end of its window. The second is a plain tile on
   purpose — a wine at the end of its window is worth knowing about, not
   worth an alarm. */

.stats--pair { grid-template-columns: 1fr 1fr; }
@media (min-width: 520px) { .stats--pair { grid-template-columns: 1fr 1fr; } }

.stat--link { text-decoration: none; transition: border-color .15s ease; }
.stat--link:active { background: var(--surface-2); }
.stat--link .stat__sub {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Colour chips scroll; the shelf-and-sort control stays pinned beside them. */
.toolbar__row--chips { gap: .4rem; }
.toolbar__row--chips .chips { flex: 1; min-width: 0; }

.icon-btn {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: .95rem;
  cursor: pointer;
}
.icon-btn.is-on { border-color: var(--wine); color: var(--text); background: var(--surface-3); }
