/* Jerk Off: smoked paprika on butcher's paper, charcoal at night.
   Big targets (≥48px) because hands are often greasy. */
/* Roboto Slab 800 (Apache 2.0, fonts/LICENSE), served from the site: phones have no Rockwell, and
   without it the wordmark fell back to a plain serif. Preloaded in index.html for the splash. */
@font-face { font-family: "Roboto Slab"; font-weight: 800; font-display: swap;
  src: url("../fonts/roboto-slab-800.woff2") format("woff2"); }
:root {
  --bg: #f7f1ea; --surface: #fffaf5; --surface-2: #f1e6da; --ink: #2a1d17; --muted: #75645a; --line: #e2d4c5;
  --brand: #7a2e1a; --brand-ink: #fff6ee; --accent: #c46a3b; --accent-soft: #f6dcc9;
  --ok: #2f7a43; --ok-soft: #dcefe0; --warn: #a15c00; --warn-soft: #fbe7c6; --bad: #b3261e; --bad-soft: #fbdad7;
  --focus: #c46a3b; --shadow: 0 1px 2px rgb(60 30 10 / .08), 0 4px 14px rgb(60 30 10 / .06);
  --radius: 14px; --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Rockwell", "Roboto Slab", "Georgia", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17110e; --surface: #211915; --surface-2: #2c211c; --ink: #f3e8de; --muted: #b3a196; --line: #3b2e27;
    --brand: #d0703f; --brand-ink: #1b0f09; --accent: #e08a55; --accent-soft: #4a2a1b;
    --ok: #6cc583; --ok-soft: #1f3a27; --warn: #f0b356; --warn-soft: #43321a; --bad: #ff8a80; --bad-soft: #4a1f1c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17110e; --surface: #211915; --surface-2: #2c211c; --ink: #f3e8de; --muted: #b3a196; --line: #3b2e27;
  --brand: #d0703f; --brand-ink: #1b0f09; --accent: #e08a55; --accent-soft: #4a2a1b;
  --ok: #6cc583; --ok-soft: #1f3a27; --warn: #f0b356; --warn-soft: #43321a; --bad: #ff8a80; --bad-soft: #4a1f1c;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-family: var(--display); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .5rem 0; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; }
.strong { font-weight: 600; }
.wordmark { font-family: var(--display); font-weight: 800; letter-spacing: -.01em; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 8px var(--gutter);
  padding-top: max(8px, env(safe-area-inset-top)); background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 1.3rem; }
.brand img { border-radius: 9px; }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.topnav a { color: inherit; text-decoration: none; padding: 10px 14px; border-radius: 10px; opacity: .85; }
.topnav a.active, .topnav a:hover { background: rgb(255 255 255 / .14); opacity: 1; }
.top-icons { margin-left: auto; display: flex; gap: 4px; }
.icon-link { position: relative; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
  color: inherit; text-decoration: none; font-size: 1.35rem; }
.icon-link.active { background: rgb(255 255 255 / .14); }
.badge { position: absolute; top: 4px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #ffd23f; color: #3b140a; font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
main { max-width: 1080px; margin: 0 auto; padding: 16px var(--gutter) calc(96px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; min-height: 60px;
  color: var(--muted); text-decoration: none; font-size: .75rem; }
.tabbar a span { font-size: 1.35rem; line-height: 1; }
.tabbar a.active { color: var(--brand); font-weight: 600; }
@media (min-width: 900px) {
  .attention { position: sticky; top: 64px; z-index: 9; }
  .topnav { display: flex; }
  .tabbar { display: none; }
  main { padding-bottom: 48px; }
}

.attention { background: var(--bad-soft); border-bottom: 2px solid var(--bad); }
.attention-inner { max-width: 1080px; margin: 0 auto; padding: 8px var(--gutter); }
.attention .reminder { background: transparent; border: 0; padding: 6px 0; }
.attention .more { font-weight: 600; }

/* ---------- splash (same pattern as Breadwinner: fixed, always dark, fades out) ---------- */
#splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; cursor: pointer; transition: opacity .5s ease;
  background: radial-gradient(circle at 50% 40%, #5a2414, #2a120a 70%); }
#splash.fade { opacity: 0; pointer-events: none; }
#splash svg { width: min(60vw, 300px); height: auto; display: block; }
#splash .wordmark { color: #f6e7d6; font-size: 2.6rem; }
#splash .tag { color: #d9a27e; font-size: .8rem; letter-spacing: .22em; text-transform: uppercase; }
/* Moisture drying off the strip: each drop rises and fades. */
#splash .drops path { animation: drops 2.4s ease-out infinite; }
#splash .drops g:nth-child(2) path { animation-delay: .8s; }
#splash .drops g:nth-child(3) path { animation-delay: 1.6s; }
@keyframes drops { 0% { opacity: 0; transform: translateY(6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-12px); } }
@media (prefers-reduced-motion: reduce) {
  #splash, #splash .drops path { animation: none; transition: none; }
}

/* ---------- unlock ---------- */
.unlock { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter);
  background: radial-gradient(circle at 30% 20%, var(--accent-soft), var(--bg) 60%); }
.unlock-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px 24px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.unlock-card img { align-self: center; border-radius: 16px; }
.unlock-card h1 { font-size: 2rem; }
.unlock-card .label { text-align: left; }

/* ---------- layout pieces ---------- */
.page { display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-block; margin-bottom: 4px; color: var(--muted); text-decoration: none; padding: 6px 0; }
.lead { font-size: 1.05rem; }
.hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.attention-card { border: 2px solid var(--bad); background: var(--bad-soft); }
.notice { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 8px; }
.empty { text-align: center; padding: 24px 8px; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.empty.error { color: var(--bad); }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.results-list .rl-stats { display: block; color: var(--muted); font-size: .9rem; }
.facts { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 6px 16px; margin: 8px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- buttons & chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: .875rem; }
.btn.big { min-height: 54px; font-size: 1.05rem; padding: 12px 22px; }
.btn.huge { min-height: 64px; font-size: 1.15rem; padding: 14px 24px; flex: 1 1 200px; }
select.btn { appearance: auto; }
.icon-btn { min-width: 40px; min-height: 40px; border: 1px solid var(--line); background: transparent; border-radius: 10px; color: var(--ink);
  font: inherit; cursor: pointer; }
.icon-btn:disabled { opacity: .35; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: .8rem; font-weight: 600;
  vertical-align: middle; font-family: var(--font); }
.st-planned { background: var(--surface-2); }
.st-preparing { background: var(--accent-soft); }
.st-marinating { background: #e6dcf5; color: #4b2a7a; }
.st-drying { background: var(--warn-soft); color: var(--warn); }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: var(--bad-soft); color: var(--bad); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-marinating { background: #33264a; color: #cdb6f2; } }
.rating-badge { font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ---------- reminders ---------- */
.reminder { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); }
.rem-main { flex: 1 1 260px; min-width: 0; }
.rem-title { font-weight: 600; }
.rem-run { font-weight: 400; }
.rem-when, .rem-body { color: var(--muted); font-size: .92rem; }
.rem-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-overdue { border-color: var(--bad); }
.rs-overdue .rem-when { color: var(--bad); font-weight: 600; }
.rs-due { border-color: var(--warn); }
.rs-due .rem-when { color: var(--warn); font-weight: 600; }
.rs-done, .rs-cancelled { opacity: .7; }
.live.overdue { color: var(--bad); font-weight: 700; }
details.history { margin-top: 8px; }
details > summary { cursor: pointer; padding: 8px 0; font-weight: 600; min-height: 40px; }

/* ---------- dashboard ---------- */
.run-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.run-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: inherit; text-decoration: none; }
.run-card:hover { border-color: var(--accent); }
.rc-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.rc-meta { color: var(--muted); font-size: .9rem; }
.rc-next { font-weight: 600; }
.rc-next.rs-overdue { color: var(--bad); }
.since { color: var(--ink); }

/* ---------- run page ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.timeline li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; font-size: .8rem; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; top: 9px; left: -50%; right: 50%; height: 3px; background: var(--line); }
.timeline li:first-child::before { display: none; }
.timeline li.past::before, .timeline li.current::before { background: var(--accent); }
.tl-dot { position: relative; width: 20px; height: 20px; border-radius: 50%; background: var(--line); border: 3px solid var(--bg); }
.timeline .past .tl-dot { background: var(--accent); }
.timeline .current .tl-dot { background: var(--brand); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline .current { color: var(--ink); font-weight: 700; }
.tl-time { font-size: .72rem; }
.timeline.cancelled { grid-template-columns: repeat(6, 1fr); }
.timeline .cancelled .tl-dot { background: var(--bad); }
.next-step { background: var(--accent-soft); border-radius: var(--radius); padding: 16px; }
.ns-status { font-size: 1.05rem; margin: 0 0 10px; }
.ns-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stage { border-left: 4px solid var(--line); padding: 4px 0 4px 12px; margin: 10px 0; }
.stage.open { border-color: var(--warn); }
.stage.planned { border-style: dashed; }
.checks { list-style: none; padding: 0; margin: 6px 0 0; }
.check-row { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); margin-bottom: 6px; position: relative; }
.check-row .btn { justify-self: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 8px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.kpi-value { font-size: 1.35rem; font-weight: 700; font-family: var(--display); }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-note { color: var(--muted); font-size: .8rem; }
.kpis.big .kpi { background: var(--surface); border: 1px solid var(--line); }
.ratings { display: grid; gap: 4px; margin: 10px 0; }
.rating-row { display: grid; grid-template-columns: 100px 1fr 28px; gap: 8px; align-items: center; font-size: .92rem; }
.rating-row .bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.rating-row .bar span { display: block; height: 100%; background: var(--accent); }
.qty-input { width: 80px; min-height: 44px; text-align: right; }
tr.excluded td { opacity: .5; }
tr.optional td:first-child { font-style: italic; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 8px 0; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.current td { font-weight: 600; }
tr.archived td, .tile.archived { opacity: .6; }
tr.warn td { color: var(--bad); }
.runs-table td { white-space: nowrap; }
.show-sm { display: none; }
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  th, td { padding: 8px 6px; }
  .qty-input { width: 64px; }
}
.compare th[scope="row"] { white-space: nowrap; text-transform: none; font-size: .9rem; color: var(--ink); }
.compare tr.differs td { background: var(--accent-soft); }
.compare td.best { font-weight: 800; }

/* ---------- tiles (marinades) ---------- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: inherit;
  text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.tile:hover { border-color: var(--accent); }
.tile-top { display: flex; justify-content: space-between; gap: 8px; }
.tile-desc { margin: 0; }
.calc-label { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.big-input { width: 140px; font-size: 1.4rem; font-weight: 700; text-align: right; }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 48px; width: 100%; max-width: 100%; }
textarea { resize: vertical; min-height: 72px; }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; accent-color: var(--brand); vertical-align: middle; }
input[type="file"] { padding: 8px; }
.search { max-width: 360px; }
.fields { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide, .field-heading, .fields .check { grid-column: 1 / -1; }
.field-heading { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .95rem; }
.label { font-weight: 600; font-size: .92rem; }
.req { color: var(--bad); }
.help { color: var(--muted); font-size: .82rem; }
.err { color: var(--bad); font-size: .85rem; min-height: 0; }
.err:empty { display: none; }
.form-error { color: var(--bad); font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
.form-actions.sticky { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; justify-content: flex-end; }
@media (min-width: 900px) { .form-actions.sticky { bottom: 0; } }
.with-unit { display: flex; align-items: center; gap: 6px; }
.with-unit .unit { color: var(--muted); white-space: nowrap; }
td .with-unit { justify-content: flex-end; }
.check { display: flex; align-items: center; gap: 8px; min-height: 48px; cursor: pointer; flex-wrap: wrap; }
.check.small { min-height: 40px; }
.check .help { flex-basis: 100%; }
.rating { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rate { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.rate.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.filters[open] { padding-bottom: 16px; }
.filter-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); align-items: end; }
.filter { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 600; }

/* marinade editor lines */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line-row { display: grid; gap: 8px; grid-template-columns: 1fr 90px 90px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.line-row > select:first-child { grid-column: 1 / -1; }
.line-row .note { grid-column: 1 / -1; }
.line-btns { display: flex; gap: 6px; grid-column: 1 / -1; justify-content: flex-end; }
@media (min-width: 760px) {
  .line-row { grid-template-columns: 2fr 90px 90px auto 2fr auto; }
  .line-row > select:first-child, .line-row .note, .line-btns { grid-column: auto; }
}

/* ---------- dialogs ---------- */
dialog.modal { width: min(720px, calc(100vw - 16px)); max-height: calc(100vh - 32px); border: 0; border-radius: 18px; padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog.modal::backdrop { background: rgb(20 10 5 / .55); }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
dialog.modal .intro { padding: 0 16px; color: var(--muted); }
dialog.modal .form { padding: 16px; }
@media (max-width: 600px) {
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
}
dialog.lightbox { border: 0; padding: 0; background: #000; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
dialog.lightbox img { width: 100%; height: calc(100% - 40px); object-fit: contain; }
.lb-cap { color: #ddd; text-align: center; margin: 8px; }

/* ---------- photos ---------- */
.photo-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.thumb { margin: 0; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; display: block; }
.thumb.loading { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); }
.thumb figcaption { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 4px; }

/* ---------- charts ---------- */
.chart { margin: 8px 0 16px; }
.chart svg { width: 100%; max-width: 560px; height: auto; display: block; }
.c-bar { fill: var(--accent); }
.c-dot { fill: var(--accent); stroke: var(--brand); stroke-width: 2; }
.c-axis { stroke: var(--line); stroke-width: 2; }
.c-label, .c-value, .c-tick { fill: var(--ink); font-size: 12px; font-family: var(--font); }
.c-tick { fill: var(--muted); font-size: 11px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgb(0 0 0 / .25); }
.toast.error { background: var(--bad); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
