/* Leggero — beach & ocean pastels. Deep-sea ink on sea-foam paper, sky-blue
   selections, and a sun-yellow highlighter that marks everything you leave out. */
:root {
  --paper: #eef6fb;      /* sea foam */
  --sheet: #fbfdfe;      /* surf */
  --sand: #f8f0df;       /* dry sand */
  --ink: #1f3b57;        /* deep sea */
  --ink-soft: #5b7189;
  --rule: #d5e4ee;
  --sky: #a9d4ef;        /* pastel ocean blue */
  --sky-soft: #dcefFa;
  --lagoon: #6fcfc4;     /* turquoise lagoon */
  --lagoon-soft: #e1f6f3;
  --lagoon-deep: #23867c;
  --sun: #ffd86b;        /* pastel sun */
  --sun-soft: #fff1c4;
  --good: #23867c;       /* lagoon */
  --mid: #c98f1f;
  --poor: #d0604f;       /* coral */
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { 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.5 var(--sans);
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
}
main { max-width: 680px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px 0; outline: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 1.85rem; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0.4em 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--sun); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
.preview-banner { background: var(--sun-soft); border-bottom: 1px solid var(--sun); font-size: 0.82rem; padding: 6px 14px; text-align: center; }

.head { margin: 6px 0 16px; }
.head h1::after { /* a small turquoise wave under each page title */
  content: ""; display: block; width: 54px; height: 8px; margin-top: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 8'%3E%3Cpath d='M1 4c4.5-4 8.5-4 13 0s8.5 4 13 0 8.5-4 13 0 8.5 4 13 0' fill='none' stroke='%236fcfc4' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat;
}
.head.row h1::after { display: none; }
.head p { color: var(--ink-soft); margin-top: 4px; }

/* inputs */
.search { position: relative; margin-bottom: 14px; display: block; }
.search input, .field input, .field select, .field textarea, textarea.plain, input.plain, select.plain {
  width: 100%; border: 1.5px solid var(--rule); background: var(--sheet); border-radius: 12px;
  padding: 12px 14px; font-size: 1rem;
}
.search input { padding-left: 42px; font-size: 1.06rem; }
.search svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; stroke: var(--ink-soft); fill: none; stroke-width: 2; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 0.875rem; color: var(--ink-soft); margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--sheet);
  border-radius: 999px; padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.quiet { border-color: var(--rule); background: var(--sheet); color: var(--ink); font-weight: 500; }
.btn.sea { background: var(--sky); border-color: var(--sky); color: var(--ink); }
.btn.danger { background: transparent; color: var(--poor); border-color: var(--poor); }
.btn.small { padding: 6px 12px; font-size: 0.875rem; }
.btn[disabled] { opacity: 0.5; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

/* segmented tabs */
.segs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px 10px; padding: 0 18px; }
.segs::-webkit-scrollbar { display: none; }
.segs button {
  flex: none; border: 1.5px solid var(--rule); background: var(--sheet); border-radius: 999px;
  padding: 7px 14px; font-size: 0.92rem; cursor: pointer; white-space: nowrap;
}
.segs button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.segs.light button[aria-selected="true"] { background: var(--sky-soft); border-color: var(--sky); color: var(--ink); }
.segs.lang { margin: 6px 0 10px; padding: 0; }

/* score ring */
.score { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 3px solid currentColor; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 1.35rem; line-height: 1; background: var(--sheet); }
.score.s-good { color: var(--good); } .score.s-mid { color: var(--mid); } .score.s-poor { color: var(--poor); }
.score.sm { width: 38px; height: 38px; font-size: 1rem; border-width: 2.5px; }

