/* Heirloom: one stylesheet for the app and the public pages.
   The visual idea is the ruled index card in a recipe box: white stock,
   pale blue rules, one red line under the title, written in navy ink. */

/* Fonts are self-hosted (SIL Open Font License, see /fonts/LICENSE-OFL.txt). */
@font-face { font-family: "Young Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/young-serif-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Young Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/young-serif-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/caveat-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --desk: #e8edf0;
  --paper: #ffffff;
  --paper-2: #f6f8fa;
  --ink: #1f2a44;
  --ink-2: #48546f;
  --ink-3: #737e95;
  --rule: #c3d7ea;
  --rule-strong: #7fa8d1;
  --margin: #d2454b;
  --herb: #2c6a4c;
  --line: #d3dae2;
  --line-strong: #b6c0cc;
  --focus: #2563d6;
  --hand-ink: #243b7a;
  --error-bg: #fdecec;
  --shadow-card: 0 1px 2px rgba(31, 42, 68, 0.12), 0 8px 20px -10px rgba(31, 42, 68, 0.25);
  --shadow-soft: 0 1px 2px rgba(31, 42, 68, 0.08);

  --font-display: "Young Serif", Georgia, "Times New Roman", serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Caveat", "Bradley Hand", cursive;

  --r-card: 3px;
  --r-ui: 8px;
  --r-panel: 12px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #131925;
    --paper: #1d2534;
    --paper-2: #232c3d;
    --ink: #e8ecf3;
    --ink-2: #b7c0d0;
    --ink-3: #8e98ab;
    --rule: rgba(127, 168, 209, 0.24);
    --rule-strong: #6f97c0;
    --margin: #e8686d;
    --herb: #6cc59a;
    --line: #313b4d;
    --line-strong: #46516a;
    --focus: #7aa7ff;
    --hand-ink: #a9bdf2;
    --error-bg: #3a2228;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 20px -10px rgba(0, 0, 0, 0.6);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #131925; --paper: #1d2534; --paper-2: #232c3d; --ink: #e8ecf3; --ink-2: #b7c0d0; --ink-3: #8e98ab;
  --rule: rgba(127, 168, 209, 0.24); --rule-strong: #6f97c0; --margin: #e8686d; --herb: #6cc59a; --line: #313b4d;
  --line-strong: #46516a; --focus: #7aa7ff; --hand-ink: #a9bdf2; --error-bg: #3a2228; color-scheme: dark;
}

/* ---- Base ------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--margin); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.15; margin: 0 0 0.5rem; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.35rem); }
h2 { font-size: 1.3rem; }
p { margin: 0 0 0.75rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--rule-strong) 45%, transparent); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; border-radius: var(--r-ui); z-index: 100; }
.skip-link:focus { top: 0.5rem; }

.lede { font-size: 1.125rem; color: var(--ink-2); max-width: 62ch; }
.sub { color: var(--ink-2); margin: 0; }
.fine { font-size: 0.9rem; color: var(--ink-3); }
.empty { color: var(--ink-2); padding: 1.25rem; border: 1.5px dashed var(--line-strong); border-radius: var(--r-panel); }
.form-error { color: var(--margin); background: var(--error-bg); padding: 0.6rem 0.85rem; border-radius: var(--r-ui); font-weight: 700; }
.badge { display: inline-block; font-family: var(--font-body); font-size: 0.8rem; font-weight: 700; color: var(--herb); border: 1.5px solid currentColor; border-radius: 999px; padding: 0 0.55rem; margin-left: 0.5rem; vertical-align: 0.1em; line-height: 1.5; }

/* ---- Icons -------------------------------------------------------------------------------- */

.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo { width: 30px; height: 30px; flex: none; color: var(--ink); }

/* ---- Buttons ----------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0 1rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-ui);
  background: var(--paper); color: var(--ink);
  font-weight: 700; font-size: 1rem; line-height: 1.2; text-decoration: none;
  cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--paper)); border-color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-large { min-height: 52px; padding: 0 1.4rem; font-size: 1.0625rem; }
.btn-small { min-height: 36px; padding: 0 0.75rem; font-size: 0.92rem; }
.btn-block { width: 100%; }
.btn-danger { background: var(--margin); border-color: var(--margin); color: #fff; }
.btn-danger-quiet { background: transparent; border-color: transparent; color: var(--margin); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; background: transparent; border-radius: var(--r-ui); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.btn-outline { border: 1.5px solid var(--line-strong); background: var(--paper); }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; font-size: 0.95rem; }
.link-btn.danger { color: var(--margin); }
.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.75rem 0; }

/* ---- Form fields ----------------------------------------------------------------------- */

