/* Mobile first; minimum width 360 px [NF-06]. */
:root {
  --bg: #fbf8f3;
  --fg: #2b2118;
  --muted: #6f6257;
  --accent: #b5651d;
  --border: #e3d9cc;
  --ok: #2e7d32;
  --warn: #b26a00;
  --error: #c62828;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--fg); }

a { color: var(--accent); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; }

.container { max-width: 64rem; margin: 0 auto; padding: 1rem; }

.flash { padding: .6rem .8rem; border-radius: .4rem; margin-bottom: 1rem; border: 1px solid var(--border); }
.flash-success { border-color: var(--ok); }
.flash-warning { border-color: var(--warn); }
.flash-error { border-color: var(--error); }

[x-cloak] { display: none !important; }

.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.inline { display: inline; margin: 0; }

.narrow { max-width: 28rem; }

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: 1rem; }
.field label { font-weight: 600; }
input, select, textarea {
  font: inherit;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: #fff;
  min-height: 2.75rem; /* comfortable touch target outdoors [NF-06] */
}
input.full { width: 100%; }
.field-error input, .field-error select { border-color: var(--error); }
.error { color: var(--error); margin: 0; font-size: .9rem; }

.button, button.button {
  display: inline-block;
  padding: .6rem 1.1rem;
  border: 0;
  border-radius: .4rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 2.75rem;
}
.button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
button.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }

.muted { color: var(--muted); font-size: .9rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .5rem .75rem; text-decoration: none; border-radius: .4rem .4rem 0 0; }
.tabs a[aria-current="page"] { background: #fff; border: 1px solid var(--border); border-bottom-color: #fff; margin-bottom: -1px; font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.search { display: flex; gap: .5rem; flex: 1 1 16rem; margin-bottom: .5rem; }
.search input[type="search"] { flex: 1; min-width: 0; }
table.catalog td.num, table.catalog th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: .75rem; padding: 0 .4rem; border-radius: 1rem; background: var(--border); color: var(--fg); margin-left: .3rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; }
.notes { white-space: pre-line; overflow-wrap: anywhere; }
.field.checkbox { flex-direction: row; align-items: center; gap: .5rem; }
.field.checkbox input { min-height: auto; width: 1.2rem; height: 1.2rem; }
textarea { min-height: 5rem; }

