/* ───── Tokens ───── */
:root{
  color-scheme: light;
  /* Palette — warm, kitchen-friendly */
  --bg: #f6f1e6;
  --bg-2: #ede5d2;
  --surface: #fffdf7;
  --surface-2: #faf5e9;
  --ink: #1d231f;
  --ink-2: #3b4540;
  --ink-3: #6b7570;
  --ink-4: #9aa39c;
  --line: #e3dcc8;
  --line-2: #d4ccb4;
  --accent: #c25b3a;        /* clay */
  --accent-soft: #efd5c7;
  --green: #3d5a47;         /* sage forest */
  --green-soft: #d4dccb;
  --warn: #c08a1d;
  --warn-soft: #f1e3bf;
  --check: #5a7d54;
  --modal-scrim: rgba(20,24,21,0.42);
  --hover: rgba(0,0,0,0.05);
  --hover-strong: rgba(0,0,0,0.08);
  /* Type */
  --serif: 'Newsreader', ui-serif, Georgia, serif;
  --sans: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  /* Shadow */
  --shadow-1: 0 1px 0 rgba(29,35,31,0.04), 0 1px 2px rgba(29,35,31,0.05);
  --shadow-2: 0 1px 0 rgba(29,35,31,0.04), 0 6px 18px rgba(29,35,31,0.08);
  --shadow-3: 0 20px 60px rgba(29,35,31,0.18);
}

