/* Look: dark navy-charcoal mobile app (user's reference screenshot). Rounded cards, teal primary accent,
   coral secondary, circular dials, settings-style rows, toggles, bottom tab bar. Font: Nunito Sans. */
:root {
  --bg: #0e1117;
  --surface: #181d26;
  --surface-2: #222935;
  --ink: #edf1f5;
  --muted: #8d97a5;
  --accent: #33d1d6;
  --accent-ink: #062427;
  --coral: #f2705e;
  --magenta: #c84fdb;
  --dial: #d6f3f4;
  --dial-ink: #0e1117;
  --error: #ff8a7a;
  --radius: 22px;
  --radius-sm: 14px;

  --step-small: 0.875rem;
  --step-body: 1.0625rem;
  --step-lead: 1.25rem;
  --step-head: clamp(1.75rem, 1.4rem + 1.6vw, 2.25rem);
  --step-figure: clamp(2.25rem, 1.8rem + 2vw, 3rem);

  --margin: 20px;
  --tabs-h: 76px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--step-body)/1.5 'Nunito Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
svg.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Page column: phone-width, centred on bigger screens, with room for the tab bar. */
main { max-width: 560px; margin: 0 auto; padding: 12px var(--margin) calc(var(--tabs-h) + 32px); }
.sheet { display: block; }

h1 { font-size: var(--step-head); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; margin: 8px 0 24px; }
h1.center { margin-bottom: 4px; }
.center { text-align: center; }
h2 { font-size: var(--step-small); font-weight: 700; color: var(--muted); margin: 32px 4px 10px; }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 600; padding: 8px 0; }
.back::before { content: ''; width: 9px; height: 9px; border-left: 2px solid; border-bottom: 2px solid; transform: rotate(45deg); }

/* Bottom tab bar */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
}
.tabs > div { display: flex; justify-content: space-around; width: 100%; max-width: 560px; }
.tabs a { display: grid; justify-items: center; gap: 2px; flex: 1; min-width: 0; padding: 4px 2px; color: var(--muted); text-decoration: none; font-size: 0.8125rem; }
.tabs a[aria-current] { color: var(--accent); }

