/* iPhone-first. One column, big taps, no framework. */

:root {
  --wine:      #7b1e3c;
  --wine-deep: #3b1220;
  --bg:        #fbf7f4;
  --card:      #ffffff;
  --ink:       #241a1d;
  --muted:     #7d6f73;
  --line:      #e7ddd9;
  --ok:        #1f6b45;
  --warn:      #8a4b12;
  --err:       #a01f28;
  --tap:       48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wine:      #c76185;
    --wine-deep: #1a0d12;
    --bg:        #171013;
    --card:      #221619;
    --ink:       #f3e9ea;
    --muted:     #a9989d;
    --line:      #3a2a2f;
    --ok:        #6fd39d;
    --warn:      #e0a463;
    --err:       #ef8b93;
  }
}

* { box-sizing: border-box; }

/* Long unbroken strings (shell commands on the profile page) must wrap rather than
   widen the page. Do NOT reach for overflow-x on html/body to enforce that: it makes
   the body a scroll container and position:sticky on the header stops working. */
code, pre { word-break: break-word; overflow-wrap: anywhere; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---- top bar ---- */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 4px;
  background: var(--wine-deep);
  color: #fff;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
}
.bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-back {
  color: #fff;
  text-decoration: none;
  font-size: 30px;
  line-height: 1;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.bar-who {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .28);
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  min-height: 34px;
}

main { padding: 14px 14px 20px; max-width: 720px; margin: 0 auto; }

/* ---- bottom tabs ---- */
.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 7px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.tabs a span { font-size: 21px; line-height: 1; }
.tabs a.on { color: var(--wine); font-weight: 600; }

/* ---- cards / list ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 0 0 12px;
}
.list { list-style: none; margin: 0 0 14px; padding: 0; }
.list li { margin-bottom: 10px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  min-height: var(--tap);
}
.row:active { background: var(--bg); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.row-side { text-align: right; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.row-chev { color: var(--muted); font-size: 22px; }
.thumb {
  width: 44px;
  height: 58px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  flex: none;
}

.group-head {
  margin: 18px 2px 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-head:first-child { margin-top: 2px; }

/* ---- drinking window ---- */
/* Four states, three of the app's existing tones plus a quiet one for "hold" —
   holding a bottle is not a warning, it is simply not tonight's bottle. */
.drink {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  vertical-align: 1px;
}
.drink-ok   { background: rgba(31, 107, 69, .13);  color: var(--ok); }
.drink-warn { background: rgba(138, 75, 18, .14);  color: var(--warn); }
.drink-err  { background: rgba(160, 31, 40, .12);  color: var(--err); }
.drink-hold { background: var(--bg); color: var(--muted); border-color: var(--line); }
.row-sub .drink { margin-right: 6px; }

.chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  margin: 0 6px 6px 0;
}

/* ---- forms ---- */
label { display: block; margin: 12px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], select, textarea {
  width: 100%;
  font-size: 17px; /* 17px+ stops iOS zoom-on-focus */
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  margin-top: 5px;
  min-height: var(--tap);
  -webkit-appearance: none;
  appearance: none;
}
select { background-image: none; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--wine); outline-offset: 1px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 8px; }

/* ---- search + filters ---- */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.filters select { margin-top: 0; font-size: 15px; padding: 10px; min-height: 42px; }
/* Five filters into two columns leaves the last one on its own; give the sort the
   whole row rather than a stranded half of one. */
.filters select:last-child { grid-column: 1 / -1; }
.filter-actions { display: flex; gap: 8px; margin-top: 10px; }
.filter-actions button, .filter-actions .btn { flex: 1; }
input[type=search] {
  width: 100%;
  font-size: 17px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  min-height: var(--tap);
  -webkit-appearance: none;
  appearance: none;
}

/* A count of identical bottles, shown inline with the wine's name. */
.count {
  display: inline-block;
  margin-left: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--wine);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: 1px;
}

/* A stepper: minus, the count, plus — thumb-sized taps either side. */
.counter { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.counter form { flex: 0 0 auto; }
.counter button { width: 56px; margin-top: 0; font-size: 24px; font-weight: 700; padding: 8px 0; }
.counter-value { flex: 1; text-align: center; font-size: 22px; font-weight: 600; }
.counter-value span { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* ---- stats ---- */
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.figures div { background: var(--bg); border-radius: 11px; padding: 10px 12px; }
.figures b { display: block; font-size: 22px; line-height: 1.15; }
.figures span { font-size: 12.5px; color: var(--muted); }
/* A figure that filters the cellar when you tap it. Same tile as a plain one — the
   link is the whole box, so it wants the box's padding rather than a text underline. */
.figures a {
  display: block;
  background: var(--bg);
  border-radius: 11px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}
.figures a:active { background: var(--line); }

.meter-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; }
.meter-label { flex: 0 0 82px; color: var(--muted); }
.meter { flex: 1; height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--wine); border-radius: 999px; }
.meter-value { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--muted); }

