/* ---------- Fonts (self-hosted; all SIL Open Font License) ---------- */
@font-face { font-family: "Cinzel"; src: url("/fonts/cinzel.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Cinzel Decorative"; src: url("/fonts/cinzel-decorative-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IM Fell English"; src: url("/fonts/im-fell-english.woff2") format("woff2"); font-style: normal; font-display: swap; }
@font-face { font-family: "IM Fell English"; src: url("/fonts/im-fell-english-italic.woff2") format("woff2"); font-style: italic; font-display: swap; }

/* ---------- Palette: candlelit parchment by day, a starlit study by night ---------- */
:root {
  --paper: #f6ecd4;
  --paper-2: #ecdfc0;
  --desk: #d9c9a6;
  --ink: #2b1d14;
  --ink-2: #6f5a45;
  --line: #d2bf98;
  --accent: #5a2d82;       /* arcane violet */
  --accent-2: #7a3fb0;
  --accent-ink: #fbf3df;
  --gold: #a87d24;
  --leather: #4a2618;
  --seal: #8e1f24;          /* wax seal */
  --low: #3f7a3a;
  --med: #a4660c;
  --high: #a8302a;
  --shadow: 0 1px 2px rgb(50 30 10 / 0.12), 0 12px 30px rgb(50 30 10 / 0.18);
  --glow: 0 0 0 1px rgb(168 125 36 / 0.35), 0 0 18px rgb(122 63 176 / 0.22);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --stains:
    radial-gradient(ellipse 60% 45% at 12% 8%, rgb(150 105 45 / 0.12), transparent 70%),
    radial-gradient(ellipse 50% 40% at 92% 96%, rgb(150 105 45 / 0.14), transparent 70%),
    radial-gradient(ellipse 35% 30% at 80% 18%, rgb(150 105 45 / 0.06), transparent 70%);
  --sky: radial-gradient(ellipse 120% 80% at 50% -10%, #efe3c4 0%, transparent 60%), radial-gradient(ellipse 100% 70% at 50% 120%, rgb(90 50 20 / 0.25), transparent 70%);
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  /* Decorative capitals for single letters only: the face joins some letter pairs, such as OO. */
  --initial: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --heading: "Cinzel", "Trajan Pro", Georgia, serif;
  --serif: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #231d30;
    --paper-2: #2c2540;
    --desk: #0d0b1a;
    --ink: #ece1c8;
    --ink-2: #a99cb8;
    --line: #42385a;
    --accent: #c4a0ff;
    --accent-2: #d8bfff;
    --accent-ink: #160f24;
    --gold: #d9b45e;
    --leather: #120d1d;
    --seal: #a8323a;
    --low: #8fd18a;
    --med: #e6b25a;
    --high: #f07f74;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 14px 34px rgb(0 0 0 / 0.55);
    --glow: 0 0 0 1px rgb(217 180 94 / 0.35), 0 0 22px rgb(196 160 255 / 0.25);
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .8 0 0 0 0 .75 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --stains:
      radial-gradient(ellipse 60% 45% at 12% 8%, rgb(196 160 255 / 0.07), transparent 70%),
      radial-gradient(ellipse 50% 40% at 92% 96%, rgb(217 180 94 / 0.05), transparent 70%);
    /* A field of stars over a deep indigo night. */
    --sky:
      radial-gradient(1px 1px at 12% 18%, #fff8 50%, transparent 51%),
      radial-gradient(1px 1px at 27% 72%, #fff6 50%, transparent 51%),
      radial-gradient(1.5px 1.5px at 41% 33%, #fffb 50%, transparent 51%),
      radial-gradient(1px 1px at 58% 84%, #fff7 50%, transparent 51%),
      radial-gradient(1px 1px at 66% 12%, #fff9 50%, transparent 51%),
      radial-gradient(1.5px 1.5px at 79% 57%, #f3e6ffcc 50%, transparent 51%),
      radial-gradient(1px 1px at 91% 28%, #fff6 50%, transparent 51%),
      radial-gradient(1px 1px at 7% 91%, #fff5 50%, transparent 51%),
      radial-gradient(ellipse 90% 60% at 80% -10%, rgb(110 70 190 / 0.28), transparent 70%),
      radial-gradient(ellipse 70% 50% at 0% 110%, rgb(40 80 160 / 0.22), transparent 70%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--sky), var(--desk);
  background-size: 100% 100%, auto;
  background-attachment: fixed;
  color: var(--ink);
  font: 17px/1.5 var(--serif);
}
@media (prefers-color-scheme: dark) {
  body { background-size: 340px 340px, 340px 340px, 340px 340px, 340px 340px, 340px 340px, 340px 340px, 340px 340px, 340px 340px, 100% 100%, 100% 100%, auto; }
}
h1, h2, h3 { font-family: var(--heading); font-weight: 600; line-height: 1.2; margin: 0; text-wrap: balance; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea { font-family: var(--sans); font-size: 0.95rem; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* Anything that should look like a page of the book. */
.card, .book, .panel, .login, dialog.sheet, main > .banner {
  background-color: var(--paper);
  background-image: var(--grain), var(--stains);
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.5em 1em; border-radius: 4px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font: 600 0.82rem/1.2 var(--heading); letter-spacing: 0.06em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: box-shadow 0.2s, border-color 0.2s, filter 0.2s;
}
.btn:hover { border-color: var(--gold); box-shadow: var(--glow); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: var(--gold); color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: var(--glow); }
.btn.danger { color: var(--high); }
.btn.danger:hover { border-color: var(--high); box-shadow: 0 0 14px rgb(168 48 42 / 0.3); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn.on { background: var(--paper-2); border-color: var(--gold); color: var(--accent); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: var(--gold); }
.icon { background: none; border: 0; padding: 0.25em 0.45em; border-radius: 4px; cursor: pointer; color: var(--ink-2); line-height: 1; }
.icon:hover { background: var(--paper-2); color: var(--ink); }
input[type="text"], input[type="search"], input[type="url"], input[type="number"], input[type="password"], textarea {
  width: 100%; padding: 0.55em 0.7em; border-radius: 4px;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 70%, transparent); color: var(--ink);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.08);
}
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 0.75; }
textarea { resize: vertical; min-height: 5em; line-height: 1.45; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  max-width: 1180px; margin: 0 auto 1rem; position: relative;
}
/* A gilt rule with a diamond in the middle. */
.topbar::after {
  content: ""; position: absolute; left: clamp(1rem, 4vw, 2.5rem); right: clamp(1rem, 4vw, 2.5rem); bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
}
.topbar::before {
  content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px;
  background: var(--gold); transform: translateX(-50%) rotate(45deg);
}
.brand { font: 700 1.6rem var(--display); color: var(--ink); text-decoration: none; letter-spacing: 0.02em; display: inline-flex; align-items: center; gap: 0.45rem; }
.brand::before { content: "✦"; color: var(--gold); font-size: 1.1rem; text-shadow: 0 0 10px var(--gold); animation: twinkle 4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.55; text-shadow: 0 0 2px var(--gold); } }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

main { padding: 0 clamp(1rem, 4vw, 2.5rem) 4rem; max-width: 1180px; margin: 0 auto; }

/* ---------- Sign in: a sealed tome ---------- */
.login {
  max-width: 24rem; margin: 14vh auto 0; padding: 2.4rem 2rem 2rem; text-align: center; position: relative;
  border-radius: 6px; box-shadow: var(--shadow), 0 0 0 8px var(--leather), 0 0 0 9px var(--gold), 0 18px 50px rgb(0 0 0 / 0.35);
}
.login::before {
  content: "✦"; display: grid; place-items: center; width: 3.4rem; height: 3.4rem; margin: -0.4rem auto 0.9rem;
  border-radius: 50%; font-size: 1.4rem; color: #f6dc9a;
  background: radial-gradient(circle at 35% 30%, #c2414a, var(--seal) 60%, #5a1014);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.35), inset 0 0 0 3px rgb(0 0 0 / 0.15);
}
.login h1 { font: 700 2rem var(--display); margin-bottom: 0.4rem; }
.login p { color: var(--ink-2); margin: 0 0 1.2rem; font-style: italic; }
.login form { display: grid; gap: 0.7rem; }
.login .btn { justify-content: center; font-size: 0.95rem; padding: 0.65em 1em; }

/* ---------- Library ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 0.5rem 0 1.5rem; }
.toolbar input { flex: 1 1 16rem; max-width: 26rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  padding: 0.35em 0.9em; border-radius: 999px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 50%, transparent); cursor: pointer; color: var(--ink-2);
  font: 600 0.78rem var(--heading); letter-spacing: 0.06em;
}
.chip:hover { border-color: var(--gold); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.4rem; }
.card {
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  color: var(--ink); text-decoration: none;
  border-radius: 6px; box-shadow: var(--shadow); transition: transform 0.2s ease, box-shadow 0.2s ease;
}
/* A thin gilt frame inside each card. */
.card::after { content: ""; position: absolute; inset: 5px; border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); border-radius: 3px; pointer-events: none; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow), var(--glow); }
.card-photo { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; background: var(--paper-2); filter: sepia(0.15) saturate(1.05); }
/* No photo: a summoning circle with the spell's initial. */
.card-nophoto {
  aspect-ratio: 4 / 3; display: grid; place-items: center;
  font: 700 3.4rem var(--initial); color: var(--accent);
  background:
    radial-gradient(circle at 50% 50%, transparent 0 2.6rem, var(--gold) 2.6rem calc(2.6rem + 1px), transparent calc(2.6rem + 2px) 3.3rem, color-mix(in srgb, var(--gold) 60%, transparent) 3.3rem calc(3.3rem + 1px), transparent calc(3.3rem + 2px)),
    repeating-conic-gradient(from 0deg at 50% 50%, color-mix(in srgb, var(--gold) 14%, transparent) 0 2deg, transparent 2deg 30deg),
    var(--paper-2);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent);
}
.card-body { padding: 0.85rem 1.1rem 1.1rem; display: grid; gap: 0.35rem; }
.card h3 { font-size: 1.12rem; letter-spacing: 0.02em; }
.meta { color: var(--ink-2); font-size: 0.9rem; font-style: italic; margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.15rem; }
.badge {
  font: 0.72rem var(--sans); padding: 0.12em 0.6em; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.badge.low { color: var(--low); border-color: currentColor; }
.badge.medium { color: var(--med); border-color: currentColor; }
.badge.high { color: var(--high); border-color: currentColor; }
.badge.star { color: var(--gold); border-color: currentColor; }
.empty { grid-column: 1 / -1; text-align: center; padding: 4rem 1rem; color: var(--ink-2); }
.empty::before { content: "❦"; display: block; font-size: 2.6rem; color: var(--gold); margin-bottom: 0.5rem; }
.empty h2 { color: var(--ink); margin-bottom: 0.4rem; font-family: var(--display); }
.empty p { font-style: italic; margin: 0 0 1.2rem; }

/* ---------- A spell: an open grimoire bound in leather ---------- */
.book {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  border-radius: 6px; margin: 22px 12px 12px;
  box-shadow: 0 0 0 10px var(--leather), 0 0 0 11px var(--gold), 0 0 0 12px var(--leather), var(--shadow), 0 24px 60px rgb(0 0 0 / 0.3);
}
.book::after {
  content: ""; position: absolute; inset: 0 auto 0 50%; width: 60px; transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgb(0 0 0 / 0.14) 46%, rgb(0 0 0 / 0.22) 50%, rgb(0 0 0 / 0.14) 54%, transparent); pointer-events: none;
}
.page { padding: clamp(1.25rem, 3vw, 2.6rem); min-width: 0; position: relative; }
.page h1 { font: 700 clamp(1.7rem, 3.2vw, 2.4rem)/1.15 var(--display); margin: 0.3rem 0 0.6rem; }
.page h2 {
  font: 700 0.9rem var(--heading); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin: 1.7rem 0 0.6rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
  display: flex; align-items: center; gap: 0.5rem;
}
.page h2::before { content: "✧"; color: var(--gold); letter-spacing: 0; }
.page h2:first-child { margin-top: 0; }
.desc { display: flow-root; font-style: italic; color: var(--ink-2); margin: 0 0 0.9rem; font-size: 1.05rem; }
/* An illuminated capital. */
.desc::first-letter {
  float: left; font: 700 2.9rem/0.9 var(--initial); color: var(--accent); font-style: normal;
  padding: 0.2rem 0.45rem 0 0; text-shadow: 1px 1px 0 var(--gold);
}
.facts-line { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; color: var(--ink-2); font-size: 0.95rem; margin: 0 0 0.8rem; clear: both; }
.facts-line b { color: var(--ink); font-weight: 600; font-family: var(--heading); font-size: 0.9em; }
.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.9rem 0 0; }
.actions .btn { font-size: 0.75rem; padding: 0.42em 0.85em; }

.gallery-main {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; background: var(--paper-2);
  border: 1px solid var(--gold); padding: 4px; box-shadow: 0 2px 10px rgb(0 0 0 / 0.15);
}
.gallery-thumbs { display: flex; gap: 0.4rem; margin: 0.45rem 0 0.9rem; overflow-x: auto; }
.gallery-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 3px; background: none; cursor: pointer; flex: none; }
.gallery-thumbs button[aria-current="true"] { border-color: var(--gold); }
.gallery-thumbs img { width: 3.6rem; height: 3.6rem; object-fit: cover; border-radius: 2px; }

.ings { list-style: none; margin: 0; padding: 0; }
.ing-header { font: 700 0.95rem var(--heading); letter-spacing: 0.04em; margin: 0.9rem 0 0.2rem; color: var(--ink-2); }
.ing-row {
  display: flex; align-items: baseline; gap: 0.6rem; width: 100%; text-align: left; font-size: 1.02rem;
  padding: 0.5rem 0.4rem; border: 0; border-bottom: 1px dotted var(--line); background: none; cursor: pointer; border-radius: 3px;
}
.ing-row::before { content: "◆"; font-size: 0.5rem; color: var(--gold); flex: none; transform: translateY(-0.2em); }
.ing-row:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ing-text { flex: 1; min-width: 0; }
.ing-instead { display: block; font-size: 0.85rem; color: var(--ink-2); text-decoration: line-through; }
.swapped .ing-text > span:first-child { color: var(--accent); font-weight: 600; }
.swapped .ing-row::before { content: "✦"; font-size: 0.75rem; color: var(--accent); }
.note-chip { flex: none; font: 0.7rem var(--sans); color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 0.08em 0.55em; white-space: nowrap; }
.note-chip.warn { color: var(--med); border-color: currentColor; }
.hint { color: var(--ink-2); font-size: 0.9rem; font-style: italic; margin: 0.6rem 0 0; }
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem;
  margin: 0.8rem 0 0; padding: 0.6rem 0.8rem; border-radius: 4px; background: var(--paper-2); font-size: 0.95rem;
}
.banner.warn { border-left: 3px solid var(--med); }
main > .banner { margin-top: 2rem; box-shadow: var(--shadow); }
.progress { flex: 1 1 8rem; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width 0.3s; box-shadow: 0 0 8px var(--accent); }

/* Each step is sealed with a roman numeral in wax. */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0.1rem 0 1.1rem 3rem; font-size: 1.1rem; line-height: 1.55; }
.steps li::before {
  content: counter(step, upper-roman); position: absolute; left: 0; top: 0;
  width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center;
  font: 700 0.72rem var(--heading); color: #f6dc9a;
  background: radial-gradient(circle at 35% 30%, #c2414a, var(--seal) 60%, #5a1014);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35), inset 0 0 0 2px rgb(0 0 0 / 0.15);
}
.notes { white-space: pre-wrap; font-style: italic; margin: 0; }

/* ---------- Nutrition (kept in the familiar label form) and glycemic load ---------- */
.facts { display: grid; grid-template-columns: minmax(17rem, 21rem) 1fr; gap: 1.5rem; margin-top: 2.4rem; align-items: start; }
.panel { border-radius: 6px; box-shadow: var(--shadow); padding: 1.3rem 1.45rem; position: relative; }
.nf { border: 2px solid var(--ink); padding: 0.5rem 0.7rem 0.6rem; font: 0.92rem/1.3 var(--sans); font-variant-numeric: tabular-nums; }
.nf h2 { font: 900 2.15rem/1 var(--sans); letter-spacing: -0.02em; padding-bottom: 0.25rem; border-bottom: 1px solid var(--ink); }
.nf-serving { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; }
.nf-serving.strong { font-weight: 700; }
.nf-thick { border-top: 9px solid var(--ink); margin-top: 0.25rem; }
.nf-medium { border-top: 5px solid var(--ink); }
.nf-cal { display: flex; justify-content: space-between; align-items: flex-end; font-weight: 800; }
.nf-cal span:first-child { font-size: 1.5rem; }
.nf-cal span:last-child { font-size: 2.4rem; line-height: 1; }
.nf-small { font-size: 0.78rem; font-weight: 700; }
.nf-dv { text-align: right; font-size: 0.78rem; font-weight: 700; padding: 0.15rem 0; }
.nf-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.18rem 0; border-top: 1px solid var(--ink-2); }
.nf-row.indent { padding-left: 1rem; }
.nf-foot { font-size: 0.72rem; color: var(--ink-2); margin: 0.4rem 0 0; }

.gl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 0.9rem; }
.gl-head h2 { font-size: 1.3rem; }
.gl-number { font: 700 3.2rem/1 var(--heading); font-variant-numeric: tabular-nums; margin-top: 0.4rem; }
.gl-number small { font: italic 400 1rem var(--serif); color: var(--ink-2); margin-left: 0.4rem; }
.gl-band { font: 700 0.78rem var(--heading); letter-spacing: 0.08em; padding: 0.25em 0.8em; border-radius: 999px; color: var(--paper); }
.gl-band.low { background: var(--low); }
.gl-band.medium { background: var(--med); }
.gl-band.high { background: var(--high); }
.gl-scale { position: relative; height: 10px; border-radius: 5px; margin: 1.1rem 0 0.3rem;
  background: linear-gradient(90deg, var(--low) 0 25%, var(--med) 25% 50%, var(--high) 50% 100%); box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.3); }
.gl-marker { position: absolute; top: -6px; width: 6px; height: 22px; border-radius: 3px; background: var(--gold); transform: translateX(-50%); box-shadow: 0 0 0 2px var(--paper), 0 0 10px var(--gold); }
.gl-ticks { display: flex; justify-content: space-between; font: 0.75rem var(--sans); color: var(--ink-2); }
.gl-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.gl-table th { text-align: right; font: 600 0.7rem var(--heading); letter-spacing: 0.06em; color: var(--ink-2); padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--gold); }
.gl-table th:first-child, .gl-table td:first-child { text-align: left; }
.gl-table td { text-align: right; padding: 0.35rem 0.4rem; border-bottom: 1px dotted var(--line); }
.bar { display: inline-block; height: 0.5em; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); margin-right: 0.4em; vertical-align: middle; }

