:root {
  --bg: #f5ede3;
  --surface: #fffaf4;
  --surface-2: #efe4d6;
  --ink: #2a1c13;
  --ink-2: #6b5545;
  --line: #e2d3c1;
  --brand: #6f3f1f;
  --brand-ink: #fffaf4;
  --crema: #c98a4b;
  --filter: #2f6f73;
  --filter-bg: #dcecea;
  --espresso: #7a3a1d;
  --espresso-bg: #f3dfcf;
  --ok: #3f8a4d;
  --hot: #c8392b;
  --warn-bg: #fbe9d3;
  --warn-line: #e7b27a;
  --ok-bg: #e2f0e1;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(42, 28, 19, .06), 0 6px 20px rgba(42, 28, 19, .06);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c140f;
    --surface: #271c15;
    --surface-2: #33251b;
    --ink: #f3e7da;
    --ink-2: #bba693;
    --line: #3e2e22;
    --brand: #d79a5e;
    --brand-ink: #1c140f;
    --crema: #d99a5a;
    --filter: #7cc3c4;
    --filter-bg: #1f3a3b;
    --espresso: #eaa77d;
    --espresso-bg: #46281a;
    --ok: #7cc28a;
    --hot: #ff7a6b;
    --warn-bg: #3d2a17;
    --warn-line: #8a5a2c;
    --ok-bg: #1f3423;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-underline-offset: 3px; }

h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; }
h3 { margin: 0 0 .15rem; font-size: 1.02rem; line-height: 1.3; }
p { margin: 0 0 .5rem; }
p:last-child { margin-bottom: 0; }

.ic {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.muted { color: var(--ink-2); }
.small { font-size: .9rem; }

/* ---------- Header & Tabs ---------- */
.hero {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
}
.hero-inner, .tabs, main, .foot { max-width: 680px; margin-inline: auto; }

.eyebrow {
  margin: 0; font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--crema);
}
.hero h1 { margin: 0; font-size: 1.7rem; line-height: 1.15; }
.lede { margin: 0 0 10px; color: var(--ink-2); font-size: .95rem; }

body:not(.has-tab) .hero { position: static; border-bottom: 0; background: transparent; padding-top: max(28px, env(safe-area-inset-top)); }
body:not(.has-tab) .hero h1 { font-size: 2.2rem; }
body:not(.has-tab) .tabs { grid-template-columns: 1fr; gap: 10px; margin-top: 8px; }
body:not(.has-tab) .tab { flex-direction: row; justify-content: flex-start; gap: 16px; min-height: 84px; padding: 14px 18px; font-size: 1.15rem; font-family: var(--serif); }
body:not(.has-tab) .tab .ic { width: 40px; height: 40px; }
body.has-tab .lede, body.has-tab .eyebrow { display: none; }
body.has-tab .hero h1 { font-size: 1.25rem; margin-bottom: 8px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 72px; padding: 10px 6px;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  text-decoration: none; text-align: center;
  font-weight: 600; font-size: .86rem; line-height: 1.2;
  box-shadow: var(--shadow);
  transition: background .15s, color .15s, transform .1s;
}
.tab:active { transform: scale(.97); }
.tab .ic { width: 28px; height: 28px; color: var(--crema); }
.tab[aria-current="page"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.tab[aria-current="page"] .ic { color: var(--brand-ink); }
body.has-tab .tab { min-height: 0; flex-direction: row; padding: 8px 6px; gap: 6px; }
body.has-tab .tab .ic { width: 20px; height: 20px; }

@media (max-width: 380px) {
  body.has-tab .tab .ic { display: none; }
}

/* ---------- Panels ---------- */
main { padding: 8px 16px 24px; }

.panel { padding-top: 18px; scroll-margin-top: 140px; }
.js .panel { display: none; }
.js .panel.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head h2 { margin: 0 0 8px; font-size: 1.75rem; line-height: 1.15; }
.panel-head h2 small { font-family: var(--sans); font-size: .95rem; font-weight: 500; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink);
  font-size: .82rem; font-weight: 600;
}

.sub {
  margin: 26px 0 10px; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2);
}

