:root {
  --bg: #17121a;
  --surface: #211a25;
  --raised: #2b2230;
  --line: #3a2f40;
  --text: #f1e9e4;
  --muted: #a8998f;
  --accent: #d9a05b;
  --accent-ink: #2a1a08;
  --danger: #e2776f;

  --red: #9c2f45;
  --white: #e6d48c;
  --rose: #eaa3ad;
  --sparkling: #b9d3df;
  --dessert: #d8962d;
  --fortified: #7a4526;
  --other: #77707c;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabs: 60px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--sans);
  padding-bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 16px);
  overflow-x: hidden;
}
main { max-width: 720px; margin: 0 auto; padding: 0 16px; outline: none; }
h1, h2, p, ul, dl, dd, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

h1 { font: 600 28px/1.15 var(--serif); letter-spacing: .01em; text-wrap: balance; }
h2 { font: 600 13px/1.2 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 20px) 0 14px; }
.back { text-decoration: none; color: var(--accent); font-weight: 600; padding: 8px 8px 8px 0; }
.back::before { content: "\2039\00a0"; }

/* type colours */
.t-red { --c: var(--red); } .t-white { --c: var(--white); } .t-rose { --c: var(--rose); }
.t-sparkling { --c: var(--sparkling); } .t-dessert { --c: var(--dessert); }
.t-fortified { --c: var(--fortified); } .t-other { --c: var(--other); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c);
  margin-right: 6px; box-shadow: 0 0 0 1px #0004; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--raised); font-weight: 600; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: none; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: none; }
.btn:disabled, button:disabled { opacity: .4; cursor: default; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 600; }
.link.danger { color: var(--danger); }

