/* Recipe Studio: warm kitchen palette (paprika, saffron, olive on cream), cookbook serif headings. */
:root {
  --accent: #c2410c;          /* paprika */
  --accent-ink: #fffaf3;
  --saffron: #e9a23b;
  --olive: #5f7a3a;
  --bg: #fbf4ea;              /* cream */
  --surface: #fffdf9;
  --surface-2: #f5e9d8;
  --ink: #2b1d14;             /* espresso */
  --ink-2: #7a5f4b;
  --good: #4f7a2a;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(80 40 10 / 7%), 0 10px 28px rgb(120 60 20 / 8%);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --max: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #f07a3e;
    --accent-ink: #1d120b;
    --bg: #1b140f;
    --surface: #261c15;
    --surface-2: #33261c;
    --ink: #f8ebdc;
    --ink-2: #c4a88f;
  }
}

body { background: var(--bg); }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
.eyebrow { margin: 0 0 4px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.center { text-align: center; justify-content: center; }
.ico { width: 15px; height: 15px; display: inline-block; vertical-align: -2px; margin-right: 4px; }

/* Header */
.app-header .brand { color: var(--ink); text-decoration: none; font-size: 1.2rem; }
.ai-pill { font-size: .75rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--olive) 16%, transparent); color: var(--olive); }
.ai-pill.remote { background: var(--accent-soft); color: var(--accent); }

/* Tab bar */
.tabbar a { gap: 3px; }
.tab-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.cooking .tabbar { display: none; }

/* Discover */
.hero { display: grid; gap: 14px; padding: 22px; margin-bottom: 14px; border-radius: 28px;
  background: radial-gradient(circle at 92% 0%, color-mix(in srgb, var(--saffron) 35%, transparent), transparent 55%),
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  box-shadow: var(--shadow); }
.hero h1 { margin: 0 0 4px; }
.hero p { margin: 0; }
.chip.soft[aria-pressed="true"] { background: var(--olive); }
.result-count { min-height: 1.2em; margin: 0 4px 8px; }
.recipe-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.recipe-card { position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .15s ease; }
.recipe-card:active { transform: scale(.985); }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-art svg { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.card-body { padding: 12px 16px 16px; }
.card-body h3 { margin: 0 0 4px; font-size: 1.15rem; }
.card-body .meta { margin: 0; font-size: .875rem; color: var(--ink-2); }
.heart { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--accent); cursor: pointer; box-shadow: var(--shadow); }
.heart svg { width: 22px; height: 22px; }
.empty-state.wide { grid-column: 1 / -1; background: var(--surface); border-radius: var(--radius); }
.row.center { justify-content: center; }

