:root {
  --bg: #F8F5EF; --ink: #17150F; --muted: #7A7468; --rule: #E6E0D4; --chip: #D9D2C4; --soft: #EFEAE0; --tint: #E7E1D4;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151412; --ink: #EDE7DA; --muted: #9A9388; --rule: #2B2925; --chip: #3A3731; --soft: #1E1C19; --tint: #26241F; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { background: transparent; border: 0; outline: none; }
input::placeholder, textarea::placeholder { color: var(--muted); }
a { color: inherit; }
img { max-width: 100%; display: block; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.hide { display: none !important; }

#app { min-height: 100vh; }
.page { max-width: 600px; margin: 0 auto; padding: calc(var(--sat) + 20px) 24px calc(var(--sab) + 96px); }
.page.bare { padding-bottom: calc(var(--sab) + 24px); }

/* logo: the dot of the i is a plate */
.logo { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 40px; line-height: 1; letter-spacing: -0.015em; display: inline-flex; align-items: baseline; }
.logo .i { position: relative; display: inline-block; }
.logo .i::after { content: ""; position: absolute; left: 0.2em; top: -0.1em; width: 0.24em; height: 0.24em; border: 0.05em solid currentColor; border-radius: 50%; }
.logo.small { font-size: 26px; }
.wordmark-sub { font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }

/* header */
.top { display: flex; justify-content: space-between; align-items: center; min-height: 48px; margin-bottom: 18px; }
.iconbtn { width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex-shrink: 0; }
.iconbtn.ring { border: 1px solid var(--ink); }
.iconbtn.fill { background: var(--ink); color: var(--bg); }
.iconbtn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* search + chips */
.search { display: flex; align-items: center; gap: 10px; height: 46px; border-bottom: 1px solid var(--ink); margin-bottom: 14px; }
.search svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 1.5; flex-shrink: 0; }
.search input { flex: 1; font-family: var(--serif); font-style: italic; font-size: 19px; min-width: 0; }
.search input:not(:placeholder-shown) { font-style: normal; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -24px 6px; padding: 2px 24px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 40px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--chip); font-size: 13px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); flex-shrink: 0; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { color: inherit; opacity: 0.6; }

/* sections */
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.eyebrow.first { margin-top: 8px; }
.rule { border: 0; border-top: 1px solid var(--rule); margin: 22px 0; }

