/* Pantry · "Lagoon kitchen"
   Layout: one column up to 760px; greeting hero, magazine recipe cards, immersive recipe pages,
   floating pill tab bar. Lagoon teal does the work, papaya is the single bright pop, turmeric for warmth.
   Fonts are bundled (Bitter for display, DM Sans for text) so the app looks the same offline. */

@font-face { font-family: "Bitter"; src: url("/fonts/bitter.woff") format("woff"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Bitter"; src: url("/fonts/bitter-italic.woff") format("woff"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/dm-sans.woff") format("woff"); font-weight: 100 1000; font-style: normal; font-display: swap; }
/* Thaana: the phone's own Dhivehi font is used first; this small bundled one (GNU FreeFont) is the fallback. */
@font-face { font-family: "Pantry Thaana"; src: url("/fonts/thaana.woff") format("woff"); unicode-range: U+0780-07BF, U+060C, U+061B, U+061F; font-display: swap; size-adjust: 128%; }

:root {
  --ground: #e9efed;
  --surface: #f6f8f7;
  --card: #ffffff;
  --ink: #11221e;
  --muted: #586964;
  --faint: #8d9c97;
  --line: #e1e8e5;
  --chip: #ebf1ef;
  --accent: #0e6e64;          /* lagoon */
  --accent-ink: #ffffff;
  --accent-soft: #daefea;
  --papaya: #ff7a45;
  --papaya-ink: #ffffff;
  --papaya-soft: #ffe8dd;
  --saffron: #f2b229;         /* turmeric */
  --tomato: #d4432b;          /* chilli */
  --glass: rgba(255, 255, 255, 0.72);
  --glass-line: rgba(17, 34, 30, 0.08);
  --scrim: rgba(9, 24, 20, 0.45);
  --shadow-sm: 0 1px 2px rgba(17, 34, 30, 0.06), 0 4px 14px -6px rgba(17, 34, 30, 0.14);
  --shadow-lg: 0 18px 40px -18px rgba(9, 40, 34, 0.45);

  --thaana: "Noto Sans Thaana", "MV Faseyha", "Faruma", "MV Boli", "Pantry Thaana";
  --display: "Bitter", var(--thaana), Georgia, "Times New Roman", serif;
  --body: "DM Sans", var(--thaana), -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;

  --radius: 20px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #070d0c; --surface: #0c1513; --card: #14201d; --ink: #e9f1ee; --muted: #9db0aa; --faint: #6f817b;
    --line: #22312d; --chip: #1b2926; --accent: #4fc2b1; --accent-ink: #062320; --accent-soft: #15372f;
    --papaya: #ff8e5e; --papaya-ink: #2a0f04; --papaya-soft: #3a2017; --saffron: #f6c451; --tomato: #ef6b52;
    --glass: rgba(20, 32, 29, 0.72); --glass-line: rgba(255, 255, 255, 0.08); --scrim: rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px -8px rgba(0,0,0,.6); --shadow-lg: 0 18px 40px -16px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #070d0c; --surface: #0c1513; --card: #14201d; --ink: #e9f1ee; --muted: #9db0aa; --faint: #6f817b;
  --line: #22312d; --chip: #1b2926; --accent: #4fc2b1; --accent-ink: #062320; --accent-soft: #15372f;
  --papaya: #ff8e5e; --papaya-ink: #2a0f04; --papaya-soft: #3a2017; --saffron: #f6c451; --tomato: #ef6b52;
  --glass: rgba(20, 32, 29, 0.72); --glass-line: rgba(255, 255, 255, 0.08); --scrim: rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px -8px rgba(0,0,0,.6); --shadow-lg: 0 18px 40px -16px rgba(0,0,0,.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 800px) { body { background: var(--ground); } }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--surface);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 40px);
  overflow-x: clip;
}
@media (min-width: 800px) { .app { box-shadow: 0 0 0 1px var(--line); } }
.gutter {
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(170%) blur(16px);
  backdrop-filter: saturate(170%) blur(16px);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-row { display: flex; align-items: center; gap: 6px; min-height: 56px; }
.topbar-row .spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -0.01em; text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 9px; box-shadow: var(--shadow-sm); }
.page-title { font-family: var(--display); font-weight: 800; font-size: 34px; letter-spacing: -0.02em; line-height: 1.08; margin: 4px 0 14px; text-wrap: balance; }
.page-title em { font-style: italic; font-weight: 600; color: var(--accent); }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 14px; color: var(--ink); transition: background .15s; }
.icon-btn:hover { background: var(--chip); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 23px; height: 23px; }
.icon-btn.solid { background: var(--papaya); color: var(--papaya-ink); box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--papaya) 80%, transparent); border-radius: 50%; }
.icon-btn.solid:hover { filter: brightness(1.04); background: var(--papaya); }
.icon-btn[aria-pressed="true"] { color: var(--papaya); }
.text-btn { color: var(--accent); font-weight: 650; padding: 8px 4px; display: inline-flex; align-items: center; gap: 3px; }
.text-btn svg { width: 20px; height: 20px; }
.text-btn:disabled { opacity: .45; cursor: default; }

