:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f4ede3;
  --text: #2a211b;
  --muted: #74675c;
  --line: #e8ddcf;
  --accent: #c2502b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6dc;
  --focus: #d9692f;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 8px 24px -12px rgb(60 40 20 / 18%);
  --shadow-lift: 0 2px 4px rgb(60 40 20 / 8%), 0 18px 36px -16px rgb(60 40 20 / 30%);
  --radius: 16px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18130f;
    --surface: #221b16;
    --surface-2: #2c231d;
    --text: #f3ebe2;
    --muted: #b3a597;
    --line: #3a2f27;
    --accent: #ef8a5f;
    --accent-ink: #1d130d;
    --accent-soft: #3d2519;
    --focus: #f19a6f;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 30%), 0 18px 36px -16px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

*, *::before, *::after { 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.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, label:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; margin: 0; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* Header and footer */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 600 22px/1 var(--serif); text-decoration: none; }
.brand-mark { font-size: 24px; }

.header-tools { display: flex; align-items: center; gap: 12px; flex: 0 1 380px; justify-content: flex-end; min-width: 0; }
.lang-switch { flex: none; display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.lang-switch > * { padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; line-height: 1; text-decoration: none; letter-spacing: .04em; }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { color: var(--text); background: var(--surface-2); }
.lang-current { background: var(--text); color: var(--bg); }

.header-search { position: relative; flex: 1 1 280px; min-width: 0; color: var(--muted); }
.header-search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; pointer-events: none; }
.header-search input {
  width: 100%; height: 40px; padding: 0 14px 0 40px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
}
.header-search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 28px 0 36px; margin-top: 72px; }

/* Hero and search */
.hero { padding: 64px 0 28px; max-width: 760px; }
.hero h1 { font-size: clamp(36px, 6vw, 60px); }
.hero h1 em { color: var(--accent); font-style: italic; }
.lede { color: var(--muted); font-size: 18px; margin: 16px 0 0; max-width: 60ch; }

.search { position: relative; margin-top: 28px; color: var(--muted); }
.search svg { position: absolute; left: 20px; top: 50%; translate: 0 -50%; pointer-events: none; }
.search input {
  width: 100%; height: 60px; padding: 0 56px 0 54px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 18px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder, .header-search input::placeholder { color: var(--muted); opacity: .8; }
.search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.kbd {
  position: absolute; right: 20px; top: 50%; translate: 0 -50%;
  font: 600 13px/1 var(--sans); padding: 5px 8px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; color: var(--muted); background: var(--surface-2);
}
.search input:focus ~ .kbd, .search input:not(:placeholder-shown) ~ .kbd { display: none; }

/* Category chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; margin: 8px -2px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; font-size: 15px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--muted); }
.chip-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.is-empty:not(.is-active) { opacity: .5; }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.is-active .chip-count { color: inherit; opacity: .7; }

.results { transition: opacity .15s; }
.results.is-loading { opacity: .55; }
.results-summary { color: var(--muted); font-size: 15px; margin: 18px 0; }
.results-summary strong { color: var(--text); }
.results-summary a { color: var(--accent); }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card-link { display: flex; flex-direction: column; height: 100%; text-decoration: none; }
.card-art {
  display: grid; place-items: center; aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 30% 25%, rgb(255 255 255 / 45%), transparent 55%),
    var(--tint);
}
.card-art span { font-size: 64px; filter: drop-shadow(0 6px 8px rgb(0 0 0 / 18%)); transition: transform .3s; }
.card:hover .card-art span { transform: scale(1.08) rotate(-4deg); }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px 20px; flex: 1; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.card-title { font-size: 22px; }
.card-summary { margin: 0; color: var(--muted); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; list-style: none; padding: 0; margin: auto 0 0; padding-top: 10px; font-size: 14px; color: var(--muted); }
.card-meta li { display: inline-flex; align-items: center; gap: 6px; }

.pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text); }
.pill-easy { background: #e3f1dc; color: #2f5a22; }
.pill-medium { background: #fbecc8; color: #6d4c08; }
@media (prefers-color-scheme: dark) {
  .pill-easy { background: #23361c; color: #b8dca6; }
  .pill-medium { background: #3d3013; color: #f0d48e; }
}

/* Tags */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.tag {
  padding: 4px 12px; border-radius: 999px; font-size: 14px; text-decoration: none;
  background: var(--accent-soft); color: var(--text);
}
.tag::before { content: '#'; color: var(--accent); margin-right: 1px; }
.tag:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent)); }