/* food results */
.food { background: var(--sheet); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; border: 1px solid var(--rule); }
.food-top { display: flex; gap: 14px; align-items: center; }
.food-top > div:first-child { flex: 1; min-width: 0; }
.food h3 { font-size: 1.12rem; }
.vals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 12px 0 6px; }
.vals b { display: block; font-family: var(--serif); font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.vals span { font-size: 0.78rem; color: var(--ink-soft); }
.vals .hot b { color: var(--poor); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1.5px solid var(--rule); background: var(--sheet); border-radius: 999px; padding: 5px 11px; font-size: 0.86rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--sky-soft); border-color: var(--sky); font-weight: 600; }
.chip.ok[aria-pressed="true"] { background: var(--lagoon-soft); border-color: var(--lagoon); color: var(--lagoon-deep); }
.chip.avoid[aria-pressed="true"] { background: #fbe0da; border-color: var(--poor); color: #8f3326; }
.chip .x { margin-left: 4px; opacity: 0.6; }

/* recipe list */
.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list li + li { border-top: 1px solid var(--rule); }
.recipe-row { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; width: 100%; text-align: left; background: none; border: 0; cursor: pointer; }
.thumb { width: 76px; height: 76px; border-radius: 14px; object-fit: cover; display: block; background: linear-gradient(160deg, var(--sky-soft) 0 55%, var(--sand) 55%); }
.recipe-row h3 { font-size: 1.04rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.orig { font-size: 0.82rem; color: var(--ink-soft); font-style: italic; }
.meta { font-size: 0.84rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 0 10px; margin-top: 2px; }
.flag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 6px; margin-top: 4px; }
.flag.ok { background: var(--lagoon-soft); color: var(--lagoon-deep); }
.flag.mod { background: var(--sun-soft); color: #7a5a00; }
.flag.hid { background: #fbe0da; color: #8f3326; }

/* the highlighter */
mark {
  background: linear-gradient(transparent 38%, var(--sun) 38%, var(--sun) 88%, transparent 88%);
  color: inherit; padding: 0 2px; border-radius: 2px;
}
.ing { list-style: none; padding: 0; margin: 8px 0 0; }
.ing li { padding: 8px 0; border-bottom: 1px dashed var(--rule); display: flex; flex-wrap: wrap; gap: 0 10px; }
.ing li > span:not(.q) { flex: 1; min-width: 0; }
.ing li.tap { cursor: pointer; }
.ing li.tap .t { text-decoration: underline dotted var(--lagoon); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.ing li.omit.tap .t { text-decoration: line-through; text-decoration-color: var(--poor); }
.ing li.tap:focus-visible { outline-offset: 0; }
.info { flex-basis: 100%; margin-top: 8px; background: var(--lagoon-soft); border-left: 3px solid var(--lagoon); border-radius: 0 12px 12px 0; padding: 10px 12px; font-size: 0.9rem; cursor: default; }
.info .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.info .vals { margin: 8px 0 4px; }
.info .vals b { font-size: 1rem; }
.info .portion { border-top: 1px solid rgb(35 134 124 / 0.2); padding-top: 6px; margin-top: 6px; }
.ing .q { flex: none; min-width: 52px; font-family: var(--serif); font-weight: 600; font-variant-numeric: tabular-nums; }
.ing li.omit .t { text-decoration: line-through; text-decoration-color: var(--poor); text-decoration-thickness: 2px; color: var(--ink-soft); }
.ing .note { display: block; font-size: 0.86rem; color: var(--ink-soft); margin-top: 2px; }
.ing li.omit .note::before, .ing li.swap .note::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--sun); margin-right: 6px; }

.changes { background: var(--sun-soft); border-radius: 14px; padding: 12px 14px; margin: 14px 0; }
.changes.ok { background: var(--lagoon-soft); }
.changes.hid { background: #fbe0da; }
.changes ul { margin: 6px 0 0; padding-left: 20px; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.totals div { background: var(--lagoon-soft); border-radius: 10px; padding: 8px 10px; }
.totals b { display: block; font-family: var(--serif); font-size: 1.1rem; }
.totals span { font-size: 0.76rem; color: var(--ink-soft); }

/* reading view */
.reader h1 { font-size: 2rem; margin: 10px 0 2px; }
.reader .hero { width: calc(100% + 36px); margin: 0 -18px 8px; aspect-ratio: 16/10; object-fit: cover; display: block; }
.reader section { margin: 22px 0; }
.reader h2 { border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-bottom: 4px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; font-family: var(--serif); font-size: 1.12rem; line-height: 1.65; }
.steps li { counter-increment: s; position: relative; padding: 12px 0 12px 44px; border-bottom: 1px solid var(--rule); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 12px; width: 30px; height: 30px; border-radius: 50%; background: var(--sky); color: var(--ink); font: 700 0.9rem/30px var(--sans); text-align: center; }
.steps .section { font-family: var(--sans); font-weight: 700; padding: 16px 0 2px; border: 0; counter-increment: none; }
.steps .section::before { display: none; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--rule); border-radius: 999px; background: var(--sheet); }
.stepper button { width: 38px; height: 38px; border: 0; background: none; font-size: 1.2rem; cursor: pointer; }
.stepper output { min-width: 86px; text-align: center; font-weight: 600; }
.back { display: inline-flex; gap: 4px; align-items: center; text-decoration: none; color: var(--ink-soft); font-weight: 500; }

/* shopping list */
.add-item { display: flex; gap: 8px; margin-bottom: 16px; }
.add-item input { flex: 1; }
.shop { list-style: none; margin: 0; padding: 0; }
.shop li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.check { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--lagoon); background: var(--sheet); cursor: pointer; display: grid; place-items: center; margin-top: 1px; }
.check svg { width: 16px; height: 16px; stroke: var(--ink); stroke-width: 3; fill: none; opacity: 0; }
.shop li.done .check { background: var(--lagoon); }
.shop li.done .check svg { opacity: 1; }
.shop li.done .item { text-decoration: line-through; color: var(--ink-soft); }
.shop .item { font-size: 1.05rem; }
.shop .sub { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 0.8rem; color: var(--ink-soft); }
.shop .sub .warn { background: var(--sun-soft); border-radius: 4px; padding: 0 5px; color: #7a5a00; }
.shop .del { margin-left: auto; border: 0; background: none; color: var(--ink-soft); font-size: 1.2rem; cursor: pointer; padding: 0 4px; }
.shop.pick li .check { border-color: var(--rule); }
.shop.pick li.picked .check { background: var(--lagoon); border-color: var(--lagoon); }
.shop.pick li.picked .check svg { opacity: 1; }
.shop.pick li:not(.picked) .item { color: var(--ink-soft); }
.shop .sub .home { background: var(--lagoon-soft); color: var(--lagoon-deep); border-radius: 4px; padding: 0 5px; }
.shop-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 4px; }

/* rules page */
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 16px; padding: 14px 16px; margin: 0 0 14px; }
.panel h2 { font-size: 1.15rem; margin-bottom: 4px; }
.presets { display: grid; gap: 8px; margin-top: 10px; }
.preset { display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--rule); border-radius: 14px; padding: 12px 14px; cursor: pointer; background: var(--sheet); text-align: left; width: 100%; }
.preset[aria-checked="true"] { border-color: var(--sky); background: var(--sky-soft); }
.preset .dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink-soft); margin-top: 2px; }
.preset[aria-checked="true"] .dot { border: 6px solid var(--ink); }
.preset b { display: block; }
.group-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--rule); }
details.more { margin: 0 0 14px; }
details.more > summary { cursor: pointer; list-style: none; font-weight: 600; padding: 14px 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 16px; }
details.more[open] > summary { margin-bottom: 14px; }
details.more > summary::after { content: "Show"; float: right; font-weight: 400; color: var(--ink-soft); }
details.more[open] > summary::after { content: "Hide"; }
details.words > summary { cursor: pointer; color: var(--ink-soft); font-size: 0.9rem; }
.group { border-top: 1px solid var(--rule); padding-top: 12px; margin-top: 12px; }
.add { display: flex; gap: 8px; margin-top: 8px; }
.add input { flex: 1; border: 1.5px solid var(--rule); border-radius: 10px; padding: 8px 10px; background: var(--paper); }
.toggle { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--ink); }
.savebar { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); display: flex; justify-content: center; padding: 8px 0; }
.savebar .btn { box-shadow: 0 6px 20px rgb(31 59 87 / 0.25); }
.notice { border-left: 4px solid var(--sun); background: var(--sheet); padding: 12px 14px; border-radius: 0 12px 12px 0; margin: 10px 0 16px; }
.empty { text-align: center; padding: 40px 10px; color: var(--ink-soft); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* bottom tabs */
.tabbar {
  position: fixed; inset: auto 0 0 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--sheet); border-top: 1px solid var(--rule); z-index: 5;
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-soft); font-size: 0.7rem; position: relative; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabbar a[aria-current="page"] svg { stroke-width: 2.3; }
.tabbar a[aria-current="page"] span { background: linear-gradient(transparent 55%, var(--sun) 55%); padding: 0 3px; }
.tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--lagoon); color: var(--ink); font-size: 0.68rem; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }

/* bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(31 59 87 / 0.35); }
.sheet-panel {
  position: absolute; inset: auto 0 0 0; max-height: 92vh; overflow-y: auto; background: var(--sheet);
  border-radius: 22px 22px 0 0; padding: 22px 18px calc(24px + var(--safe-b)); max-width: 680px; margin: 0 auto;
  animation: up 0.22s ease-out;
}
.sheet-close { position: absolute; right: 12px; top: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--paper); font-size: 1.4rem; cursor: pointer; }
@keyframes up { from { transform: translateY(30px); opacity: 0.4; } }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); translate: -50% 0; background: var(--ink); color: var(--sheet); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sheet-panel { animation: none; } #toast { transition: none; } }
@media (min-width: 720px) { .sheet-panel { border-radius: 22px; bottom: 5vh; } }
