:root {
  --paper: #f4efe6; --card: #fffdf8; --ink: #24232b; --muted: #65636b; --line: #e2d8c8;
  --accent: #b5562f; --accent-dk: #8e3f1f; --mustard: #d69a3a; --sage: #5f7d5a; --hi: #f6e3a6;
  --radius: 14px; --shadow: 0 1px 0 rgba(36,35,43,.04), 0 6px 18px rgba(36,35,43,.06);
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink);
  background: var(--paper) radial-gradient(circle at 6% 3%, rgba(214,154,58,.12), transparent 40%), radial-gradient(circle at 96% 28%, rgba(181,86,47,.08), transparent 45%); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1080px; margin: 0 auto; padding: 18px 18px 6px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; font-family: var(--serif); }
.sub { margin: 0; color: var(--muted); font-size: .92rem; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
main { max-width: 1080px; margin: 0 auto; padding: 6px 18px 24px; }
.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0 10px; padding: 10px 14px; border-radius: 12px; background: #f3e3d6; color: var(--accent-dk); font-size: .93rem; }
.banner.info { background: #e4ebe1; color: #3e5639; }
.banner.bad { background: #f6dcd2; color: #8e2f1a; }
.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent-dk); text-decoration: underline; font-weight: 600; cursor: pointer; }
button { cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: 9px 14px; min-height: 42px; background: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(181,86,47,.3); outline-offset: 2px; }
.ghost { background: transparent; border-color: var(--line); }
.ghost:hover { background: #efe8da; }
.sm { min-height: 34px; padding: 5px 10px; font-size: .9rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
h2 { font-family: var(--serif); font-size: 1.12rem; margin: 0; }
.step-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.step-aside, .hint { color: var(--muted); font-size: .88rem; }
.hint { margin: 10px 0 6px; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 26px; align-items: center;
  background: linear-gradient(155deg, #fffdf8 0%, #f6efe3 60%, #efe6d8 100%); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
.hero-kicker { margin: 0; color: var(--muted); font-size: .9rem; }
.hero-title { margin: 4px 0 6px; font-family: var(--hand); font-size: 2.7rem; line-height: 1.05; color: var(--accent-dk); font-weight: 700; }
.hero-sub { margin: 0 0 8px; font-size: 1.02rem; }
.notes { margin: 6px 0 12px; padding-left: 18px; color: var(--ink); font-size: .95rem; }
.notes li { margin: 4px 0; }
.mode { display: grid; gap: 6px; margin-top: 8px; }
.mode label { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.6); cursor: pointer; font-size: .95rem; }
.mode label:has(input:checked) { border-color: var(--accent); background: #fbeee5; }
.mode input { accent-color: var(--accent); }
.drawing { margin: 0; text-align: center; }
.drawing svg { width: 100%; max-height: 260px; }
.drawing figcaption { color: var(--muted); font-size: .85rem; }
.ta > * { fill: rgba(214,154,58,.22); stroke: #a87a26; stroke-width: .35; stroke-dasharray: 1.2 .8; vector-effect: non-scaling-stroke; }
.tb > * { fill: rgba(181,86,47,.12); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.ta > *, .tb > * { stroke-width: 2.2px; }
.ta .hole, .tb .hole { fill: var(--paper); }
.d-empty { fill: var(--muted); font-size: 13px; }
.key { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.key::before { content: ""; width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.key.a::before { background: rgba(214,154,58,.35); border: 1.5px dashed #a87a26; }
.key.b::before { background: rgba(181,86,47,.15); border: 2px solid var(--accent); }

.tins { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 12px; align-items: stretch; margin-bottom: 16px; }
.swap { align-self: center; font-size: 1.3rem; width: 46px; height: 46px; padding: 0; border-radius: 50%; background: var(--card); }
.tin-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tin-desc { font-family: var(--hand); font-size: 1.35rem; color: var(--accent-dk); }
#tin-from .tin-desc { color: #8a6418; }
.shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.shape { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fbf7ef; font-size: .86rem; padding: 6px 8px; min-height: 38px; text-align: left; }
.shape.on { border-color: var(--accent); background: #fbeee5; font-weight: 600; }
.si { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.fields { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.f { display: grid; gap: 3px; font-size: .85rem; color: var(--muted); }
.in { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.in input { width: 78px; border: 0; background: none; padding: 8px 4px 8px 10px; font-size: 1rem; color: var(--ink); }
.in em { font-style: normal; padding-right: 9px; color: var(--muted); }
.f select { border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: #fff; color: var(--ink); }
.units { display: flex; gap: 0; }
.u { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); background: #fff; border-radius: 0; font-size: .88rem; }
.u:first-child { border-radius: 9px 0 0 9px; } .u:last-child { border-radius: 0 9px 9px 0; border-left: 0; }
.u.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tin-err { margin: 8px 0 0; color: #8e2f1a; font-size: .9rem; }

.shelf { margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .hint { margin: 0; }
.chip { display: inline-flex; border: 1px solid var(--accent); border-radius: 999px; overflow: hidden; background: #fbeee5; }
.chip-use { min-height: 34px; padding: 4px 12px; font-size: .9rem; border-radius: 999px; }
.chip .chip-use { border-radius: 0; }
.chip-x { min-height: 34px; padding: 4px 10px; border-left: 1px solid rgba(181,86,47,.3); border-radius: 0; color: var(--accent-dk); }
.preset { border: 1px dashed var(--line); background: #fbf7ef; }
.preset:hover, .chip-use:hover { background: #f3e7d6; }

.recipe { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; margin-bottom: 16px; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; font: .95rem/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; resize: vertical; }
.bake { display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.bake input { width: 80px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #fff; }
.empty { color: var(--muted); font-style: italic; }
.out { list-style: none; margin: 0; padding: 0; }
.out li { padding: 4px 0; }
.out .gap { height: 8px; padding: 0; }
.out .h { font-family: var(--serif); font-weight: 700; margin-top: 4px; }
.out .t { color: var(--pencil, #4a4850); font-size: .95rem; }
.out .i { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; border-bottom: 1px dotted var(--line); }
.amt { font-weight: 700; }
.ch .amt { background: linear-gradient(transparent 55%, var(--hi) 55%); }
.was { color: var(--muted); font-size: .82rem; margin-left: auto; }
.nt { flex-basis: 100%; color: var(--sage); font-size: .84rem; font-style: italic; }
.how p { color: #3d3b43; font-size: .95rem; max-width: 72ch; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 4px 0 28px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .93rem; box-shadow: var(--shadow); z-index: 10; }

@media (max-width: 820px) {
  .hero, .recipe { grid-template-columns: 1fr; }
  .tins { grid-template-columns: 1fr; }
  .swap { justify-self: center; transform: rotate(90deg); }
  .hero-title { font-size: 2.2rem; }
}
@media print {
  .top-actions, .mode, .tins, .shelf, .recipe > .card:first-child, .how, .banner, .foot, .toast { display: none !important; }
  body { background: #fff; }
  .hero, .card { box-shadow: none; border: 0; }
  .recipe { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1.4fr 1fr; }
}