/* ── Home hero ── */
.hello { padding-top: 6px; }
.hello .eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.hello h1 { font-family: var(--display); font-weight: 800; font-size: clamp(32px, 9vw, 42px); line-height: 1.04; letter-spacing: -0.025em; margin: 6px 0 18px; text-wrap: balance; }
.hello h1 em { font-style: italic; font-weight: 600; color: var(--accent); }

.today {
  position: relative; overflow: hidden; border-radius: 24px; padding: 18px;
  color: #f4fffc; background: linear-gradient(135deg, #0f7a6e 0%, #0b5c53 60%, #0a4f48 100%);
  box-shadow: var(--shadow-lg); isolation: isolate;
}
.today::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background:
    radial-gradient(circle at 110% -10%, rgba(255, 186, 120, .55) 0 22%, transparent 23%),
    repeating-radial-gradient(circle at 120% 120%, rgba(255,255,255,.10) 0 2px, transparent 2px 18px);
}
.today .label { font-size: 12.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; opacity: .85; display: flex; align-items: center; gap: 8px; }
.today .label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--saffron); box-shadow: 0 0 0 4px rgba(242,178,41,.25); }
.today h2 { font-family: var(--display); font-size: 22px; font-weight: 700; margin: 6px 0 12px; line-height: 1.2; }
.today .meals { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px; padding: 0 18px 2px; }
.today .meals::-webkit-scrollbar { display: none; }
.today .meal {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; max-width: 260px;
  background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18); border-radius: 16px; padding: 7px 14px 7px 7px;
  text-decoration: none; color: inherit; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.today .meal .mini { width: 42px; height: 42px; border-radius: 11px; overflow: hidden; flex-shrink: 0; }
