/* Daily Bread — web app styles.
   Layout: an app shell. Sidebar + content on wide screens (like the iPad
   sidebar), bottom tab bar on phones. Sheets slide up for editing. */

/* Look: Green Band. Green top band with cream title, white sidebar and cards with soft shadows, green buttons, gold badges. All colors from the logo. */
:root {
  --parchment: #F3F1E9;
  --ink: #2E3A24;
  --muted: #747A6A;
  --green: #3C4F2B;
  --green-soft: #E3E9DA;
  --on-green: #FFFFFF;
  --gold: #C8892F;
  --gold-soft: #F6E8CF;
  --card: #FFFFFF;
  --line: #E3E0D4;
  --field: #EDEBE1;
  --search: #FFFFFF;
  --danger: #A8372E;
  --band: #3C4F2B;
  --on-band: #F6F3EA;
  --band-soft: rgba(246, 243, 234, 0.16);
  --card-shadow: 0 4px 14px rgba(40, 50, 30, 0.08);
  --side: #FFFFFF;
  --heading: #3C4F2B;
  --btn: #3C4F2B; --on-btn: #FFFFFF;
  --btn2: #E3E9DA; --on-btn2: #3C4F2B;
  --nav-on: #E3E9DA; --on-nav-on: #3C4F2B;
  --seg-on: #FFFFFF; --on-seg-on: #2E3A24; --seg-on-line: transparent;
  --band-line: transparent;
  --shadow: 0 10px 30px rgba(40, 50, 30, 0.16);
  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
  --radius: 12px;
  --tabbar-h: 60px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --parchment: #10140F; --ink: #ECEAE2; --muted: #9A9F92; --green: #B9CBA3; --green-soft: #26331F;
    --on-green: #10140F; --gold: #E6B852; --gold-soft: #2B2A14; --card: #1B2119; --line: #2A3326;
    --field: #141A12; --search: #0D110C; --danger: #F0938A; --shadow: 0 10px 30px rgba(0, 0, 0, 0.55); --band: #0E130D; --on-band: #F4F2E9; --band-soft: rgba(244, 242, 233, 0.12); --card-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --side: #0B0F0A; --heading: #F6F3EA; --btn: #2F4A22; --on-btn: #EEF2E6; --btn2: #2B3328; --on-btn2: #E3E6DC;
    --nav-on: #202C1B; --on-nav-on: #EEF2E6; --seg-on: #1C2A17; --on-seg-on: #B9CBA3; --seg-on-line: #3F5A33; --band-line: #222B1F; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --parchment: #10140F; --ink: #ECEAE2; --muted: #9A9F92; --green: #B9CBA3; --green-soft: #26331F;
    --on-green: #10140F; --gold: #E6B852; --gold-soft: #2B2A14; --card: #1B2119; --line: #2A3326;
    --field: #141A12; --search: #0D110C; --danger: #F0938A; --shadow: 0 10px 30px rgba(0, 0, 0, 0.55); --band: #0E130D; --on-band: #F4F2E9; --band-soft: rgba(244, 242, 233, 0.12); --card-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --side: #0B0F0A; --heading: #F6F3EA; --btn: #2F4A22; --on-btn: #EEF2E6; --btn2: #2B3328; --on-btn2: #E3E6DC;
    --nav-on: #202C1B; --on-nav-on: #EEF2E6; --seg-on: #1C2A17; --on-seg-on: #B9CBA3; --seg-on-line: #3F5A33; --band-line: #222B1F; color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0; background: var(--parchment); color: var(--ink);
  font-family: var(--font-body); font-size: 17px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}
a { color: var(--green); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 44px; height: 44px; stroke-width: 1.4; }

/* ----- Shell ----- */
.shell { display: grid; grid-template-columns: 1fr; height: 100%; }
.sidebar { display: none; }
.main { position: relative; height: 100%; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px); }
.screen-inner { max-width: 760px; margin: 0 auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); padding-block: 0 24px; }

