/* Layout: sticky header with two tabs; recipe grid of photo cards; detail opens as a sheet with an index card (ruled lines, red margin) beside the dish picture. */
:root {
  --paper: #F4F6F1;
  --surface: #FFFFFF;
  --card: #FFFEF9;
  --ink: #1D2924;
  --muted: #5A6761;
  --line: #DCE3DC;
  --rule: #CADCEB;
  --margin: #E7A3A0;
  --accent: #2E6A4E;
  --accent-soft: #E3EEE7;
  --accent-ink: #FFFFFF;
  --saffron: #A87108;
  --saffron-soft: #FBF0D9;
  --heart: #CF3F37;
  --danger: #B3362E;
  --shade: rgba(16, 28, 22, .10);
  --scrim: rgba(12, 20, 16, .5);
  --f-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --f-body: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-hand: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111714; --surface: #18201C; --card: #1D2621; --ink: #E6ECE8; --muted: #9AA8A1;
    --line: #2B3731; --rule: #26394A; --margin: #7B3C3A; --accent: #74C49A; --accent-soft: #1F3329;
    --accent-ink: #0D1A13; --saffron: #E7B54C; --saffron-soft: #33291A; --heart: #F06A5F; --danger: #F0776D;
    --shade: rgba(0,0,0,.35); --scrim: rgba(0,0,0,.6); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.5; padding-bottom: env(safe-area-inset-bottom, 0px); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand img { flex: none; }
.brand b { font-family: var(--f-display); font-weight: 800; font-size: 19px; letter-spacing: -.01em; white-space: nowrap; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 16px; }
.tabs button[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.me { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.me .link { border: 0; background: none; padding: 4px; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 14px; }
@media (max-width: 560px) {
  .top-in { gap: 6px 10px; padding-block: 8px; }
  .brand span { display: none; }
  .brand b { font-size: 17px; }
  .brand img { width: 28px; height: 28px; }
  .tabs { order: 3; flex: 1; }
  .tabs button { padding: 7px 12px; }
  .me { order: 2; }
  .me > span:not(.av) { display: none; }
}
.av { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; flex: none; line-height: 1; }
.av.sm { width: 22px; height: 22px; font-size: 11px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 72px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 9px 15px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none; min-height: 42px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: none; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { flex: none; }
input[type=text], input[type=search], input[type=date], input[type=number], input[type=password], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; width: 100%; font-size: 16px;
}
textarea { resize: vertical; line-height: 1.5; }
label.lbl, .lbl { display: grid; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); }

/* sign-in screens */
.gate { min-height: 80vh; display: grid; place-items: center; padding-block: 24px; }
.gate-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 30px 22px; display: grid; gap: 16px; text-align: center; box-shadow: 0 12px 40px var(--shade); }
.gate-card h1 { font-size: 28px; }
.gate-card p { margin: 0; }
.gate-card input { font-size: 20px; text-align: center; padding: 12px; }
.gate-card .btn { padding: 13px 18px; font-size: 17px; }
.gate-card form { display: grid; gap: 12px; }
.err { color: var(--danger); font-size: 15px; margin: 0; }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; text-align: center; }
.who button { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); cursor: pointer; font-weight: 600; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.who button:hover { border-color: var(--accent); }
.who .av { width: 52px; height: 52px; font-size: 22px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 240px; }
.toolbar select { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip[aria-pressed="true"] .hint { color: var(--paper); }
.count { font-size: 14px; color: var(--muted); margin: 0 0 12px; font-variant-numeric: tabular-nums; }

/* recipe grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.rcard { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.rcard:hover { transform: translateY(-2px); box-shadow: 0 8px 22px var(--shade); }
.thumb { aspect-ratio: 4 / 3; max-width: 100%; background: var(--accent-soft); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rbody { padding: 11px 13px 13px; display: grid; gap: 4px; }
.rbody h3 { font-size: 18px; font-weight: 700; }
.meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tagrow { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.heart { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 999px; padding: 7px 10px; background: var(--surface); box-shadow: 0 1px 4px var(--shade); cursor: pointer; font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.heart.on { color: var(--heart); }
.heart svg, .icon16 svg { width: 18px; height: 18px; display: block; }
.icon16 { display: inline-flex; }

/* placeholder plate */
.plate { width: 100%; height: 100%; display: grid; place-items: center; background:
  radial-gradient(circle at 50% 50%, var(--surface) 0 27%, var(--line) 27.5% 29%, var(--surface) 29.5% 36%, transparent 36.5%), var(--accent-soft); }
.plate span { font-family: var(--f-hand); font-size: 38px; color: var(--accent); }

/* empty states */
.empty { border: 1.5px dashed var(--line); border-radius: 14px; padding: 36px 20px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty h2 { font-size: 22px; }
.empty p { margin: 0; color: var(--muted); max-width: 52ch; }
.empty .row { justify-content: center; }
.banner { background: var(--saffron-soft); border: 1px solid var(--saffron); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 15px; }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 50; overflow-y: auto; background: var(--paper); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-overflow-scrolling: touch; }
.sheet-inner { background: var(--paper); min-height: 100%; }
@media (min-width: 820px) {
  .sheet { background: var(--scrim); padding-block: 32px; padding-inline: 20px; }
  .sheet-inner { max-width: 1060px; margin: 0 auto; border-radius: 16px; min-height: 0; box-shadow: 0 20px 60px var(--shade); }
}
.sheet-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
@media (min-width: 820px) { .sheet-bar { border-radius: 16px 16px 0 0; } }
.sheet-bar .grow { flex: 1; }
.sheet-body { padding: 20px 16px 28px; }
@media (min-width: 820px) { .sheet-body { padding: 24px 28px 32px; } }

/* detail */
.detail-grid { display: grid; gap: 24px; }
@media (min-width: 820px) { .detail-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.media { display: grid; gap: 12px; }
@media (min-width: 820px) { .media { position: sticky; top: 72px; } }
.hero { aspect-ratio: 4 / 3; max-width: 100%; border-radius: 12px; overflow: hidden; background: var(--accent-soft); position: relative; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .busy { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; background: color-mix(in srgb, var(--paper) 80%, transparent); text-align: center; padding: 16px; }
.camera-anim { width: 44px; height: 44px; color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.92); opacity: .7; } 50% { transform: scale(1.06); opacity: 1; } }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: var(--f-body); font-weight: 700; }
.people { display: flex; flex-wrap: wrap; gap: 10px; }
.person { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

/* the index card */
.icard { background: var(--card); border-radius: 4px; box-shadow: 0 1px 2px var(--shade), 0 10px 28px var(--shade); overflow: hidden; }
.icard-head { padding: 22px 22px 14px; border-bottom: 2px solid var(--margin); }
.icard-head .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.icard-head h1 { font-family: var(--f-hand); font-weight: 700; font-size: clamp(30px, 5vw, 40px); line-height: 1.1; margin-top: 2px; }
.icard-head p { margin: 6px 0 0; color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
.facts div { display: grid; }
.facts b { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; line-height: 1; padding: 0; font-size: 18px; }
.ruled {
  --lh: 32px;
  line-height: var(--lh);
  padding: 4px 22px var(--lh) 58px;
  font-size: 17px;
  background-image:
    linear-gradient(to right, transparent 43px, var(--margin) 43px, var(--margin) 45px, transparent 45px),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px), var(--rule) var(--lh));
  background-position: 0 4px;
}
.ruled h2 { font-family: var(--f-body); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); line-height: var(--lh); margin-top: var(--lh); }
.ruled h2:first-child { margin-top: 0; }
.ruled ul, .ruled ol { margin: 0; padding: 0; list-style: none; }
.ruled li { position: relative; }
.ing .q { display: inline-block; min-width: 4.2em; font-weight: 700; font-variant-numeric: tabular-nums; }
.ing .n { color: var(--muted); }
.steps { counter-reset: s; }
.steps li { counter-increment: s; }
.steps li::before { content: counter(s); position: absolute; left: -34px; width: 22px; text-align: right; font-family: var(--f-hand); font-weight: 700; color: var(--accent); }
.steps li.hint::before { content: none; }
.hand { font-family: var(--f-hand); font-size: 18px; }
.icard-foot { padding: 0 22px 18px 58px; font-size: 14px; color: var(--muted); display: grid; gap: 6px; overflow-wrap: anywhere; }