.today .meal b { font-weight: 650; font-size: 14.5px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.today .meal small { display: block; opacity: .75; font-size: 12.5px; }
.today .cta { display: inline-flex; align-items: center; gap: 8px; background: #fff; color: #0b5c53; font-weight: 700; border-radius: 999px; padding: 10px 16px; font-size: 15px; }
.today .cta svg { width: 18px; height: 18px; }

.banner {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 12px 12px 14px;
  background: var(--papaya-soft); border-radius: 18px;
}
.banner .art { width: 40px; height: 40px; border-radius: 12px; overflow: hidden; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.banner .grow { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; }
.banner strong { display: block; font-size: 15px; }
.banner .go { font-weight: 700; color: var(--papaya); padding: 8px; }
.banner .x { color: var(--muted); }

/* ── Search and chips ── */
.search {
  display: flex; align-items: center; gap: 10px; margin-top: 18px;
  background: var(--card); border-radius: 16px; padding: 0 14px; height: 48px; box-shadow: 0 0 0 1px var(--line);
}
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.search svg { width: 19px; height: 19px; color: var(--faint); flex-shrink: 0; }
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; height: 100%; font-size: 16px; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 2px; scrollbar-width: none; margin: 0 calc(-1 * max(18px, env(safe-area-inset-left, 0px))); padding-inline: max(18px, env(safe-area-inset-left, 0px)) 18px; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; border-radius: 999px; padding: 8px 15px; background: var(--card); box-shadow: 0 0 0 1px var(--line); font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); box-shadow: none; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { font-family: var(--display); font-weight: 750; font-size: 21px; margin: 0; }
.section-title span { color: var(--faint); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ── Recipe tiles (photo or generated pattern) ── */
.tile { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--c1); }
.tile::before { content: ""; position: absolute; inset: 0; }
.tile .letter {
  position: absolute; right: -4%; bottom: -16%; font-family: var(--display); font-style: italic; font-weight: 800;
  font-size: 150%; line-height: 1; color: var(--c2); opacity: .9; user-select: none;
}
.pat-dots::before { background-image: radial-gradient(var(--c2) 22%, transparent 24%); background-size: 22px 22px; opacity: .55; }
.pat-stripes::before { background-image: repeating-linear-gradient(-45deg, var(--c2) 0 7px, transparent 7px 20px); opacity: .45; }
.pat-waves::before { background-image: radial-gradient(circle at 50% 100%, transparent 9px, var(--c2) 10px 12px, transparent 13px); background-size: 28px 16px; opacity: .55; }
.pat-rings::before { background-image: repeating-radial-gradient(circle at 15% 20%, var(--c2) 0 3px, transparent 3px 16px); opacity: .45; }
.pat-grid::before { background-image: linear-gradient(var(--c2) 2px, transparent 2px), linear-gradient(90deg, var(--c2) 2px, transparent 2px); background-size: 20px 20px; opacity: .35; }
.photo { width: 100%; height: 100%; object-fit: cover; }

/* ── Recipe grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.rcard {
  position: relative; display: block; aspect-ratio: 4 / 5; max-width: 100%; border-radius: var(--radius); overflow: hidden;
  text-decoration: none; color: #fff; box-shadow: var(--shadow-sm); isolation: isolate;
  transition: transform .18s ease, box-shadow .18s ease;
}
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.rcard:active { transform: scale(.98); }
.rcard .media { position: absolute; inset: 0; z-index: -2; }
.rcard .media .letter { font-size: 128px; }
.rcard::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,0) 38%, rgba(5,18,15,.78) 100%); }
.rcard .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 13px 13px; display: grid; gap: 6px; }
.rcard b { font-family: var(--display); font-weight: 700; font-size: 17px; line-height: 1.18; text-shadow: 0 1px 8px rgba(0,0,0,.35); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.rcard .pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.2); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.pill svg { width: 13px; height: 13px; }
.rcard .fav { position: absolute; top: 10px; inset-inline-end: 10px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.9); color: var(--papaya); }
.rcard .fav svg { width: 17px; height: 17px; }
.badge { position: absolute; top: 10px; inset-inline-start: 10px; font-size: 11.5px; font-weight: 800; background: var(--saffron); color: #2b1d00; border-radius: 8px; padding: 3px 8px; letter-spacing: .01em; }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; display: grid; gap: 10px; justify-items: center; }
.empty .art { width: 132px; height: 96px; position: relative; margin-bottom: 6px; }
.empty .art span { position: absolute; width: 64px; height: 80px; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.empty .art span:nth-child(1) { left: 6px; top: 10px; transform: rotate(-10deg); }
.empty .art span:nth-child(2) { left: 34px; top: 0; z-index: 2; }
.empty .art span:nth-child(3) { left: 62px; top: 10px; transform: rotate(10deg); }
.empty .art .letter { font-size: 64px; }
.empty h2 { margin: 0; font-family: var(--display); font-size: 22px; color: var(--ink); }
.empty p { margin: 0; max-width: 32ch; }
.empty > svg { width: 44px; height: 44px; color: var(--faint); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 16px; font-weight: 700;
  background: var(--chip); color: var(--ink); transition: transform .12s, filter .12s;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--accent) 90%, transparent); }
.btn.warm { background: var(--papaya-soft); color: color-mix(in srgb, var(--papaya) 75%, var(--ink)); }
.btn.danger { color: var(--tomato); background: color-mix(in srgb, var(--tomato) 9%, var(--card)); }
.btn.wide { width: 100%; }
.btn:active { transform: scale(.98); filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Recipe page ── */
.hero-wrap { position: relative; }
.hero { aspect-ratio: 5 / 4; max-height: 58vh; width: 100%; max-width: 100%; overflow: hidden; }
.hero .letter { font-size: 300px; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.28) 0%, rgba(0,0,0,0) 30%); pointer-events: none; }
.float-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px));
}
.float-bar .spacer { flex: 1; }
.glass-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); color: var(--ink); box-shadow: 0 0 0 1px var(--glass-line), var(--shadow-sm);
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
}
.glass-btn svg { width: 21px; height: 21px; }
.glass-btn[aria-pressed="true"] { color: var(--papaya); }
.sheetface { position: relative; margin-top: -28px; background: var(--surface); border-radius: 28px 28px 0 0; padding-top: 22px; }
.detail-title { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 7.5vw, 36px); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 8px; text-wrap: balance; overflow-wrap: anywhere; }
.summary { color: var(--muted); margin: 0 0 12px; font-size: 16.5px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.fact { display: inline-flex; align-items: center; gap: 6px; background: var(--card); box-shadow: 0 0 0 1px var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; max-width: 100%; }
.fact svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.fact span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.fact { text-decoration: none; }
.fact.review { background: color-mix(in srgb, var(--saffron) 25%, var(--card)); box-shadow: none; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); padding: 16px 18px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 10px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 750; flex: 1; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--card); box-shadow: 0 0 0 1px var(--line); border-radius: 999px; padding: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; }
.stepper button:active { transform: scale(.9); }
.stepper button svg { width: 17px; height: 17px; }
.stepper output { min-width: 92px; text-align: center; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ing { list-style: none; margin: 0; padding: 4px 18px; }
.ing li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.ing li:last-child { border-bottom: 0; }
.ing .q { min-width: 78px; font-weight: 750; color: var(--accent); font-variant-numeric: tabular-nums; }
.ing .n { min-width: 0; overflow-wrap: anywhere; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps button { display: flex; gap: 14px; text-align: start; width: 100%; padding: 14px 16px; align-items: flex-start; background: var(--card); border-radius: 18px; box-shadow: 0 0 0 1px var(--line); transition: background .2s, opacity .2s; }
.steps .num { font-family: var(--display); font-style: italic; font-weight: 800; font-size: 26px; line-height: 1; color: var(--papaya); min-width: 26px; padding-top: 1px; }
.steps .t { overflow-wrap: anywhere; font-size: 16.5px; }
.steps .done button { background: var(--chip); box-shadow: none; }
.steps .done .num { color: var(--accent); }
.steps .done .t { color: var(--faint); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--faint) 60%, transparent); }
.hint { font-size: 13.5px; color: var(--faint); margin: 8px 2px 0; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.toggle-row .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--saffron) 22%, var(--card)); color: color-mix(in srgb, var(--saffron) 60%, var(--ink)); flex-shrink: 0; }
.toggle-row .ic svg { width: 22px; height: 22px; }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Lists (plan, groceries, pickers) ── */
.group-label { font-size: 12.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 2px 8px; display: flex; align-items: center; gap: 8px; }
.group-label .today-pill, .today-pill { letter-spacing: .02em; text-transform: none; background: var(--papaya); color: var(--papaya-ink); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 750; }
.aisle-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--ac) 18%, var(--card)); color: var(--ac); }
.aisle-ic svg { width: 16px; height: 16px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 650; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .mini { width: 48px; height: 48px; border-radius: 13px; overflow: hidden; flex-shrink: 0; display: block; }
.mini .letter { font-size: 48px; }
.row.add { color: var(--accent); font-weight: 700; }
.row.add svg { width: 20px; height: 20px; }
button.row { width: 100%; text-align: start; }
button.row:hover { background: color-mix(in srgb, var(--chip) 60%, transparent); }
.serv { display: inline-flex; align-items: center; gap: 2px; background: var(--chip); border-radius: 999px; padding: 2px; }
.serv button { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.serv button svg { width: 15px; height: 15px; }
.serv span { font-size: 13px; font-weight: 700; min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.x { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); flex-shrink: 0; }
.x:hover { background: var(--chip); }
.x svg { width: 18px; height: 18px; }

.weekbar { display: flex; align-items: center; gap: 6px; }
.weekbar .label { flex: 1; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.weekbar .label small { display: block; font-weight: 500; }
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.wday {
  display: grid; justify-items: center; gap: 2px; padding: 9px 0 8px; border-radius: 16px; background: var(--card);
  box-shadow: 0 0 0 1px var(--line); text-decoration: none; min-width: 0;
}
.wday small { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wday b { font-family: var(--display); font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
.wday .dots { display: flex; gap: 3px; height: 6px; }
.wday .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.wday.is-today { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.wday.is-today small { color: inherit; opacity: .85; }
.wday.is-today .dots i { background: var(--saffron); }
.day-card.is-today .list { box-shadow: 0 0 0 2px var(--accent); }

.add-bar { display: flex; gap: 8px; }
.add-bar input { flex: 1; min-width: 0; height: 50px; border-radius: 16px; border: 0; box-shadow: 0 0 0 1px var(--line); background: var(--card); padding: 0 16px; font-size: 16px; outline: none; }
.add-bar input:focus { box-shadow: 0 0 0 2px var(--accent); }
.add-bar .icon-btn { width: 50px; height: 50px; }

.progress { margin-top: 14px; display: grid; gap: 7px; }
.progress .track { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.progress .fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--saffron))); transition: width .35s ease; }
.progress .txt { font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; }
.progress .txt b { color: var(--ink); }

.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--faint) 70%, transparent); display: grid; place-items: center; flex-shrink: 0; color: transparent; transition: background .15s, border-color .15s; }
.check svg { width: 15px; height: 15px; stroke-width: 3; }
.checked .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); animation: pop .25s ease-out; }
.checked .title { color: var(--faint); text-decoration: line-through; }
.gitem { cursor: pointer; }
.gitem:hover { background: color-mix(in srgb, var(--chip) 50%, transparent); }
.gitem .qty { color: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: end; max-width: 40%; overflow-wrap: anywhere; }