.callout, .warn, .ok {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 14px;
}
.callout { background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px; }
.callout .ic { color: var(--crema); }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); margin-top: 10px; }
.warn .ic { color: var(--hot); }
.ok { background: var(--ok-bg); margin-top: 10px; }
.ok .ic { color: var(--ok); }

/* ---------- Steps ---------- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step {
  position: relative; display: flex; gap: 14px;
  padding: 0 0 18px;
  counter-increment: step;
}
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 23px; top: 50px; bottom: 4px;
  width: 2px; background: var(--line); border-radius: 2px;
}
.step-icon {
  position: relative; flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--brand);
  box-shadow: var(--shadow);
}
.step-icon::after {
  content: counter(step);
  position: absolute; right: -4px; top: -4px;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--crema); color: #fff;
  font-size: .72rem; font-weight: 700;
}
.step-body { flex: 1; min-width: 0; padding-top: 3px; }
.step-body p { color: var(--ink-2); }
.step-body strong { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 1rem var(--sans); cursor: pointer;
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.btn .ic { width: 20px; height: 20px; }

/* Mini-Timer (20 s) */
.mini-timer {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px;
  margin-top: 10px;
}
.mini-timer .btn { grid-column: 1 / -1; justify-self: start; }
.mini-bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.mini-bar span { display: block; height: 100%; width: 0; background: var(--crema); border-radius: 8px; }
.mini-out { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3ch; text-align: right; }
.mini-timer.is-done .mini-bar span { background: var(--ok); }