/* summary */
#summary { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.split { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.split i { background: var(--c); min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 14px; font-size: 13px; color: var(--muted); }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 1px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.tile span { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tile b { font: 600 24px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.tile b.muted { font-size: 19px; line-height: 1.5; }
.tile small { font-size: 12.5px; color: var(--muted); }
.extras { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.extras .link { font-weight: 500; padding: 6px 0; }

/* filters */
.filters { display: grid; gap: 10px; margin: 16px 0 6px; }
input, select { width: 100%; min-height: 46px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); }
input::placeholder { color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 19px;
  border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.selects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.selects label, .sheet label { display: grid; gap: 4px; min-width: 0; }
.selects span, .sheet label > span, .sheet .lbl, legend { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.selects select { padding: 0 8px; font-size: 14.5px; }

.count { display: flex; justify-content: space-between; align-items: center; min-height: 40px;
  font-size: 13.5px; color: var(--muted); }

/* list */
.list li + li { border-top: 1px solid var(--line); }
.list .none { padding: 32px 0; text-align: center; color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; text-decoration: none; }
.thumb { flex: none; width: 46px; height: 68px; border-radius: 8px; object-fit: contain; background: #efe9e2; padding: 3px; }
.thumb.own, .label.own { object-fit: cover; padding: 0; }
.ph, .thumb.ph, .label.ph { display: grid; place-items: center; background: color-mix(in srgb, var(--c) 22%, var(--surface)); padding: 0; }
.ph svg { height: 70%; fill: var(--c); opacity: .9; }
.info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.producer { font-size: 12.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.name { font: 600 17px/1.25 var(--serif); overflow-wrap: anywhere; }
.name em { font-style: normal; font-weight: 400; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 13px; color: var(--muted); }
.where::before { content: "\00b7\00a0"; }
.qty { flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px; display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; }

.badge { font-style: normal; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; border: 1px solid currentColor; white-space: nowrap; }
.w-ready { color: #8fcf9b; } .w-hold { color: #8db8e8; } .w-past { color: #e8b06a; } .w-unknown { color: var(--muted); }

/* empty */
.empty { text-align: center; padding: 48px 8px; display: grid; gap: 12px; justify-items: center; }
.empty h2 { font: 600 22px var(--serif); text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.empty p { color: var(--muted); max-width: 34ch; }
.ph.big { width: 72px; height: 104px; border-radius: 14px; }

/* wine page */
.wine { display: grid; gap: 22px; }
.hero { display: flex; gap: 16px; align-items: flex-start; }
.hero > div { min-width: 0; display: grid; gap: 4px; }
.hero h1 { font-size: 24px; overflow-wrap: anywhere; }
.label { flex: none; width: 104px; height: 156px; border-radius: 12px; object-fit: contain; background: #efe9e2; padding: 6px; }
.vintage { color: var(--muted); display: flex; align-items: center; gap: 0; }
.vintage .dot { margin-left: 10px; }
.photo-actions { display: flex; gap: 16px; }
.facts, .windows { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.facts div, .windows div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 14px; background: var(--surface); }
dt { color: var(--muted); }
dd { text-align: right; overflow-wrap: anywhere; }
.windows .using { box-shadow: inset 3px 0 0 var(--accent); }
.note { font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.note.pad { margin-top: 16px; }
.h-count { color: var(--text); }
.places { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.places li { display: flex; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); }
.bottles { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bottles li + li { border-top: 1px solid var(--line); }
.bottles button { width: 100%; min-height: 48px; display: grid; grid-template-columns: 5.5em 1fr auto; gap: 10px; align-items: center;
  text-align: left; padding: 6px 14px; background: var(--surface); border: 0; font-variant-numeric: tabular-nums; }
.scores li { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; }
.scores b { font: 600 20px var(--serif); }
.out { width: 100%; }

/* locations */
.locs { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.locs li { background: var(--surface); padding: 6px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 12px; }
.locs li + li { border-top: 1px solid var(--line); }
.loc-main { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  min-height: 44px; background: none; border: 0; padding: 0; text-align: left; }
.loc-main b { font: 600 19px var(--serif); }
.loc-main span { color: var(--muted); font-variant-numeric: tabular-nums; }
.loc-actions { display: flex; gap: 18px; }
.check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }
.check span { font-size: 14.5px !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--text) !important; }

/* settings */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 10px; justify-items: start; }
.card + .card { margin-top: 12px; }
.card h2 { margin: 0; }
.report { width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--raised); border-left: 3px solid #8fcf9b; font-size: 14.5px; }
.report.bad { border-left-color: var(--danger); }
.report ul { margin-top: 6px; padding-left: 18px; list-style: disc; color: var(--muted); font-size: 13.5px; }

/* dialog */
dialog { width: min(100% - 24px, 460px); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--text); padding: 0; }
dialog::backdrop { background: #0009; }
.sheet { display: grid; gap: 14px; padding: 20px; }
.sheet h2 { font: 600 21px var(--serif); text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.sheet .note { margin: 0; }
.sheet input, .sheet select { background: var(--bg); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; display: grid; gap: 8px; min-width: 0; }
legend { padding: 0 6px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.targets { display: grid; gap: 8px; }
.stepper { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 12px; }
.stepper > span { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stepper button { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); font-size: 22px; }
.stepper output { min-width: 4.5em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.error { color: var(--danger); font-size: 14px; }

/* tabs */
.tabs { position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; max-width: 240px; height: var(--tabs); display: grid; place-content: center; justify-items: center; gap: 3px;
  text-decoration: none; font-size: 11.5px; letter-spacing: .04em; color: var(--muted); }
.tabs svg { width: 22px; height: 22px; fill: currentColor; }
.tabs a.on { color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 14px); z-index: 20;
  transform: translate(-50%, 12px); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14.5px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* pricing and insights */
a.tile { text-decoration: none; }
.progress { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; margin-bottom: 16px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.price-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 14px; }
.price-card label { display: grid; gap: 4px; min-width: 0; }
.price-card label > span { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.price-card input { background: var(--bg); }
.price-card input[name=price] { min-height: 60px; font: 600 26px var(--serif); font-variant-numeric: tabular-nums; }
.price-card .note { margin: 0; }
.price-card .note a { color: var(--accent); }
.pc-head { display: flex; gap: 12px; align-items: center; }
.bottles small { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; margin-top: -4px; }
.big-num { font: 600 34px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.big-num.muted { font-size: 24px; }
.bars li + li { border-top: 1px solid var(--line); }
.bars li > * { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline;
  padding: 10px 0; background: none; border: 0; text-align: left; }
.b-label { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.b-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.b-n small { font-weight: 400; color: var(--muted); display: inline-block; min-width: 2.6em; text-align: right; }
.b-bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.b-bar i { display: block; height: 100%; min-width: 3px; background: var(--accent); border-radius: 4px; }
.b-cost { grid-column: 1 / -1; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tabs a { min-width: 0; }

/* bulk assign */
h1.sub { margin-bottom: 4px; }
.filters .lbl { display: block; margin-bottom: 6px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.btn.wide { width: 100%; margin-bottom: 14px; }
.assign li { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.assign li.done .info { opacity: .55; }
.assign .name .dot { margin-right: 7px; vertical-align: 1px; }
.as-step { flex: none; display: grid; grid-template-columns: 44px 30px 44px 62px; align-items: center; gap: 4px; }
.as-step button { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); font-size: 21px; padding: 0; }
.as-step .all { font-size: 13.5px; font-weight: 600; margin-left: 4px; }
.as-step output { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn.rest { width: 100%; margin-top: 18px; }
.list-none { padding: 28px 0; text-align: center; color: var(--muted); }

/* pick */
.pick-opts { display: flex; flex-wrap: wrap; gap: 0 22px; }
.pick-start { display: grid; padding: 40px 0; }
.btn.big { min-height: 64px; font-size: 19px; border-radius: 16px; }
.pick-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px 16px 16px;
  display: grid; gap: 4px; justify-items: center; text-align: center; }
.pick-card .label { margin-bottom: 10px; }
.pick-card h2 { font: 600 23px/1.2 var(--serif); text-transform: none; letter-spacing: 0; color: var(--text);
  display: block; margin: 0; overflow-wrap: anywhere; text-wrap: balance; }
.pick-card h2 em { font-style: normal; font-weight: 400; color: var(--muted); }
.pick-card .meta { justify-content: center; font-size: 14px; }
.pick-where { margin-top: 8px; font-weight: 600; }
.pick-where .muted { font-weight: 400; }
.pick-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.pick-actions .primary { grid-column: 1 / -1; min-height: 54px; font-size: 17px; }
.empty .btn { width: 100%; max-width: 320px; }
.recent { margin-top: 28px; }
.history { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.history li { display: flex; align-items: center; gap: 12px; padding: 4px 14px; min-height: 48px; background: var(--surface); }
.history li + li { border-top: 1px solid var(--line); }
.history li > :first-child { flex: 1; min-width: 0; }
.history a { text-decoration: none; display: grid; padding: 6px 0; overflow-wrap: anywhere; }
.history em { font-style: normal; color: var(--muted); }
.history small { color: var(--muted); font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.warn { color: #e8b06a; }
#toast { display: flex; align-items: center; gap: 14px; }
#toast.show { pointer-events: auto; }
#toast button { background: none; border: 0; padding: 4px 0; font-weight: 700; color: #8a4a12; text-decoration: underline; }

@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .targets { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
