:root {
  --paper: oklch(97.2% 0.012 80);
  --paper-2: oklch(94.5% 0.016 80);
  --paper-3: oklch(90.5% 0.02 78);
  --line: oklch(86% 0.02 75);
  --ink: oklch(26% 0.03 60);
  --ink-2: oklch(46% 0.025 60);
  --ink-3: oklch(62% 0.02 60);
  --accent: oklch(52% 0.19 27);
  --accent-ink: oklch(42% 0.17 27);
  --accent-tint: oklch(94% 0.04 27);
  --leaf: oklch(48% 0.09 150);
  --leaf-tint: oklch(94% 0.04 150);
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tabs-h: calc(60px + env(safe-area-inset-bottom));
  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
  padding-bottom: var(--tabs-h);
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; line-height: 1.12; font-variation-settings: 'opsz' 72, 'SOFT' 50; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13.5px; }
.view { max-width: 680px; margin: 0 auto; padding: 0 18px 32px; animation: rise .32s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 0 10px; min-height: 56px; }
.topbar h1 { font-size: 26px; }
.back { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px 8px 4px; margin-left: -4px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.back svg { width: 20px; height: 20px; }
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-weight: 600; transition: transform .12s var(--ease), background .2s; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: oklch(98% 0.01 27); }
.btn.primary:disabled { opacity: .55; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.danger { color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }

/* inputs */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.input, textarea.input { width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: oklch(99% 0.006 80); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px oklch(52% 0.19 27 / .12); }
textarea.input { resize: vertical; line-height: 1.5; min-height: 96px; }
textarea.mono { font-size: 15px; }
.row { display: flex; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabs-h); padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: space-around; align-items: stretch; background: oklch(97.2% 0.012 80 / .92); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-top: 1px solid var(--line); z-index: 20; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a.active { color: var(--accent); }
.tabs a.tab-add svg { width: 30px; height: 30px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; text-align: center; }
.login .mark { width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 18px; }
.login h1 { font-size: 40px; margin-bottom: 6px; }
.login form { margin-top: 26px; display: grid; gap: 10px; width: min(320px, 100%); margin-inline: auto; }
.login .input { text-align: center; font-size: 18px; letter-spacing: .08em; }

/* library */
.search { position: sticky; top: 0; z-index: 10; padding: 8px 0 10px; background: linear-gradient(var(--paper) 80%, transparent); }
.search .input { padding-left: 42px; background: var(--paper-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a6f66' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center / 18px; border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.count { font-size: 13px; color: var(--ink-3); padding: 0 0 8px; }
.rlist { list-style: none; margin: 0; padding: 0; }
.rlist li + li { border-top: 1px solid var(--line); }
.rrow { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: center; padding: 12px 0; text-decoration: none; }
.rrow:active { background: var(--paper-2); margin: 0 -18px; padding-inline: 18px; }
.thumb { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: var(--paper-3); display: grid; place-items: center; font-size: 30px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rrow .t { font-family: var(--serif); font-size: 19px; line-height: 1.2; font-weight: 500; }
.rrow .m { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.rrow .m .src { text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 700; color: var(--ink-3); }
.rrow .stub { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent-tint); padding: 2px 8px; border-radius: 6px; }
.empty { padding: 48px 12px; text-align: center; color: var(--ink-2); }
.empty h2 { margin-bottom: 8px; }

/* recipe */
.hero { margin: 0 -18px; width: calc(100% + 36px); aspect-ratio: 4/3; max-height: 360px; background: var(--paper-3); overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero.none { aspect-ratio: auto; height: 0; }
.rhead { padding: 18px 0 10px; }
.rhead .src { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); text-decoration: none; }
.rhead .src svg { width: 14px; height: 14px; }
.rhead p.desc { margin-top: 8px; color: var(--ink-2); font-size: 16px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 4px; font-size: 14px; color: var(--ink-2); }
.meta b { color: var(--ink); font-weight: 600; }
.warn { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-tint); color: var(--accent-ink); font-size: 14px; }
.warn ul { margin: 6px 0 0; padding-left: 18px; }
section.block { margin-top: 26px; }
section.block > h2 { margin-bottom: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
section.block > h2 .small { font-family: var(--sans); font-weight: 500; }
.ing { list-style: none; margin: 0; padding: 0; }
.ing .grp { font-family: var(--serif); font-size: 17px; font-weight: 600; padding: 14px 0 4px; color: var(--ink); }
.ing li.i { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ing li.i:last-child { border-bottom: 0; }
.ck { flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; border: 1.6px solid var(--ink-3); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.ck svg { width: 14px; height: 14px; stroke: var(--paper); stroke-width: 3; opacity: 0; }
li.on .ck { background: var(--accent); border-color: var(--accent); }
li.on .ck svg { opacity: 1; }
.ing .txt { flex: 1; font-size: 17px; }
.ing .txt .qty { font-weight: 600; }
.ing .txt .note { color: var(--ink-2); }
.sticky-cta { position: sticky; bottom: calc(var(--tabs-h) + 10px); z-index: 5; padding-top: 12px; }
.sticky-cta .btn { box-shadow: 0 8px 24px oklch(30% 0.05 40 / .18); }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 12px 0; font-size: 17px; line-height: 1.5; }
.steps li::before { counter-increment: step; content: counter(step); font-family: var(--serif); font-size: 26px; line-height: 1; color: var(--accent); font-weight: 500; padding-top: 2px; }
.steps li.done { color: var(--ink-3); }
.steps li.done::before { color: var(--ink-3); }
.notes { width: 100%; min-height: 64px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line); background: oklch(98.5% 0.01 80); resize: vertical; line-height: 1.5; }
.notes:focus { outline: none; border-style: solid; border-color: var(--ink-3); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--paper-2); }
.sw { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--paper-3); border: 0; transition: background .2s; flex: none; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 1px 3px oklch(0% 0 0 / .25); transition: transform .2s var(--ease); }
.sw.on { background: var(--leaf); }
.sw.on::after { transform: translateX(18px); }
.actions { display: flex; gap: 10px; margin-top: 32px; flex-wrap: wrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); text-decoration: none; }

/* add */
.addbox { display: grid; gap: 12px; }
.addbox textarea { min-height: 120px; font-size: 17px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.hint { font-size: 13.5px; color: var(--ink-3); }
.loading { text-align: center; padding: 56px 12px; }
.loading .pot { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid var(--paper-3); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { font-family: var(--serif); font-size: 20px; }
.loading .small { margin-top: 6px; }
.cover { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: var(--paper-3); display: grid; place-items: center; color: var(--ink-3); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .btn { position: absolute; right: 10px; bottom: 10px; }
.editor h2 { margin: 22px 0 10px; }
.sep { height: 1px; background: var(--line); margin: 20px 0; }

/* groceries */
.quick { display: flex; gap: 8px; position: sticky; top: 0; z-index: 10; padding: 8px 0 12px; background: linear-gradient(var(--paper) 80%, transparent); }
.quick .input { flex: 1; }
.glist { list-style: none; margin: 0; padding: 0; }
.glist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
.glist li .ck { width: 28px; height: 28px; }
.glist li .gt { flex: 1; min-width: 0; }
.glist li .gt .from { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glist li .x { border: 0; background: none; color: var(--ink-3); padding: 8px; margin-right: -8px; opacity: .7; }
.glist li .x svg { width: 18px; height: 18px; }
.glist li.done .gt { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.glist li.done .ck { background: var(--leaf); border-color: var(--leaf); }
.glist li.done .ck svg { opacity: 1; }
.cart-head { display: flex; align-items: center; justify-content: space-between; margin-top: 28px; padding-bottom: 6px; }
.cart-head h2 { font-size: 18px; color: var(--ink-2); }
.board-empty { text-align: center; padding: 60px 16px; color: var(--ink-2); }
.board-empty .big { font-family: var(--serif); font-size: 24px; color: var(--ink); margin-bottom: 6px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 14px); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; font-size: 15px; font-weight: 500; z-index: 30; box-shadow: 0 10px 30px oklch(0% 0 0 / .25); display: flex; gap: 14px; align-items: center; max-width: min(92vw, 420px); animation: rise .25s var(--ease); }
.toast a { color: oklch(85% 0.1 27); font-weight: 700; text-decoration: none; white-space: nowrap; }

@media (min-width: 720px) {
  .view { padding-inline: 24px; }
  .hero { margin: 16px 0 0; width: 100%; border-radius: var(--radius); }
  .rrow:active { margin: 0; padding-inline: 0; }
}