.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--band) 90%, transparent); color: var(--on-band);
  box-shadow: 0 2px 10px rgba(20, 30, 15, 0.18); border-bottom: 1px solid var(--band-line);
}
.topbar .iconbtn, .topbar .textbtn, .topbar .backbtn { color: var(--on-band); }
.topbar .iconbtn:hover, .topbar .textbtn:hover, .topbar .backbtn:hover { background: var(--band-soft); }
.topbar .textbtn.danger { color: #F3B9B3; }
.topbar h1.band-title { font-size: 22px; color: var(--on-band); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }
.topbar-inner { max-width: 760px; margin: 0 auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); padding-block: 8px; display: flex; align-items: center; gap: 6px; min-height: 52px; }
.topbar-inner .spacer { flex: 1; }
.topbar h1 { font-size: 20px; }
.topbar .title-inline { font-size: 17px; font-family: var(--font-display); font-weight: 600; color: var(--on-band); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; text-align: center; flex: 1; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; color: var(--green); }
.iconbtn:hover { background: var(--green-soft); }
.iconbtn:disabled { opacity: 0.4; cursor: default; }
.textbtn { color: var(--green); font-weight: 600; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.textbtn:hover { background: var(--green-soft); }
.textbtn:disabled { opacity: 0.4; cursor: default; }
.textbtn.danger { color: var(--danger); }
.backbtn { display: inline-flex; align-items: center; gap: 2px; color: var(--green); font-weight: 600; padding: 6px 8px 6px 2px; border-radius: 8px; min-width: 0; }
.backbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.page-title { padding: 10px 0 6px; }
.page-title h1 { font-size: 28px; letter-spacing: -0.01em; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 var(--gutter-r) env(safe-area-inset-bottom, 0px) var(--gutter-l);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; min-width: 0; }
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--green); }
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 248px 1fr; }
  .sidebar { display: flex; flex-direction: column; gap: 4px; padding: 20px 14px 20px max(14px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); background: color-mix(in srgb, var(--side) 80%, transparent); overflow-y: auto; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
  .brand img { width: 80px; height: 80px; border-radius: 16px; }
  .brand b { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--heading); }
  .brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; }
  .brand { gap: 12px; padding: 4px 4px 16px; }
  .navitem { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink); font-weight: 600; text-align: left; width: 100%; }
  .navitem:hover { background: var(--green-soft); }
  .navitem[aria-current="page"] { background: var(--nav-on); color: var(--on-nav-on); }
  .sidebar .navsep { height: 1px; background: var(--line); margin: 8px 6px; }
  .sidebar .foot { margin-top: auto; padding: 8px 12px 0; font-size: 12px; color: var(--muted); }
  .topbar [data-action="settings"] { display: none; }
  .screen-inner.wide { max-width: 1140px; }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 22px; align-items: start; }
  .pane-detail { position: sticky; top: 12px; }
  .pane-detail .dcard { max-height: calc(100vh - 120px); overflow-y: auto; }
  .sidebar .foot a { color: var(--muted); }
  .tabbar { display: none; }
  .screen { padding-bottom: 32px; }
  .backbtn span { max-width: 240px; }
}