/* Empty states */
.empty { text-align: center; padding: 56px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h1, .empty h2 { font-size: 28px; }
.empty p { color: var(--muted); }
.empty .tag-row { justify-content: center; }
.empty-art { font-size: 56px; margin: 0 0 8px; }
.empty-page { margin-top: 64px; border: 0; }
.button {
  display: inline-block; padding: 12px 20px; border-radius: 999px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}

/* Recipe detail */
.crumbs { padding: 24px 0 8px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 15px; }
.crumbs a:hover { color: var(--text); }

.recipe-hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; align-items: center; padding: 16px 0 40px; }
.recipe-art {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 28px;
  background:
    radial-gradient(circle at 30% 25%, rgb(255 255 255 / 50%), transparent 55%),
    var(--tint);
  box-shadow: var(--shadow-lift);
}
.recipe-art span { font-size: clamp(96px, 16vw, 168px); filter: drop-shadow(0 10px 14px rgb(0 0 0 / 20%)); }
.recipe-intro h1 { font-size: clamp(34px, 5vw, 52px); margin: 8px 0 0; }
.recipe-intro .lede { margin-top: 14px; }
.recipe-intro .tag-row { margin-top: 20px; }

.stats { display: flex; flex-wrap: wrap; gap: 0; margin: 24px 0 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.stats div { flex: 1 1 90px; padding: 12px 16px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats dt { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stats dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.recipe-body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 40px; }
.section-head h2 { font-size: 28px; }

.ingredients { position: sticky; top: 88px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.ingredient-list { list-style: none; margin: 0; padding: 0; }
.ingredient-list li + li { border-top: 1px solid var(--line); }
.ingredient-list label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; border-radius: 6px; }
.ingredient-list input {
  appearance: none; flex: none; width: 20px; height: 20px; margin: 3px 0 0;
  border: 2px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.ingredient-list input::after { content: ''; width: 10px; height: 6px; border: solid var(--accent-ink); border-width: 0 0 2px 2px; rotate: -45deg; translate: 0 -1px; opacity: 0; }
.ingredient-list input:checked { background: var(--accent); border-color: var(--accent); }
.ingredient-list input:checked::after { opacity: 1; }
.ingredient-list input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.ingredient-list input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ingredient-list label:focus-within { outline: none; }
.qty { font-weight: 700; font-variant-numeric: tabular-nums; }

.scaler { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface-2); }
.scaler output { min-width: 96px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.step-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--surface); color: var(--text); font-size: 18px; line-height: 1; box-shadow: var(--shadow);
}
.step-btn:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.step-btn:disabled { opacity: .4; cursor: default; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.ghost-btn:hover { background: var(--surface-2); }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps li {
  counter-increment: step; position: relative; padding: 4px 0 24px 60px; cursor: pointer;
  transition: opacity .2s;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font: 600 18px/1 var(--serif);
  transition: background .2s, color .2s;
}
.steps li:not(:last-child)::after { content: ''; position: absolute; left: 19px; top: 48px; bottom: 8px; width: 2px; background: var(--line); }
.steps li p { margin: 0; font-size: 17px; line-height: 1.7; }
.steps li.is-done { opacity: .5; }
.steps li.is-done::before { content: '✓'; background: var(--accent); color: var(--accent-ink); font-family: var(--sans); }
.steps-hint { font-size: 13px; color: var(--muted); margin: -4px 0 18px; }

.tip { margin-top: 8px; padding: 18px 20px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.tip strong { font-family: var(--serif); font-size: 18px; }
.tip p { margin: 4px 0 0; color: var(--muted); }

.related { margin-top: 72px; padding-top: 40px; border-top: 1px solid var(--line); }
.related h2 { font-size: 30px; margin-bottom: 24px; }

@media (max-width: 860px) {
  .recipe-hero, .recipe-body { grid-template-columns: 1fr; gap: 28px; }
  .recipe-art { aspect-ratio: 16 / 9; }
  .ingredients { position: static; }
}

@media (max-width: 560px) {
  .header-inner { height: 58px; }
  .header-inner { gap: 10px; }
  .header-tools { gap: 8px; }
  .header-search { flex-basis: 140px; }
  .header-search input { padding-left: 34px; }
  .header-search svg { left: 10px; }
  .hero { padding-top: 40px; }
  .search input { height: 54px; font-size: 16px; }
  .kbd { display: none; }
  .grid { grid-template-columns: 1fr; gap: 18px; }
  .ingredients { padding: 20px 16px; }
  .section-head { flex-wrap: wrap; }
  .stats div { flex-basis: 33%; border-bottom: 1px solid var(--line); }
}

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

@media print {
  .site-header, .site-footer, .crumbs, .related, .scaler, .ghost-btn, .tag-row, .steps-hint { display: none !important; }
  body { background: #fff; color: #000; }
  .recipe-hero { grid-template-columns: 1fr; padding-bottom: 16px; }
  .recipe-art { display: none; }
  .recipe-body { grid-template-columns: 1fr 1.4fr; gap: 24px; }
  .ingredients { position: static; box-shadow: none; }
  .ingredient-list input { display: none; }
  .steps li.is-done { opacity: 1; }
}