/* ---------- Ingredient sheet ---------- */
dialog.sheet {
  width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 1px solid var(--gold); border-radius: 8px;
  color: var(--ink); box-shadow: var(--shadow), var(--glow);
}
dialog.sheet::backdrop { background: radial-gradient(circle at 50% 40%, rgb(40 15 60 / 0.45), rgb(10 5 20 / 0.7)); backdrop-filter: blur(2px); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem 0.6rem; position: sticky; top: 0; z-index: 1; background-color: var(--paper); background-image: var(--grain); }
.sheet-head h2 { font-size: 1.2rem; }
.sheet-body { padding: 0 1.25rem 1.25rem; }
.sheet h3 { font: 700 0.75rem var(--heading); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 1.1rem 0 0.5rem; }
.opt { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 0.45rem; cursor: pointer; }
.opt:hover { border-color: var(--gold); }
.opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--paper)); box-shadow: var(--glow); }
.opt input { margin-top: 0.3rem; accent-color: var(--accent); }
.opt-body { flex: 1; min-width: 0; display: grid; gap: 0.15rem; }
.opt-text { font-weight: 600; }
.opt-text em { font-weight: 400; color: var(--ink-2); }
.opt-note { font-size: 0.9rem; color: var(--ink-2); font-style: italic; }
.deltas { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.15rem; }
.delta { font: 0.72rem var(--sans); padding: 0.05em 0.55em; border-radius: 999px; border: 1px solid currentColor; font-variant-numeric: tabular-nums; }
.delta.down { color: var(--low); }
.delta.up { color: var(--high); }
.delta.flat { color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row > input { flex: 1 1 10rem; }
.field { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.3rem 0.75rem; align-items: center; margin-bottom: 0.6rem; }
.field input[type="number"] { width: 6.5rem; }
.field small { grid-column: 2; color: var(--ink-2); font-size: 0.85rem; font-style: italic; }
.results { list-style: none; margin: 0.5rem 0 0; padding: 0; max-height: 14rem; overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
.results button { display: flex; justify-content: space-between; gap: 1rem; width: 100%; text-align: left; padding: 0.45rem 0.7rem; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; font-size: 0.95rem; }
.results button:hover { background: var(--paper-2); }
.results span:last-child { color: var(--ink-2); white-space: nowrap; font: 0.8rem var(--sans); }

/* ---------- Scribing (the editor) ---------- */
.editor { max-width: 46rem; }
.editor .panel { margin-bottom: 1.4rem; }
.editor h1 { font: 700 2rem var(--display); margin: 0.4rem 0 1.1rem; }
.editor label { display: block; font: 600 0.82rem var(--heading); letter-spacing: 0.08em; margin: 1.1rem 0 0.35rem; }
.editor label small { font: italic 400 0.92rem var(--serif); letter-spacing: 0; color: var(--ink-2); margin-left: 0.4em; }
.editor label:first-child { margin-top: 0; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.import { border: 1px dashed var(--gold); }
.import h2 { font-size: 1.15rem; margin-bottom: 0.25rem; }
.import p { margin: 0 0 0.8rem; color: var(--ink-2); font-style: italic; }
.import details { margin-top: 0.8rem; }
.import summary { cursor: pointer; color: var(--accent); }
.import textarea { margin: 0.6rem 0; min-height: 9rem; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.thumb { position: relative; margin: 0; width: 7rem; }
.thumb img { width: 7rem; height: 7rem; object-fit: cover; border-radius: 3px; border: 1px solid var(--gold); }
.thumb figcaption, .thumb .link { display: block; font-size: 0.82rem; text-align: center; margin: 0.2rem auto 0; color: var(--ink-2); font-style: italic; }
.thumb .link { color: var(--accent); }
.thumb .remove { position: absolute; top: 4px; right: 4px; background: rgb(0 0 0 / 0.6); color: #fff; border-radius: 50%; width: 1.5rem; height: 1.5rem; padding: 0; }
.editor .add-photo {
  width: 7rem; height: 7rem; display: grid; place-items: center; text-align: center; margin: 0 !important;
  border: 2px dashed var(--line); border-radius: 3px; color: var(--ink-2); cursor: pointer; font: italic 400 0.92rem var(--serif) !important; letter-spacing: 0 !important;
}
.editor .add-photo:hover, .photo-strip.drag .add-photo { border-color: var(--gold); color: var(--accent); box-shadow: var(--glow); }
.form-actions { display: flex; gap: 0.6rem; justify-content: flex-end; position: sticky; bottom: 0; padding: 0.9rem 0; background: linear-gradient(transparent, var(--desk) 40%); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); z-index: 100;
  max-width: min(32rem, calc(100vw - 2rem)); padding: 0.7rem 1.1rem; border-radius: 4px;
  background: var(--ink); color: var(--paper); border: 1px solid var(--gold); box-shadow: var(--shadow), var(--glow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--high); color: #fff; border-color: #5a1014; }

@media (max-width: 820px) {
  .book { grid-template-columns: 1fr; margin: 14px 7px 7px; box-shadow: 0 0 0 6px var(--leather), 0 0 0 7px var(--gold), var(--shadow); }
  .book::after { display: none; }
  .page + .page { padding-top: 0; }
  .facts { grid-template-columns: 1fr; }
  .trio { grid-template-columns: 1fr 1fr; }
  .field { grid-template-columns: 1fr; }
  .field small { grid-column: 1; }
  .brand { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  body { background: #fff; }
  .card, .book, .panel { background-image: none; }
  .topbar, .actions, .note-chip, #toast { display: none; }
  .book, .panel { box-shadow: none; }
}