/* library cards */
.cards { display: flex; flex-direction: column; gap: 30px; }
.card { display: block; text-decoration: none; color: inherit; }
.card .img { aspect-ratio: 3 / 2; width: 100%; border-radius: 2px; overflow: hidden; background: var(--tint); position: relative; }
.card .img img { width: 100%; height: 100%; object-fit: cover; }
.ph { background: var(--tint); background-image: radial-gradient(120% 90% at 30% 20%, rgba(255,255,255,0.35), rgba(0,0,0,0.12)); }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: 26px; line-height: 1.15; letter-spacing: -0.01em; margin: 12px 0 4px; text-wrap: balance; }
.meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.meta .src { font-family: var(--serif); font-style: italic; font-size: 15px; }
.badge { position: absolute; top: 12px; left: 12px; background: var(--bg); color: var(--ink); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 7px 11px; border-radius: 999px; }
.capturing { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.capturing .thumb { width: 64px; height: 64px; border-radius: 2px; background: var(--tint); flex-shrink: 0; position: relative; overflow: hidden; }
.capturing .thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent); animation: shimmer 1.6s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.capturing .what { flex: 1; min-width: 0; }
.capturing .what .t { font-family: var(--serif); font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capturing .what .s { font-size: 13px; color: var(--muted); }
.capturing .what .e { font-size: 13px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.textbtn { font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 10px 0; }
.empty { font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--muted); padding: 40px 0; text-align: center; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--rule); padding: 8px 8px calc(var(--sab) + 8px); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 600px; margin: 0 auto; z-index: 5; }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; height: 46px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabs a.on { color: var(--ink); font-weight: 600; }
.tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* recipe */
.hero { position: relative; margin: calc(-1 * (var(--sat) + 20px)) -24px 0; aspect-ratio: 4 / 3; background: var(--tint); overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero .over { position: absolute; top: calc(var(--sat) + 12px); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; }
.hero .iconbtn { background: var(--bg); }
.pill { height: 44px; padding: 0 16px; border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.pill svg { width: 14px; height: 14px; fill: currentColor; }
.nohero .over { position: static; margin: 0 -8px 8px; }
h1.title { font-family: var(--serif); font-weight: 500; font-size: 40px; line-height: 1.05; letter-spacing: -0.015em; margin: 22px 0 8px; text-wrap: balance; }
.source { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); }
.source a { color: inherit; }
.facts { display: flex; gap: 22px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 12px 0; margin: 20px 0; }
.facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-shrink: 0; }
.facts div:last-child { flex-shrink: 1; }
.facts .k { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.facts .v { font-size: 15px; font-weight: 500; white-space: nowrap; }
.facts div:last-child .v { white-space: normal; }
.review { background: var(--soft); padding: 16px 18px; margin: 0 0 22px; }
.review .h { font-family: var(--serif); font-style: italic; font-size: 19px; margin-bottom: 8px; }
.review ul { margin: 0 0 12px; padding-left: 18px; font-size: 14px; }
.review li { margin-bottom: 4px; }
.review .row { display: flex; gap: 8px; }
.btn { height: 48px; padding: 0 20px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn.sm { height: 40px; padding: 0 16px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.4; }
.servings { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 18px; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper .n { font-family: var(--serif); font-size: 22px; min-width: 96px; text-align: center; }
.stepper .n b { font-weight: 500; }
.toggle { display: flex; border: 1px solid var(--chip); border-radius: 999px; overflow: hidden; height: 44px; }
.toggle button { padding: 0 14px; font-size: 12px; font-weight: 600; color: var(--muted); }
.toggle button.on { background: var(--ink); color: var(--bg); }
.ing { display: grid; grid-template-columns: 82px minmax(0, 1fr) 24px; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--rule); width: 100%; text-align: left; }
.ing .q { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 500; }
.ing .t { font-family: var(--serif); font-size: 19px; line-height: 1.3; }
.ing .t .p { color: var(--muted); }
.ing .box { width: 20px; height: 20px; border: 1px solid var(--ink); border-radius: 999px; align-self: center; position: relative; }
.ing.done .t, .ing.done .q { color: var(--muted); text-decoration: line-through; }
.ing.done .box { background: var(--ink); }
.ing.flag .t::after { content: "?"; font-family: var(--sans); font-size: 11px; font-weight: 700; margin-left: 8px; background: var(--soft); padding: 2px 7px; border-radius: 999px; vertical-align: middle; }
.group { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); padding: 16px 0 4px; }
.steps { display: flex; flex-direction: column; gap: 22px; }
.step { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
.step .n { font-family: var(--serif); font-style: italic; font-size: 30px; line-height: 1; color: var(--muted); }
.step .x { font-family: var(--serif); font-size: 19px; line-height: 1.4; }
.step .m { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.notes { width: 100%; font-family: var(--serif); font-size: 18px; line-height: 1.45; min-height: 60px; resize: none; padding: 0; }
.qa { display: flex; flex-direction: column; gap: 16px; }
.qa .q { font-family: var(--serif); font-style: italic; font-size: 18px; }
.qa .a { font-family: var(--serif); font-size: 18px; line-height: 1.45; margin-top: 4px; }
.ask { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--ink); height: 48px; margin-top: 10px; }
.ask input { flex: 1; font-family: var(--serif); font-size: 18px; min-width: 0; }
.cooks { display: flex; flex-direction: column; gap: 14px; }
.cook { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; }
.cook .ph, .cook img { width: 56px; height: 56px; border-radius: 2px; object-fit: cover; }
.cook .d { font-size: 13px; color: var(--muted); }
.cook .t { font-family: var(--serif); font-size: 18px; line-height: 1.4; }
.stars { letter-spacing: 2px; font-size: 13px; }
.footer { font-size: 13px; color: var(--muted); line-height: 1.6; padding-bottom: 20px; }
.footer a { color: var(--ink); }
.dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 24px calc(var(--sab) + 16px); background: linear-gradient(180deg, transparent, var(--bg) 40%); display: flex; gap: 10px; max-width: 600px; margin: 0 auto; z-index: 5; }
.dock .btn { flex: 1; height: 56px; font-size: 16px; }
.dock .iconbtn { width: 56px; height: 56px; border: 1px solid var(--ink); }
.danger { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 12px 0; }

/* edit */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.field input, .field textarea { border-bottom: 1px solid var(--rule); padding: 8px 0; font-size: 17px; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; font-family: var(--serif); font-size: 18px; }
.field input.big { font-family: var(--serif); font-size: 28px; }
.field .hint { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

/* capture */
.capture .tabsrow { display: flex; gap: 8px; margin-bottom: 20px; }
.bigin { width: 100%; font-family: var(--serif); font-size: 22px; border-bottom: 1px solid var(--ink); padding: 10px 0; }
.bigta { width: 100%; font-family: var(--serif); font-size: 18px; min-height: 180px; border-bottom: 1px solid var(--ink); padding: 10px 0; resize: vertical; line-height: 1.45; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 2px; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* cook mode */
.cookpage { min-height: 100vh; display: flex; flex-direction: column; padding: calc(var(--sat) + 12px) 24px calc(var(--sab) + 20px); max-width: 600px; margin: 0 auto; }
.cookpage .head { display: flex; justify-content: space-between; align-items: center; height: 44px; }
.cookpage .head .t { font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { display: grid; gap: 5px; margin-top: 10px; }
.progress i { height: 2px; background: var(--chip); display: block; }
.progress i.on { background: var(--ink); }
.timers { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; min-height: 40px; }
.timer { height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--ink); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.timer i { width: 8px; height: 8px; border-radius: 999px; background: var(--ink); }
.timer.done { background: var(--ink); color: var(--bg); animation: pulse 1s infinite; }
.timer.done i { background: var(--bg); }
@keyframes pulse { 50% { opacity: 0.55; } }
.timer .rem { color: var(--muted); }
.timer.done .rem { color: inherit; }
.cookbody { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 26px; padding: 20px 0; }
.cookbody .k { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.cookbody .big { font-family: var(--serif); font-size: clamp(24px, 7.5vw, 32px); line-height: 1.25; letter-spacing: -0.01em; text-wrap: pretty; }
.cookbody .for { border-left: 1px solid var(--ink); padding-left: 16px; display: flex; flex-direction: column; gap: 8px; }
.cookbody .for div { font-family: var(--serif); font-size: 19px; }
.cookbody .for b { font-family: var(--sans); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; margin-right: 6px; }
.startbtn { height: 56px; padding: 0 20px 0 16px; border-radius: 999px; border: 1px solid var(--ink); font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; gap: 12px; align-self: flex-start; font-variant-numeric: tabular-nums; }
.startbtn svg { width: 20px; height: 20px; fill: currentColor; }
.cooknav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px; }
.cooknav .btn { height: 60px; font-size: 16px; }
.mise { display: flex; flex-direction: column; }
.mise .task { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--rule); text-align: left; width: 100%; }
.mise .task .box { width: 22px; height: 22px; border: 1px solid var(--ink); border-radius: 999px; margin-top: 2px; }
.mise .task.done .box { background: var(--ink); }
.mise .task .x { font-family: var(--serif); font-size: 19px; line-height: 1.35; }
.mise .task.done .x { color: var(--muted); text-decoration: line-through; }
.rate { display: flex; gap: 10px; }
.rate button { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--ink); font-family: var(--serif); font-size: 18px; }
.rate button.on { background: var(--ink); color: var(--bg); }
.preview { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; }

/* groceries */
.gitem { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--rule); width: 100%; text-align: left; }
.gitem .box { width: 22px; height: 22px; border: 1px solid var(--ink); border-radius: 999px; margin-top: 3px; }
.gitem.done .box { background: var(--ink); }
.gitem .x { font-family: var(--serif); font-size: 19px; line-height: 1.35; }
.gitem.done .x { color: var(--muted); text-decoration: line-through; }
.gitem .from { font-size: 12px; color: var(--muted); }
.picker .pk { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); width: 100%; text-align: left; }
.picker .pk .box { width: 22px; height: 22px; border: 1px solid var(--ink); border-radius: 4px; }
.picker .pk.on .box { background: var(--ink); }
.picker .pk .t { font-family: var(--serif); font-size: 19px; }

/* log */
.logday { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); margin: 24px 0 8px; }
.logitem { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; padding: 10px 0; text-decoration: none; color: inherit; }
.logitem img, .logitem .ph { width: 72px; height: 72px; border-radius: 2px; object-fit: cover; }
.logitem .t { font-family: var(--serif); font-size: 21px; line-height: 1.2; }
.logitem .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.logitem .n { font-family: var(--serif); font-style: italic; font-size: 16px; margin-top: 4px; }

/* private */
.private { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.private p { font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--muted); margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 100px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 20; white-space: nowrap; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 15; display: flex; align-items: flex-end; }
.sheet .in { background: var(--bg); width: 100%; max-width: 600px; margin: 0 auto; padding: 24px 24px calc(var(--sab) + 24px); border-radius: 12px 12px 0 0; max-height: 85vh; overflow-y: auto; }
@media (prefers-reduced-motion: reduce) { .capturing .thumb::after, .timer.done { animation: none; } }
@media (min-width: 640px) { .tabs, .dock { left: 50%; transform: translateX(-50%); width: 600px; } }
