/* Recipe Hub design system (docs/UX-PLAN.md §4): calm, grouped lists, one accent, large titles. */
:root {
  --bg: #f6f2ec; --surface: #ffffff; --surface-2: #efe8de; --text: #231a12; --muted: #85776a; --faint: #b9ab9c;
  --line: #e9e0d4; --accent: #8a4b1f; --accent-ink: #fff; --accent-soft: #f3e4d4;
  --star: #e1a127; --danger: #b3261e;
  --dot-planned: #4a7bd0; --dot-made: #d99a1e; --dot-done: #3c9a55; --dot-dropped: #a59a8e;
  --radius: 14px; --gutter: 16px; --tabbar: 60px;   /* the bottom bar (ui.js navRow): Back, actions, Home */
  --shadow: 0 1px 2px rgb(60 40 20 / .05);
  color-scheme: light;
}
/* Dark colors: the phone's setting (Automatic), or Settings → Appearance (data-theme on <html>, see ui.js applyTheme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131009; --surface: #1f1a14; --surface-2: #2a231b; --text: #f3ebe1; --muted: #a6978a; --faint: #6d6155;
    --line: #322a21; --accent: #e3a066; --accent-ink: #1b120a; --accent-soft: #3a2a1b;
    --star: #f0b443; --danger: #ff8a80; --shadow: none;
    --dot-planned: #7ea6ee; --dot-made: #f0b443; --dot-done: #6cc788; --dot-dropped: #7b7065;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131009; --surface: #1f1a14; --surface-2: #2a231b; --text: #f3ebe1; --muted: #a6978a; --faint: #6d6155;
  --line: #322a21; --accent: #e3a066; --accent-ink: #1b120a; --accent-soft: #3a2a1b;
  --star: #f0b443; --danger: #ff8a80; --shadow: none;
  --dot-planned: #7ea6ee; --dot-made: #f0b443; --dot-done: #6cc788; --dot-dropped: #7b7065;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
main { max-width: 680px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 24px) var(--gutter) calc(var(--tabbar) + env(safe-area-inset-bottom) + 32px); }
body.modal main { padding-bottom: calc(env(safe-area-inset-bottom) + 110px); }

/* ---------- type ---------- */
.large-title { font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 4px; }
.title { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; margin: 4px 0; }
.sub { color: var(--muted); font-size: 15px; margin: 0 0 4px; }
.section-label { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 26px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.section-label a, .section-label button { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
p { margin: 6px 0; }

/* ---------- nav ---------- */
.navrow { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin: 0 -6px; }
.navrow .back { display: inline-flex; align-items: center; gap: 2px; font-size: 17px; font-weight: 500; padding: 8px 6px; color: var(--accent); background: none; border: 0; cursor: pointer; }
.icon-btn { border: 0; background: transparent; color: var(--accent); width: 44px; height: 44px; border-radius: 12px; cursor: pointer; display: inline-grid; place-items: center; flex: none; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.muted { color: var(--muted); }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--faint); }
.tabbar a.on { color: var(--accent); }
body.modal .tabbar { display: none; }

/* ---------- groups (inset grouped lists) ---------- */
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group + .group { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px; color: var(--text); position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
.row.with-thumb + .row.with-thumb::before { left: 74px; }
a.row:active, button.row:active { background: var(--surface-2); }
button.row { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-meta { display: block; }
.row-title { font-size: 17px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.with-thumb .row-meta, .row.wrap .row-meta { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.star-badge { color: var(--text); font-size: 14px; font-weight: 650; white-space: nowrap; }
.star-badge .s { color: var(--star); }
.row-end { display: flex; align-items: center; gap: 6px; color: var(--faint); flex: none; font-size: 15px; }
.chev { color: var(--faint); flex: none; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; font-size: 24px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.planned { background: var(--dot-planned); } .dot.in_progress { background: var(--dot-made); }
.dot.done { background: var(--dot-done); } .dot.abandoned { background: var(--dot-dropped); }
.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; }
.stars .dim { opacity: .22; }
.half-star { background: linear-gradient(90deg, var(--star) 50%, color-mix(in srgb, var(--star) 22%, transparent) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.next { border-left: 4px solid var(--accent); }
.next .next-text { font-size: 17px; font-weight: 600; }
.next .next-hint { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.next .btn-row { display: flex; gap: 8px; }
.active-card .row-title { white-space: normal; }
.banner { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 10px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 18px; min-height: 48px;
  border-radius: 12px; border: 0; background: var(--surface-2); color: var(--text); font-weight: 650; font-size: 16px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; }
.btn.hero { width: 100%; min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.danger { color: var(--danger); }
.btn.quiet { background: none; color: var(--accent); padding-inline: 6px; }
.btn:active { filter: brightness(.95); }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 650; padding: 0; cursor: pointer; }

/* ---------- stats strip ---------- */
.stats { display: flex; gap: 22px; margin: 10px 0 2px; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 22px; font-weight: 750; line-height: 1.1; }
.stats span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.goal { color: var(--muted); font-size: 15px; margin: 2px 0 6px; }

/* ---------- chips / segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chip { flex: none; border: 0; background: var(--surface); box-shadow: var(--shadow); color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 15px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 9px; font-weight: 600; font-size: 15px; cursor: pointer; }
.seg input:checked + span { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.search { width: 100%; border: 0; background: var(--surface-2); border-radius: 11px; padding: 10px 14px; font-size: 16px; color: var(--text); margin: 6px 0 8px; }

/* ---------- formula table ---------- */
.formula { width: 100%; border-collapse: collapse; }
.formula td, .formula th { padding: 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.formula tr:first-child td { border-top: 0; }
.formula th { font-size: 12px; color: var(--muted); font-weight: 650; text-align: right; border-top: 0; padding-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.formula .r { text-align: right; padding-left: 12px; white-space: nowrap; }
.formula .g { font-size: 17px; font-weight: 650; }
.formula .p { color: var(--muted); }
.formula .stage-row td { font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 14px; }
.formula tfoot td { font-weight: 750; }
.ing-sub { font-size: 13px; color: var(--muted); }

/* ---------- disclosure ---------- */
details.disc { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
details.disc + details.disc, .card + details.disc, details.disc + .card { margin-top: 12px; }
details.disc > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; min-height: 52px; }
details.disc > summary::-webkit-details-marker { display: none; }
details.disc > summary .sum-title { font-weight: 650; font-size: 17px; }
details.disc > summary .sum-meta { color: var(--muted); font-size: 14px; flex: 1; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.disc > summary::after { content: "›"; color: var(--faint); font-size: 22px; line-height: 1; transition: transform .15s; }
details.disc[open] > summary::after { transform: rotate(90deg); }
details.disc > .disc-body { padding: 0 16px 16px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.notes { white-space: pre-wrap; }
.steps-list { margin: 0; padding-left: 1.3rem; }
.steps-list li { margin: 8px 0; }
.steps-list li::marker { color: var(--muted); font-weight: 650; }

/* ---------- photos ---------- */
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.photo-strip img, .photo-add { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; flex: none; cursor: pointer; }
.photo-add { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center; line-height: 1.2; }
.viewer img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: #000; }

/* ---------- forms ---------- */
.modal-head { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; margin: 0 calc(-1 * var(--gutter)); padding: calc(env(safe-area-inset-top) + 6px) var(--gutter) 6px; background: var(--bg); border-bottom: 1px solid transparent; }
.modal-head h2 { font-size: 17px; margin: 0; }
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.save-bar .inner { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.save-bar .live { flex: 1; font-size: 14px; color: var(--muted); }
.save-bar .live b { color: var(--text); font-size: 16px; }
.form .group { padding: 4px 14px; }
.form .group + .group, .form details.disc { margin-top: 12px; }
.f-row { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 4px 0; position: relative; }
.f-row + .f-row { border-top: 1px solid var(--line); }
.f-row > label, .f-label { flex: 0 0 38%; font-size: 16px; color: var(--text); }
.f-row > .ctl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.f-stack { padding: 10px 0; }
.f-stack + .f-stack, .f-row + .f-stack, .f-stack + .f-row { border-top: 1px solid var(--line); }
.f-stack > label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: transparent; border: 0; width: 100%; min-width: 0; padding: 8px 0; border-radius: 8px;
}
.ctl input, .ctl select { text-align: right; }
textarea { background: var(--surface-2); padding: 10px 12px; resize: vertical; min-height: 64px; }
.boxed { background: var(--surface-2) !important; padding: 9px 12px !important; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.unit { color: var(--muted); font-size: 15px; flex: none; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 36px; text-align: right; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* ingredient rows */
.ing { padding: 8px 0; border-top: 1px solid var(--line); }
.ing:first-child { border-top: 0; }
.ing-line { display: flex; align-items: center; gap: 8px; }
.role-tag { flex: none; width: auto; max-width: 92px; padding: 5px 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; font-weight: 650; color: var(--muted); text-align: left; }
.ing-name { flex: 1; font-size: 17px; font-weight: 550; }
.amt { flex: none; width: 92px; display: flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 9px; padding: 0 10px; }
.amt input { text-align: right; font-size: 17px; font-weight: 650; padding: 8px 0; }
.ing-sub-line { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.ing-brand { font-size: 14px; color: var(--muted); padding: 4px 0; }
.ing-pct { flex: none; font-size: 14px; color: var(--muted); min-width: 52px; text-align: right; }
.rm { width: 32px; height: 32px; border: 0; background: none; color: var(--faint); font-size: 18px; cursor: pointer; flex: none; }
.add-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0 8px; border-top: 1px solid var(--line); }
.add-chip { border: 0; background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.stage-name { font-size: 13px !important; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--muted) !important; padding-top: 12px !important; }
.add-link { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--accent); font-weight: 650; padding: 12px 0; cursor: pointer; border-top: 1px solid var(--line); }
.step { padding: 8px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step .ing-line input:first-child { font-weight: 550; }
.temps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.temps .amt { width: auto; padding: 0 6px; }
.temps .amt input { font-size: 14px; font-weight: 500; }
.temps .unit { font-size: 12px; }

/* steppers */
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--surface-2); color: var(--text); font-size: 20px; font-weight: 600; cursor: pointer; }
.stepper input { width: 44px; text-align: center !important; font-size: 18px; font-weight: 700; padding: 4px 0; }
.avail { font-size: 13px; color: var(--muted); }

/* stars input */
.star-input { display: flex; align-items: center; }
.star-input button { border: 0; background: transparent; font-size: 30px; color: var(--line); cursor: pointer; width: 40px; height: 44px; padding: 0; line-height: 1; }
.star-input button.on { color: var(--star); }
.star-input button.half { background: linear-gradient(90deg, var(--star) 50%, var(--line) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.star-input.sm button { font-size: 22px; width: 30px; }
.rating-guide { font-size: 13px; color: var(--muted); }

/* sheets, toasts, viewer */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .4); display: flex; align-items: flex-end; justify-content: center; touch-action: none; }
body.sheet-open { overflow: hidden; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 85vh; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; transition: transform .15s ease; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: 2px auto 10px; opacity: .6; }
.sheet h3 { margin: 4px 4px 12px; font-size: 20px; }
.sheet-sub { margin: -8px 4px 12px; }
.danger-text { color: var(--danger); font-size: 15px; }
.sheet .group { margin-bottom: 12px; }
.sheet .row-title { font-size: 17px; font-weight: 550; }
.sheet .row.danger .row-title { color: var(--danger); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 20px + env(safe-area-inset-bottom)); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); color: #fff; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.copy-box { width: 100%; font-family: ui-monospace, monospace; font-size: 13px; }

/* login */
.login { max-width: 360px; margin: 10vh auto 0; text-align: center; display: grid; gap: 12px; }
.login img { margin: 0 auto; border-radius: 22px; }
.login h1 { margin: 0; font-size: 30px; }
.login .boxed { text-align: left; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* history (recipe page) */
.hist-v { padding: 12px 14px; }
.hist-v + .hist-v { border-top: 1px solid var(--line); }
.hist-head { display: flex; align-items: baseline; gap: 8px; }
.hist-head b { font-size: 16px; }
.cur { font-size: 12px; font-weight: 750; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.hist-bakes { margin-top: 6px; display: grid; gap: 2px; }
.hist-bakes a { display: flex; justify-content: space-between; gap: 10px; color: var(--text); padding: 6px 0; font-size: 15px; }
.import-table td { vertical-align: top; }
.warn { color: var(--danger); }

/* polish after visual review */
.role-tag { -webkit-appearance: none; appearance: none; padding: 5px 7px; max-width: 64px; text-align: center; }
input::-webkit-calendar-picker-indicator { display: none !important; }
input[type="date"]::-webkit-calendar-picker-indicator { display: block !important; opacity: .5; }
.ing-name { font-size: 16px; }

/* bake → recipe link */
.recipe-link { display: flex; align-items: center; gap: 10px; background: var(--surface); box-shadow: var(--shadow); border-radius: 12px; padding: 10px 12px; margin: 8px 0 4px; color: var(--text); }
.recipe-link > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe-link > span .small:first-child { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.recipe-link svg:first-child { color: var(--accent); flex: none; }
.recipe-link .chev, .recipe-link svg:last-child { color: var(--faint); flex: none; }

/* review banner: ⓘ reveals what you're approving */
.banner.review { flex-wrap: wrap; }
.banner.review > span { flex: 1; min-width: 0; }
.info-btn { border: 0; background: none; color: var(--accent); font-size: 17px; padding: 0 4px; cursor: pointer; vertical-align: -1px; }
.review-help { flex-basis: 100%; color: var(--text); margin-top: 2px; line-height: 1.4; }

/* expandable text: fade + chevron (no "More/Less" words) */
.clamp.expandable { cursor: pointer; -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent); mask-image: linear-gradient(to bottom, #000 55%, transparent); }
.clamp.expanded { -webkit-line-clamp: unset; display: block; overflow: visible; -webkit-mask-image: none; mask-image: none; }
.expander { display: flex; justify-content: center; width: 100%; border: 0; background: none; color: var(--faint); padding: 0; height: 28px; margin-bottom: -6px; cursor: pointer; }
.expander svg { transition: transform .2s ease; }
.expander.open svg { transform: rotate(180deg); }
.expander:active { color: var(--accent); }


/* ================= modernization (docs/UX-PLAN.md §5) ================= */
/* Emphasis where it matters (Material 3 Expressive): key numbers and the primary action stand out; the rest stays calm. */
.stats b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.result-stars { font-size: 28px; line-height: 1; margin-bottom: 6px; }
.btn.primary { font-weight: 700; box-shadow: 0 1px 0 rgb(0 0 0 / .06), 0 4px 12px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn.hero { border-radius: 18px; font-size: 19px; letter-spacing: -.01em; }

/* Micro-interactions: quick press feedback and gentle transitions; none if the user prefers reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .row, .icon-btn, .add-chip, .expander, .edit-pencil, .tabbar a { transition: transform .12s ease, background-color .15s ease, color .15s ease, box-shadow .15s ease; }
  .btn:active, .chip:active, .add-chip:active { transform: scale(.97); }
  .tabbar a:active svg { transform: scale(.9); }
  details.disc[open] > .disc-body { animation: reveal .18s ease-out; }
  .toast { animation: toast-in .2s ease-out; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
}
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Toast with an action (Undo) */
.toast.with-action { display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 16px; }
.toast-action { border: 0; background: none; color: var(--accent-soft); font: inherit; font-weight: 800; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-action { color: var(--accent); } }
:root[data-theme="dark"] .toast-action { color: var(--accent); }

/* Edit in place: visible ✎ signifier; editing happens right where the text is. */
.editable { position: relative; }
.editable .notes { margin: 0; padding-right: 30px; }
.edit-pencil { position: absolute; top: -4px; right: -6px; width: 36px; height: 36px; border: 0; background: none; color: var(--faint); border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.edit-pencil:active, .edit-pencil:hover { color: var(--accent); background: var(--surface-2); }
.add-note { border: 0; background: none; color: var(--faint); font: inherit; font-size: 15px; padding: 2px 0; cursor: pointer; text-align: left; }
.add-note:active, .add-note:hover { color: var(--accent); }
.editable.editing .edit-area { width: 100%; min-height: 72px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 16px; line-height: 1.45; resize: none; overflow: hidden; }
.edit-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.small-btn { min-height: 36px; padding: 6px 16px; font-size: 15px; }
.editable + .expander { margin-top: 0; }
.goal-row { display: flex; gap: 8px; align-items: baseline; margin: 4px 0 6px; color: var(--muted); font-size: 15px; }
.goal-label { flex: none; font-weight: 650; }
.goal-edit { flex: 1; min-width: 0; }
.goal-edit .notes { color: var(--muted); }
.goal-edit .edit-pencil { top: -10px; }
.small-edit .notes { font-size: 14px; color: var(--muted); }
.small-edit .add-note { font-size: 14px; }

/* Skeleton placeholders while data loads */
.skeleton-wrap { padding: 6px 0; }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 50%, var(--surface-2) 75%); background-size: 200% 100%; border-radius: 8px; }
@media (prefers-reduced-motion: no-preference) { .sk { animation: shimmer 1.2s linear infinite; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-row { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.sk-thumb { width: 48px; height: 48px; border-radius: 10px; flex: none; }
.sk-line { height: 12px; margin: 6px 0; }
.sk-title { height: 28px; width: 70%; margin: 14px 0 10px; }
.sk-card { height: 120px; border-radius: var(--radius); margin: 14px 0; }
.w70 { width: 70%; } .w60 { width: 60%; } .w40 { width: 40%; }

/* Now: in-progress card holds a link and a separate button (no nested interactive elements) */
.active-card { display: block; }
.active-link { display: block; color: inherit; }

/* Changes by AI apps (ai.js) */
.row.act a.row-main { color: inherit; text-decoration: none; }
.row.act .row-title { white-space: normal; font-size: 16px; }
.month-label { font-size: 14px; font-weight: 600; color: var(--muted); margin: 18px 4px 8px; }
.quiet-adds { margin-top: 22px; display: grid; gap: 2px; }
.quiet-adds .editable.editing { background: var(--surface); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.btn-row .btn:not(.wide) { white-space: nowrap; }
/* bake log (log.js) */
.quick-row { display: flex; gap: 8px; margin-top: 10px; }
.quick-row .btn { flex: 1; min-height: 40px; padding: 6px 8px; font-size: 15px; }
.quick-row .btn.quiet { flex: 0 0 auto; }
.log-day { font-size: 13px; font-weight: 650; color: var(--muted); padding: 10px 14px 4px; }
.log-day { border-top: 1px solid var(--line); }
.log-day:first-child { border-top: 0; }
.log-row { align-items: flex-start; }
.log-time { flex: 0 0 72px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.log-row.note .row-title { font-weight: 450; white-space: normal; }
.log-note { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.log-sum { margin: -2px 4px 8px; }
.guide-tips { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
/* Wide screens: the menu is a sidebar that's always there; ☰ is hidden (PRD D28). Solid, no blur. */
.sidenav { display: none; }
@media (min-width: 900px) {
  body.signed-in .sidenav { display: block; position: fixed; top: 0; bottom: 0; left: 0; width: var(--side); overflow-y: auto; z-index: 35;
    padding: calc(env(safe-area-inset-top) + 20px) 12px 24px; background: var(--surface); border-right: 1px solid var(--line); }
  body.signed-in { padding-left: var(--side); }
  body.signed-in .bottombar, body.signed-in .save-bar { left: var(--side); }
  body.signed-in .menu-btn { display: none; }
}
:root { --side: 248px; }
.side-home { display: block; font-size: 20px; font-weight: 800; color: var(--text); padding: 6px 12px 10px; }
.side-head { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 12px 4px; }
.side-link { display: block; padding: 8px 12px; border-radius: 10px; color: var(--text); }
.side-link .row-title { font-size: 15px; font-weight: 550; }
.side-link .row-meta { display: block; font-size: 12.5px; color: var(--muted); white-space: normal; }
.side-link:hover { background: var(--surface-2); }
.side-link[aria-current="page"] { background: var(--accent-soft); }
.side-link[aria-current="page"] .row-title { color: var(--accent); }
.now-label { margin-top: 18px; }

/* ---------- redesign (PRD D16): Home, Library, projects, walk-through, story ---------- */
.nowrow { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); }
.nowrow .dot { width: 9px; height: 9px; margin: 0; }
.nowrow .row-meta { white-space: normal; }
.quiet-row { justify-content: center; color: var(--accent); font-weight: 600; min-height: 44px; }
.quiet-link { display: block; margin: 16px 4px 0; color: var(--accent); font-weight: 600; }
.quiet-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 18px 4px 0; align-items: center; }
.quiet-links .quiet-link { margin: 0; }
.spark { flex: none; }
.ratings-chart { display: block; width: 100%; height: auto; }
.letter { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 14px 3px; background: var(--surface-2); }
.letter:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.tag { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 5px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 6px 0 0; }
.idea-link { display: block; margin-top: 12px; color: var(--accent); font-weight: 600; word-break: break-all; }
.attempt .row-main { white-space: normal; }
.attempt-note { display: block; font-size: 14px; color: var(--muted); margin-top: 3px; }
/* walk-through */
.wt { margin-top: 14px; }
.wt-card { background: var(--surface); border: 2px solid var(--accent); border-radius: 18px; padding: 16px; margin: 10px 0; }
.wt-card .eyebrow { display: flex; justify-content: space-between; margin: 0; }
.wt-card .t { font-size: 23px; font-weight: 700; line-height: 1.2; margin: 4px 0 6px; }
.wt-card .what { margin: 0; }
.wt-card .amounts, .wt-more .amounts { margin-top: 10px; display: grid; }
.wt-card .amounts div, .wt-more .amounts div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.wt-card .amounts span:last-child, .wt-more .amounts span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wt-card .timer { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.wt-card .btn-row .btn { flex: 1; }
.wt-undo { text-align: center; margin: 10px 0 0; font-size: 14px; }
/* the story of a finished bake */
.story-stars { margin: 12px 4px 0; font-size: 20px; }
.story-day { display: grid; gap: 8px; margin-bottom: 14px; }
.quote, .quote-edit { border-left: 3px solid var(--line); padding-left: 12px; }
.quote .who { font-size: 13px; color: var(--muted); }
.chips-static { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-static span { background: var(--accent-soft); color: var(--accent); border-radius: 7px; padding: 3px 9px; font-size: 14px; font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.facts div { background: var(--surface); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.facts b { display: block; font-size: 18px; line-height: 1.2; }
.facts span { font-size: 13px; color: var(--muted); }
.navrow-end { display: flex; align-items: center; }
.page-kind { margin: 2px 0 -2px; }
/* AI-rewritten recipe steps waiting for the user (PRD D19) */
/* Change history (PRD D35): a quiet line under a record's title when an AI app changed it last; each change's lines */
.changed-hint { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.change-row .row-main { min-width: 0; }
.change-lines { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
a.banner { color: var(--text); }
/* General cooking (docs/COOKING.md): pick what kind of food; amounts with a unit */
.cat-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.cat-pick input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.cat-pick span { display: block; text-align: center; padding: 9px 4px; border-radius: 11px; background: var(--surface-2); font-weight: 600; font-size: 15px; cursor: pointer; }
.cat-pick input:checked + span { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.cat-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ing-unit { width: 84px; flex: none; }
/* the recipe page (PRD D23): make it first, how it's going in a card */
.kind-link { display: inline-block; text-decoration: none; }
.kind-link:hover, .kind-link:focus-visible { text-decoration: underline; }
.make-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 14px; }
.next-time { margin-top: 12px; border-left: 4px solid var(--accent); }
.next-time .notes { margin: 4px 0 0; }
.more-rows { margin-top: 22px; }
.more-rows .row-title .small { font-weight: 500; }
.sheet-notes { white-space: pre-wrap; max-height: 55vh; overflow-y: auto; }
.summary-card { display: flex; align-items: center; gap: 12px; margin-top: 22px; color: var(--text); text-decoration: none; }
.summary-card .row-title, .summary-card .row-meta { display: block; }
.fav-star { color: var(--star); }
.notes-line { white-space: normal; font-weight: 500; }
.counter { gap: 10px; }
.counter .btn { min-width: 40px; min-height: 36px; padding: 4px 10px; }
.counter b { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.sheet-form { padding: 4px 14px; }
.row.grocery { cursor: pointer; }
.row.grocery input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.row.grocery input:checked ~ .row-main .row-title { text-decoration: line-through; color: var(--muted); }
.recipe-desc { margin: 6px 0 2px; }
.recipe-desc .notes { margin: 0; }
/* The bottom bar (PRD D24): Back, the page's actions and Home in thumb reach. Solid, no translucency. */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; background: var(--bg); border-top: 1px solid var(--line);
  padding: 4px max(10px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); }
.bottombar .bb-inner { max-width: 680px; margin: 0 auto; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bottombar .back { min-width: 0; max-width: 60%; }
.bottombar .back-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottombar .icon-btn { width: 48px; height: 48px; }
body.modal .bottombar { display: none; }
.bottombar { display: block; }
.bottombar .bb-inner { width: 100%; }
.recipe-desc .add-note { text-align: left; padding: 2px 0; width: auto; min-height: 0; margin: 0; }
.recipe-desc .editable.empty { text-align: left; padding: 0; color: inherit; }
/* Home (PRD D25): the two indexes as big buttons */
.make-btn { margin-top: 16px; }
.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.home-link { display: grid; gap: 2px; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.home-link b { font-size: 18px; }
.home-link span { font-size: 14px; color: var(--muted); }
.home-link:active { background: var(--surface-2); }
/* Walk-through timeline: a rail down the left; done steps ✓, the step you're on a filled ring, upcoming hollow. Any
   step opens in place for its details. */
.wt { position: relative; padding-left: 28px; }
.wt::before { content: ""; position: absolute; left: 10px; top: 14px; bottom: 14px; width: 2px; background: var(--line); }
.wt-step summary { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr) auto 14px; gap: 8px; align-items: baseline; padding: 8px 2px; cursor: pointer; position: relative; font-size: 15px; color: var(--muted); }
.wt-step summary::-webkit-details-marker { display: none; }
.wt-step summary::after { content: "›"; color: var(--faint); transition: transform .15s ease; justify-self: end; }
.wt-step[open] summary::after { transform: rotate(90deg); }
.wt-step[open] summary { color: var(--text); font-weight: 600; }
.wt-step .w { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wt-step .mark { position: absolute; left: -28px; top: 7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg); }
.wt-step.done .mark { background: var(--dot-done); color: #fff; }
.wt-step.up .mark { border: 2px solid var(--faint); }
.wt-more { padding: 0 2px 12px; display: grid; gap: 6px; }
.wt-more p { margin: 0; }
.wt-now { position: relative; }
.wt-now::before { content: ""; position: absolute; left: -28px; top: 22px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.wt-card { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); box-shadow: 0 4px 18px rgb(60 40 20 / .10); }

/* A step's ingredients in the editor (PRD D33): chips, on = this step adds it. */
.uses { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 2px; }
.uses-label { font-size: 13px; color: var(--muted); margin-right: 2px; }
.use-chip { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.use-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.uses-warn { color: var(--danger); margin: 8px 4px 0; }
