:root {
  --bg: #f6f3ee; --card: #fff; --text: #2b2620; --muted: #7a7166; --line: #e3ddd2;
  --accent: #b8741a; --accent-text: #fff; --danger: #b3382c; --ok: #2f7d4f; --star: #e8a817;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f; --card: #211d16; --text: #ece6da; --muted: #9b9181; --line: #3a3429;
    --accent: #d99a3d; --accent-text: #1a1408; --danger: #e0685a; --ok: #6cc08b; --star: #f0b92e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .hint { color: var(--muted); font-size: .9rem; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 1rem 16px 4rem; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem 16px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.links { display: flex; flex-wrap: wrap; gap: .2rem .9rem; flex: 1; }
.links a { color: var(--text); }
.right { display: flex; align-items: center; gap: .6rem; }
.lang a { color: var(--muted); padding: 0 .25rem; } .lang a.on { color: var(--text); font-weight: 700; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 999px; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 2.2rem; min-width: 190px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .4rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 30; }
.menu-pop a, .linklike { padding: .35rem .5rem; border-radius: 6px; color: var(--text); background: none; border: 0; text-align: left; font: inherit; cursor: pointer; width: 100%; }
.menu-pop a:hover, .linklike:hover { background: var(--bg); text-decoration: none; }
.dot { background: var(--accent); color: var(--accent-text); border-radius: 999px; font-size: .75rem; padding: 0 .4rem; }

.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .7rem; border: 1px solid var(--line); background: var(--card); }
.flash.ok { border-color: var(--ok); } .flash.error { border-color: var(--danger); }
.flash.invite { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; border-color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.narrow, .narrow { max-width: 440px; margin: 2rem auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid2 .card { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.tile { display: flex; gap: .8rem; align-items: center; color: var(--text); margin: 0; }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tilecode { font: 700 1.3rem ui-monospace, monospace; color: var(--accent); min-width: 3.2rem; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: .3rem; }
.code { font-family: ui-monospace, "SF Mono", monospace; font-weight: 700; color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border: 0; }
.overdue { color: var(--danger); font-weight: 600; } .ready { color: var(--ok); font-weight: 600; }

.btn, button.btn { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .15rem .55rem; font-size: .85rem; }
.btns { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; } .btns form { margin: 0; }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.dangerzone { margin-top: 2rem; text-align: right; }

input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .55rem; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.fieldrow { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; } .fieldrow .grow, .grow { flex: 1; min-width: 140px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; margin: 0; }
legend { padding: 0 .4rem; color: var(--muted); }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; } td.num { white-space: nowrap; text-align: right; }
td .btns { justify-content: flex-end; }

.badge { display: inline-block; padding: 0 .55rem; border-radius: 999px; border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.s-fermenting { color: var(--accent); border-color: var(--accent); } .s-aging { color: #8a6bbd; border-color: #8a6bbd; }
.s-bottled, .s-finished { color: var(--ok); border-color: var(--ok); } .s-dropped { color: var(--danger); border-color: var(--danger); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .8rem; } .facts dd { margin: 0; }
.notes { white-space: pre-wrap; border-top: 1px solid var(--line); padding-top: .6rem; margin-bottom: 0; }

.log { list-style: none; padding: 0; margin: 0 0 .8rem; }
.log li { display: grid; grid-template-columns: 6.5rem 1fr auto; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.log .when { color: var(--muted); font-variant-numeric: tabular-nums; } .steptext { white-space: pre-wrap; }
.thumb { display: block; max-width: 160px; max-height: 120px; border-radius: 8px; margin-top: .4rem; }
@media (max-width: 560px) { .log li { grid-template-columns: 1fr; } }
details.addform { margin-top: .8rem; } details.addform summary { cursor: pointer; display: inline-block; list-style: none; }
details.addform[open] summary { margin-bottom: .7rem; }
details.inline-menu { position: relative; } details.inline-menu summary { list-style: none; cursor: pointer; }
details.inline-menu .menu-pop { right: auto; left: 0; min-width: 240px; padding: .8rem; }

/* star rating input (radios, reversed so ~ selects lower stars) */
.stars { display: inline-flex; flex-direction: row-reverse; }
.stars input { display: none; }
.stars label { font-size: 1.6rem; line-height: 1; color: var(--line); cursor: pointer; padding: 0 .08rem; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: var(--star); }
.stars-ro { color: var(--line); letter-spacing: 1px; } .stars-ro .on { color: var(--star); }
.ratings { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .3rem 1.5rem; margin-bottom: .8rem; }
.rrow { display: grid; grid-template-columns: 6rem auto 1fr; align-items: center; gap: .5rem; }
.rrow.big { grid-column: 1 / -1; font-weight: 600; }

.chartwrap { max-width: 640px; } svg.chart { width: 100%; height: auto; color: var(--accent); }
svg.chart .grid { stroke: var(--line); } svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .line { stroke: var(--accent); stroke-width: 2; } svg.chart .dot { fill: var(--accent); }

/* calculator */
dialog.calc { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--text); padding: 1rem 1.2rem; }
dialog.calc::backdrop { background: rgba(0,0,0,.5); }
.calc-grid { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: .8rem; }
.calc-row { display: grid; grid-template-columns: 1fr 7rem 2.4rem; gap: .5rem; align-items: center; margin-bottom: .45rem; }
.calc-row.sugar { grid-template-columns: 1fr 6rem 2.6rem 2.2rem 2rem; }
.calc-row .unit { color: var(--muted); font-size: .85rem; }
.calc-label { color: var(--muted); }
label.lock { flex-direction: row; align-items: center; cursor: pointer; }
label.lock input { position: absolute; opacity: 0; pointer-events: none; }
label.lock span { opacity: .35; filter: grayscale(1); font-size: 1.2rem; }
label.lock input:checked + span { opacity: 1; filter: none; }
.calc-out { margin-top: .8rem; padding: .7rem; border-radius: var(--radius); background: var(--bg); min-height: 1rem; }
.calc-out.error { border: 1px solid var(--danger); color: var(--danger); } .calc-out.ok { border: 1px solid var(--ok); }
.calc-out strong { color: var(--accent); }
.calc-out ul { margin: .4rem 0 0; padding-left: 1.1rem; }

/* default batch */
.default-star { color: var(--star); font-size: 1.2rem; }
.default-badge { color: var(--star); border-color: var(--star); padding: .15rem .7rem; }
.detail-title { margin: 1.6rem 0 .6rem; padding-top: 1rem; border-top: 2px solid var(--line); }
.detail { margin-top: .4rem; }

/* notifications */
li.chan { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.indent { margin-left: 1.6rem; }

.note { margin: .8rem 0; }
.note-text { white-space: pre-wrap; margin: .4rem 0 0; }
.note form { margin-top: .6rem; }

/* landing + gallery */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2.6rem; margin-bottom: .3rem; }
.lead { font-size: 1.15rem; max-width: 40rem; margin: .5rem auto 1.2rem; color: var(--muted); }
.herobtns { justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; margin: 1.5rem 0; }
.features .card { margin: 0; }
.features h3 { margin-top: 0; }
.pubgrid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pubcard { display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.pubcard h3 { margin: .3rem 0 0; }
.pubmain { color: var(--text); display: block; }
.pubmain:hover { text-decoration: none; }
.pubstars { display: flex; gap: 1rem; margin: .4rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .3rem; }
.fav { font-size: 1.3rem; color: var(--muted); } .fav.on { color: var(--danger); }
.subtitle { font-size: 1.1rem; color: var(--muted); margin-bottom: .3rem; }
.pager { margin: 1rem 0; flex-wrap: wrap; }
.filters .fieldrow { align-items: end; }

dialog.popup { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); max-width: 28rem; width: calc(100% - 2rem); padding: 1rem; }
dialog.popup::backdrop { background: rgba(0,0,0,.5); }
.btn.on { border-color: var(--ok); color: var(--ok); }
.sugarblock[hidden], [data-bottle-custom][hidden] { display: none; }

/* ---------- icons, nav polish ---------- */
.ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.2em; }
.brand { display: inline-flex; align-items: center; gap: .35rem; }
.links { align-items: center; }
.links a { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border-radius: 999px; color: var(--muted); font-weight: 500; }
.links a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.links a.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.iconbtn { display: inline-flex; align-items: center; gap: .4rem; }
.menu summary { display: inline-flex; align-items: center; gap: .4rem; }
.menu-pop a, .linklike { display: flex; align-items: center; gap: .55rem; }
.dot { display: inline-block; min-width: 1.2rem; text-align: center; font-style: normal; line-height: 1.2rem; }
.tabbar { display: none; }

/* action menu on the brew page */
.actionmenu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.actionmenu summary::-webkit-details-marker { display: none; }
details.actionmenu .menu-pop { right: 0; left: auto; top: 2.9rem; min-width: 250px; }
.actionmenu { position: relative; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; width: 100%; }
.menu-pop form.stack { padding: .3rem .5rem; }

/* collapsible sections */
details.sect { padding: 0; }
details.sect > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; }
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary h2 { margin: 0; }
details.sect > summary::after { content: ""; width: .55rem; height: .55rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s; margin-right: .2rem; }
details.sect[open] > summary::after { transform: rotate(-135deg); }
details.sect > .sect-body { padding: 0 1rem 1rem; }
details.sect[open] > summary { padding-bottom: .5rem; }

/* sheets (bottom sheets on phones, centred popups on desktop) */
.sheet-grip { display: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.sheet-head .lang { display: flex; align-items: center; gap: .2rem; }
.sheet-list { display: flex; flex-direction: column; }
.sheet-list a, .sheet-list button, .sheet-list .linklike { display: flex; align-items: center; gap: .8rem; padding: .75rem .4rem; border: 0; background: none; color: var(--text);
  font: inherit; text-align: left; width: 100%; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 0; }
.sheet-list a:hover { text-decoration: none; background: var(--bg); }
.sheet-list > form:last-child .linklike { border-bottom: 0; color: var(--danger); }
#more-sheet { padding: 1rem 1.2rem; }

@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.filter-toggle { display: none; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: nowrap; padding: .5rem 14px; padding-top: calc(.5rem + env(safe-area-inset-top)); gap: .6rem; }
  .topbar .links, .topbar .lang { display: none; }
  .topbar .right { margin-left: auto; gap: .5rem; }
  .iconbtn .lbl { display: none; }
  .iconbtn { padding: .35rem .55rem; min-height: 38px; }
  .menu { display: none; }
  .brand { font-size: 1.15rem; }
  .wrap { padding: .8rem 14px calc(6rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.4rem; }

  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--card); border-top: 1px solid var(--line);
    padding: .25rem .3rem calc(.25rem + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end; }
  .tabbar a, .tabbar button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .35rem .1rem;
    background: none; border: 0; color: var(--muted); font: inherit; font-size: .68rem; cursor: pointer; min-height: 52px; justify-content: center; text-decoration: none; }
  .tabbar .ic { width: 1.5rem; height: 1.5rem; }
  .tabbar .on { color: var(--accent); }
  .tabbar .tab-new { flex: 0 0 56px; height: 56px; min-height: 56px; margin-top: -1.1rem; border-radius: 50%; background: var(--accent); color: var(--accent-text);
    justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.35); padding: 0; }
  .tabbar .tab-new .ic { width: 1.8rem; height: 1.8rem; stroke-width: 2.2; }
  .tabbar .dot { position: absolute; top: .15rem; right: 22%; font-size: .65rem; line-height: 1rem; min-width: 1rem; padding: 0 .25rem; }

  /* bigger touch targets, no zoom on focus */
  input, select, textarea { font-size: 16px; min-height: 44px; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: 1.2rem; height: 1.2rem; }
  .btn, button.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
  .btn.small { min-height: 38px; padding: .25rem .7rem; }
  .fieldrow > label { flex: 1 1 140px; }
  .fieldrow > label.grow { flex-basis: 100%; }
  .card { padding: .85rem; }
  .card.narrow, .narrow { margin: 1rem auto; }

  /* dialogs become bottom sheets */
  dialog.popup, dialog.calc { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%; max-height: 90vh; overflow-y: auto;
    border-radius: 18px 18px 0 0; border-bottom: 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); animation: sheet-up .18s ease-out; }
  .sheet-grip { display: block; width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: -.3rem auto .7rem; }
  .calc-row { grid-template-columns: minmax(0, 1fr) 5rem 2rem; }
  .calc-row.sugar { grid-template-columns: minmax(0, 1fr) 4.2rem 1.6rem 1.8rem 1.4rem; gap: .35rem; }
  .calc-row input, .calc-row select { min-width: 0; }

  /* brew page */
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts dd { overflow-wrap: anywhere; }
  details.actionmenu .menu-pop { position: fixed; left: 14px; right: 14px; top: auto; bottom: calc(5rem + env(safe-area-inset-bottom)); min-width: 0; }
  table { font-size: .93rem; }
  th, td { padding: .4rem .3rem; }
  td .btns { flex-wrap: nowrap; }
  .ratings { grid-template-columns: 1fr; }
  .rrow { grid-template-columns: 5.5rem auto 1fr; }
  .stars label { font-size: 1.9rem; padding: 0 .12rem; }
  .row.between { align-items: flex-start; }
  .crumbs { overflow-x: auto; white-space: nowrap; }
  .chartwrap { max-width: 100%; }

  /* landing + gallery */
  .hero { padding: 1.5rem 0 1rem; } .hero h1 { font-size: 2rem; } .lead { font-size: 1rem; }
  .cards, .pubgrid, .features, .grid2 { grid-template-columns: 1fr; }
  .filter-toggle { display: inline-flex; }
  .pager .btn { min-width: 44px; }
  .dangerzone { text-align: center; }
}

.crumbs + .row .badge, .row.between > div > .badge { margin-top: .35rem; }
#ingredients form.inline { flex-wrap: wrap; }
#ingredients form.inline label { flex-direction: row; align-items: center; gap: .4rem; }
#ingredients form.inline input { width: 5rem; }
