/* Little Bowls of Happy — mobile-first styles. Colours match the printed book. */
:root {
  --paper: #FFFAF2;
  --card: #FFFFFF;
  --soft: #FFF6EC;
  --ink: #4E3B31;
  --ink2: #8A7566;
  --line: #EFE3D3;
  --pink: #E8828F;
  --bg: #FCEFC7; --accent: #F2C14E; --deep: #8A6A1F;
  --radius: 22px;
  --title: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", ui-rounded, "Nunito", "Varela Round", system-ui, sans-serif;
  --body: "Avenir Next", Avenir, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, .t { font-family: var(--title); font-weight: 400; margin: 0; letter-spacing: 0.01em; }
button { font: inherit; color: inherit; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.loading { text-align: center; padding: 30vh 20px; color: var(--ink2); font-family: var(--title); }
.loading img { margin: 0 auto 8px; }

/* ---------- header ---------- */
.top { padding: calc(14px + var(--safe-top)) 0 6px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 46px; height: 46px; }
.brand h1 { font-size: 22px; line-height: 1.15; }
.brand h1 span { color: var(--pink); }
.brand p { margin: 1px 0 0; font-size: 13px; color: var(--ink2); font-style: italic; }

/* ---------- category menu ---------- */
.cats {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: calc(8px + var(--safe-top)) 0 10px; margin-top: 4px;
}
.cats .wrap { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 9px; border-radius: 18px; text-decoration: none;
  background: var(--soft); border: 2px solid transparent;
  transition: transform .15s ease, background .15s ease;
}
.cat img { width: 46px; height: 38px; object-fit: contain; }
.cat b { font: 400 14px/1.1 var(--title); }
.cat small { font-size: 10.5px; color: var(--ink2); font-style: italic; line-height: 1.1; }
.cat[aria-current="page"] { background: var(--cbg); border-color: var(--caccent); }
.cat[aria-current="page"] small { color: var(--cdeep); }
.cat:active { transform: scale(.96); }

/* ---------- section intro ---------- */
.lead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 12px; }
.lead h2 { font-size: 26px; }
.lead p { margin: 0; font-size: 14px; color: var(--ink2); }
.count { font: 400 13px var(--title); color: var(--deep); background: var(--bg); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }

/* ---------- preview cards ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
.card {
  display: flex; flex-direction: column; height: 100%;
  background: var(--card); border-radius: var(--radius); overflow: hidden; text-decoration: none;
  box-shadow: 0 1px 0 var(--line), 0 6px 18px -12px rgba(78, 59, 49, .35);
  transition: transform .15s ease;
}
.card:active { transform: scale(.98); }
.card-art { background: var(--bg); aspect-ratio: 1 / .82; display: grid; place-items: center; padding: 10px 12px 6px; position: relative; }
.card-art img { width: 100%; height: 100%; object-fit: contain; }
.card-art .num { position: absolute; top: 8px; left: 10px; font: 400 11px var(--title); color: var(--deep); background: rgba(255,255,255,.75); border-radius: 99px; padding: 2px 8px; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card-body h3 { font-size: 15.5px; line-height: 1.25; }
.card-body .indo { margin: 0; font-size: 12px; font-style: italic; color: var(--deep); }
.card-body .meta { margin: auto 0 0; padding-top: 6px; font-size: 12px; color: var(--ink2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chilis { display: inline-flex; gap: 1px; vertical-align: middle; }
.chilis img { width: 14px; height: 14px; }

/* ---------- tips strip ---------- */
.tips { margin: 26px 0 8px; }
.tips h2 { font-size: 19px; margin-bottom: 10px; }
.tiprow { display: grid; gap: 10px; }
@media (min-width: 620px) { .tiprow { grid-template-columns: repeat(3, 1fr); } }
.tip { background: var(--soft); border-radius: 18px; padding: 12px 14px; }
.tip b { display: block; font: 400 15px var(--title); color: var(--deep); margin-bottom: 2px; }
.tip p { margin: 0; font-size: 14px; }

.foot { margin: 28px 0 0; padding: 18px 0 calc(28px + var(--safe-bottom)); display: grid; gap: 10px; }
.foot a { display: flex; align-items: center; gap: 12px; text-decoration: none; background: var(--card); border-radius: 18px; padding: 10px 14px; box-shadow: 0 1px 0 var(--line); }
.foot a img { width: 38px; height: 38px; object-fit: contain; }
.foot a b { font: 400 15px var(--title); display: block; }
.foot a span { font-size: 13px; color: var(--ink2); }
.small { font-size: 12.5px; color: var(--ink2); text-align: center; margin: 6px 0 0; }

/* ---------- recipe page ---------- */
.bar { position: sticky; top: 0; z-index: 5; padding: calc(8px + var(--safe-top)) 0 8px; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.bar .wrap { display: flex; align-items: center; gap: 10px; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font: 400 15px var(--title); color: var(--deep); background: rgba(255,255,255,.8); border-radius: 99px; padding: 7px 14px 7px 10px; }
.back svg { width: 18px; height: 18px; }
.bar .crumb { margin-left: auto; font: 400 13px var(--title); color: var(--deep); }
.hero { background: var(--bg); padding: 0 0 34px; position: relative; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 26px; background: var(--paper); border-radius: 26px 26px 0 0; }
.hero-art { max-width: 380px; margin: 0 auto; padding: 4px 24px 0; aspect-ratio: 1 / .78; display: grid; place-items: center; }
.hero-art img { width: 100%; height: 100%; object-fit: contain; }
.head { margin-top: -6px; position: relative; }
.head h1 { font-size: 30px; line-height: 1.15; }
.head .indo { margin: 4px 0 0; font-style: italic; color: var(--deep); font-size: 16px; }
.head .blurb { margin: 10px 0 0; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; box-shadow: 0 1px 0 var(--line); }
.chip img, .chip svg { width: 18px; height: 18px; flex: none; }
.chip svg { color: var(--deep); }
.chip.soft { background: var(--soft); font-weight: 500; }
.spice { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 13.5px; color: var(--ink2); }
.spice .chilis img { width: 20px; height: 20px; }

.box { background: var(--card); border-radius: var(--radius); padding: 16px 16px 18px; margin: 18px 0 0; box-shadow: 0 1px 0 var(--line), 0 8px 22px -16px rgba(78, 59, 49, .4); }
.box h2 { font-size: 21px; display: flex; align-items: center; gap: 10px; }
.box h2 .tab { font-size: 12px; font-family: var(--body); font-weight: 600; color: var(--deep); background: var(--bg); padding: 3px 10px; border-radius: 99px; }
.box h3 { font-size: 16px; color: var(--deep); margin: 16px 0 4px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.box h3 small { font: italic 12px var(--body); color: var(--ink2); }
.per { margin: 4px 0 0; font-size: 13px; color: var(--ink2); font-style: italic; }

.checks { list-style: none; margin: 8px 0 0; padding: 0; }
.checks li + li { border-top: 1px dashed var(--line); }
.checks label { display: flex; align-items: flex-start; gap: 12px; padding: 10px 2px; cursor: pointer; }
.checks input { appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border-radius: 50%; border: 2px solid var(--accent); background: var(--card); display: grid; place-items: center; transition: background .12s ease; }
.checks input::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: translateY(-1px) rotate(-45deg); opacity: 0; }
.checks input:checked { background: var(--accent); }
.checks input:checked::after { opacity: 1; }
.checks input:focus-visible { outline: 3px solid var(--bg); outline-offset: 2px; }
.checks .it { flex: 1; min-width: 0; }
.checks .it span { display: block; font-weight: 500; }
.checks .it small { display: block; font-size: 13px; color: var(--ink2); }
.checks input:not(:checked) + .it span { color: var(--ink2); }

.actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 16px 0 0; }
.btn { appearance: none; border: 0; border-radius: 16px; padding: 13px 16px; font-weight: 600; font-size: 15.5px; background: var(--soft); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--deep); color: #fff; }
.btn:active { transform: scale(.98); }
.btn svg { width: 19px; height: 19px; flex: none; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--ink2); }
.hint a { color: var(--deep); }

