:root {
  --bg: #faf6f0;
  --card: #fffdf9;
  --text: #2b2420;
  --muted: #7a6e65;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --accent-soft: #fbe8db;
  --border: #ece3d8;
  --done: #4d7c0f;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(70, 45, 20, 0.06), 0 6px 18px rgba(70, 45, 20, 0.07);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --card: #26201c;
    --text: #f4ede6;
    --muted: #a99c91;
    --accent: #fb923c;
    --accent-text: #1f1208;
    --accent-soft: #3a2618;
    --border: #382f29;
    --done: #a3e635;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.01em; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.topbar h1 { margin: 0; font-size: 28px; line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back {
  display: grid; place-items: center; width: 36px; height: 36px; margin-left: -8px;
  border-radius: 50%; color: var(--accent);
}
.topbar .back svg { width: 26px; height: 26px; stroke-width: 2.5; }
.topbar .back[hidden] { display: none; }
main { max-width: 640px; margin: 0 auto; padding: 4px 16px 24px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 3;
  display: flex;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px; color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tabbar[hidden] { display: none; }
.tabbar svg { width: 26px; height: 26px; stroke-width: 1.8; }
.tabbar .dot { fill: currentColor; stroke: none; }
.tabbar a.active { color: var(--accent); }

/* ---------- Basics ---------- */
input[type="url"], input[type="password"], input[type="search"] {
  width: 100%; padding: 13px 14px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 20px;
  font: inherit; font-size: 16px; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
  text-decoration: none; cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
button:active, .button:active { transform: scale(0.97); }
button:disabled { opacity: 0.55; }
button svg, .button svg { width: 20px; height: 20px; }
button.secondary, .button.secondary { background: var(--accent-soft); color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border: 1px solid currentColor; padding: 10px 16px; font-size: 15px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

.panel { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.panel-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 600; }
.panel-title svg { width: 20px; height: 20px; color: var(--accent); }

.message { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.message.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.muted { color: var(--muted); }
.section-label { margin: 28px 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; color: var(--accent); opacity: 0.8; stroke-width: 1.5; }
.empty h2 { color: var(--text); margin: 12px 0 4px; font-size: 22px; }
.empty p { margin: 0 auto 16px; max-width: 300px; }

/* ---------- Recipe cards (lists) ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li + li { margin-top: 12px; }
.card {
  display: flex; gap: 14px; align-items: center;
  background: var(--card); border-radius: 16px; padding: 10px;
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
  transition: transform 0.1s ease;
}
.card:active { transform: scale(0.98); }
.card img, .card .noimg {
  width: 84px; height: 84px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--accent-soft);
}
.card .body { flex: 1; min-width: 0; }
.card .title { font-family: var(--serif); font-weight: 700; font-size: 18px; line-height: 1.25; }
.card .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card .chev { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.score { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 13px; background: var(--accent-soft); color: var(--accent); }
.score.full { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }

/* ---------- Passcode ---------- */
.lock { text-align: center; padding-top: 40px; }
.lock img { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); }
.lock h2 { font-size: 28px; margin: 16px 0 4px; }
.lock form { max-width: 320px; margin: 24px auto 0; }
.lock button { width: 100%; }

/* ---------- One recipe (cooking view) ---------- */
.hero { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 20px; background: var(--accent-soft); box-shadow: var(--shadow); }
.recipe h2 { margin: 18px 0 8px; font-size: 30px; line-height: 1.15; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.facts li { padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; }
.facts a { color: inherit; text-decoration: none; }

.awake {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 12px 16px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
}
.awake small { display: block; color: var(--muted); }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background 0.2s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 10px; }
.section-head h3 { margin: 0; font-size: 22px; }
.linkish { background: none; color: var(--accent); padding: 4px 0; font-size: 14px; font-weight: 600; }

.ticks { list-style: none; margin: 0; padding: 4px 0; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.ticks li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; cursor: pointer; }
.ticks li + li { border-top: 1px solid var(--border); }
.tick {
  width: 24px; height: 24px; flex-shrink: 0; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center; transition: all 0.15s;
}
.tick svg { width: 14px; height: 14px; stroke-width: 3; color: #fff; opacity: 0; }
.ticks li.done .tick { background: var(--done); border-color: var(--done); }
.ticks li.done .tick svg { opacity: 1; }
.ticks li.done .text { color: var(--muted); text-decoration: line-through; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: flex; gap: 14px; padding: 16px; border-radius: 16px; background: var(--card);
  box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent; transition: all 0.15s;
}
.steps li + li { margin-top: 10px; }
.steps .num {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px;
}
.steps .num svg { width: 16px; height: 16px; stroke-width: 3; }
.steps .text { font-size: 17px; line-height: 1.55; }
.steps li.current { border-color: var(--accent); }
.steps li.done { opacity: 0.55; box-shadow: none; }
.steps li.done .num { background: var(--done); color: #fff; }
.recipe .delete { margin-top: 36px; text-align: center; }

/* ---------- Spin ---------- */
.spin { display: flex; flex-direction: column; gap: 12px; }
.spin .button, .spin button { width: 100%; padding: 15px 20px; font-size: 17px; }
.spin-card { position: relative; background: var(--card); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.spin-card .pic { position: relative; aspect-ratio: 4 / 3; background: var(--accent-soft); display: grid; place-items: center; }
.spin-card .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.spin-card .pic > svg { width: 72px; height: 72px; color: var(--accent); stroke-width: 1.4; }
.spin-card .label { padding: 16px 18px 20px; text-align: center; }
.spin-card .kicker { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); min-height: 1.2em; }
.spin-card .title { font-family: var(--serif); font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.spin-card.spinning .pic img { filter: blur(1.5px) saturate(0.9); }
.spin-card.spinning .title { color: var(--muted); }
.spin-card.landed { animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { 0% { transform: scale(0.94); } 100% { transform: scale(1); } }
.spin-btn svg { transition: transform 0.6s ease; }
.spin-btn.rolling svg { transform: rotate(360deg); }

/* ---------- What can I make? ---------- */
.intro { margin: 0 0 14px; color: var(--muted); }
.picker { max-height: 280px; overflow-y: auto; margin-top: 10px; -webkit-overflow-scrolling: touch; }
.picker label { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.picker label:last-child { border-bottom: 0; }
.picker input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.chip.clear { background: transparent; color: var(--muted); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