/* ---------- Figures ---------- */
.figure {
  margin: 12px 0 0; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.figure svg { display: block; width: 100%; height: auto; }

.gauge { max-width: 280px; margin: 0 auto; }
.gauge path { fill: none; stroke-width: 14; }
.gauge .gauge-ok { stroke: var(--ok); stroke-linecap: round; }
.gauge .gauge-hot { stroke: var(--hot); stroke-linecap: round; }
.gauge-ticks path { stroke: var(--ink-2); stroke-width: 2; opacity: .5; }
.gauge-needle { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.gauge-hub { fill: var(--ink); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 8px; font-size: .88rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); }
.dot-hot { background: var(--hot); }

/* Pour-Chart */
.pour-chart .grid path { stroke: var(--line); stroke-width: 1; }
.pour-chart .axis-label text { fill: var(--ink-2); font: 600 11px var(--sans); }
.pour-fill { fill: var(--crema); opacity: .18; }
.pour-line { fill: none; stroke: var(--crema); stroke-width: 3; stroke-linejoin: round; }
.pour-dot circle { fill: var(--surface); stroke: var(--brand); stroke-width: 3; }
.pour-wait text { fill: var(--ink-2); font: 500 11px var(--sans); }
.pour-step text { fill: var(--brand); font: 700 12px var(--sans); }

.pours { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.pours li {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.pour-num {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 700;
}

/* Brüh-Assistent */
.brew {
  margin-top: 20px; padding: 18px;
  border-radius: var(--radius);
  background: var(--brand); color: var(--brand-ink);
  box-shadow: var(--shadow);
}
.brew-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.brew-kicker { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.brew-step { margin: 2px 0 2px; font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.brew-hint { margin: 0; font-size: .9rem; opacity: .85; }
.brew-target {
  flex: none; text-align: right; font-family: var(--serif); font-weight: 700;
  font-size: 2.4rem; line-height: 1; font-variant-numeric: tabular-nums;
}
.brew-target small { font-family: var(--sans); font-size: 1rem; margin-left: 2px; opacity: .8; }
.brew-time {
  margin: 14px 0 10px; font-size: 3.4rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.brew-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.brew-progress span { height: 6px; border-radius: 6px; background: currentColor; opacity: .22; transition: opacity .2s; }
.brew-progress span.done { opacity: .9; }
.brew-progress span.now { opacity: .6; }
.brew-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.brew .btn-primary { background: var(--brand-ink); color: var(--brand); border-color: var(--brand-ink); flex: 1; }
.brew .btn-ghost { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand-ink) 40%, transparent); }
.brew.is-waiting .brew-time { color: var(--crema); }

/* ---------- Mühle ---------- */
.dial-intro { display: grid; gap: 14px; }
.photo { margin: 0; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.photo img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; }
.photo figcaption { padding: 10px 14px; font-size: .92rem; color: var(--ink-2); }
.photo figcaption strong { color: var(--ink); }

@media (min-width: 560px) {
  .dial-intro { grid-template-columns: 1fr 1fr; align-items: center; }
}

.grind-test { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grind-card {
  margin: 0; padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  text-align: center; font-size: .9rem; color: var(--ink-2);
}
.grind-card strong { color: var(--ink); }
.grind-card svg { display: block; width: 100%; height: auto; margin-bottom: 6px; }
.grains rect { fill: #8a5a35; stroke: #5d3a20; stroke-width: .6; }
.powder { fill: #5a3620; }
.clumps circle { fill: #4a2c19; }
.ground { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
@media (prefers-color-scheme: dark) {
  .grains rect { fill: #c08350; stroke: #8a5a35; }
  .powder { fill: #9a6440; }
  .clumps circle { fill: #b57a4c; }
}

.tag {
  display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700;
}
.tag-filter { background: var(--filter-bg); color: var(--filter); }
.tag-espresso { background: var(--espresso-bg); color: var(--espresso); }

.mode-card {
  margin-top: 22px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.mode-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mode-head .tag { margin: 0; font-size: .9rem; }
.mode-head .ic { color: var(--ink-2); width: 20px; height: 20px; }
.mode-body { display: grid; gap: 12px; }
.mode-body h3 { font-family: var(--serif); font-size: 1.3rem; margin-bottom: 4px; }
.mode-body h3 em { font-style: normal; color: var(--crema); }
.mode-body h3 em.alt { color: var(--filter); }
.mode-body > div > p { color: var(--ink-2); }
.mode-body > div > p strong { color: var(--ink); }

@media (min-width: 560px) {
  .mode-body { grid-template-columns: 200px 1fr; align-items: start; }
}

.dial { width: 100%; max-width: 220px; height: auto; margin: 0 auto; display: block; }
.knob-rim { fill: #111; }
.knob { fill: #262321; }
.knob-line { stroke: #f1efe9; stroke-width: 3; stroke-linecap: round; }
.knob-mark { stroke: var(--crema); stroke-width: 5; stroke-linecap: round; }
.knob-num text { fill: #f1efe9; font: 700 22px var(--sans); }
.knob-fine { fill: #f1efe9; font: 700 15px var(--sans); letter-spacing: .1em; opacity: .55; }
.knob-notch { fill: #b7b7b7; stroke: #777; stroke-width: 1; }
.turn-arrow { fill: none; stroke: var(--crema); stroke-width: 6; stroke-linecap: round; }
.turn-arrow.alt { stroke: var(--filter); }
.arrowhead { fill: var(--crema); }
.arrowhead.alt { fill: var(--filter); }
.turn-label { fill: var(--crema); font: 700 17px var(--sans); }
.turn-label.alt { fill: var(--filter); }

/* Vierteldrehungen */
.quarters { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.quarters-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.quarters-head p { margin: 0; }
.quarters-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.q {
  -webkit-appearance: none; appearance: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-2);
  font: 600 .78rem var(--sans); cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.q:active { transform: scale(.95); }
.q svg { width: 40px; height: 40px; }
.q .q-bg { fill: var(--surface-2); }
.q .q-fill { fill: var(--line); }
.q .q-rim { fill: none; stroke: var(--ink-2); stroke-width: 1.5; opacity: .5; }
.q.is-next { border-color: var(--crema); color: var(--ink); }
.q.is-next .q-fill { fill: var(--crema); opacity: .45; }
.q.is-done { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.q.is-done .q-fill { fill: var(--ok); }
.quarters-status { margin: 10px 0 0; font-size: .92rem; color: var(--ink-2); }
.quarters-status.is-done { color: var(--ok); font-weight: 700; }

/* ---------- Footer ---------- */
.foot { padding: 8px 16px max(28px, env(safe-area-inset-bottom)); text-align: center; color: var(--ink-2); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