.field { display: grid; gap: 0.35rem; margin-bottom: 1.1rem; }
.field > span { font-weight: 700; font-size: 0.95rem; }
.field em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 0.88rem; margin-top: -0.2rem; }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
  width: 100%; min-height: 46px; padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-ui);
  background: var(--paper); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
select { appearance: none; padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 1.15rem) 52%, calc(100% - 0.8rem) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
:where(input, select, textarea):focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 0; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 0.85rem; }
textarea.ruled {
  line-height: 2rem; padding-top: 0.25rem; padding-bottom: 0.25rem;
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(2rem - 1px), var(--rule) calc(2rem - 1px) 2rem);
  background-position: 0 0.25rem; background-attachment: local;
}
.copy-field { display: flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.copy-field input { flex: 1; min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.inline-input:not(:focus) { border-color: transparent; background: transparent; }

/* Steps editor */
.steps-editor ol { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 0.5rem; }
.steps-editor li { display: flex; align-items: flex-start; gap: 0.4rem; }
.step-num { width: 1.6rem; flex: none; text-align: right; padding-top: 0.55rem; font-family: var(--font-display); color: var(--margin); }
.steps-editor textarea { flex: 1; min-height: 46px; resize: none; overflow: hidden; }
.steps-editor .is-heading textarea { font-family: var(--font-display); }
.steps-editor .icon-btn { margin-top: 1px; }

/* ---- The index card ------------------------------------------------------------------- */

.index-card {
  --ic-row: 2rem;
  --ic-head: 3.25rem;
  position: relative;
  padding: 0.75rem 1.25rem 1rem;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  background:
    linear-gradient(var(--margin), var(--margin)) 0 calc(var(--ic-head) - 2px) / 100% 2px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--ic-row) - 1px), var(--rule) calc(var(--ic-row) - 1px) var(--ic-row)) 0 var(--ic-head) / 100% 100% no-repeat,
    var(--paper);
}
.index-card > :first-child {
  height: calc(var(--ic-head) - 0.75rem); line-height: calc(var(--ic-head) - 0.75rem);
  margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.index-card p, .index-card li { line-height: var(--ic-row); margin: 0; }
.index-card ul { list-style: none; margin: 0; padding: 0; }
.index-card h2 { font-size: 1.25rem; }
.ing-heading { font-family: var(--font-display); color: var(--margin); }
.scaled-note { font-size: 0.88rem; color: var(--herb); font-weight: 700; }

/* ---- Headers and navigation ---------------------------------------------------------- */

.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; font-family: var(--font-display); font-size: 1.3rem; color: var(--ink); }
.site-header, .app-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem max(1rem, env(safe-area-inset-left)); min-height: 60px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.site-nav, .top-nav { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.site-nav > a:not(.btn) { text-decoration: none; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 480px) { .site-nav > a:not(.btn) { display: none; } }
.top-nav a { text-decoration: none; font-weight: 700; color: var(--ink-2); padding: 0.4rem 0; border-bottom: 2px solid transparent; }
.top-nav a.active { color: var(--ink); border-bottom-color: var(--margin); }
.kitchen-switch select { min-height: 36px; width: auto; max-width: 46vw; border-radius: 999px; border-color: var(--line); background-color: var(--paper-2); font-weight: 700; font-size: 0.92rem; padding: 0.2rem 2rem 0.2rem 0.85rem; }

.tab-bar { display: none; }
@media (max-width: 759px) {
  .top-nav { display: none; }
  .kitchen-switch { margin-left: auto; }
  .tab-bar {
    display: grid; grid-template-columns: repeat(3, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--paper); border-top: 1px solid var(--line);
  }
  .tab-bar a { display: grid; place-items: center; align-content: center; gap: 0.1rem; text-decoration: none; color: var(--ink-3); font-size: 0.8rem; font-weight: 700; position: relative; }
  .tab-bar a .icon { width: 24px; height: 24px; }
  .tab-bar a.active { color: var(--ink); }
  .tab-bar a.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--margin); border-radius: 0 0 3px 3px; }
  .app-main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1.5rem); }
}