/* editor */
.form { display: grid; gap: 16px; }
.form .two { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.ing-rows { display: grid; gap: 10px; }
.ing-row { display: grid; grid-template-columns: 72px 80px minmax(0, 1fr) 34px; gap: 6px; align-items: center; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.ing-row select { grid-column: 1 / 3; }
.ing-row .note { grid-column: 3 / 4; }
@media (min-width: 720px) {
  .ing-row { grid-template-columns: 72px 90px minmax(0, 2fr) minmax(0, 1.2fr) 160px 36px; padding-bottom: 0; border-bottom: 0; }
  .ing-row select, .ing-row .note { grid-column: auto; }
  .ing-row .x { order: 6; }
}
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 22px; padding: 4px 8px; border-radius: 6px; line-height: 1; }
.x:hover { color: var(--danger); }

/* add / scan */
.ways { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.way { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 10px; align-content: start; }
.way h3 { font-size: 19px; }
.way p { margin: 0; color: var(--muted); font-size: 15px; }
.status { font-size: 15px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.status.err { background: var(--saffron-soft); color: var(--ink); }

/* occasions */
.occ-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.occ { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; cursor: pointer; align-items: center; text-align: left; }
.occ:hover { border-color: var(--muted); }
.cal { border-radius: 8px; overflow: hidden; text-align: center; border: 1px solid var(--line); background: var(--card); }
.cal .m { background: var(--heart); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 1px 0; }
.cal .d { font-family: var(--f-display); font-weight: 800; font-size: 22px; line-height: 1.3; }
.occ h3 { font-size: 18px; }
.newocc { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.newocc input[type=text] { flex: 2 1 200px; width: auto; }
.newocc input[type=date] { flex: 1 1 150px; width: auto; }

.occ-head { display: grid; gap: 10px; margin-bottom: 20px; }
.occ-title { font-family: var(--f-display); font-weight: 800; font-size: clamp(24px, 4vw, 34px) !important; border: 1px solid transparent !important; background: none !important; padding: 2px 6px !important; margin-left: -6px; }
.occ-title:hover, .occ-title:focus { border-color: var(--line) !important; }
.occ-cols { display: grid; gap: 22px; }
@media (min-width: 900px) { .occ-cols { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.menu { display: grid; gap: 8px; }
.mitem { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.mitem .thumb { border-radius: 7px; aspect-ratio: 1; }
.mitem .plate span { font-size: 20px; }
.mitem button.link { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font-weight: 700; font-size: 16px; }
.shop { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.shop-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.aisle h4 { margin: 4px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--saffron); }
.aisle ul { list-style: none; margin: 0; padding: 0; }
.aisle li label { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); cursor: pointer; align-items: start; }
.aisle li input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--accent); }
.aisle li .what b { font-variant-numeric: tabular-nums; }
.aisle li .for { display: block; font-size: 13px; color: var(--muted); }
.aisle li.done .what { text-decoration: line-through; color: var(--muted); }
.copybox { width: 100%; min-height: 160px; font-size: 14px !important; }

/* picker */
.pick { display: grid; gap: 6px; }
.pick label { display: grid; grid-template-columns: 22px 52px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.pick input { width: 20px; height: 20px; accent-color: var(--accent); }
.pick .thumb { border-radius: 6px; aspect-ratio: 1; }
.pick .plate span { font-size: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 15px; z-index: 90; max-width: calc(100% - 32px); box-shadow: 0 6px 20px var(--shade); }
