:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --text: #2b2420;
  --muted: #7a6d63;
  --line: #e7ddd0;
  --accent: #c2410c;
  --accent-soft: #fde8dc;
  --accent-text: #9a3412;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
  --radius: 14px;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1714;
    --surface: #24201c;
    --surface-2: #2e2924;
    --text: #efe7de;
    --muted: #a89b8f;
    --line: #3a332d;
    --accent: #fb923c;
    --accent-soft: #3b2417;
    --accent-text: #fdba74;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 var(--sans);
}
img { max-width: 100%; height: auto; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 26px; }
.brand-text { font-family: var(--serif); font-weight: 700; font-size: 19px; line-height: 1.15; display: flex; flex-direction: column; }
.brand-text small { font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* hero */
.hero { padding: 40px 0 16px; }
.hero h1 { font-family: var(--serif); font-size: clamp(30px, 6vw, 44px); margin: 0 0 4px; line-height: 1.2; }
.hero p { margin: 0; color: var(--muted); }
.hero-sm { padding-top: 28px; }
.crumb { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.crumb a { color: var(--muted); }

/* filters */
.filters { padding: 12px 0 8px; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 18px; box-shadow: var(--shadow); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--text); padding: 13px 0;
}
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.chip-label { font-size: 13px; color: var(--muted); margin-right: 4px; min-width: 2.5em; }
.chip {
  font: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 4px 12px; border-radius: 999px; transition: .15s;
}
.chip em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 2px; }
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active em { color: rgba(255,255,255,.8); }
.count { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

/* grid + cards */
.grid {
  display: grid; gap: 20px; padding: 16px 0 48px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-3px); text-decoration: none; box-shadow: 0 2px 4px rgba(60,40,20,.08), 0 14px 32px rgba(60,40,20,.12); }
.card[hidden] { display: none; }
.card-img { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, var(--surface-2) 0 14px, var(--accent-soft) 14px 28px);
}
.placeholder span { font-family: var(--serif); font-size: 56px; color: var(--accent-text); background: var(--surface); width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; }
.badge-time {
  position: absolute; left: 10px; bottom: 10px; font-size: 12px; padding: 3px 9px;
  border-radius: 999px; background: rgba(20, 14, 10, .7); color: #fff; backdrop-filter: blur(4px);
}
.card-body { padding: 12px 16px 16px; }
.card-body h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 19px; line-height: 1.35; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.chip-sm { background: var(--accent-soft); color: var(--accent-text); padding: 1px 8px; border-radius: 6px; font-size: 12px; }
.by { margin-left: auto; }
.empty { text-align: center; color: var(--muted); padding: 32px 0 64px; }

/* recipe page */
.recipe-head { padding-top: 28px; }
.recipe-head h1 { font-family: var(--serif); font-size: clamp(30px, 6vw, 46px); line-height: 1.2; margin: 0 0 8px; }
.lede { color: var(--muted); font-size: 18px; margin: 0 0 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; padding: 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: 15px; }

.gallery {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px;
  padding-top: 24px; padding-bottom: 4px;
}
.gallery p { display: contents; margin: 0; }
.gallery a.img-link { display: contents; }
.gallery img, .gallery .video {
  flex: 0 0 auto; height: min(56vh, 460px); width: auto; max-width: 92%;
  object-fit: cover; border-radius: var(--radius); scroll-snap-align: start; box-shadow: var(--shadow);
}
.gallery img:only-child { max-width: 100%; }
.gallery .video { aspect-ratio: 16 / 9; height: auto; width: min(92%, 720px); }