/* ---- App pages ------------------------------------------------------------------------------- */

.page { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-narrow { max-width: 700px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.head-links { display: flex; gap: 1rem; font-weight: 700; font-size: 0.95rem; }
.head-links a { color: var(--ink-2); }
.back-link { display: inline-flex; align-items: center; gap: 0.2rem; margin: 0 0 0.75rem -0.25rem; color: var(--ink-2); font-weight: 700; text-decoration: none; }
.back-link:hover { color: var(--ink); }
.splash { min-height: 40vh; }
.message-page { max-width: 560px; margin: 12vh auto; padding: 0 1rem; }
.panel { background: var(--paper); border-radius: var(--r-panel); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow-soft); }
.panel h2 { font-size: 1.15rem; }
.hide-narrow { display: inline; }
@media (max-width: 420px) { .hide-narrow { display: none; } }

/* Search and chips */
.search-box { position: relative; margin-bottom: 0.75rem; }
.search-box > .icon { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search-box input { padding-left: 2.6rem; min-height: 50px; border-radius: 999px; }
.chips { display: flex; gap: 0.5rem; margin: 0.25rem 0 1.25rem; overflow-x: auto; padding: 0.15rem 0.1rem 0.35rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; flex: none;
  min-height: 36px; padding: 0 0.85rem; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--paper); color: var(--ink);
  font-weight: 700; font-size: 0.92rem; cursor: pointer; text-decoration: none;
}
.chip .icon { width: 1em; height: 1em; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip-tag::before { content: "#"; color: var(--ink-3); font-weight: 400; }
.chip-tag[aria-pressed="true"]::before { color: inherit; }

/* Recipe tiles */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 220px), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.recipe-tile { display: flex; flex-direction: column; text-decoration: none; background: var(--paper); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; min-height: 100%; }
.recipe-tile:hover .tile-text strong { text-decoration: underline; text-decoration-color: var(--margin); text-underline-offset: 0.18em; }
.tile-visual { position: relative; aspect-ratio: 4 / 3; background: var(--paper-2); overflow: hidden; }
.tile-visual img { width: 100%; height: 100%; object-fit: cover; }
.card-lines {
  height: 100%; padding: 0.95rem 0.85rem 0;
  font-size: 0.85rem; color: var(--ink-2);
  background:
    linear-gradient(var(--margin), var(--margin)) 0 0.55rem / 100% 2px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 calc(1.6rem - 1px), var(--rule) calc(1.6rem - 1px) 1.6rem) 0 0.95rem / 100% 100% no-repeat,
    var(--paper);
  border-bottom: 1px solid var(--line);
}
.card-lines span { display: block; line-height: 1.6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-text { padding: 0.7rem 0.85rem 0.85rem; display: grid; gap: 0.15rem; }
.tile-text strong { font-family: var(--font-display); font-weight: 400; font-size: 1.08rem; line-height: 1.25; }
.tile-meta, .tile-text > span { color: var(--ink-3); font-size: 0.86rem; display: flex; flex-wrap: wrap; column-gap: 0.75rem; }
.tile-badge { position: absolute; left: 0.5rem; bottom: 0.5rem; background: var(--paper); color: var(--herb); font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; box-shadow: var(--shadow-soft); }
.recipe-tile.skeleton { min-height: 220px; background: var(--paper-2); box-shadow: none; }

/* Empty recipe box */
.welcome { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 2rem; align-items: center; margin: 1rem 0 2rem; }
.welcome-card { transform: rotate(-2.5deg); min-height: 150px; }
.welcome-card .welcome-card-title { font-family: var(--font-display); font-size: 1.3rem; }
.welcome-card p:not(:first-child) { font-family: var(--font-hand), var(--font-body); color: var(--ink-3); }
@media (max-width: 620px) { .welcome { grid-template-columns: 1fr; gap: 1.25rem; } .welcome-card { max-width: 260px; } }

/* Ways to add a recipe */
.add-options { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 1rem 0 2rem; }
.add-option {
  display: flex; gap: 0.9rem; align-items: flex-start; padding: 1rem 1.1rem;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-panel);
  text-decoration: none; box-shadow: var(--shadow-soft);
}
.add-option:hover { border-color: var(--ink-2); }
.add-option > .icon { width: 28px; height: 28px; color: var(--ink-2); margin-top: 0.1rem; }
.add-option strong { display: block; font-size: 1.05rem; }
.add-option small { display: block; color: var(--ink-2); font-size: 0.93rem; }
.add-option-main { border-color: var(--ink); border-width: 2px; }
.add-option-main > .icon { color: var(--margin); }