ul.plain { list-style: none; margin: 8px 0 0; padding: 0; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  margin-top: 16px;
  padding: 13px 16px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--wine);
  border: 1px solid transparent;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
button:active, .btn:active { filter: brightness(.92); }
.btn-2 { background: var(--card); color: var(--wine); border-color: var(--line); }
.btn-danger { background: var(--card); color: var(--err); border-color: var(--line); }
button:disabled { opacity: .5; }

.seg { display: flex; gap: 8px; margin-top: 6px; }
.seg label {
  flex: 1;
  margin: 0;
  text-align: center;
  padding: 12px 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span,
.seg label:has(input:checked) { background: var(--wine); color: #fff; border-color: var(--wine); }

.stars-pick { display: flex; gap: 6px; margin-top: 6px; }
.stars-pick label {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 24px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stars-pick label:has(input:checked) { background: var(--wine); border-color: var(--wine); color: #fff; }

/* ---- misc ---- */
.flash { padding: 11px 13px; border-radius: 11px; margin: 0 0 14px; font-size: 15px; }
.flash.ok   { background: rgba(31, 107, 69, .12);  color: var(--ok); }
.flash.warn { background: rgba(138, 75, 18, .12);  color: var(--warn); }
.flash.err  { background: rgba(160, 31, 40, .12);  color: var(--err); }

.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 44px 16px; }
.empty-big { font-size: 44px; display: block; margin-bottom: 10px; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.stack-tight > * + * { margin-top: 8px; }
h2 { font-size: 17px; margin: 0 0 8px; }
a { color: var(--wine); }
.hero-photo { width: 100%; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 14px; }

/* The camera input is driven by its <label>, which can be styled as a button. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- the snark ---- */

/* The verdict is the headline of a bottle, so it is allowed to be loud: it is the
   one place in the app where type is bigger than the bottle's own name. */
.snark-verdict {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  font-style: italic;
  color: var(--wine);
  margin: 0 0 10px;
}

.snark-body { margin: 0; }

/* Collapsed by default: the joke is the product, the sober notes are the receipt. */
.snark-straight { margin-top: 12px; font-size: 14.5px; }
.snark-straight summary {
  cursor: pointer;
  color: var(--muted);
  list-style: none;
}
.snark-straight summary::-webkit-details-marker { display: none; }
.snark-straight summary::before { content: '▸ '; }
.snark-straight[open] summary::before { content: '▾ '; }
.snark-straight p { margin: 8px 0 0; color: var(--muted); }

/* ---- a photo with several bottles in it ---- */
.bottle-row {
  min-width: 0;   /* a fieldset defaults to min-content, which the grid below overflows */
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 12px;
  margin: 12px 0 0;
}
.bottle-row:has(.bottle-keep input:not(:checked)) { opacity: .45; }
.bottle-keep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 30px;
}
.bottle-keep input { flex: 0 0 auto; width: 22px; height: 22px; margin: 0; accent-color: var(--wine); }
.bottle-row input[type=text], .bottle-row input[type=number], .bottle-row select { margin-top: 8px; }
.bottle-three { display: grid; grid-template-columns: 1fr 0.7fr 1.1fr; gap: 8px; }
.bottle-read { margin: 9px 0 0; }
.bottle-read:empty { display: none; }
#multi-one { margin-top: 10px; }

/* The byline under a cellar's name. Quiet on purpose: the heading is whose bottles
   these are, and the app is only signing its work. nowrap because the h1 above it
   ellipsises long cellar names and a wrapped byline would fight that. */
.bar-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .05em;
  opacity: .62;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- a photo with several bottles in it ---- */
.bottle-row {
  min-width: 0;   /* a fieldset defaults to min-content, which the grid below overflows */
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 12px;
  margin: 12px 0 0;
}
.bottle-row:has(.bottle-keep input:not(:checked)) { opacity: .45; }
.bottle-keep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 30px;
}
.bottle-keep input { flex: 0 0 auto; width: 22px; height: 22px; margin: 0; accent-color: var(--wine); }
.bottle-row input[type=text], .bottle-row input[type=number], .bottle-row select { margin-top: 8px; }
.bottle-three { display: grid; grid-template-columns: 1fr 0.7fr 1.1fr; gap: 8px; }
.bottle-read { margin: 9px 0 0; }
.bottle-read:empty { display: none; }
#multi-one { margin-top: 10px; }


/* A shelf row's verdict. Smaller than the bottle page's, because a dozen of these
   stacked at 20px would be a wall rather than a joke. */
.bottle-verdict {
  margin: 6px 0 0;
  font-size: 14px;
  font-style: italic;
  font-weight: 500;
  color: var(--wine);
}