/* ── Forms ── */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field input[type="text"], .field input[type="url"], .field input[type="number"], .field input[type="date"], .field textarea, .field select {
  width: 100%; border: 0; box-shadow: 0 0 0 1px var(--line); background: var(--card); border-radius: 14px;
  padding: 12px 14px; font-size: 16px; outline: none;
}
.field textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { box-shadow: 0 0 0 2px var(--accent); }
.field .help { font-size: 13px; color: var(--faint); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two > * { min-width: 0; }
.photo-pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.photo-pick .preview { width: 92px; height: 70px; border-radius: 14px; overflow: hidden; background: var(--chip); flex-shrink: 0; }
.photo-pick .preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-pick label.btn, .photo-pick .btn { min-height: 42px; font-size: 15px; }
.photo-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.notice { border-radius: 18px; padding: 14px 16px; background: var(--accent-soft); display: grid; gap: 4px; font-size: 15px; }
.notice.warn { background: color-mix(in srgb, var(--tomato) 13%, var(--card)); }
.notice strong { font-weight: 750; }
.preview-card { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.preview-card img { width: 100%; max-height: 220px; object-fit: cover; }
.preview-card .body { padding: 14px 16px; display: grid; gap: 6px; }
.preview-card strong { font-family: var(--display); font-size: 18px; }
.preview-card p { margin: 0; color: var(--muted); font-size: 14px; white-space: pre-wrap; max-height: 9em; overflow: hidden; }

/* ── Sheets ── */
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; max-height: 94dvh;
  border-radius: 28px 28px 0 0; display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: var(--shadow-lg);
}
.sheet::before { content: ""; width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 8px auto 0; flex-shrink: 0; }
@media (min-width: 700px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { border-radius: 28px; max-height: 88dvh; }
  .sheet::before { display: none; }
}
.sheet-head {
  display: flex; align-items: center; gap: 8px; min-height: 54px;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
}
.sheet-head h2 { flex: 1; margin: 0; text-align: center; font-family: var(--display); font-size: 18px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .text-btn { min-width: 66px; }
.sheet-head .text-btn.end { justify-content: flex-end; font-weight: 800; }
.sheet-body { overflow-y: auto; padding-block: 8px 26px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Welcome */
.welcome { display: grid; gap: 18px; text-align: center; justify-items: center; padding-top: 4px; }
.welcome .stack-art { position: relative; width: 220px; height: 150px; }
.welcome .stack-art span { position: absolute; width: 104px; height: 130px; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-lg); }
.welcome .stack-art span:nth-child(1) { left: 0; top: 14px; transform: rotate(-9deg); }
.welcome .stack-art span:nth-child(2) { left: 58px; top: 0; z-index: 2; }
.welcome .stack-art span:nth-child(3) { left: 116px; top: 14px; transform: rotate(9deg); }
.welcome .stack-art .letter { font-size: 110px; }
.welcome h2 { font-family: var(--display); font-size: 30px; line-height: 1.1; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
.welcome h2 em { color: var(--accent); }
.welcome ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; text-align: start; width: 100%; max-width: 400px; }
.welcome li { display: flex; gap: 12px; align-items: flex-start; }
.welcome li .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.welcome li .ic.warm { background: var(--papaya-soft); color: var(--papaya); }
.welcome li .ic svg { width: 20px; height: 20px; }
.welcome li b { display: block; }
.welcome li span { color: var(--muted); font-size: 14.5px; }

/* ── Tab bar ── */
.tabbar {
  position: fixed; left: 0; right: 0; z-index: 10; pointer-events: none;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
}
.tabbar nav {
  pointer-events: auto; max-width: 420px; margin: 0 auto; height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px;
  background: var(--glass); border-radius: 26px; box-shadow: 0 0 0 1px var(--glass-line), var(--shadow-lg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-decoration: none; border-radius: 20px; transition: background .2s, color .2s; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.tab:active { transform: scale(.96); }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; z-index: 30; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 22px);
  background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: 999px;
  font-size: 14.5px; font-weight: 650; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); text-align: center;
}
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.loading { display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); padding: 28px; }