/* Scanning */
.photo-strip { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.photo-strip li { position: relative; width: 130px; aspect-ratio: 3 / 4; }
.photo-strip img { width: 100%; height: 100%; object-fit: cover; border: 5px solid var(--paper); box-shadow: var(--shadow-card); }
.on-photo { position: absolute; top: 4px; right: 4px; background: var(--paper); width: 36px; height: 36px; }
.tips { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--ink-2); }
.tips h2 { font-size: 1.05rem; color: var(--ink); }
.tips ul { margin: 0; padding-left: 1.2rem; }
.working { display: grid; justify-items: center; gap: 1.25rem; text-align: center; padding: 3rem 1rem; color: var(--ink-2); font-weight: 700; }
.working-card {
  width: 220px; height: 140px; padding: 1.6rem 1rem 0; border-radius: var(--r-card); box-shadow: var(--shadow-card);
  background:
    linear-gradient(var(--margin), var(--margin)) 0 1.2rem / 100% 2px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 calc(1.75rem - 1px), var(--rule) calc(1.75rem - 1px) 1.75rem) 0 1.6rem / 100% 100% no-repeat,
    var(--paper);
}
.working-card span { display: block; height: 0.5rem; margin: 0.6rem 0 0.65rem; background: var(--hand-ink); border-radius: 4px; opacity: 0.75; width: 0; animation: write 2.4s ease-in-out infinite; }
.working-card span:nth-child(2) { animation-delay: 0.4s; }
.working-card span:nth-child(3) { animation-delay: 0.8s; }
.working-card span:nth-child(4) { animation-delay: 1.2s; }
@keyframes write { 0% { width: 0; } 45%, 80% { width: 85%; } 100% { width: 0; opacity: 0; } }

/* Editor */
.editor-layout { display: grid; gap: 1.5rem; }
.editor-with-original .editor-layout { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .editor-with-original .editor-layout { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: start; }
  .original-panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
}
.editor:not(.editor-with-original) .editor-layout { max-width: 720px; }
.original-panel details { background: var(--paper); border-radius: var(--r-panel); padding: 0.75rem; box-shadow: var(--shadow-soft); }
.original-panel summary { font-weight: 700; cursor: pointer; padding: 0.25rem; }
.original-panel img { margin-top: 0.75rem; width: 100%; border-radius: 4px; }
.photo-field img { max-height: 240px; border-radius: 6px; object-fit: cover; }

/* Recipe page (app and public) */
.recipe-head { margin-bottom: 1rem; }
.recipe-head h1 { font-size: clamp(2rem, 1.5rem + 2.4vw, 3rem); max-width: 22ch; }
.byline { color: var(--ink-2); margin-bottom: 0.5rem; }
.recipe-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1.25rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0 0 1.5rem; padding: 0.75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { display: grid; gap: 0.05rem; }
.facts dt { color: var(--ink-3); font-size: 0.85rem; }
.facts dd { margin: 0; font-weight: 700; display: flex; align-items: center; gap: 0.4rem; min-height: 36px; }
.scaler output { min-width: 2.2ch; text-align: center; font-size: 1.15rem; }
.step-btn { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--paper); font-size: 1.2rem; font-weight: 700; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.step-btn:hover { border-color: var(--ink); }
.recipe-photo { width: 100%; max-height: 440px; object-fit: cover; border-radius: 4px; margin-bottom: 1.75rem; box-shadow: var(--shadow-soft); }
.recipe-body { display: grid; gap: 2rem; align-items: start; }
@media (min-width: 860px) {
  .recipe-body { grid-template-columns: minmax(300px, 380px) 1fr; gap: 2.5rem; }
  .ingredients-card { position: sticky; top: 1rem; }
}
.ingredients-card li { padding-left: 0.1rem; }
.steps h2, .notes h2, .originals h2 { margin-top: 0.4rem; }
.steps ol { margin: 0; padding-left: 2.1rem; max-width: 68ch; }
.steps li { margin-bottom: 1rem; padding-left: 0.35rem; line-height: 1.6; }
.steps li::marker { font-family: var(--font-display); color: var(--margin); font-size: 1.1em; }
.steps .step-heading { list-style: none; margin-left: -2.1rem; font-family: var(--font-display); font-size: 1.1rem; margin-top: 1.5rem; }
.notes { margin-top: 1.75rem; padding: 1rem 1.15rem; background: var(--paper); border-left: 3px solid var(--rule-strong); border-radius: 0 var(--r-ui) var(--r-ui) 0; }
.notes p { white-space: pre-line; margin: 0; }
.tag-line { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.25rem; }
.originals { margin-top: 2.5rem; }
.original-grid { display: flex; flex-wrap: wrap; gap: 1rem; }
.original-grid img { max-height: 320px; width: auto; border: 7px solid var(--paper); box-shadow: var(--shadow-card); }
.cook-mode .ingredients-card li { font-size: 1.15rem; }
.cook-mode .ingredients-card { --ic-row: 2.25rem; }
.cook-mode .steps li { font-size: 1.25rem; cursor: pointer; padding: 0.35rem 0.35rem 0.35rem 0.5rem; border-radius: 6px; }
.cook-mode .steps li:hover { background: var(--paper); }
.cook-mode .steps li.done { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--margin); text-decoration-thickness: 2px; }