[data-theme="dark"]{
  color-scheme: dark;
  --bg: #161917;
  --bg-2: #1d211f;
  --surface: #232826;
  --surface-2: #2a302d;
  --ink: #f1ede3;
  --ink-2: #d4cfc3;
  --ink-3: #9aa39c;
  --ink-4: #6b7570;
  --line: #353b39;
  --line-2: #454c49;
  --accent: #e3724e;
  --accent-soft: #4a2c20;
  --green: #8db391;
  --green-soft: #2c3d33;
  --warn: #e0a73a;
  --warn-soft: #4a3d1a;
  --check: #7ea577;
  --modal-scrim: rgba(0,0,0,0.6);
  --hover: rgba(255,255,255,0.05);
  --hover-strong: rgba(255,255,255,0.08);
}
/* Meal-type chips — re-tinted for dark */
[data-theme="dark"] .chip-meal-breakfast{ background:#3d2f17; border-color:#5a472a; color:#e6c688 }
[data-theme="dark"] .chip-meal-lunch{ background:#2a3a28; border-color:#3f5a3c; color:#bfd6b8 }
[data-theme="dark"] .chip-meal-dinner{ background:#3d2620; border-color:#5a3a32; color:#e6b8a8 }
[data-theme="dark"] .chip-meal-snack{ background:#2f2a40; border-color:#473d5e; color:#c6b9e0 }
[data-theme="dark"] .chip-meal-dessert{ background:#3d212a; border-color:#5a323f; color:#e6a8bd }
[data-theme="dark"] .chip-accent{ background:var(--accent-soft); border-color:#5a3525; color:#f4b89a }
[data-theme="dark"] .chip-green{ background:var(--green-soft); border-color:#3a523f; color:#c2d8c5 }
[data-theme="dark"] .chip-warn{ background:var(--warn-soft); border-color:#5e4f24; color:#e8c876 }
/* Soft callout cards (link-recipe warning) */
[data-theme="dark"] .callout-warn{ background:#332916 !important; border-color:#5e4f24 !important; }
[data-theme="dark"] .callout-warn, [data-theme="dark"] .callout-warn *{ color:#e8c876 !important }
[data-theme="dark"] .recipe-card.style-editorial .photo .glyph{ color: rgba(255,253,247,0.16) }
[data-theme="dark"] .recipe-card.style-editorial .photo{
  background:
    radial-gradient(circle at 30% 30%, rgba(227,114,78,0.25), transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(141,179,145,0.18), transparent 60%),
    var(--bg-2);
}

*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;padding:0;overflow-x:hidden;max-width:100%}
body{
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* optimizeLegibility turns on fi/fl ligatures, which read oddly in UI text. */
  font-variant-ligatures: none;
  transition: background-color .25s ease, color .25s ease;
}
button{font: inherit; color: inherit}
input, textarea, select{font: inherit; color: inherit}
a{color: var(--accent); text-decoration: none}
a:hover{text-decoration: underline}

h1,h2,h3,h4{ font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
h1{ font-size: clamp(28px, 4vw, 38px); line-height: 1.05; letter-spacing: -0.02em }
h2{ font-size: 22px; line-height: 1.15 }
h3{ font-size: 18px; line-height: 1.2 }

/* Default icon sizing */
.icon{ display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; line-height: 0 }
.icon > svg{ width: 100%; height: 100%; display: block }
.icon-btn .icon{ width: 18px; height: 18px }

.serif{ font-family: var(--serif) }
.muted{ color: var(--ink-3) }
.tiny{ font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); font-weight: 600 }
.divider{ border: 0; border-top: 1px solid var(--line); margin: 16px 0 }

/* ───── App shell ───── */
.app{
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  max-width: 100vw;
}
.app > *{ min-width: 0 }
@media (min-width: 900px){
  .app{
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr;
  }
}
.sidenav{
  display: none;
  position: sticky; top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
}
@media (min-width: 900px){ .sidenav{ display: flex; flex-direction: column; gap: 4px } }
.brand{
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
}
.brand-mark{
  width: 32px; height: 32px;
  background: var(--accent);
  color: var(--surface);
  display: grid; place-items: center;
  border-radius: 9px;
  font-family: var(--serif); font-weight: 600;
  font-size: 18px; line-height: 1;
}
.brand-name{ font-family: var(--serif); font-size: 20px; letter-spacing: -0.01em }

.nav-link{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500;
  cursor: default;
  border: 0; background: transparent; text-align: left;
  width: 100%;
}
.nav-link:hover{ background: var(--hover) }
.nav-link.active{ background: var(--ink); color: var(--bg) }
.nav-link .icon{ width: 20px; height: 20px; flex: 0 0 20px }

.sidenav .nav-foot{
  margin-top: auto;
  padding: 12px 8px 4px;
  color: var(--ink-3);
  font-size: 12px;
}

/* Top bar (mobile) — frosted, and padded clear of the notch / Dynamic Island */
.topbar{
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
           8px calc(18px + env(safe-area-inset-left));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
@media (min-width: 900px){ .topbar{ display: none } }

/* Bottom tab bar (mobile) */
.tabbar{
  position: fixed; left: 0; right: 0; bottom: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 20;
  padding: 8px env(safe-area-inset-right)
           calc(8px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
@media (min-width: 900px){ .tabbar{ display: none } }
.tab{
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; cursor: default;
  border: 0; background: transparent;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
}
.tab .icon{ width: 22px; height: 22px }
.tab.active{ color: var(--ink) }

/* Main */
.main{
  padding: 8px calc(18px + env(safe-area-inset-right))
           calc(96px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  max-width: 1100px;
  width: 100%;
}
@media (min-width: 900px){
  .main{ padding: 28px 40px 60px }
}

/* ───── Buttons ───── */
.btn{
  appearance: none; border: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600; font-size: 14px;
  cursor: default;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover{ background: #000 }
.btn:active{ transform: translateY(1px) }
.btn-accent{ background: var(--accent) }
.btn-accent:hover{ background: #a94a2d }
.btn-ghost{ background: transparent; color: var(--ink-2); border: 1px solid var(--line-2) }
.btn-ghost:hover{ background: var(--hover) }
.btn-soft{ background: var(--surface); color: var(--ink); border: 1px solid var(--line) }
.btn-soft:hover{ background: var(--surface-2) }
.btn-sm{ padding: 6px 12px; font-size: 13px }
.btn-icon{ width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn-danger{ background: transparent; color: #b04a3a; border: 1px solid #e5c7c0 }
.btn-danger:hover{ background: #f5e8e3 }

.icon-btn{
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  cursor: default; color: var(--ink-2);
}
.icon-btn:hover{ background: var(--surface-2) }

/* Floating action button (mobile only). Sits above the tab bar and clears
   the home indicator; the media query — not a JS width check — hides it on
   desktop so it responds correctly to window resizes. */
.fab{
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(88px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  padding: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-2);
  z-index: 25;
}
@media (min-width: 900px){ .fab{ display: none } }

/* ───── Inputs ───── */
.field{ display: flex; flex-direction: column; gap: 6px }
.field-label{ font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.02em }
.input, .textarea, .select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, .select:focus{
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px rgba(29,35,31,0.06);
}
.textarea{ resize: vertical; min-height: 84px; line-height: 1.5 }
.select{
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23425045' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.chip{
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px; font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip-accent{ background: var(--accent-soft); border-color: #e8c1ac; color: #7a3219 }
.chip-green{ background: var(--green-soft); border-color: #c0caaf; color: #2d4632 }
.chip-warn{ background: var(--warn-soft); border-color: #e6d29a; color: #6c4f10 }
.chip-meal-breakfast{ background: #f5e4c9; border-color: #e6cf9c; color: #6e500c }
.chip-meal-lunch{ background: #ddead4; border-color: #c0d4b1; color: #36513b }
.chip-meal-dinner{ background: #ead4cd; border-color: #d6b3a8; color: #6d2c19 }
.chip-meal-snack{ background: #e3dcef; border-color: #c5b9da; color: #463468 }
.chip-meal-dessert{ background: #f0d2dc; border-color: #dca9b8; color: #6a253a }

.dot{ width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block }

/* ───── Cards ───── */
.card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card-pad-sm{ padding: 12px }
.card-flat{ box-shadow: none }
.card-elevated{ box-shadow: var(--shadow-2) }

/* Page header */
.page-head{
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.page-head .title-row{ display: flex; flex-direction: column; gap: 4px }
.page-head h1{ margin: 0 }
.page-head .sub{ color: var(--ink-3); font-size: 14px }
.page-actions{ display: flex; gap: 8px; flex-wrap: wrap }

/* Toolbar (search + filter) */
.toolbar{
  display: flex; gap: 8px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar .search{
  flex: 1 1 220px;
  position: relative;
}
.toolbar .search .input{ padding-left: 36px }
.toolbar .search .icon{
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-3); pointer-events: none;
}
.filter-pills{ display: flex; gap: 6px; flex-wrap: wrap }
.pill{
  appearance: none; border: 1px solid var(--line);
  background: var(--surface); padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  cursor: default;
}
.pill:hover{ background: var(--surface-2) }
.pill.active{ background: var(--ink); color: var(--bg); border-color: var(--ink) }

/* Recipe grid */
.recipe-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
/* minmax(0,1fr) — not 1fr — so a long recipe title can't widen one track
   past its siblings. Cards truncate inside instead. */
@media (min-width: 560px){ .recipe-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)) } }
@media (min-width: 1000px){ .recipe-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)) } }

/* Recipe card variants */
.recipe-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
  cursor: default;
  min-width: 0;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.recipe-card:hover{ border-color: var(--line-2); box-shadow: var(--shadow-1) }
.recipe-card .ttl{
  font-family: var(--serif); font-size: 20px; line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0;
  /* clamp */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-card .meta{
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--ink-3); font-size: 13px;
}
.recipe-card .row{ display: flex; align-items: center; justify-content: space-between; gap: 8px }
.recipe-card .domain{
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-3);
  font-weight: 600; letter-spacing: 0.01em;
}
.recipe-card.link.style-editorial::before,
.recipe-card.link.style-minimal::before{
  content:''; position: absolute; left: 0; top: 18px; bottom: 18px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
/* style: editorial */
.recipe-card.style-editorial{
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
}
.recipe-card.style-editorial .ttl{ font-size: 24px; }
.recipe-card.style-editorial .photo{
  height: 120px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 60%),
    radial-gradient(circle at 70% 70%, var(--green-soft), transparent 60%),
    var(--bg-2);
  border-radius: 14px;
  border: 1px solid var(--line);
  position: relative; overflow: hidden;
  margin: -4px -4px 4px;
}
.recipe-card.style-editorial .photo .glyph{
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--serif); font-size: 48px;
  color: rgba(29,35,31,0.18);
}
/* style: index card — a filing/label card, no ruled lines */
.recipe-card.style-index{
  background: var(--surface);
  border-top: 4px solid var(--accent);
  border-radius: 4px 4px 12px 12px;
  padding-top: 14px;
}
.recipe-card.style-index .ttl{ font-family: var(--serif); }
/* Top edge color follows meal type */
.recipe-card.style-index.meal-breakfast{ border-top-color: #d4a84a }
.recipe-card.style-index.meal-lunch{ border-top-color: #7a9b6a }
.recipe-card.style-index.meal-dinner{ border-top-color: #c25b3a }
.recipe-card.style-index.meal-snack{ border-top-color: #8c7ab8 }
.recipe-card.style-index.meal-dessert{ border-top-color: #c46380 }
[data-theme="dark"] .recipe-card.style-index{ background: var(--surface) }
/* style: minimal */
.recipe-card.style-minimal{
  padding: 14px;
  background: transparent;
  border: 1px dashed var(--line-2);
}
.recipe-card.style-minimal .ttl{ font-family: var(--sans); font-weight: 700; font-size: 16px; letter-spacing: -0.01em }

/* style: hero — color-block, meal-type background (muted) */
.recipe-card.style-hero{
  color: #2a221a;
  border: 0;
  border-radius: 14px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0;
  position: relative;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .2s ease;
}
.recipe-card.style-hero:hover{
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.recipe-card.style-hero .hero-corner{
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700;
  color: color-mix(in srgb, currentColor 65%, transparent);
}
/* Meal label keeps its size; the source domain shrinks/ellipsises to fit
   beside the corner thumbnail on narrow cards. */
.recipe-card.style-hero .hero-meal{ flex-shrink: 0 }
.recipe-card.style-hero .hero-domain{
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
}
.recipe-card.style-hero .hero-domain .hd-text{
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recipe-card.style-hero .hero-ttl{
  font-family: var(--serif); font-weight: 500; font-size: 22px; line-height: 1.1;
  letter-spacing: -0.01em; margin: 0;
  color: currentColor;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-card.style-hero .hero-rule{
  border: 0;
  border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  margin: 2px 0;
}
.recipe-card.style-hero .hero-meta{
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700;
  color: color-mix(in srgb, currentColor 65%, transparent); margin-top: auto;
}
.recipe-card.style-hero .hero-meta b{
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em; display: block; text-transform: none; color: currentColor;
  margin-bottom: 1px;
}

/* Hero — round thumbnail in top-right corner */
.recipe-card.style-hero .hero-thumb{
  position: absolute;
  top: 14px; right: 14px;
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid color-mix(in srgb, currentColor 20%, transparent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  z-index: 2;
}
.recipe-card.style-hero .hero-corner.has-thumb{ padding-right: 56px }
/* Reserve the top-right corner so a long title wraps instead of running
   under the round thumbnail (most visible on narrow / mobile cards). */
.recipe-card.style-hero .hero-ttl.has-thumb{ padding-right: 56px }

/* Image picker (in recipe editor) */
.image-picker{
  display: flex; align-items: center; gap: 14px;
}
.thumb-preview{
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px dashed var(--line-2);
  display: grid; place-items: center;
  color: var(--ink-3);
  overflow: hidden;
  flex-shrink: 0;
  cursor: default;
  transition: border-color .15s ease;
}
.thumb-preview:hover{ border-color: var(--ink-3) }
.thumb-preview.filled{ border-style: solid; border-color: var(--line) }
.thumb-preview img{ width: 100%; height: 100%; object-fit: cover; display: block }

/* Hero — light mode: dusty pastels with dark text */
.recipe-card.style-hero.meal-breakfast{ background: #e8d7a8 }
.recipe-card.style-hero.meal-lunch{ background: #c8d6bf }
.recipe-card.style-hero.meal-dinner{ background: #e0baa8 }
.recipe-card.style-hero.meal-snack{ background: #d4cae4 }
.recipe-card.style-hero.meal-dessert{ background: #e6c8d1 }

/* Hero — dark mode: deep dusty tones with cream text */
[data-theme="dark"] .recipe-card.style-hero{ color: #f1ede3 }
[data-theme="dark"] .recipe-card.style-hero.meal-breakfast{ background: #5a4a26 }
[data-theme="dark"] .recipe-card.style-hero.meal-lunch{ background: #3a4d35 }
[data-theme="dark"] .recipe-card.style-hero.meal-dinner{ background: #5e3528 }
[data-theme="dark"] .recipe-card.style-hero.meal-snack{ background: #443a66 }
[data-theme="dark"] .recipe-card.style-hero.meal-dessert{ background: #5c3947 }

/* ───── Modal ───── */
.modal-backdrop{
  position: fixed; inset: 0;
  background: var(--modal-scrim);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 100;
  /* Inset from every edge so a centred modal never slides under the
     Dynamic Island, notch, or browser chrome. */
  padding: 16px;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  animation: fade .15s ease;
}
@keyframes fade{ from{ opacity: 0 } to{ opacity: 1 } }
@keyframes slideUp{ from{ transform: translateY(8px); opacity: 0 } to{ transform: none; opacity: 1 } }
/* Continuous spinner — used for the loader icon (transform-origin defaults to centre). */
@keyframes spin{ to{ transform: rotate(360deg) } }
.icon.spin{ animation: spin 0.8s linear infinite }
.modal{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 540px;
  /* Dynamic viewport units track iOS toolbars; subtract the safe-area insets
     and backdrop padding so the header and footer are always reachable. */
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  animation: slideUp .18s ease;
  overflow: hidden;
}
.modal-lg{ max-width: 720px }
.modal-head{
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2{ margin: 0 }
.modal-body{ padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px }
.modal-foot{
  padding: 14px 20px;
  display: flex; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.modal-no-head{ position: relative }
.modal-no-head .modal-body{ padding-top: 28px }
.modal-floating-close{
  position: absolute; top: 14px; right: 14px;
  z-index: 2;
}

/* Drawer (right side, large screens) */
.drawer-backdrop{
  position: fixed; inset: 0;
  background: var(--modal-scrim);
  z-index: 100;
  animation: fade .15s ease;
}
.drawer{
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  z-index: 101;
  animation: slideIn .22s ease;
}
@keyframes slideIn{ from{ transform: translateX(20px); opacity: 0 } to{ transform: none; opacity: 1 } }

/* ───── Donut / progress ───── */
.donut-wrap{ position: relative; display: inline-grid; place-items: center }
.donut-wrap svg{ display: block }
.donut-center{
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
}
.donut-num{
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.donut-sub{ font-size: 11px; color: var(--ink-3); margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600 }

/* progress pill */
.progress{
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-3); font-weight: 600;
}
.progress .bar{
  flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden;
  min-width: 60px;
}
.progress .bar > span{
  display: block; height: 100%; background: var(--green);
  border-radius: 3px;
  transition: width .25s ease;
}
.progress.over .bar > span{ background: var(--warn) }

/* ───── Plan list / cards ───── */
.plan-card{
  display: flex; gap: 14px; align-items: center;
  padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  cursor: default;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.plan-card:hover{ border-color: var(--line-2); box-shadow: var(--shadow-1) }
.plan-card .body{ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px }
.plan-card .title-row{
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.plan-card h3{ font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 0; letter-spacing: -0.01em }
.plan-card .meta{ color: var(--ink-3); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap }
.plan-card .meta .dot{ width: 3px; height: 3px; background: var(--ink-4); border-radius: 50% }

/* Coverage badge — green pill with serif numerator */
.coverage-badge{
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--green) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 32%, transparent);
  white-space: nowrap;
}
.coverage-badge .num{
  font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1;
  color: var(--green);
  letter-spacing: -0.01em;
}
.coverage-badge .label{
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* Inline progress line on plan cards */
.plan-progress{
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--ink-3); font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.plan-progress .bar{
  flex: 1; height: 4px; background: var(--line);
  border-radius: 2px; overflow: hidden;
}
.plan-progress .bar > span{
  display: block; height: 100%; background: var(--green);
  border-radius: 2px;
  transition: width .25s ease;
}

/* ───── Plan detail tabs ───── */
.tabs{
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.tabs button{
  appearance: none; border: 0; background: transparent;
  padding: 7px 14px;
  font-weight: 600; font-size: 13px; color: var(--ink-3);
  border-radius: 999px;
  cursor: default;
}
.tabs button.active{ background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1) }

/* week section */
.week-head{
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 0 10px;
  gap: 12px; flex-wrap: wrap;
}
.week-head h2{ font-family: var(--serif); font-size: 24px; margin: 0 }
.week-head .sub{ color: var(--ink-3); font-size: 13px }

/* Kanban */
.kanban{
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
/* minmax(0,1fr) keeps every meal column the same width — an empty column and
   one packed with long-titled recipes both get an equal share of the row. */
@media (min-width: 700px){ .kanban.cols-2{ grid-template-columns: repeat(2, minmax(0, 1fr)) } }
@media (min-width: 900px){ .kanban.cols-3{ grid-template-columns: repeat(3, minmax(0, 1fr)) } }
.column{
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
  min-height: 140px;
}
.column .col-head{
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.column .col-head .h{
  display: flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 18px;
}
.column .col-list{ display: flex; flex-direction: column; gap: 8px }
.column .empty{
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  padding: 14px;
  text-align: center; color: var(--ink-3); font-size: 13px;
}

/* Recipe slot — used in plan */
.slot{
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.slot .body{ flex: 1; min-width: 0 }
.slot .ttl{
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot .sub{
  font-size: 12px; color: var(--ink-3);
}
.slot .x{
  appearance: none; border: 0; background: transparent; cursor: default;
  width: 28px; height: 28px; border-radius: 50%;
  color: var(--ink-3); display: grid; place-items: center;
}
.slot .x:hover{ background: var(--hover-strong); color: var(--ink) }
.add-recipe{
  appearance: none; border: 1px dashed var(--line-2); background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-3); font-weight: 600; font-size: 13px;
  cursor: default; width: 100%;
}
.add-recipe:hover{ border-color: var(--ink-3); color: var(--ink-2); background: var(--hover) }

/* List layout (alt for kanban) */
.meal-list{ display: flex; flex-direction: column; gap: 12px }
.meal-section{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
}
.meal-section .head{
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.meal-section .head .h{
  display: flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 18px;
}
.meal-section .list{ display: flex; flex-direction: column; gap: 8px }

/* Shopping list */
.aisle{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 6px 4px;
  margin-bottom: 14px;
}
.aisle-head{
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 16px;
}
.aisle-head .count{
  margin-left: auto; color: var(--ink-3); font-size: 12px; font-weight: 600;
}
.ingredient{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.ingredient:last-child{ border-bottom: 0 }
.ingredient .check{
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line-2);
  flex: 0 0 22px;
  display: grid; place-items: center;
  cursor: default;
  background: var(--surface);
  color: transparent;
  transition: all .15s ease;
}
.ingredient .check:hover{ border-color: var(--ink-3) }
.ingredient.checked .check{
  background: var(--check); border-color: var(--check); color: var(--bg);
}
.ingredient.checked .name{ text-decoration: line-through; color: var(--ink-4) }
.ingredient.checked .qty{ color: var(--ink-4) }
.ingredient .name{ flex: 1; font-weight: 500; min-width: 0 }
.ingredient .qty{ color: var(--ink-3); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap }
.ingredient .from{
  font-size: 11px; color: var(--ink-4); display: block; margin-top: 2px;
  font-weight: 500;
}

/* Empty state */
.empty-state{
  text-align: center; padding: 40px 20px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-xl);
  color: var(--ink-3);
}
.empty-state .glyph{
  font-family: var(--serif); font-size: 48px; color: var(--ink-4); line-height: 1;
}
.empty-state h3{ margin: 8px 0 4px; color: var(--ink-2) }

/* Servings stepper */
.stepper{
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.stepper-fill{
  display: flex; width: 100%;
}
.stepper button{
  appearance: none; border: 0; background: transparent;
  width: 40px; height: 40px;
  font-size: 18px; line-height: 1; color: var(--ink-2);
  cursor: default;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.stepper button:hover{ background: var(--hover) }
.stepper .val{
  min-width: 36px; text-align: center; font-weight: 700; font-size: 15px;
  font-variant-numeric: tabular-nums;
  flex: 1;
  padding: 0 8px;
}

/* Recipe detail */
.recipe-detail h1{ margin-bottom: 8px }
.recipe-detail .meta-row{
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px;
  color: var(--ink-3);
}
.ingredients-list{ margin: 0; padding: 0; list-style: none }
.ingredients-list li{
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  display: flex; gap: 12px; align-items: baseline;
}
.ingredients-list li:last-child{ border-bottom: 0 }
.ingredients-list .qty{ font-weight: 700; min-width: 80px; font-variant-numeric: tabular-nums; color: var(--ink-2) }

.steps{ counter-reset: step; padding: 0; margin: 0; list-style: none }
.steps li{
  display: flex; gap: 16px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.steps li:last-child{ border-bottom: 0 }
.steps li::before{
  counter-increment: step;
  content: counter(step);
  font-family: var(--serif);
  font-size: 22px;
  color: var(--accent);
  min-width: 28px;
  line-height: 1.2;
}

/* Picker rows */
.picker-row{
  display: flex; gap: 10px; align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: default;
}
.picker-row:hover{ background: var(--surface-2) }
.picker-row + .picker-row{ margin-top: 8px }
.picker-row .body{ flex: 1; min-width: 0 }
.picker-row .ttl{ font-weight: 600; font-size: 14px }
.picker-row .sub{ font-size: 12px; color: var(--ink-3) }

/* Meal type checkboxes */
.meal-toggle{
  display: flex; gap: 8px; flex-wrap: wrap;
}
.meal-toggle label{
  cursor: default;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600; font-size: 13px;
  background: var(--surface);
  color: var(--ink-2);
  user-select: none;
}
.meal-toggle input{ position: absolute; opacity: 0; pointer-events: none }
.meal-toggle label:has(input:checked){
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

/* Toggle row (label + iOS-style switch) */
.toggle-row{
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: default;
  user-select: none;
}
.toggle-row > div{ flex: 1; min-width: 0 }
input.switch{
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--line-2);
  position: relative;
  cursor: default;
  flex-shrink: 0;
  transition: background .2s ease;
}
input.switch::after{
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .2s ease;
}
input.switch:checked{ background: var(--check) }
input.switch:checked::after{ transform: translateX(18px) }

/* Ingredient input rows */
.ingred-row{
  display: grid;
  grid-template-columns: 1fr 1fr 30px;
  gap: 8px;
  align-items: end;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.ingred-row .name-row{
  grid-column: 1 / -1;
}
.ingred-row .input{ padding: 8px 10px; font-size: 14px }
.ingred-row .x{
  width: 30px; height: 30px;
  border: 0; background: transparent; color: var(--ink-3);
  border-radius: 50%; cursor: default;
  display: grid; place-items: center;
  align-self: end;
  margin-bottom: 1px;
}
.ingred-row .x:hover{ background: var(--hover-strong); color: var(--ink) }

.add-row{
  appearance: none; width: 100%;
  border: 1px dashed var(--line-2); background: transparent;
  padding: 12px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-3); font-weight: 600; font-size: 13px;
  cursor: default;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.add-row:hover{ border-color: var(--ink-3); color: var(--ink-2); background: var(--hover) }

/* utility */
.row{ display: flex; align-items: center; gap: 10px }
.col{ display: flex; flex-direction: column; gap: 10px }
.gap-sm{ gap: 6px }
.gap-md{ gap: 12px }
.gap-lg{ gap: 20px }
.between{ justify-content: space-between }
.wrap{ flex-wrap: wrap }
.hidden{ display: none }
.grow{ flex: 1 }
.center{ align-items: center; justify-content: center }
.mt-sm{ margin-top: 8px }
.mt-md{ margin-top: 16px }
.mt-lg{ margin-top: 24px }
.mb-sm{ margin-bottom: 8px }
.mb-md{ margin-bottom: 16px }
.mb-lg{ margin-bottom: 24px }
.text-sm{ font-size: 13px }
.text-xs{ font-size: 12px }
.bold{ font-weight: 700 }
