/* ── Space Grotesk (self-hosted) ────────────────────
   Vendored deliberately, same as the landing page: Google Fonts is unreliable
   behind the Great Firewall and a blocked <link> stalls the whole page. */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url('../fonts/space-grotesk-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url('../fonts/space-grotesk-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Theme tokens ──────────────────────────────────── */
:root {
  --accent:     #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.12);
  --accent-glow:rgba(34, 211, 238, 0.25);
  --bg:         #0b1120;
  --bg-card:    #111827;
  --bg-inset:   #0b1120;
  --border:     rgba(255, 255, 255, 0.07);
  --border-hover: rgba(34, 211, 238, 0.35);
  --text:       #e2e8f0;
  --text-dim:   #94a3b8;
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.5);
  --grid-line:  rgba(255, 255, 255, 0.035);
  --edited:     #fbbf24;
  --edited-dim: rgba(251, 191, 36, 0.12);
}

[data-theme="light"] {
  --accent:     #0284c7;
  --accent-dim: rgba(2, 132, 199, 0.10);
  --accent-glow:rgba(2, 132, 199, 0.18);
  --bg:         #f0f4f8;
  --bg-card:    #ffffff;
  --bg-inset:   #f8fafc;
  --border:     rgba(0, 0, 0, 0.09);
  --border-hover: rgba(2, 132, 199, 0.40);
  --text:       #0f172a;
  --text-dim:   #64748b;
  --shadow:     0 8px 32px rgba(0, 0, 0, 0.10);
  --grid-line:  rgba(0, 0, 0, 0.045);
  --edited:     #b45309;
  --edited-dim: rgba(180, 83, 9, 0.10);
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Base ──────────────────────────────────────────── */
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ── Header ────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  user-select: none;
}

.logo span { color: var(--text-dim); font-weight: 400; }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.04);
}

.theme-toggle svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }

/* ── Main layout ───────────────────────────────────── */
main {
  max-width: 780px;
  margin: 0 auto;
  padding: 60px 24px 110px;
}

/* ── Back link ─────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  margin-bottom: 28px;
  transition: color 0.2s;
}

.back-link:hover { color: var(--accent); }

/* ── Hero ──────────────────────────────────────────── */
.hero { margin-bottom: 56px; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.hero-eyebrow::before {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.05;
  margin-bottom: 20px;
}

.hero h1 .highlight { color: var(--accent); }

.hero p {
  font-size: 1rem;
  color: var(--text-dim);
  max-width: 520px;
  line-height: 1.7;
}

/* ── Section label ─────────────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  order: 1;
}

.section-label .reset-all { order: 2; }

/* ── Panels ────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 44px;
}

/* ── Batch inputs ──────────────────────────────────── */
.batch {
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.field input:focus,
.pct-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.total {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--accent-dim);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.total strong {
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.total-note {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

/* ── Reset-all button ──────────────────────────────── */
.reset-all {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--edited);
  background: var(--edited-dim);
  border: 1px solid transparent;
  border-radius: 100px;
  padding: 5px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.18s, opacity 0.18s;
}

.reset-all:hover:not(:disabled) { border-color: var(--edited); }

.reset-all:disabled {
  opacity: 0;
  pointer-events: none;
}

/* ── Ingredient table ──────────────────────────────── */
.table { padding: 6px 22px 4px; }

.thead,
.row {
  display: grid;
  grid-template-columns: 1fr 168px 108px;
  align-items: center;
  gap: 12px;
}

.thead {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
}

.th-pct { padding-left: 2px; }
.th-amt { text-align: right; }

.row {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: none; }

.row-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.row-note {
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--text-dim);
}

.row-pct {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pct-input {
  width: 92px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  transition: border-color 0.18s, box-shadow 0.18s, color 0.18s;
}

.pct-sign {
  font-size: 0.85rem;
  color: var(--text-dim);
  width: 10px;
}

.row-reset {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--edited);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, border-color 0.18s, background-color 0.18s;
}

.row-reset svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row.is-changed .row-reset {
  opacity: 1;
  pointer-events: auto;
}

.row-reset:hover {
  background: var(--edited-dim);
  border-color: var(--edited);
}

.row.is-changed .pct-input {
  border-color: var(--edited);
  color: var(--edited);
}

.row-amount {
  text-align: right;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.table-note {
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding: 14px 0 16px;
  margin-top: 4px;
}

/* ── Method ────────────────────────────────────────── */
.steps {
  list-style: none;
  counter-reset: step;
  margin-bottom: 44px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 44px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.steps strong { color: var(--text); font-weight: 700; }

/* ── Notes ─────────────────────────────────────────── */
.notes { padding: 22px; }

.notes p {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.notes p:last-child { margin-bottom: 0; }

.notes strong { color: var(--text); }

/* ── Footer ────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 28px 24px;
  color: var(--text-dim);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  letter-spacing: 0.02em;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 620px) {
  header { padding: 12px 16px; }
  main   { padding: 44px 16px 80px; }
  .batch { grid-template-columns: 1fr; padding: 18px; }
  .table { padding: 4px 16px 2px; }
  .notes { padding: 18px; }

  /* The three-column table folds: name on top, then percent and amount
     side by side underneath, so nothing has to scroll sideways. */
  .thead { display: none; }

  .row {
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
    padding: 13px 0;
  }

  .row-name { grid-column: 1 / -1; }
  .row-pct  { grid-column: 1; }
  .row-amount { grid-column: 2; align-self: center; }

  .total-note { margin-left: 0; width: 100%; }
}