/* ----- Page backgrounds (Settings → Background) ----- */
/* Photos cover the viewport at any size; the body never scrolls (the screen does), so the photo stays put. Dark theme dims them. */
:root { --bg-dim: transparent; }
:root[data-theme="dark"] { --bg-dim: rgba(8, 12, 7, 0.62); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg-dim: rgba(8, 12, 7, 0.62); } }
:root[data-background="marble"] body, .bg-preview.marble { background-image: linear-gradient(var(--bg-dim), var(--bg-dim)), url("assets/backgrounds/marble-olive.webp"); background-size: cover; background-position: center; background-repeat: no-repeat; }
:root[data-background="stone-basil"] body, .bg-preview.stone-basil { background-image: linear-gradient(var(--bg-dim), var(--bg-dim)), url("assets/backgrounds/stone-basil.webp"); background-size: cover; background-position: center; background-repeat: no-repeat; }
:root[data-background="travertine-olive"] body, .bg-preview.travertine-olive { background-image: linear-gradient(var(--bg-dim), var(--bg-dim)), url("assets/backgrounds/travertine-olive.webp"); background-size: cover; background-position: center; background-repeat: no-repeat; }
:root[data-background="oak-tomatoes"] body, .bg-preview.oak-tomatoes { background-image: linear-gradient(var(--bg-dim), var(--bg-dim)), url("assets/backgrounds/oak-tomatoes.webp"); background-size: cover; background-position: center; background-repeat: no-repeat; }
:root[data-background="sunlit-marble"] body, .bg-preview.sunlit-marble { background-image: linear-gradient(var(--bg-dim), var(--bg-dim)), url("assets/backgrounds/sunlit-marble.webp"); background-size: cover; background-position: center; background-repeat: no-repeat; }
.bg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px 14px 14px; }
@media (max-width: 420px) { .bg-grid { grid-template-columns: repeat(2, 1fr); } }
.bg-tile { display: flex; flex-direction: column; gap: 6px; align-items: stretch; border-radius: 12px; padding: 4px; border: 2px solid transparent; text-align: center; color: var(--ink); }
.bg-tile:hover { background: var(--field); }
.bg-tile[aria-checked="true"] { border-color: var(--green); }
.bg-preview { display: block; height: 64px; border-radius: 9px; background-color: var(--parchment); border: 1px solid var(--line); position: relative; overflow: hidden; }
.bg-mini { position: absolute; left: 14%; right: 14%; top: 26%; height: 48%; border-radius: 6px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--card-shadow); }
.bg-name { font-size: 13px; font-weight: 600; }

/* ----- Lists & cards ----- */
.group { background: color-mix(in srgb, var(--card) 80%, transparent); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 16px; box-shadow: var(--card-shadow); }
.group-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 0 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.group-footer { padding: 6px 4px 0; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 52px; width: 100%; text-align: left; color: inherit; }
.row:first-child { border-top: 0; }
.row.link:hover { background: color-mix(in srgb, var(--green-soft) 50%, transparent); }
.row.selected, .row.selected:hover { background: var(--green-soft); }
.row .grow { flex: 1; min-width: 0; }
.row .chev { color: var(--muted); opacity: 0.7; }
.row .value { color: var(--muted); text-align: right; }
.row .label { font-weight: 600; }
.row .caption { font-size: 14px; color: var(--muted); }
.row-text { padding: 12px 14px; border-top: 1px solid var(--line); white-space: pre-wrap; }
.row-text:first-child { border-top: 0; }
.row-heading { padding: 12px 14px 2px; font-weight: 700; color: var(--muted); font-size: 15px; }
.row-heading + .row-text, .row-heading + .row { border-top: 0; }

.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--gold-soft); color: var(--gold); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.recipe-title { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.badge.mine { background: var(--green-soft); color: var(--green); }
.badge.saved { background: var(--gold-soft); color: var(--gold); }

.search { display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--search) 80%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 14px 0 14px; box-shadow: var(--card-shadow); color: var(--muted); }
.search input { flex: 1; background: none; border: 0; outline: none; min-width: 0; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search .clear { color: var(--muted); display: inline-flex; }

.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty .icon { color: var(--muted); margin-bottom: 10px; }
.empty h2 { font-size: 20px; color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 auto 14px; max-width: 32ch; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; font-weight: 600; background: var(--btn2); color: var(--on-btn2); }
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--btn); color: var(--on-btn); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.gold { background: var(--gold-soft); color: var(--gold); }

.segmented { display: flex; background: var(--field); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; padding: 6px 10px; border-radius: 7px; font-weight: 600; color: var(--muted); font-size: 15px; }
.segmented button[aria-pressed="true"] { background: var(--seg-on); color: var(--on-seg-on); box-shadow: 0 1px 3px rgba(0,0,0,0.12), inset 0 0 0 1px var(--seg-on-line); }