.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.install-steps { margin: 0; padding-inline-start: 1.3em; display: grid; gap: 6px; }
.kbd { display: inline-flex; vertical-align: -4px; width: 20px; height: 20px; color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: no-preference) {
  .scrim { animation: dim .22s ease-out; }
  .sheet { animation: rise .28s cubic-bezier(.2,.8,.2,1); }
  .toast { animation: toast-in .25s cubic-bezier(.2,.8,.2,1); }
  .hello h1, .today, .grid .rcard { animation: settle .45s cubic-bezier(.2,.8,.2,1) both; }
  .today { animation-delay: .05s; }
  .grid .rcard:nth-child(2) { animation-delay: .04s; }
  .grid .rcard:nth-child(3) { animation-delay: .08s; }
  .grid .rcard:nth-child(4) { animation-delay: .12s; }
  @keyframes dim { from { background-color: transparent; } }
  @keyframes rise { from { transform: translateY(48px); } }
  @keyframes toast-in { from { transform: translate(-50%, 14px); opacity: 0; } }
  @keyframes settle { from { transform: translateY(10px); opacity: .4; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.day-card { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 72px); }

/* Settings: how-to sections */
.howto { display: grid; gap: 8px; }
.howto details { background: var(--card); border-radius: 16px; box-shadow: 0 0 0 1px var(--line); padding: 0 14px; }
.howto summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; min-height: 50px; font-weight: 700; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
.howto details[open] summary::after { transform: rotate(225deg) translateY(-1px); }
.howto details > .stack { padding-bottom: 14px; }
.howto .add-bar input { height: 44px; font-size: 14px; }
.howto .add-bar .btn { min-height: 44px; }


/* ── Home: compact "today" when nothing is planned ── */
.today.compact { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; padding-inline: 16px 12px; border-radius: 20px; }
.today.compact .grow { flex: 1; min-width: 0; font-weight: 650; font-size: 15.5px; line-height: 1.3; }
.today.compact .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--saffron); box-shadow: 0 0 0 4px rgba(242,178,41,.25); flex-shrink: 0; }
.today.compact .cta { padding: 8px 14px; font-size: 14.5px; flex-shrink: 0; }