.recipe-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 28px; padding-bottom: 32px; }
@media (min-width: 900px) {
  .recipe-grid { grid-template-columns: 340px minmax(0, 1fr); align-items: start; gap: 40px; }
  .ingredients { position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow: auto; }
}
.ingredients-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px 8px; }
.ing-head { display: flex; align-items: baseline; justify-content: space-between; }
.ing-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; }
.link-btn { font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--accent-text); }
.ing-list h3 { font-size: 15px; color: var(--muted); margin: 18px 0 4px; }
.ing-list ol, .ing-list ul { list-style: none; padding: 0; margin: 8px 0 12px; }
.ing-list li { position: relative; padding: 8px 0 8px 30px; border-bottom: 1px dashed var(--line); cursor: pointer; line-height: 1.55; }
.ing-list li:last-child { border-bottom: 0; }
.ing-list li::before {
  content: ""; position: absolute; left: 0; top: 11px; width: 18px; height: 18px;
  border: 1.5px solid var(--muted); border-radius: 5px; transition: .15s;
}
.ing-list li.done { color: var(--muted); text-decoration: line-through; }
.ing-list li.done::before { background: var(--accent); border-color: var(--accent); }
.ing-list li.done::after { content: ""; position: absolute; left: 6px; top: 14px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* prose */
.prose { overflow-wrap: anywhere; }
.prose h2 { font-family: var(--serif); font-size: 24px; margin: 32px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.steps > h2:first-child { margin-top: 0; }
.prose h3 { font-size: 18px; margin: 24px 0 8px; }
.prose h4 { font-size: 16px; margin: 20px 0 6px; }
.prose .headerlink { display: none; }
.prose img { border-radius: 10px; display: block; margin: 12px 0; }
.prose blockquote { margin: 16px 0; padding: 10px 16px; background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; }
.prose blockquote p { margin: 0; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.prose pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.steps ol { counter-reset: step; list-style: none; padding: 0; }
.steps ol > li { counter-increment: step; position: relative; padding: 10px 12px 10px 48px; margin: 4px 0; border-radius: 10px; cursor: pointer; transition: background .15s; }
.steps ol > li::before {
  content: counter(step); position: absolute; left: 8px; top: 10px;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent-text); font-weight: 700; font-size: 14px; line-height: 1;
}
.steps ol > li:hover { background: var(--surface); }
.steps ol > li.current { background: var(--accent-soft); }
.steps ol > li.current::before { background: var(--accent); color: #fff; }
.steps ul { padding-left: 1.3em; }
.note { color: var(--muted); }

.mermaid-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin: 16px 0; overflow-x: auto; }
.mermaid-wrap pre.mermaid { background: none; margin: 0; padding: 0; min-width: 560px; }
.mermaid-wrap pre.mermaid:not([data-processed]) { color: transparent; min-height: 200px; }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 16px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

.more { padding-bottom: 16px; }
.more h2 { font-family: var(--serif); font-size: 24px; margin: 8px 0 0; }

.page { padding-top: 32px; padding-bottom: 48px; }
.page h1 { font-family: var(--serif); font-size: 36px; margin: 0 0 12px; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 20px 0 32px; }

@media (max-width: 560px) {
  .brand-text small { display: none; }
  .nav a { padding: 6px 7px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-body { padding: 10px 12px 12px; }
  .card-body h3 { font-size: 16px; }
  .by { display: none; }
  .gallery img { height: min(46vh, 420px); }
}
@media (max-width: 360px) { .grid { grid-template-columns: 1fr; } }

/* timeline (gantt) */
.timeline { margin: 16px 0 24px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 10px; }
.timeline figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600; margin-bottom: 4px; }
.tl-total { font-weight: 400; font-size: 14px; color: var(--muted); }
.tl-total b { color: var(--accent-text); }
.tl-section + .tl-section { margin-top: 10px; }
.tl-sec-name { font-size: 12px; color: var(--muted); letter-spacing: .05em; padding: 8px 0 2px; border-bottom: 1px solid var(--line); }
.tl-row {
  display: grid; align-items: center; column-gap: 10px;
  grid-template-columns: 3.2em minmax(6em, 11em) 5.5em minmax(0, 1fr);
  padding: 5px 0; font-size: 14px; border-bottom: 1px dashed var(--line);
}
.tl-row:last-child { border-bottom: 0; }
.tl-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.tl-name { line-height: 1.35; }
.tl-dur { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.tl-track {
  position: relative; height: 10px; border-radius: 5px; background: var(--surface-2);
}
.tl-track i { position: absolute; top: 0; bottom: 0; min-width: 4px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.tl-row.crit .tl-track i { background: var(--accent); }
.tl-row.crit .tl-name { font-weight: 600; }
@media (max-width: 640px) {
  .tl-row { grid-template-columns: 3em minmax(0, 1fr) auto; row-gap: 4px; padding: 7px 0; }
  .tl-track { grid-column: 2 / -1; height: 6px; }
}

/* wake lock */
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.share-btn {
  font: inherit; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 6px 14px 6px 12px; border-radius: 999px; transition: .15s;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.share-btn.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.wake-btn {
  font: inherit; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 6px 14px 6px 10px; border-radius: 999px;
}
.wake-btn i { width: 30px; height: 18px; border-radius: 9px; background: var(--line); position: relative; transition: .2s; }
.wake-btn i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.wake-btn.on { border-color: var(--accent); }
.wake-btn.on i { background: var(--accent); }
.wake-btn.on i::after { left: 14px; }

/* timers */
.timer-chip {
  font: inherit; cursor: pointer; color: var(--accent-text); background: var(--accent-soft);
  border: 0; border-radius: 6px; padding: 0 6px; margin: 0 1px; line-height: inherit;
}
.timer-chip::before { content: "⏱ "; font-size: .85em; }
.timer-chip:hover { background: var(--accent); color: #fff; }
.timer-dock {
  position: fixed; z-index: 20; right: 16px; bottom: 16px; width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px;
}
.timer {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface); box-shadow: 0 4px 24px rgba(0,0,0,.18); border: 1px solid var(--line);
}
.timer-info { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.35; }
.timer-info a { font-size: 12px; color: var(--muted); }
.timer-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.1; }
.timer-time small { display: block; font-size: 12px; font-weight: 400; color: inherit; opacity: .85; }
.timer-time b { font-size: 16px; }
.timer-actions { display: flex; gap: 4px; }
.timer-actions button {
  font: inherit; font-size: 13px; cursor: pointer; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
.timer-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width 1s linear; }
.timer.done { background: var(--accent); color: #fff; border-color: var(--accent); animation: ring 1s ease-in-out infinite; }
.timer.done .timer-info a { color: rgba(255,255,255,.85); }
.timer.done .timer-actions button { background: #fff; color: var(--accent); border-color: #fff; font-weight: 700; }
@keyframes ring { 50% { transform: translateX(-3px); } }
body.has-dock { padding-bottom: 120px; }
@media (max-width: 560px) {
  .timer-dock { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; }
}
@media (prefers-reduced-motion: reduce) { .timer.done { animation: none; } }

/* 步骤里的照片：限高，多张并排 */
.steps p:has(> .img-link) { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.steps .img-link img { max-height: 220px; width: auto; max-width: 100%; margin: 0; }
@media (max-width: 560px) {
  .steps p:has(> .img-link) { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory; }
  .steps .img-link { flex: 0 0 auto; scroll-snap-align: start; max-width: 85%; }
  .steps .img-link img { max-height: 240px; }
}