select.select { background: var(--field); border: 0; border-radius: 8px; padding: 6px 28px 6px 10px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236B705F' stroke-width='1.8' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; max-width: 100%; }
.field { width: 100%; background: var(--field); border: 0; border-radius: 8px; padding: 9px 12px; color: var(--ink); min-width: 0; }
.field::placeholder { color: var(--muted); }
textarea.field { resize: vertical; min-height: 44px; line-height: 1.4; }
.field.right { text-align: right; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--line); transition: background 0.2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.2s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ----- Split panes (wide screens) ----- */
.pane-label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 2px 0 8px; }
.dcard { background: color-mix(in srgb, var(--card) 80%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 20px; box-shadow: var(--card-shadow); min-width: 0; }
.dcard .group { margin: 0 0 4px; box-shadow: none; border-color: color-mix(in srgb, var(--line) 60%, transparent); background: transparent; }
.dcard .group-header { padding-top: 12px; }
.dcard-head { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 6px; }
.dcard-head .grow { flex: 1; min-width: 0; }
.dcard-head h2 { font-size: 26px; line-height: 1.15; margin-bottom: 6px; color: var(--heading); }
.dcard .hero { margin: 10px 0 12px; }
.dbtns { display: flex; gap: 10px; margin-top: 16px; }
.dbtns .btn { flex: 1; }
.dcard .completion { position: static; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 12px 0 0; }
.empty-detail { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty-detail .icon { color: var(--muted); margin-bottom: 8px; }
.empty-detail p { margin: 0; }

/* ----- Recipe detail ----- */
.hero { margin: 0 0 16px; border-radius: var(--radius); overflow: hidden; background: var(--gold-soft); aspect-ratio: 16 / 9; max-width: 100%; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-head { padding: 4px 0 14px; }
.detail-head h1 { font-size: 30px; line-height: 1.15; margin-bottom: 8px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 15px; }
.summary b { color: var(--ink); font-weight: 600; }
.ingredient { display: flex; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--line); }
.ingredient::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-top: 9px; flex: none; }
.ingredient:first-child { border-top: 0; }
.row-heading + .ingredient { border-top: 0; }
.step { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.step:first-child, .row-heading + .step { border-top: 0; }
.step .num { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 24px; text-align: right; font-weight: 600; }
.stage { padding: 10px 14px; border-top: 1px solid var(--line); }
.stage:first-child { border-top: 0; }
.stage .method { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.stage .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 15px; color: var(--ink); margin-top: 2px; }
.stage .meta span { display: inline-flex; align-items: center; gap: 5px; }
.stage .note { font-size: 14px; color: var(--muted); margin-top: 2px; }
.toolrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 15px; }
.toolrow:first-child { border-top: 0; }
.flags { display: grid; gap: 8px; margin-bottom: 16px; }
.flag { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--gold-soft); color: var(--ink); font-size: 15px; align-items: flex-start; }
.flag .icon { color: var(--gold); }
.flag.info { background: var(--green-soft); }
.flag.info .icon { color: var(--green); }