.help { margin: 0; color: var(--muted); font-size: .85rem; }
.cards { list-style: none; padding: 0; display: grid; gap: .75rem; }
.card { background: #fff; border: 1px solid var(--border); border-radius: .5rem; padding: .75rem 1rem; }
.card h2 { font-size: 1.15rem; margin: 0 0 .25rem; }
.card p { margin: 0 0 .25rem; }
.actions { margin: 1rem 0; }

/* ---- Recipe editor ---------------------------------------------------- */
.recipe-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; margin: .25rem 0 .5rem; }
.recipe-head h1 { margin: 0; }
.title-input { font-size: 1.6rem; font-weight: 700; border: 1px solid transparent; background: transparent; padding: .2rem .3rem; margin-left: -.3rem; flex: 1 1 14rem; min-width: 0; }
.title-input:hover, .title-input:focus { border-color: var(--border); background: #fff; }
.version { color: var(--muted); font-size: .9rem; }
.saved { color: var(--ok); }
.not-saved { color: var(--error); font-weight: 600; }

.layout { display: grid; gap: .75rem; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; min-width: 0; }
.stats { background: #fff; border: 1px solid var(--border); border-radius: .6rem; }
.stats-full { display: none; padding: .75rem; }
.stats-compact > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: nowrap; align-items: center; gap: .55rem; padding: .55rem .6rem .55rem .75rem; font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.stats-compact > summary::-webkit-details-marker { display: none; }
.stats-compact > summary::after { content: "▾"; margin-left: auto; padding-left: .25rem; color: var(--muted); }
.stats-compact[open] > summary::after { content: "▴"; }
.stats-compact > :not(summary) { margin: 0 .75rem; }
.stats-compact[open] { padding-bottom: .5rem; }
@media (max-width: 899px) {
  .stats { position: sticky; top: 0; z-index: 3; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
}
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 20rem; grid-template-areas: "main stats"; align-items: start; }
  .stats { grid-area: stats; position: sticky; top: 1rem; }
  .stack { grid-area: main; }
  .stats-compact { display: none; }
  .stats-full { display: block; }
}
.style-line { font-size: .85rem; margin: .1rem 0 .5rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { border-radius: .4rem; padding: .35rem .45rem; background: var(--bg); border-left: 4px solid var(--border); }
.stat.in { border-left-color: var(--ok); }
.stat.low, .stat.high { border-left-color: var(--warn); background: #fff6e8; }
.stat .k, .stat .r { display: block; font-size: .72rem; color: var(--muted); }
.stat .v { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.flag { color: var(--warn); font-weight: 600; font-size: .75rem; margin-left: .15rem; }
.swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 50%; vertical-align: -.1rem; border: 1px solid rgba(0,0,0,.2); }
.warnings { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .8rem; color: var(--warn); }

.fold-all { display: none; justify-content: flex-end; gap: 1rem; font-size: .85rem; }
@media (min-width: 900px) { .fold-all { display: flex; } }
details.section { background: #fff; border: 1px solid var(--border); border-radius: .6rem; scroll-margin-top: 3.5rem; }
details.section > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: .5rem; padding: .7rem .75rem; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: "▸"; color: var(--accent); width: .8rem; }
details.section[open] > summary::before { content: "▾"; }
details.section > summary h2 { font-size: 1.05rem; margin: 0; }
.summary { margin-left: auto; color: var(--muted); font-size: .85rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.section-body { padding: 0 .75rem .75rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .75rem; }
.f { display: flex; flex-direction: column; min-width: 0; }
.f label { font-size: .78rem; color: var(--muted); }
.f input, .f select, .f textarea { width: 100%; min-height: 2.5rem; padding: .35rem .5rem; }
.f .error:empty { display: none; }
.wide { grid-column: 1 / -1; }
.line { border-top: 1px solid var(--border); padding: .6rem 0; display: grid; grid-template-columns: 1fr auto; gap: .25rem .5rem; }
.line:first-child { border-top: 0; }
.line .name { font-weight: 600; }
.line .brand { color: var(--muted); font-size: .8rem; }
.line .meta { text-align: right; font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); }
.line .meta b { color: var(--fg); }
.line .fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: .4rem; }
.line .fields .wide { grid-column: span 2; }
.line .tools { grid-column: 1 / -1; display: flex; gap: 1rem; font-size: .8rem; }
button.link:disabled { color: var(--muted); text-decoration: none; cursor: default; }
button.link.danger { color: var(--error); }
.add { margin-top: .5rem; }
.add input { width: 100%; }
.suggest { display: grid; margin-top: .25rem; }
.suggestion { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem; text-align: left; background: #fff; border: 1px solid var(--border); border-top: 0; padding: .55rem .6rem; font: inherit; cursor: pointer; min-height: 2.75rem; }
.suggestion:first-child { border-top: 1px solid var(--border); border-radius: .4rem .4rem 0 0; }
.suggestion:last-child { border-radius: 0 0 .4rem .4rem; }
.suggestion:only-child { border-radius: .4rem; }
.suggestion:hover, .suggestion:focus { background: var(--bg); }
.add-step { margin-top: .5rem; }
dl.water { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; margin: 0 0 .5rem; font-variant-numeric: tabular-nums; }
dl.water dd { margin: 0; text-align: right; font-weight: 600; }
.danger-zone { text-align: right; font-size: .85rem; margin-top: .5rem; }

.new-recipe { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .75rem; margin-bottom: 1rem; }
.new-recipe .f { flex: 1 1 12rem; }
.recipe-figures { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: .25rem 0 0; font-variant-numeric: tabular-nums; }

/* ---- Batches ------------------------------------------------------------ */
.compare { font-variant-numeric: tabular-nums; }
.compare th[scope="row"] { font-weight: 400; white-space: normal; }
.compare td.num, .compare th.num { text-align: right; }
.compare td.neg { color: var(--warn); }
.compare td.pos { color: var(--ok); }
.chart-box { position: relative; height: 16rem; margin-bottom: 1rem; }
.reading-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .5rem .75rem; align-items: end; margin: .75rem 0; }
.reminders, .timeline { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .4rem; }
.reminders li { background: var(--bg); border-left: 4px solid var(--ok); border-radius: .4rem; padding: .4rem .6rem; }
.reminders li.late { border-left-color: var(--warn); background: #fff6e8; }
.timeline li { font-size: .9rem; }
.note-item { border-top: 1px solid var(--border); padding: .4rem 0; }
.note-item.deviation { border-left: 4px solid var(--warn); padding-left: .5rem; }
.note-item p { margin: .15rem 0; }
.status-planned { background: #e8e1d6; }
.status-fermenting, .status-brewing { background: #fde7c8; }
.status-conditioning, .status-packaged { background: #d8ead9; }
.status-done { background: #d9dfe8; }

.pdf-links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .9rem; margin: .25rem 0 .75rem; }

.gravity-measure { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .4rem; }
.corrected:empty { display: none; }
.corrected { margin: .2rem 0 0; }

/* Packaging [F-C01 to F-C04] */
.packaging-item { border-left: 3px solid var(--border); padding: .25rem .75rem; margin: .5rem 0; }
.packaging-item p { margin: .2rem 0; }
.flag.ok { color: var(--ok, #2e7d32); }
.packaging-preview { background: var(--panel, rgba(0,0,0,.03)); padding: .5rem .75rem; border-radius: 6px; }
.packaging-preview p { margin: .2rem 0; }
#packaging-form .error { color: var(--warn); font-size: .78rem; margin: .1rem 0 0; }
.formats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.formats li { border: 1px solid var(--border); border-radius: .4rem; padding: .3rem .6rem; }
code.token { word-break: break-all; font-size: .95rem; background: var(--border); padding: .1rem .3rem; border-radius: .25rem; }

/* Dashboard and calendar [F-T01, F-T02] */
.upcoming .when { display: inline-block; min-width: 5.5rem; font-variant-numeric: tabular-nums; }
.card h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.month { display: grid; gap: 2px; margin: .5rem 0 1rem; font-size: .8rem; }
.month-head, .month-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.month-head div { text-align: center; color: var(--muted); padding: .2rem 0; }
.month-day { background: #fff; border: 1px solid var(--border); border-radius: .3rem; min-height: 4.5rem; padding: .15rem .2rem; overflow: hidden; }
.month-day.other { opacity: .45; }
.month-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.month-day .num { font-weight: 600; display: block; }
.cal-item { display: block; font-size: .7rem; line-height: 1.2; margin-top: .15rem; padding: .05rem .2rem; border-radius: .2rem; background: #f3e7da; color: var(--fg); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item .cal-batch { font-weight: 700; }
.cal-item.kind-brew { background: var(--accent); color: #fff; }
.cal-item.kind-ready { background: #dcefd8; }
.cal-item.kind-packaging { background: #dbe7f3; }
.cal-item.done { opacity: .6; }
.cal-item.late { outline: 1px solid var(--warn); }
@media (max-width: 560px) {
  .month { font-size: .7rem; }
  .month-day { min-height: 3rem; }
  .cal-item { font-size: 0; padding: 0; height: .4rem; margin-top: .12rem; }
  .cal-item .cal-batch { display: none; }
}

/* Brew-day view [F-T07] */
[x-cloak] { display: none !important; }
.brew-day .phase { background: #fff; border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .9rem .75rem; margin: .75rem 0; }
.brew-day .phase h2 { font-size: 1.15rem; margin: .3rem 0 .5rem; }
.check-line { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; font-size: 1.02rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-line input { width: 1.4rem; height: 1.4rem; flex: none; margin-top: .05rem; }
.check-line.done span { color: var(--muted); text-decoration: line-through; }
.timer-row { display: flex; align-items: center; gap: .6rem; justify-content: space-between; }
.timer-row .check-line { flex: 1; border-bottom: 0; }
.timer-btn { flex: none; min-height: 2.6rem; }
.timer-sticky { position: sticky; top: 0; z-index: 20; }
.timer-sticky .ring { margin: .4rem 0; box-shadow: 0 2px 8px rgba(0,0,0,.2); background: #fff6e8; }
.timer-bar { background: var(--fg, #2b2118); color: #fff; border-radius: .5rem; padding: .5rem .8rem; margin: .5rem 0; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.timer-main { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.timer-label { font-size: .95rem; }
.timer-clock { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-clock.over { color: #ffb347; }
.timer-next { margin: .1rem 0; font-size: .9rem; color: #f3e7da; }
.timer-actions { display: flex; gap: 1.2rem; }
.timer-bar .link { color: #fff; }
.ring { display: flex; justify-content: space-between; align-items: center; gap: .75rem; font-size: 1.05rem; }
.boil-plan { list-style: none; padding: 0; margin: .5rem 0; }
.boil-plan li { padding: .35rem 0; border-bottom: 1px solid var(--border); }
.boil-plan li.passed { color: var(--muted); text-decoration: line-through; }
.boil-plan .when { display: inline-block; min-width: 4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
/* Timer banner on the other pages */
.timer-banner { position: sticky; top: 0; z-index: 30; background: var(--fg, #2b2118); color: #fff; padding: .4rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem 1rem; font-size: .9rem; }
.timer-banner[hidden] { display: none; }
.timer-banner a.timer-banner-main { color: #fff; text-decoration: none; display: flex; gap: .75rem; align-items: baseline; flex: 1 1 auto; justify-content: space-between; }
.timer-banner strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.timer-banner strong.over { color: #ffb347; }
.timer-banner-next { color: #f3e7da; flex-basis: 100%; }
.timer-banner.ringing { background: #b35c00; }
.timer-banner-ring { flex-basis: 100%; font-weight: 700; }
.timer-banner .button { padding: .2rem .9rem; min-height: 2.2rem; }

/* Stock [F-S01 to F-S05] */
a.suggestion { color: var(--fg); text-decoration: none; }
.flag.danger { color: #b3261e; }
.stock-table td { vertical-align: top; }
.stock-actions { align-items: start; }
.shortages .missing { color: #b3261e; }
.shortages .check { color: var(--warn); }
@media (max-width: 560px) { .hide-phone { display: none; } }
.stock-block { margin: .5rem 0; }
.stock-block > summary { cursor: pointer; color: var(--muted); }
td .sub { display: block; font-size: .8rem; }
td .sub:empty { display: none; }
.nowrap { white-space: nowrap; }
.shortages .ok { color: var(--ok); }

/* Tastings [F-D01 to F-D03] */
.chart-box.small { height: 240px; }
.tasting-item { border-bottom: 1px solid var(--border); padding: .4rem 0; }
.tasting-item > summary { cursor: pointer; }
.tasting-criterion { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: .5rem .75rem; margin: .4rem 0; align-items: start; }
@media (max-width: 560px) { .tasting-criterion { grid-template-columns: minmax(0, 1fr); } }

/* Tools [F-O02 to F-O06] */
.tool-result { background: var(--bg); border-radius: .4rem; padding: .4rem .75rem; margin: .5rem 0; }
.tool-result p { margin: .3rem 0; }
.ion-table { max-width: 24rem; }
.ion-table input { width: 100%; min-height: 2.3rem; padding: .2rem .3rem; }
.salts { margin: .3rem 0; padding-left: 1.2rem; }
.recipe-tools { margin: .25rem 0 .75rem; }
.recipe-tools > summary { cursor: pointer; color: var(--accent); }

/* Recipe import review [F-R11] */
.import-line { border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .75rem; margin: .5rem 0; background: #fff; }
.import-review details > summary { cursor: pointer; color: var(--accent); margin: .5rem 0; }
.excel-rows .check-line { border-bottom: 1px solid var(--border); }
