:root {
  --paper: #f4efe6;
  --paper-2: #ebe4d6;
  --card: #fffdf9;
  --ink: #2a241c;
  --ink-soft: #5e5348;
  --line: #e4d8c6;
  --red: #c4473c;
  --red-deep: #9d332b;
  --blue: #356684;
  --blue-deep: #24485e;
  --sage: #e5f0e4;
  --butter: #f8ecc8;
  --blush: #f8e4dc;
  --shadow: 0 12px 32px rgba(70, 48, 30, 0.07);
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Nunito", "Segoe UI", sans-serif;
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
h1, h2, h3, .brand strong {
  font-family: var(--serif);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
h1 { font-size: clamp(2rem, 4vw, 3.1rem); margin: 0 0 0.4rem; }
h2 { font-size: 1.45rem; margin: 0 0 0.6rem; }
h3 { font-size: 1.15rem; margin: 0; }
p { margin: 0 0 0.7rem; }
a { color: var(--blue-deep); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: white;
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 12px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.site-header { background: rgba(255, 253, 249, 0.92); position: sticky; top: 0; z-index: 4; }
.topbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-center { justify-content: center; margin-bottom: 8px; }
.brand small { display: block; color: var(--ink-soft); font-family: var(--sans); letter-spacing: 0; font-size: 0.82rem; }
.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: white;
  font-family: var(--serif);
  font-size: 1.15rem;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.38);
}
.nav { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.nav a, .text-btn {
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav a[aria-current="page"] { background: var(--blush); color: var(--red-deep); }
.logout-form { margin: 0; }
.towel {
  height: 12px;
  background-color: #f7f1e8;
  background-image:
    linear-gradient(90deg, rgba(196, 71, 60, 0.18) 50%, transparent 50%),
    linear-gradient(rgba(53, 102, 132, 0.16) 50%, transparent 50%);
  background-size: 12px 12px;
}

.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px 64px; }
.site-footer { max-width: 1100px; margin: 0 auto; padding: 0 20px 28px; color: var(--ink-soft); font-size: 0.92rem; }

.hero, .page-head { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 22px; }
.hero p, .page-head p, .lede { color: var(--ink-soft); max-width: 46rem; }
.hero-actions, .action-row, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; color: var(--blue); font-weight: 750; margin: 0 0 6px; }

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: white;
}
.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: var(--red-deep); }
.btn-secondary { background: white; color: var(--blue-deep); border-color: #b7c9d4; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: white; color: var(--red-deep); border-color: #e3b2ac; }
.btn.is-disabled { opacity: 0.4; }
.is-on { box-shadow: inset 0 0 0 2px var(--blue); }

label { display: grid; gap: 6px; font-weight: 650; }
input, textarea, select {
  width: 100%;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .chip:focus-within span {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.stack { display: grid; gap: 12px; }
.finder, .panel, .editor, .mail-box, .mail-form, .login-card, .detail, .source-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.finder { padding: 16px; margin-bottom: 28px; }
.panel { padding: 18px; display: grid; gap: 12px; align-content: start; }
.import-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.editor { padding: 18px; display: grid; gap: 18px; }
.editor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-family: var(--serif); font-size: 1.2rem; margin-bottom: 8px; }
.hint, .meta, .cooked, .reason { color: var(--ink-soft); font-size: 0.95rem; }
.filter-meta { display: flex; gap: 12px; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; font-weight: 650; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.chip:has(input:checked) span { background: var(--red); color: white; border-color: var(--red); }

.search-row, .email-row { display: flex; gap: 8px; align-items: center; }
.search-row input, .email-row input { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.shelf { margin-top: 28px; }
.shelf-head { margin-bottom: 12px; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-link { color: inherit; text-decoration: none; display: block; }
.card-photo { aspect-ratio: 4 / 3; background: var(--paper-2); }
.card-photo img, .hero-photo img, .gallery img, .preview-grid img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 16px; display: grid; gap: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--butter); border-radius: 999px; padding: 2px 8px; font-size: 0.82rem; }
.pill-soft { background: var(--sage); }
.stars { letter-spacing: 0.08em; color: #d9c7a4; }
.stars .on, .stars button.on { color: var(--red); }
.stars-input { display: flex; gap: 2px; align-items: center; background: transparent; border: 0; box-shadow: none; padding: 0; }
.stars-input button { background: transparent; border: 0; font-size: 1.5rem; min-height: 44px; min-width: 36px; color: #d9c7a4; padding: 0; }
.clear-rating { font-size: 0.9rem !important; color: var(--ink-soft) !important; min-width: auto !important; margin-left: 6px; }
.heart-form { position: absolute; top: 10px; right: 10px; }
.heart {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: white;
  color: var(--red);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.heart path { fill: transparent; stroke: currentColor; stroke-width: 1.6; }
.heart.is-on path { fill: currentColor; }

.napkin {
  width: 100%;
  height: 100%;
  min-height: 140px;
  background-color: #f3eadc;
  background-image:
    linear-gradient(90deg, rgba(196, 71, 60, 0.16) 50%, transparent 50%),
    linear-gradient(rgba(53, 102, 132, 0.14) 50%, transparent 50%);
  background-size: 18px 18px;
}
.napkin-lg { width: min(180px, 70%); height: 120px; border-radius: 16px; margin: 0 auto 12px; }
.empty { text-align: center; padding: 28px 12px 8px; }
.empty .napkin { width: 140px; height: 100px; border-radius: 16px; margin: 0 auto 12px; }

.detail { padding: 18px; display: grid; gap: 22px; }
.detail-hero { display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: 18px; }
.hero-photo { border-radius: 16px; overflow: hidden; background: var(--paper-2); min-height: 220px; }
.hero-photo .napkin { min-height: 220px; }
.detail-columns { display: grid; grid-template-columns: 1fr 1.2fr; gap: 22px; }
.ingredient-list, .step-list, .cook-ings, .cook-steps, .shop-list, .flags { list-style: none; padding: 0; margin: 0; }
.ingredient-list li, .step-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.qty { font-weight: 750; margin-right: 6px; }
.scaler { background: var(--butter); border-radius: 16px; padding: 14px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper strong { min-width: 8rem; text-align: center; font-size: 1.2rem; }
.flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.flag { border-radius: 12px; padding: 8px 10px; background: var(--paper); display: flex; justify-content: space-between; gap: 8px; }
.flag-yes { background: var(--blush); }
.flag-no { background: var(--sage); }
.flag-unknown { background: var(--paper-2); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery img { border-radius: 12px; aspect-ratio: 1; object-fit: cover; }
.gallery figcaption { font-size: 0.85rem; color: var(--ink-soft); }
.photo-form { max-width: 420px; margin-top: 12px; }
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--blue);
  color: white;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 750;
  margin-right: 6px;
}
.end-actions { margin-top: 8px; }

.line-list { display: grid; gap: 8px; }
.line-title { margin-top: 8px; }
.suggest-title { color: var(--blue-deep); }
.ing-head, .ing-row {
  display: grid;
  grid-template-columns: 44px 5.2rem 5.2rem minmax(0, 1.4fr) minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}
.ing-head { color: var(--ink-soft); font-size: 0.82rem; font-weight: 750; }
.ing-row, .step-row { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.ing-row.is-suggestion, .step-row.is-suggestion { background: #f3f7fb; border-color: #c5d5e2; }
.step-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 6.5rem 44px;
  gap: 8px;
  align-items: start;
}
.tick { place-items: center; }
.tick input { width: 22px; height: 22px; accent-color: var(--red); }
.name-cell { display: grid; gap: 4px; }
.timer-field { font-size: 0.82rem; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  font-size: 1.3rem;
}
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.preview-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-grid img, .preview-static img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; }
.dropzone {
  border: 1.5px dashed #c9b79a;
  border-radius: 16px;
  padding: 14px;
  background: var(--paper);
}
.dropzone.is-hot { border-color: var(--blue); background: #f3f7fb; }
.source-dump, .mail-form details { margin-top: 16px; }
pre {
  white-space: pre-wrap;
  background: var(--paper);
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
}
.cancel-import { margin-top: 10px; }
.aside-link { margin-top: 16px; }

.notice { border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; }
.notice-ok { background: var(--sage); }
.notice-warn { background: var(--butter); }
.notice-tip { background: #e7f0f6; }
.flash { border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; }
.flash-error { background: var(--blush); }
.flash-ok { background: var(--sage); }
.flash-info, .flash-message { background: var(--butter); }
.flashes:empty { display: none; }

.shop-list { display: grid; gap: 8px; margin-bottom: 16px; }
.shop-row { display: flex; gap: 8px; align-items: stretch; }
.shop-row form:first-child { flex: 1; }
.check-hit {
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 52px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
}
.box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--blue);
  border-radius: 6px;
  flex: 0 0 auto;
}
.shop-row.is-done .box { background: var(--blue); }
.shop-row.is-done .shop-label { text-decoration: line-through; color: var(--ink-soft); }
.shop-label { display: grid; }
.shop-label small, .iname + small { color: var(--ink-soft); font-weight: 450; }
.mail-box, .mail-form { padding: 16px; margin-top: 18px; }

.login-body {
  background-color: #f6f1e8;
  background-image:
    linear-gradient(90deg, rgba(196, 71, 60, 0.08) 50%, transparent 50%),
    linear-gradient(rgba(53, 102, 132, 0.08) 50%, transparent 50%);
  background-size: 22px 22px;
}
.login-body .page {
  max-width: none;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-body .flashes { width: min(440px, 100%); }
.login-card { width: min(440px, 100%); padding: 22px; }
.demo-hint { margin-top: 16px; background: var(--butter); border-radius: 12px; padding: 10px 12px; }
.demo-hint code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

body.cook {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fffdfb;
}
body.cook .page {
  flex: 1;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.cook-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cook-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.cook-title h1 { font-size: clamp(1.3rem, 2.5vw, 1.8rem); }
.cook-title p { margin: 0; color: var(--ink-soft); }
.cook-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.timer-start { display: flex; gap: 8px; align-items: end; }
.timer-start input { width: 5rem; }
.sound-toggle { display: flex; gap: 6px; align-items: center; font-weight: 650; }
.sound-toggle input { width: auto; }
.wake-status { flex-basis: 100%; margin: 0; color: var(--ink-soft); }
.wake-status:empty { display: none; }
.cook-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane { overflow: auto; min-height: 0; padding: 16px 18px 32px; }
.pane-ings { max-height: 38vh; background: #fff8e8; border-bottom: 1px solid var(--line); }
.pane-steps { flex: 1; }
.cook-layout.ings-hidden .pane-ings { display: none; }
.cook-ings li, .cook-steps .step { padding: 8px 0; border-bottom: 1px solid var(--line); }
.cook-ings label, .cook-steps label { display: flex; gap: 12px; align-items: flex-start; }
.cook-ings { font-size: 1.12rem; }
.cook-steps .step label { font-size: 1.32rem; line-height: 1.35; }
.cook-ings input, .cook-steps input[type="checkbox"] {
  width: 32px;
  height: 32px;
  margin-top: 2px;
  accent-color: var(--red);
  flex: 0 0 auto;
}
.cook-steps em { font-family: var(--serif); font-style: normal; color: var(--red); margin-right: 8px; }
.step.is-done span, .ing.is-done span { opacity: 0.45; text-decoration: line-through; }
.step-timer { margin: 8px 0 4px 44px; }
.cooked-form { margin-top: 18px; }
.timer-dock {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: white;
}
.timer-chip {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--blush);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  white-space: nowrap;
}
.timer-chip.is-done { background: var(--sage); }
.timer-chip button { border: 0; background: white; border-radius: 999px; min-height: 36px; padding: 4px 10px; }
.timer-remaining { font-variant-numeric: tabular-nums; font-weight: 750; min-width: 4.5rem; }

@media (orientation: landscape) and (min-width: 700px), (min-width: 960px) {
  .cook-layout { display: grid; grid-template-columns: minmax(260px, 34%) 1fr; }
  .pane-ings { max-height: none; border-bottom: 0; border-right: 1px solid var(--line); }
  .collapse-ings { display: none; }
}

@media (max-width: 900px) {
  .import-grid, .detail-hero, .detail-columns, .editor-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hero, .page-head { flex-direction: column; align-items: start; }
  .nav { margin-left: 0; }
}
@media (max-width: 720px) {
  .ing-head { display: none; }
  .ing-row { grid-template-columns: 44px 1fr 1fr 44px; }
  .name-cell, .note-cell { grid-column: 1 / -1; }
  .step-row { grid-template-columns: 44px 1fr 44px; }
  .timer-field { grid-column: 1 / -1; }
  .search-row, .email-row { flex-direction: column; align-items: stretch; }
}

@media print {
  .site-header, .site-footer, .action-row, .scaler, .heart-form, .cook-tools, .timer-dock { display: none !important; }
  body.cook { height: auto; overflow: visible; }
  .pane { overflow: visible; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