/* ----- Shopping ----- */
.check { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); width: 100%; text-align: left; color: inherit; }
.check:first-child, .row-heading + .check { border-top: 0; }
.check .icon { color: var(--muted); margin-top: 1px; }
.check.done .icon { color: var(--green); }
.check.done .text { color: var(--muted); text-decoration: line-through; }
.check .text { flex: 1; min-width: 0; }
.check .edit { color: var(--muted); opacity: 0; }
.check:hover .edit, .check:focus-within .edit { opacity: 1; }
@media (hover: none) { .check .edit { opacity: 1; } }
.ring { width: 32px; height: 32px; flex: none; }
.completion { position: sticky; bottom: 0; margin-top: 8px; padding: 10px 0 4px; background: color-mix(in srgb, var(--parchment) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.completion .note { text-align: center; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* ----- Discover ----- */
.discover-intro { padding: 4px 0 0; }
.discover-intro .lead { font-size: 15px; color: var(--muted); margin: 6px 0 16px; }
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; gap: 8px; }
.card h3 { font-size: 18px; }
.card p { margin: 0; font-size: 15px; color: var(--muted); }
.card .btn { align-self: flex-start; margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); margin: -8px 0 12px 2px; }

/* ----- Sheets, dialogs, menus ----- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 24, 14, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease; }
.sheet { background: var(--parchment); width: 100%; height: calc(100% - 28px - env(safe-area-inset-top, 0px)); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); animation: rise 0.22s ease; }
.sheet .topbar { position: static; border-radius: 16px 16px 0 0; }
@media (min-width: 720px) { .sheet .topbar { border-radius: 16px 16px 0 0; } }
.sheet .sheet-body { flex: 1; overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.sheet .screen-inner { padding-bottom: 24px; }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { width: min(680px, 100%); height: min(860px, 100%); border-radius: 16px; }
}
.dialog-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20, 24, 14, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px var(--gutter-r) 24px var(--gutter-l); animation: fade 0.15s ease; }
.dialog { background: var(--card); border-radius: 14px; width: min(360px, 100%); padding: 20px; box-shadow: var(--shadow); animation: pop 0.15s ease; }
.dialog h2 { font-family: var(--font-body); font-size: 18px; text-align: center; margin-bottom: 6px; }
.dialog p { margin: 0 0 14px; text-align: center; color: var(--muted); font-size: 15px; }
.dialog .field { margin-bottom: 12px; }
.dialog .actions { display: flex; flex-direction: column; gap: 6px; }
.dialog .actions button { padding: 10px; border-radius: 9px; font-weight: 600; color: var(--green); background: var(--green-soft); }
.dialog .actions button.primary { background: var(--green); color: var(--on-green); }
.dialog .actions button.destructive { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.dialog .actions button.cancel { background: transparent; color: var(--muted); }
.menu-backdrop { position: fixed; inset: 0; z-index: 50; }
.menu { position: fixed; z-index: 51; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 220px; max-width: min(320px, calc(100vw - 32px)); padding: 6px; animation: pop 0.12s ease; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; color: var(--ink); }
.menu button:hover { background: var(--green-soft); }
.menu button.destructive { color: var(--danger); }
.menu button:disabled { opacity: 0.45; cursor: default; }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .menu-title { padding: 6px 12px 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.menu .checkrow[aria-checked="true"]::before { content: "✓"; color: var(--green); font-weight: 700; width: 14px; }
.menu .checkrow::before { content: ""; width: 14px; }
@media (max-width: 719px) {
  .menu.sheetmenu { left: var(--gutter-l) !important; right: var(--gutter-r) !important; top: auto !important; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); max-width: none; min-width: 0; }
  .menu-backdrop.dim { background: rgba(20, 24, 14, 0.35); }
}
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px); z-index: 70; background: var(--ink); color: var(--parchment); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; box-shadow: var(--shadow); animation: fade 0.2s ease; max-width: calc(100vw - 32px); text-align: center; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ----- Editor ----- */
.editor-lines { display: flex; flex-direction: column; }
.eline { display: flex; align-items: flex-start; gap: 6px; padding: 8px 8px 8px 12px; border-top: 1px solid var(--line); }
.eline:first-child { border-top: 0; }
.eline .field { flex: 1; }
.eline.heading .field { font-weight: 700; }
.eline .handle { display: flex; flex-direction: column; }
.eline .handle button, .eline .remove { width: 30px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 6px; }
.eline .remove { height: 38px; color: var(--danger); }
.eline .handle button:hover, .eline .remove:hover { background: var(--field); }
.eline .handle button:disabled { opacity: 0.25; }
.eline-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.eline .parsed { font-size: 12px; color: var(--muted); padding-left: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.eline .parsed b { color: var(--green); font-weight: 600; }
.addrow { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.addrow button { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.addrow button:hover { background: var(--green-soft); }
.photo-pick { display: flex; align-items: center; gap: 14px; padding: 14px; }
.photo-pick .preview { width: 96px; height: 96px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.photo-pick .preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick .choices { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-edit { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.stage-edit:first-child { border-top: 0; }
.stage-edit .full { grid-column: 1 / -1; }
.stage-edit label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 3px; }
.stage-edit .inline { display: flex; gap: 6px; align-items: center; }
.stage-edit .inline .field { flex: 1; }
.stage-edit .remove-stage { grid-column: 1 / -1; justify-self: end; color: var(--danger); font-weight: 600; font-size: 14px; }
.share-text { white-space: pre-wrap; font-size: 15px; line-height: 1.5; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; max-height: 50vh; overflow: auto; }

.progress-overlay { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; background: rgba(20,24,14,0.3); }
.progress-overlay .box { background: var(--card); border-radius: 14px; padding: 20px 24px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; font-weight: 600; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; }

@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===================== Front page ===================== */
html[data-phase="landing"], html[data-phase="privacy"] { height: auto; }
html[data-phase="landing"] body, html[data-phase="privacy"] body { height: auto; overflow: auto; }
#landing { min-height: 100%; background: var(--parchment); color: var(--ink); }
.site-nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.site-nav-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); padding-block: 10px; }
.site-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; margin-right: auto; }
.site-brand img { width: 52px; height: 52px; border-radius: 12px; }
.site-brand b { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--heading); display: block; line-height: 1.05; }
.site-brand small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.site-links { display: none; gap: 26px; }
.site-links a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 8px 0; border-bottom: 2px solid transparent; }
.site-links a.on, .site-links a:hover { border-bottom-color: var(--green); color: var(--green); }
.site-nav-sep { display: none; width: 1px; height: 26px; background: var(--line); }
.site-signin { background: var(--btn); color: var(--on-btn); text-decoration: none; font-weight: 700; padding: 11px 26px; border-radius: 12px; white-space: nowrap; }
@media (min-width: 900px) { .site-links, .site-nav-sep { display: flex; } }

.front-hero { position: relative; overflow: hidden; }
.front-hero-inner { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 28px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); padding-block: 44px 40px; }
@media (min-width: 960px) { .front-hero-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 36px; padding-block: 64px 64px; align-items: center; } }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--green); margin: 0 0 14px; }
.front-hero h1 { font-size: clamp(38px, 5.2vw, 66px); line-height: 1.02; letter-spacing: -0.015em; color: var(--heading); margin-bottom: 18px; }
.front-hero .lead, .discover-copy .lead, .doc .lead { font-size: 19px; line-height: 1.5; color: var(--muted); margin: 0 0 26px; max-width: 54ch; }
.signin-row { display: grid; grid-template-columns: 1fr; gap: 12px; max-width: 580px; }
@media (min-width: 560px) { .signin-row { grid-template-columns: 1fr 1fr; } }
.provider { position: relative; height: 54px; }
.apple-host { position: absolute; inset: 0; opacity: 0.01; overflow: hidden; }
.apple-host > * { width: 100% !important; height: 100% !important; min-width: 0 !important; margin: 0 !important; }
.provider-face { position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; height: 54px; width: 100%; border-radius: 12px; font-weight: 700; font-size: 17px; border: 1px solid transparent; box-sizing: border-box; }
.provider-face svg { width: 22px; height: 22px; flex: none; }
.provider-face.apple { background: #000; color: #fff; pointer-events: none; }
.provider-face.google { background: #fff; color: #1F1F1F; border-color: #DADCE0; cursor: pointer; }
.provider-face.google:hover { background: #F7F8F8; }
.provider-face.google:disabled { opacity: 0.55; cursor: default; }
.provider[data-state="unconfigured"] .provider-face.apple, .provider[data-state="unavailable"] .provider-face.apple { opacity: 0.55; }
.provider[data-state="loading"] .provider-face.apple::after { content: ""; position: absolute; right: 14px; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.9s linear infinite; }
:root[data-theme="dark"] .provider-face.apple { background: #fff; color: #000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .provider-face.apple { background: #fff; color: #000; } }
.signin-notes { display: grid; grid-template-columns: 1fr; gap: 4px 12px; max-width: 580px; margin-top: 10px; }
@media (min-width: 560px) { .signin-notes { grid-template-columns: 1fr 1fr; } }
.signin-notes p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.signin-status { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.signin-status[data-kind="error"] { color: var(--danger); }
.or { display: flex; align-items: center; gap: 14px; max-width: 580px; margin: 20px 0 18px; color: var(--muted); font-weight: 600; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.browse-btn { display: inline-flex; align-items: center; gap: 10px; background: var(--btn); color: var(--on-btn); text-decoration: none; font-weight: 700; font-size: 18px; padding: 15px 30px; border-radius: 12px; }
.browse-btn:hover { filter: brightness(1.06); }
.fineprint { font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.fineprint a { color: var(--green); }

.front-hero-art { position: relative; min-height: 420px; }
@media (min-width: 960px) { .front-hero-art { min-height: 560px; } }
.art-photo { position: absolute; inset: 0; border-radius: 22px; background: url("assets/backgrounds/stone-basil.webp") center / cover no-repeat; }
.mock-list, .mock-detail { position: absolute; background: var(--card); color: var(--ink); border-radius: 16px; box-shadow: 0 24px 60px rgba(30, 40, 20, 0.22); font-size: 12px; }
.mock-list { left: 4%; top: 22%; width: 44%; padding: 14px 14px 8px; transform: rotate(-4deg); }
.mock-list-head { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 10px; }
.mock-list-head img, .mock-detail-head img { width: 22px; height: 22px; border-radius: 6px; }
.mock-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.mock-row b { display: block; font-size: 13px; }
.mock-row small { color: var(--muted); font-size: 11px; }
.mock-thumb, .mock-photo { background: linear-gradient(135deg, #E8C27A, #C8892F 55%, #9A6420); border-radius: 8px; }
.mock-thumb { width: 42px; height: 42px; flex: none; }
.mock-detail { right: 3%; top: 8%; width: 58%; padding: 16px 18px 18px; transform: rotate(2deg); }
.mock-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mock-rule { flex: 1; height: 1px; background: var(--line); }
.mock-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mock-title b { font-family: var(--font-display); font-size: 20px; color: var(--heading); }
.mock-icons i { display: inline-block; width: 18px; height: 18px; border: 1.6px solid var(--muted); border-radius: 50%; margin-left: 6px; }
.mock-photo { height: 150px; border-radius: 12px; margin-bottom: 12px; }
.mock-stats { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.mock-stats span { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mock-stats small { color: var(--muted); font-size: 10px; }
.mock-stats b { font-size: 13px; }
.mock-ings b { display: block; font-size: 13px; margin-bottom: 6px; }
.mock-ings p { margin: 0 0 5px 14px; position: relative; font-size: 11.5px; }
.mock-ings p::before { content: ""; position: absolute; left: -12px; top: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
@media (max-width: 599px) { .mock-list { display: none; } .mock-detail { width: 86%; left: 7%; right: auto; } }

.features { background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.features-inner { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 22px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); padding-block: 34px; }
@media (min-width: 640px) { .features-inner { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .features-inner { grid-template-columns: repeat(4, 1fr); gap: 28px; } .feature + .feature { border-left: 1px solid var(--line); padding-left: 28px; } }
.feature { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.feature-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); display: grid; place-items: center; flex: none; }
.feature-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.feature h3 { font-family: var(--font-body); font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.feature p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 15px; }

.discover-band { display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .discover-band { grid-template-columns: 1fr 1fr; } }
.discover-photo { min-height: 300px; background: url("assets/backgrounds/oak-tomatoes.webp") left center / cover no-repeat; }
.discover-copy { padding: 48px max(20px, env(safe-area-inset-right, 0px)) 56px max(20px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; justify-content: center; max-width: 620px; }
.discover-copy h2 { font-size: clamp(30px, 3.6vw, 44px); line-height: 1.08; color: var(--heading); margin-bottom: 16px; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 18px max(20px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); background: var(--card); }
.site-footer a { color: var(--muted); }

/* Privacy and other documents */
.doc { background: var(--parchment); min-height: 100%; }
.doc-inner { max-width: 720px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); padding-block: 32px 64px; }
.doc-back { color: var(--green); text-decoration: none; font-weight: 600; }
.doc h1 { font-size: 40px; margin: 18px 0 12px; color: var(--heading); }
.doc h2 { font-size: 22px; margin: 28px 0 8px; color: var(--heading); }
.doc p, .doc li { line-height: 1.55; }
.doc ul { padding-left: 20px; }

/* Demo strip at the top of the app */
.demo-bar { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 8px var(--gutter-r) 8px var(--gutter-l); background: var(--gold-soft); color: var(--ink); font-size: 14px; font-weight: 600; }
.demo-bar button { background: var(--btn); color: var(--on-btn); font-weight: 700; padding: 6px 14px; border-radius: 8px; }