/* Shopping list */
.quick-add { display: flex; gap: 0.5rem; margin: 0.5rem 0 1.25rem; }
.quick-add input { flex: 1; min-width: 0; min-height: 50px; }
.quick-add select { width: auto; flex: none; }
.quick-add .btn { min-height: 50px; }
.aisles { background: var(--paper); border-radius: var(--r-panel); box-shadow: var(--shadow-soft); padding: 0.25rem 0 0.5rem; overflow: hidden; }
.aisle h2 {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-size: 1.05rem; margin: 0; padding: 1rem 1rem 0.45rem;
  border-bottom: 2px solid var(--margin);
}
.aisle h2 small { font-family: var(--font-body); font-size: 0.82rem; color: var(--ink-3); font-weight: 700; }
.aisle ul { list-style: none; margin: 0; padding: 0; }
.aisle-done h2 { color: var(--ink-3); border-bottom-color: var(--rule); }
.item { display: flex; align-items: center; border-bottom: 1px solid var(--rule); }
.item:last-child { border-bottom: 0; }
.item-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.85rem;
  min-height: 58px; padding: 0.5rem 0.25rem 0.5rem 1rem;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.tick { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--rule-strong); display: grid; place-items: center; transition: background-color 0.15s, border-color 0.15s; }
.tick .icon { width: 16px; height: 16px; stroke-width: 3; color: var(--paper); }
.item-text { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.6rem; min-width: 0; }
.item-name {
  font-size: 1.08rem; font-weight: 700;
  background-image: linear-gradient(var(--margin), var(--margin));
  background-repeat: no-repeat; background-position: 0 58%; background-size: 0% 2px;
  transition: background-size 0.28s ease-out, color 0.2s;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.item-qty { color: var(--ink-2); }
.item-for { flex-basis: 100%; color: var(--ink-3); font-size: 0.85rem; }
.item.checked .tick { background: var(--ink-3); border-color: var(--ink-3); }
.item.checked .item-name { background-size: 100% 2px; color: var(--ink-3); font-weight: 400; }
.item.checked .item-qty, .item.checked .item-for { color: var(--ink-3); opacity: 0.7; }
.list-footer { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; align-items: center; }
.list-footer .fine { flex-basis: 100%; margin-top: 0.25rem; }
.empty-list p:last-child { margin: 0; }

/* Rows: staples, aisles, members */
.row-list { list-style: none; margin: 0.5rem 0 1rem; padding: 0; }
.row-list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.row-list li:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-main small { color: var(--ink-3); font-size: 0.88rem; }
.row-list select { width: auto; min-height: 40px; font-size: 0.92rem; }
.row-list .inline-input { min-height: 38px; padding: 0.25rem 0.5rem; margin-left: -0.5rem; }
.aisle-rows { background: var(--paper); border-radius: var(--r-panel); padding: 0.25rem 0.75rem; box-shadow: var(--shadow-soft); }
.aisle-rows .inline-input { flex: 1; font-weight: 700; margin-left: 0; }
.row-num { width: 1.8rem; text-align: right; font-family: var(--font-display); color: var(--margin); flex: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-letter { display: grid; place-items: center; background: var(--rule); color: var(--ink); font-weight: 700; }
.report-row { flex-wrap: wrap; }
.kitchen-page h1 { margin-bottom: 0.25rem; }
.kitchen-page > .sub { margin-bottom: 1.25rem; }

.join-page { padding-top: 3rem; }
.join-card { --ic-head: 4rem; padding-bottom: 1.5rem; }
.join-card h1 { font-size: 1.7rem; }
.join-card .btn { margin-top: 1rem; }

/* Sheets (dialogs) */
.sheet { border: 0; padding: 0; background: var(--paper); color: var(--ink); width: min(540px, 100vw); max-width: 100vw; max-height: 88vh; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.sheet::backdrop { background: rgba(15, 20, 32, 0.5); }
.sheet[open] { animation: sheet-in 0.2s ease-out; }
.sheet-inner { padding: 0.5rem 1.25rem 1.25rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; top: 0; background: var(--paper); padding: 0.5rem 0; z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; }
.sheet-actions { position: sticky; bottom: -1.25rem; background: var(--paper); padding: 0.75rem 0 0.5rem; margin-bottom: 0; }
@media (max-width: 600px) {
  .sheet { margin: auto 0 0; width: 100vw; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet[open] { animation: sheet-up 0.22s ease-out; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes sheet-up { from { transform: translateY(40%); opacity: 0.5; } }
.menu-list { display: grid; margin: 0.25rem -1.25rem 0; }
.menu-list button { text-align: left; min-height: 54px; padding: 0 1.25rem; border: 0; border-top: 1px solid var(--line); background: none; font-weight: 700; cursor: pointer; }
.menu-list button:hover { background: var(--paper-2); }
.menu-list button.danger { color: var(--margin); }
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-list label { display: flex; align-items: center; gap: 0.75rem; min-height: 48px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.pick-list span { flex: 1; font-weight: 700; }
.pick-list small { color: var(--ink-2); font-size: 0.92rem; }

/* Toasts */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 50; display: grid; gap: 0.5rem; width: min(480px, calc(100vw - 2rem)); }
@media (max-width: 759px) { .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 0.75rem); } }
.toast { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: var(--ink); color: var(--paper); padding: 0.8rem 1rem; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); font-weight: 700; animation: sheet-in 0.2s ease-out; }
.toast a { color: var(--paper); white-space: nowrap; text-decoration-color: var(--margin); text-decoration-thickness: 2px; }

/* Ads and support */
.ad-slot { margin: 2.25rem 0; padding: 0.75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 60px; }
.ad-label { display: block; font-size: 0.75rem; color: var(--ink-3); margin-bottom: 0.4rem; }
.ad-slot.sponsor a { font-weight: 700; }
.ad-slot.house { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; padding: 1rem 0; }
.ad-slot.house p { margin: 0; max-width: 56ch; color: var(--ink-2); }

/* ---- Public site ----------------------------------------------------------------------- */

.site main { min-height: 60vh; }
.site-footer { margin-top: 4rem; border-top: 1px solid var(--line); background: var(--paper); }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.footer-inner nav a { color: var(--ink-2); font-size: 0.95rem; }
.brand-quiet { font-size: 1.1rem; }

.hero {
  max-width: 1120px; margin: 0 auto; padding: clamp(2rem, 5vw, 4.5rem) 1rem clamp(2rem, 5vw, 4rem);
  display: grid; gap: 2.5rem; align-items: center;
}
@media (min-width: 900px) { .hero { grid-template-columns: 1.05fr 1fr; gap: 3.5rem; } }
.hero h1 { font-size: clamp(2.4rem, 1.6rem + 3.6vw, 4.1rem); line-height: 1.04; letter-spacing: -0.02em; max-width: 13ch; margin-bottom: 1.1rem; }
.hero .lede { font-size: clamp(1.1rem, 1rem + 0.4vw, 1.25rem); margin-bottom: 1.5rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.75rem; }
.hero-visual { position: relative; min-height: 400px; max-width: 520px; width: 100%; justify-self: center; }
.handwritten { --ic-row: 2.15rem; --ic-head: 3.6rem; width: min(92%, 400px); transform: rotate(-3deg); font-family: var(--font-hand); color: var(--hand-ink); font-size: 1.55rem; padding: 0.75rem 1.4rem 1.25rem; }
.handwritten p { line-height: var(--ic-row); }
.handwritten .hw-title { font-size: 2rem; }
.handwritten .hw-title span { font-size: 1.4rem; opacity: 0.8; }
.hero-sheet {
  position: absolute; right: 0; bottom: 0; width: min(78%, 330px);
  background: var(--paper); border-radius: 10px; padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 2px 4px rgba(31, 42, 68, 0.1), 0 24px 48px -16px rgba(31, 42, 68, 0.4);
  transform: rotate(1.5deg);
  animation: sheet-arrive 0.7s 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.sheet-title { font-family: var(--font-display); font-size: 1.3rem; line-height: 1.2; margin-bottom: 0.3rem; }
.sheet-meta { display: flex; gap: 1rem; color: var(--ink-3); font-size: 0.88rem; margin-bottom: 0.6rem; }
.hero-sheet ul { margin: 0 0 0.75rem; padding: 0; list-style: none; font-size: 0.98rem; }
.hero-sheet li { padding: 0.28rem 0; border-bottom: 1px solid var(--rule); }
.sheet-toast { margin: 0; font-size: 0.86rem; font-weight: 700; color: var(--herb); animation: fade-in 0.4s 1.1s both; }
@keyframes sheet-arrive { from { opacity: 0; transform: translate(-30px, -20px) rotate(-3deg); } }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 520px) { .hero-visual { min-height: 470px; } .hero-sheet { width: 84%; } }

.features { max-width: 1120px; margin: 0 auto; padding: 1rem 1rem 2rem; display: grid; gap: 2.5rem 3rem; }
@media (min-width: 800px) { .features { grid-template-columns: 1fr 1fr; } .feature-list { grid-column: 1 / -1; } }
.feature h2 { font-size: 1.5rem; margin-bottom: 0.6rem; }
.feature p { color: var(--ink-2); max-width: 58ch; }
.feature-list { display: grid; gap: 1.5rem 3rem; align-items: center; padding-top: 2rem; border-top: 1px solid var(--line); }
@media (min-width: 800px) { .feature-list { grid-template-columns: 1fr minmax(280px, 380px); } }
.mini-list { background: var(--paper); border-radius: var(--r-panel); padding: 0.25rem 1rem 0.75rem; box-shadow: var(--shadow-card); }
.mini-aisle { font-family: var(--font-display); margin: 0.8rem 0 0; padding-bottom: 0.3rem; border-bottom: 2px solid var(--margin); }
.mini-item { margin: 0; padding: 0.45rem 0; border-bottom: 1px solid var(--rule); font-weight: 700; display: flex; justify-content: space-between; }
.mini-item span { font-weight: 400; color: var(--ink-2); }
.mini-item.done { color: var(--ink-3); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--margin); text-decoration-thickness: 2px; }

.shared-strip, .explore, .prose, .public-recipe, .support-band { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem; }
.strip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.strip-head a { font-weight: 700; color: var(--ink-2); }
.support-band { margin-top: 1.5rem; }
.support-band > * { max-width: 60ch; }
.support-band h2 { font-size: 1.6rem; }
.search-form { display: flex; gap: 0.5rem; margin: 1rem 0 1.5rem; max-width: 560px; }
.search-form input { flex: 1; border-radius: 999px; }
.pager { display: flex; gap: 0.75rem; }
.prose { max-width: 720px; }
.prose h2 { margin-top: 1.75rem; }
.crumbs { margin-bottom: 0.75rem; }
.crumbs a { color: var(--ink-2); font-weight: 700; }
.report { margin-top: 2rem; color: var(--ink-2); max-width: 520px; }
.report summary { cursor: pointer; font-size: 0.92rem; }
.report form { margin-top: 1rem; }

/* ---- Motion and print ------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .working-card span { width: 85%; }
}

@media print {
  .app-header, .site-header, .site-footer, .tab-bar, .recipe-actions, .back-link, .ad-slot, .report, .crumbs, .toasts, .tag-line, .originals, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .recipe-body { grid-template-columns: 1fr 1.6fr !important; }
  .index-card, .recipe-photo { box-shadow: none; }
  .ingredients-card { position: static; border: 1px solid #ccc; }
  .recipe-photo { max-height: 260px; }
}