/* ── Recipe page: short header without a photo, add-photo button ── */
.hero.short { aspect-ratio: auto; height: 190px; }
.hero.short .letter { font-size: 210px; bottom: -30%; }
.photo-btn {
  position: absolute; z-index: 3; bottom: 40px; inset-inline-end: max(14px, env(safe-area-inset-right, 0px));
  width: auto; height: 38px; border-radius: 999px; padding: 0 14px; gap: 7px; display: inline-flex; align-items: center;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.photo-btn svg { width: 18px; height: 18px; }
.btn.cook-btn { background: var(--papaya); color: var(--papaya-ink); margin-bottom: 10px; min-height: 54px; font-size: 17px; box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--papaya) 85%, transparent); }
.btn.cook-btn svg { width: 22px; height: 22px; }
.caption-card { display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: start; margin: 4px 0 16px; padding: 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--saffron) 16%, var(--card)); }
.caption-card .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); color: color-mix(in srgb, var(--saffron) 55%, var(--ink)); }
.caption-card .ic svg { width: 22px; height: 22px; }
.caption-card p { margin: 2px 0 0; font-size: 14.5px; color: var(--muted); }
.caption-card .btn { grid-column: 1 / -1; min-height: 46px; }

/* ── Plan: empty days fold into one row ── */
.days { display: grid; gap: 0; }
.day-card.folded { margin-top: 8px; }
.day-card.folded + .day-card:not(.folded) .group-label { margin-top: 18px; }
.day-empty {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px;
  background: var(--card); border-radius: 16px; box-shadow: 0 0 0 1px var(--line); text-align: start;
}
.day-empty:hover { background: color-mix(in srgb, var(--chip) 60%, var(--card)); }
.day-empty .dname { font-weight: 700; }
.day-empty .ddate { color: var(--muted); font-size: 14px; }
.day-empty .add-hint { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 700; font-size: 14px; }
.day-empty .add-hint svg { width: 17px; height: 17px; }
.day-card.folded.is-today .day-empty { box-shadow: 0 0 0 2px var(--accent); }