/* Home */
.sub { display: block; text-align: center; color: var(--accent); text-decoration: none; margin-bottom: 28px; }
.sub::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-right: 2px solid; border-top: 2px solid; transform: rotate(45deg) translateY(-2px); }
.rings { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; list-style: none; padding: 0; margin: 0 0 32px; }
.rings a { display: grid; justify-items: center; gap: 8px; text-decoration: none; font-size: clamp(0.6875rem, 2.8vw, 0.875rem); overflow-wrap: anywhere; text-align: center; }
.ring { display: grid; place-items: center; width: clamp(42px, 13vw, 56px); aspect-ratio: 1; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2.5px var(--ring, var(--accent)); color: var(--ring, var(--accent)); }
.score {
  display: grid; place-items: center; align-content: center;
  width: min(220px, 62vw); aspect-ratio: 1; margin: 0 auto 28px; border-radius: 50%;
  background: var(--dial); color: var(--dial-ink); text-decoration: none;
  box-shadow: 0 0 0 10px var(--surface), 0 0 48px rgba(51, 209, 214, 0.25);
}
.score small { color: #3a4654; font-size: var(--step-small); font-weight: 600; }
.score strong { font-size: 4.5rem; line-height: 1; font-weight: 800; font-variant-numeric: lining-nums; }
.nudge { display: flex; align-items: center; gap: 14px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.nudge .dot { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--coral); color: var(--bg); }
.nudge p { margin: 0; flex: 1; font-size: var(--step-small); }

/* Cards and settings-style rows */
.card, .menu, .ledger, .chart, .notice { background: var(--surface); border-radius: var(--radius); }
.menu { list-style: none; margin: 0 0 24px; padding: 6px 0; }
.menu li { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.menu li + li { box-shadow: 0 -1px 0 var(--surface-2); }
.menu a { flex: 1; text-decoration: none; font-weight: 600; }
.menu a::after { content: ''; position: absolute; inset: 0; } /* whole row is the link */
.menu li { position: relative; }
.menu li::after { content: ''; flex: none; width: 7px; height: 7px; border-right: 2px solid var(--accent); border-top: 2px solid var(--accent); transform: rotate(45deg); }
.figure { color: var(--muted); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.menu li:hover { background: var(--surface-2); }
.menu li:first-child:hover { border-radius: var(--radius) var(--radius) 0 0; }
.menu li:last-child:hover { border-radius: 0 0 var(--radius) var(--radius); }

/* Ledger: stat cards with a big number over a small caption. */
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 4px; margin: 0 0 24px; padding: 20px; }
.ledger div { display: grid; gap: 2px; text-align: center; }
.ledger dt { order: 2; color: var(--muted); font-size: var(--step-small); }
.ledger dd { margin: 0; font-size: var(--step-figure); font-weight: 800; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }

/* Circular scale dial */
.dial { position: relative; width: min(300px, 80vw); aspect-ratio: 1; margin: 8px auto 24px; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial .track { fill: none; stroke: var(--surface-2); stroke-width: 16; }
.dial .arc { fill: none; stroke: var(--coral); stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset 90ms linear; }
.dial .face { fill: var(--surface); }
.dial-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.dial-text strong { font-size: 3.5rem; font-weight: 800; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.dial-text span { color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.dial-text .timer { color: var(--ink); font-size: var(--step-lead); font-weight: 700; }

/* Tag chips */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags label { font-weight: 600; font-size: var(--step-small); background: var(--surface-2); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.tags label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.tags input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tags label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.photo { max-width: 100%; height: auto; margin-top: 8px; border-radius: var(--radius-sm); }

/* Control chart */
.chart { margin: 0 0 24px; padding: 16px; }
.chart svg { width: 100%; height: clamp(240px, 50vw, 340px); display: block; font: 400 14px 'Nunito Sans', system-ui, sans-serif; }
.chart text { fill: var(--muted); }
.chart .ideal { fill: var(--surface-2); }
.chart circle { fill: var(--accent); }
.chart a:hover circle, .chart a:focus circle { fill: var(--coral); }
.chart figcaption { font-size: var(--step-small); color: var(--muted); margin-top: 8px; }

/* Brew curve */
.curve .plot { position: relative; height: clamp(200px, 45vw, 280px); }
.curve svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.curve polyline { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.curve .weight { stroke: var(--accent); }
.curve .flow { stroke: var(--coral); stroke-width: 1.5; }
.curve .ghost { stroke-width: 2; }
.curve .g0, .key.g0 { stroke: var(--coral); color: var(--coral); }
.curve .g1, .key.g1 { stroke: var(--magenta); color: var(--magenta); }
.curve .g2, .key.g2 { stroke: #7fb3ff; color: #7fb3ff; }
.curve .bloom { fill: var(--surface-2); }
.curve .pulse, .curve .event, .curve .target { stroke-width: 1; vector-effect: non-scaling-stroke; }
.curve .pulse { stroke: var(--muted); stroke-dasharray: 3 5; }
.curve .event { stroke: var(--ink); opacity: 0.5; }
.curve .target { stroke: var(--accent); opacity: 0.4; stroke-dasharray: 6 6; }
.curve .mark { position: absolute; top: 0; transform: translateX(4px); font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.curve figcaption { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.key::before { content: ''; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.key.weight { color: var(--accent); }
.key.flow { color: var(--coral); }
.rows li::after { display: none; }
.rows li:hover { background: none; }
.rows span:first-child { flex: 1; }
.freezer-link { margin: 0 0 16px; }
.home { position: relative; }
.ring.small { width: 36px; height: 36px; flex: none; }
.ring.small svg { width: 20px; height: 20px; }
.menu li.total { color: var(--muted); }
.menu li.total span:first-child { flex: 1; }
.menu li.total::after { visibility: hidden; }
h2 a { color: var(--ink); text-decoration: none; font-size: var(--step-body); }
.linkish { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.profile { flex-wrap: wrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.row-actions .button { padding: 8px 16px; font-size: var(--step-small); }
.flags { margin-bottom: 24px; border-left: 4px solid var(--coral); }
.flags p { margin: 4px 0; }

/* Segmented choice (Aiden / manual) */
.seg { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg label { flex: 1; text-align: center; padding: 10px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: var(--step-body); }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }

/* Forms: each section is a card of field rows. */
.group { background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; }
.field { padding: 14px 18px; display: grid; gap: 6px; }
.field + .field { box-shadow: 0 -1px 0 var(--surface-2); }
label { font-weight: 600; font-size: var(--step-small); color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface-2); border: 0; border-radius: var(--radius-sm);
  padding: 11px 14px; width: 100%;
}
input[inputmode=decimal], input[type=number] { font-variant-numeric: tabular-nums; }
small { font-size: var(--step-small); color: var(--muted); }
small.error, .errors { color: var(--error); }
small.error:empty { display: none; }

/* Toggle switch rows (booleans) */
.field.check { grid-template-columns: 1fr auto; align-items: center; }
.field.check label { color: var(--ink); font-size: var(--step-body); }
input[type=checkbox]:not(.tags input):not(.pick) {
  appearance: none; width: 52px; height: 30px; padding: 0; border-radius: 999px;
  background: var(--surface-2); position: relative; cursor: pointer; transition: background 150ms;
}
input[type=checkbox]:not(.tags input):not(.pick)::before {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); transition: transform 150ms;
}
input[type=checkbox]:not(.tags input):not(.pick):checked { background: var(--accent); }
input[type=checkbox]:not(.tags input):not(.pick):checked::before { transform: translateX(22px); }

/* Buttons: pills */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 24px 0; }
.button {
  display: inline-block; font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 999px; padding: 12px 24px;
  text-decoration: none; cursor: pointer; transition: transform 120ms ease, background 120ms;
}
.button.quiet { background: var(--surface-2); color: var(--ink); }
.button:disabled { opacity: 0.4; cursor: not-allowed; }
.button:active { transform: scale(0.97); }
.actions select { width: auto; }
.notice { padding: 14px 18px; font-size: var(--step-small); }
.status { color: var(--muted); }
p.sheet { background: var(--surface); border-radius: var(--radius); padding: 20px; }
@media (prefers-reduced-motion: reduce) { .button, .dial .arc, input[type=checkbox]::before { transition: none; } }
.nudge .button { white-space: nowrap; padding: 10px 18px; }
.freezer-link .figure { white-space: normal; text-align: right; }
.menu li .button { position: relative; z-index: 1; padding: 7px 14px; font-size: var(--step-small); }

/* Brew history */
.filters { margin-bottom: 20px; padding: 4px 0; }
.filters summary { cursor: pointer; padding: 12px 20px; font-weight: 700; color: var(--accent); }
.filters .group { background: none; }
.filters .actions { margin: 0 20px 12px; }
.pick { appearance: none; position: relative; z-index: 1; flex: none; width: 24px; height: 24px; padding: 0; border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--muted); cursor: pointer; }
.pick:checked { background: var(--accent); box-shadow: inset 0 0 0 6px var(--surface); }
.card { padding: 4px 0; margin-bottom: 20px; }

/* Compare */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--step-small); }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); margin-bottom: 24px; }
.compare { border-collapse: collapse; width: 100%; font-size: var(--step-small); font-variant-numeric: tabular-nums; }
.compare th, .compare td { padding: 8px 12px; text-align: left; vertical-align: top; min-width: 110px; }
.compare tbody tr + tr > * { box-shadow: 0 -1px 0 var(--surface-2); }
.compare th[scope=row] { color: var(--muted); font-weight: 600; position: sticky; left: 0; background: var(--surface); min-width: 120px; }
.compare thead th { font-weight: 700; }
.compare thead a { color: var(--accent); text-decoration: none; }
.compare td.diff { background: rgba(242, 112, 94, 0.18); color: var(--ink); font-weight: 700; }

/* Coffee page */
.story small { color: var(--muted); font-weight: 400; }
.story small.changed { color: var(--coral); }
h3 { font-size: var(--step-small); font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 24px; }
.trends .chart { margin: 0; padding: 12px; }
.scatter svg { width: 100%; height: 180px; display: block; font: 400 12px 'Nunito Sans', system-ui, sans-serif; }
.scatter text { fill: var(--muted); }
.scatter circle { fill: var(--accent); }
.scatter a:hover circle, .scatter a:focus circle { fill: var(--coral); }
.dialin { padding: 14px 20px; }
.dialin p { margin: 8px 0; }
.dialin ul { margin: 4px 0 8px; padding-left: 20px; }
.dialin .actions { margin: 12px 0 4px; }
.reminders { margin-top: 16px; }

/* Sync banner and messages */
.sync { margin: 0; padding: 10px var(--margin); background: var(--coral); color: var(--bg); text-align: center; font-weight: 700; font-size: var(--step-small); }
.sync a { color: inherit; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px); transform: translateX(-50%); z-index: 20; width: min(520px, calc(100% - 32px)); margin: 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
small.error { display: inline; }

/* Profile */
.avatar { display: grid; place-items: center; width: 96px; height: 96px; margin: 8px auto 12px; border-radius: 50%; background: var(--surface); color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent); }
.avatar svg { width: 48px; height: 48px; }
.section { margin-bottom: 12px; padding: 0; }
.section > summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 16px 20px; font-weight: 700; list-style: none; }
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after { content: ''; flex: none; width: 8px; height: 8px; margin-left: 12px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); transition: transform 150ms; }
.section[open] > summary::after { transform: rotate(-135deg); }
.section > summary .figure { margin-left: auto; font-weight: 400; }
.section .menu { margin: 0; background: none; }
.pad { padding: 0 20px 16px; margin: 0; }
.avatar-link { position: absolute; top: 12px; right: var(--margin); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.home h1.center, .home .sub { padding: 0 48px; }

/* Sign-in */
.signed-out .tabs, .signed-out .sync { display: none; }
.login { max-width: 420px; margin: 0 auto; }
.center-actions { justify-content: center; }
.button.google { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #1f1f1f; }
.g-mark { width: 20px; height: 20px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: var(--step-small); margin: 8px 0 16px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--surface-2); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.field.check input:disabled { opacity: 0.4; }
.inline { flex-wrap: wrap; } .inline input { min-width: 150px; }

/* Recipe search */
.search { margin-bottom: 12px; }
.search input { border-radius: 999px; padding: 12px 18px; background: var(--surface); }
.tag-filter { margin-bottom: 16px; }
.tag-filter .n { color: inherit; opacity: 0.6; font-weight: 400; }

/* Dial-in helper */
.question { border: 0; padding: 0; margin: 0 0 14px; }
.question legend { font-weight: 700; font-size: var(--step-small); color: var(--muted); margin-bottom: 6px; }
.verdict { font-size: var(--step-lead); font-weight: 800; margin: 4px 0 8px; }
.dialin details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 8px 0; }