/* Recipe detail */
.back { display: inline-flex; min-height: var(--tap); align-items: center; font-weight: 600; text-decoration: none; }
.detail { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); margin-bottom: 18px; }
@media (min-width: 820px) { .detail { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; } }
.detail-art svg { width: 100%; height: auto; border-radius: 26px; box-shadow: var(--shadow); }
.detail-head h1 { margin-bottom: 6px; }
.lede { font-size: 1.1rem; color: var(--ink-2); }
.facts { list-style: none; display: flex; gap: 10px; padding: 0; margin: 12px 0; }
.facts li { flex: 1; padding: 10px; text-align: center; border-radius: var(--radius-sm); background: var(--surface-2); }
.facts strong { display: block; font-family: var(--font-display); font-size: 1.1rem; }
.facts span { font-size: .75rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.badge.diet { background: color-mix(in srgb, var(--olive) 16%, transparent); color: var(--olive); }
.actions { margin-top: 14px; }
.btn svg { width: 18px; height: 18px; }
.two-col { display: grid; gap: 16px; }
@media (min-width: 820px) { .two-col { grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr); align-items: start; } }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper output { min-width: 92px; text-align: center; font-weight: 700; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients label { display: flex; gap: 12px; align-items: center; min-height: var(--tap); padding: 6px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.ingredients .qty { min-width: 72px; font-weight: 700; color: var(--accent); }
.ingredients label.done span { text-decoration: line-through; opacity: .5; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 4px 0 14px 48px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-weight: 700; }
.steps p { margin: 0 0 6px; }
.timer-tag { display: inline-flex; align-items: center; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--saffron) 25%, transparent); color: #8a5208; }

/* AI chef */
.ai-tools { margin: 0 0 16px; background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--saffron) 12%, var(--surface))); }
.ai-tools-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ai-tools-head h2 { margin: 0; }
#ai-out:not(:empty) { margin-top: 16px; display: grid; gap: 16px; }
.thinking { color: var(--ink-2); font-style: italic; }
.review, .visual { border-top: 1px solid var(--line); padding-top: 16px; }
.review-top { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.review-top h3 { margin: 0; font-size: 1.3rem; }
.score { --pct: 0; flex: none; width: 88px; height: 88px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--surface) 78%, transparent 80%), conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-2) 0); }
.score span { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; line-height: 1; }
.score small { color: var(--ink-2); }
.criteria { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.crit-row { display: flex; justify-content: space-between; font-size: .9rem; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 4px 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--saffron), var(--accent)); border-radius: inherit; }
.criteria p { margin: 0; }
.review h4, .visual h4 { margin: 12px 0 6px; font-family: var(--font-display); font-size: 1.05rem; }
.good-list, .fix-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.good-list li::marker { color: var(--olive); }
.fix-list .badge { margin-right: 4px; }
.chef-notes p { margin-bottom: .5em; }
.visual { display: grid; gap: 16px; }
@media (min-width: 720px) { .visual { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.visual-art { margin: 0; }
.visual-art svg { width: 100%; height: auto; border-radius: 20px; }

/* Cook mode */
body.cooking .app-header { display: none; }
body.cooking .app-main { max-width: 900px; padding-bottom: calc(var(--dock-h, 0px) + 24px + var(--safe-bottom)); }
body.cooking .install-hint { display: none; }
.cook { display: flex; flex-direction: column; gap: 14px; min-height: calc(100dvh - 48px - var(--dock-h, 0px)); }
.cook-top { display: flex; align-items: center; gap: 10px; padding-top: var(--safe-top); }
.cook-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cook-title strong { font-family: var(--font-display); font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-count { font-weight: 700; color: var(--accent); white-space: nowrap; }
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--saffron), var(--accent)); transition: width .3s ease; }
.cook-body { flex: 1; display: flex; flex-direction: column; gap: 18px; justify-content: center; padding: 20px 4px; touch-action: pan-y; }
.cook-step { font-family: var(--font-display); font-size: clamp(1.5rem, 3.6vw, 2.3rem); line-height: 1.35; margin: 0; }
.uses { background: var(--surface); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.uses ul { margin: 0; padding-left: 20px; columns: 2 200px; }
.timer-btn { align-self: flex-start; min-height: 56px; font-size: 1.1rem; background: var(--saffron); border-color: transparent; color: #3a2405; }
.cook-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.btn.big { min-height: 60px; font-size: 1.15rem; }
.hint { margin: 0; }
.done-screen { align-items: center; text-align: center; justify-content: center; }
.cook-art svg { width: min(420px, 90vw); height: auto; border-radius: 26px; box-shadow: var(--shadow); }
.stars { display: flex; gap: 6px; }
.star { width: 52px; height: 52px; border: 0; background: none; font-size: 2.2rem; color: var(--surface-2); cursor: pointer; -webkit-text-stroke: 1px var(--saffron); }
.star[aria-pressed="true"] { color: var(--saffron); }

/* Timer dock */
body:not(.cooking) .app-main { padding-bottom: calc(96px + var(--dock-h, 0px) + var(--safe-bottom)); }
#timer-dock.compact { left: auto; right: calc(12px + var(--safe-right)); transform: none; width: min(340px, calc(100vw - 24px)); }
#timer-dock.compact .timer { padding: 6px 8px 6px 14px; border-radius: 16px; }
#timer-dock.compact .clock { font-size: 1.1rem; }
.timer.paused .clock { opacity: .6; }
#timer-dock { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(72px + var(--safe-bottom)); width: min(560px, calc(100vw - 24px)); display: grid; gap: 8px; }
body.cooking #timer-dock { bottom: calc(12px + var(--safe-bottom)); }
.timer { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-radius: 18px; background: var(--ink); color: var(--bg); box-shadow: 0 10px 30px rgb(0 0 0 / 25%); }
.timer-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.timer-label { font-size: .8rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; }
.timer-actions { display: flex; gap: 6px; }
.timer .btn { background: color-mix(in srgb, var(--bg) 14%, transparent); color: var(--bg); border-color: transparent; }
.timer.ringing { background: var(--accent); animation: ring 1s ease-in-out infinite; }
@keyframes ring { 50% { transform: scale(1.02); } }

/* Mix & match */
.page-head { margin-bottom: 14px; }
.page-head h1 { margin-bottom: 4px; }
.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2); margin-bottom: 14px; }
.segmented button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: none; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented [aria-selected="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.mix-layout, .editor-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .mix-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
  .editor-layout { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
  .mix-preview, .editor-preview { position: sticky; top: 76px; } }
.swap-list { list-style: none; margin: 0 0 8px; padding: 0; }
.swap-list li { display: grid; grid-template-columns: 1fr minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.swap-name { font-size: .95rem; }
.roles { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.roles legend { font-size: .875rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.before-after { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 12px; }
.before-after figure { margin: 0; text-align: center; font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.before-after svg { width: 100%; height: auto; border-radius: 16px; margin-bottom: 4px; }
.arrow { font-size: 1.6rem; color: var(--accent); }
.changes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.changes li { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.changes s { opacity: .6; }
.plus { color: var(--good); font-weight: 700; }
.minus { color: var(--bad); font-weight: 700; }
#mix-ai:not(:empty), #editor-ai:not(:empty) { margin-top: 14px; }

/* Editor */
.editor h2 { margin: 18px 0 10px; }
.field-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.field-error { margin: 0; color: var(--bad); font-size: .85rem; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--bad); }
.ing-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.ing-row { display: grid; grid-template-columns: 72px 92px minmax(0, 1fr) 120px 44px; gap: 6px; align-items: center; }
@media (max-width: 600px) { .ing-row { grid-template-columns: 64px 84px minmax(0, 1fr) 44px; } .ing-row [name=ing-role] { grid-column: 1 / 4; } }
.step-rows { padding-left: 22px; margin: 0 0 10px; display: grid; gap: 10px; }
.step-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.step-row textarea { min-height: 64px; }
.step-side { display: flex; flex-direction: column; gap: 6px; width: 84px; }
.editor-actions { margin-top: 18px; }
#preview-art svg { width: 100%; height: auto; border-radius: 18px; }

/* My kitchen */
.cooked-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cooked-row a { flex: 1; font-weight: 600; color: var(--ink); }
.stars-static { color: var(--saffron); letter-spacing: 2px; }
.danger-zone { margin-top: 28px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .timer.ringing { animation: none; }
  .progress i, .recipe-card { transition: none; }
}