/* ── Language switch ── */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--chip); border-radius: 14px; }
.seg button { min-height: 42px; border-radius: 11px; font-weight: 700; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.group-label svg { width: 15px; height: 15px; }
.lang-switch { justify-content: center; gap: 6px; }
.lang-switch svg { width: 18px; height: 18px; }

/* ── Cooking mode ── */
.cook {
  position: fixed; inset: 0; z-index: 40; background: var(--surface); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-reduced-motion: no-preference) { .cook { animation: rise .28s cubic-bezier(.2,.8,.2,1); } }
.cook-head { display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); }
.cook-head .grow { flex: 1; min-width: 0; }
.cook-head small { display: block; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--papaya); }
.cook-head b { display: block; font-family: var(--display); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cook-progress { display: flex; gap: 4px; padding: 6px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.cook-progress i { flex: 1; height: 5px; border-radius: 999px; background: var(--line); transition: background .25s; }
.cook-progress i.on { background: var(--accent); }
.cook-body { flex: 1; overflow-y: auto; padding-block: 26px 18px; max-width: 760px; width: 100%; margin: 0 auto; }
.cook-eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cook-text { font-family: var(--display); font-weight: 600; font-size: clamp(24px, 6.4vw, 34px); line-height: 1.32; margin: 0 0 18px; overflow-wrap: anywhere; text-wrap: pretty; }
h2.cook-text { font-weight: 800; }
.timer-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.uses { display: flex; flex-wrap: wrap; gap: 8px; }
.uses .fact b { color: var(--accent); }
.cook-timers { display: grid; gap: 8px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); max-width: 760px; width: 100%; margin: 0 auto; }
.cook-timers:empty { display: none; }
.timer { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; padding-inline: 14px 8px; border-radius: 16px; background: var(--ink); color: var(--surface); }
.timer > svg { width: 22px; height: 22px; color: var(--saffron); }
.timer .grow { flex: 1; }
.timer small { display: block; font-size: 12.5px; opacity: .75; }
.timer b { font-size: 22px; font-variant-numeric: tabular-nums; font-family: var(--body); }
.timer .x { color: inherit; opacity: .7; }
.timer.done { background: var(--papaya); color: var(--papaya-ink); animation: pulse 1s ease-in-out infinite; }
.timer.done > svg { color: inherit; }
.cook-foot { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; padding-block: 10px 14px; max-width: 760px; width: 100%; margin: 0 auto; }
.cook-foot .btn { min-height: 56px; font-size: 17px; }
.timer-pill {
  position: fixed; z-index: 11; inset-inline-end: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 22px);
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--surface); font-weight: 800; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-lg);
}
.timer-pill svg { width: 20px; height: 20px; color: var(--saffron); }
.timer-pill.done { background: var(--papaya); color: var(--papaya-ink); animation: pulse 1s ease-in-out infinite; }
.timer-pill.done svg { color: inherit; }
@keyframes pulse { 50% { transform: scale(1.04); } }