.steps { list-style: none; margin: 10px 0 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; }
.steps button { all: unset; box-sizing: border-box; width: 100%; display: flex; gap: 12px; padding: 10px 2px; cursor: pointer; font-size: 16px; line-height: 1.5; }
.steps button::before { content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--bg); color: var(--deep); font: 400 15px/28px var(--title); text-align: center; margin-top: 1px; }
.steps li.done button { color: var(--ink2); text-decoration: line-through; text-decoration-color: var(--accent); }
.steps li.done button::before { content: "✓"; background: var(--accent); color: #fff; }
.steps button:focus-visible { outline: 3px solid var(--bg); border-radius: 12px; }
.method { margin: 10px 0 0; font-size: 16px; }

.tipcards { display: grid; gap: 10px; margin: 18px 0 0; }
@media (min-width: 620px) { .tipcards { grid-template-columns: repeat(3, 1fr); } }
.tc { display: flex; gap: 12px; align-items: flex-start; border-radius: 18px; padding: 12px 14px; }
.tc img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.tc b { display: block; font: 400 15px var(--title); }
.tc p { margin: 2px 0 0; font-size: 14.5px; }
.tc.light { background: #FFF6DA; } .tc.solo { background: #EEF6EA; } .tc.him { background: #FDEBE7; }

.wake { margin: 16px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--soft); border-radius: 16px; padding: 10px 14px; font-size: 14px; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch:checked { background: var(--deep); }
.switch:checked::after { transform: translateX(18px); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0 0; padding-bottom: calc(26px + var(--safe-bottom)); }
.pager a { text-decoration: none; background: var(--card); border-radius: 16px; padding: 10px 12px; box-shadow: 0 1px 0 var(--line); font-size: 13px; color: var(--ink2); }
.pager a b { display: block; font: 400 14.5px/1.25 var(--title); color: var(--ink); margin-top: 2px; }
.pager a.next { text-align: right; }

/* ---------- notes & setup pages ---------- */
.page h1 { font-size: 28px; margin: 6px 0 4px; }
.page .sub { margin: 0; color: var(--ink2); font-style: italic; }
.mgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.m { background: var(--soft); border-radius: 18px; padding: 10px; display: flex; gap: 10px; align-items: center; }
.m img { width: 44px; height: 44px; object-fit: contain; flex: none; }
.m b { display: block; font: 400 15px var(--title); }
.m span { font-size: 12.5px; color: var(--ink2); line-height: 1.35; display: block; }
.plate { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; }
.plate img { width: 120px; }
.plate dl { margin: 0; font-size: 14px; }
.plate dt { font-weight: 700; }
.plate dd { margin: 0 0 6px; color: var(--ink2); }
.swaps { list-style: none; margin: 10px 0 0; padding: 0; }
.swaps li { display: grid; grid-template-columns: 1fr 18px 1.4fr; gap: 8px; align-items: center; padding: 9px 0; font-size: 14px; }
.swaps li + li { border-top: 1px dashed var(--line); }
.swaps b { font-weight: 600; }
.swaps i { font-style: normal; color: var(--pink); text-align: center; }
.pantry h3 { margin-top: 12px; }
.pantry p { margin: 2px 0 0; font-size: 14px; }
.steps-setup { margin: 10px 0 0; padding-left: 22px; }
.steps-setup li { margin: 0 0 10px; }
.field { display: grid; gap: 6px; margin: 12px 0 0; font-size: 14px; color: var(--ink2); }
.field input { font: inherit; font-size: 16px; color: var(--ink); padding: 11px 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; }
.field input:focus { outline: none; border-color: var(--accent); }
code { font-size: 13px; background: var(--soft); padding: 1px 5px; border-radius: 6px; word-break: break-all; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translate(-50%, calc(100% + 40px)); opacity: 0; visibility: hidden; pointer-events: none; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 14.5px; font-weight: 600; transition: transform .25s ease; z-index: 20; max-width: calc(100% - 32px); text-align: center; }
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#toast { transition: transform .25s ease, opacity .25s ease, visibility .25s; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