/* ── Right-to-left (Dhivehi) ── */
[dir="rtl"] .flip { transform: scaleX(-1); }
[dir="rtl"] .tile .letter { right: auto; left: -4%; }
html[lang="dv"] body { font-size: 17px; line-height: 1.75; }
html[lang="dv"] em, html[lang="dv"] .page-title em, html[lang="dv"] .hello h1 em { font-style: normal; }
html[lang="dv"] .eyebrow, html[lang="dv"] .group-label, html[lang="dv"] .today .label, html[lang="dv"] .cook-eyebrow, html[lang="dv"] .cook-head small, html[lang="dv"] .wday small { letter-spacing: 0; text-transform: none; }
html[lang="dv"] .hello h1, html[lang="dv"] .page-title, html[lang="dv"] .detail-title, html[lang="dv"] .welcome h2 { line-height: 1.45; letter-spacing: 0; font-weight: 700; }
html[lang="dv"] .tab { font-size: 12.5px; }
html[lang="dv"] .chip, html[lang="dv"] .btn, html[lang="dv"] .text-btn { font-weight: 600; }
[dir="rtl"] .search input, [dir="rtl"] .add-bar input { text-align: start; }

/* Amounts like "1375 g" keep their order inside right-to-left text. */
[dir="rtl"] .qty, [dir="rtl"] .ing .q, [dir="rtl"] .uses .fact b, [dir="rtl"] .serv span, [dir="rtl"] .timer b, [dir="rtl"] .timer-pill span { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .gitem .qty, [dir="rtl"] .ing .q { text-align: end; }
html[lang="dv"] .wday small { font-size: 13px; }
html[lang="dv"] .group-label, html[lang="dv"] .eyebrow, html[lang="dv"] .cook-eyebrow { font-size: 14px; }
html[lang="dv"] .tab { font-size: 13px; }
