/* ─────────────────────────────────────────────────────────
   TwinVital · Editorial Wellness UI
   v9 — bold, premium, sheet-over-hero
   ───────────────────────────────────────────────────────── */

:root {
  /* Canvas + paper */
  --canvas:   #FBF6E9;          /* warm ivory page */
  --paper:    #FFFFFF;          /* pure card */
  --paper-2:  #F4EEDC;          /* sand card */
  --sand:     #EAE2C8;          /* divider tint */
  --shell:    #0A2A1F;          /* phone shell behind safe areas */

  /* Brand ramp — deep emerald + sage */
  --brand-50:  #ECFAF3;
  --brand-100: #D2F2E2;
  --brand-200: #A6E2C5;
  --brand-400: #2DBE85;
  --brand-500: #1FA773;
  --brand-600: #0F6E56;
  --brand-700: #0E5A3D;
  --brand-800: #0A4D33;
  --brand-900: #0A2A1F;

  /* Warm accent — coral */
  --coral-50:  #FCEAE2;
  --coral-300: #F2A88B;
  --coral-500: #E66B47;
  --coral-600: #C9522F;
  --coral-700: #8C3A20;

  /* Layered dark (for hero / scan / dark screens) */
  --ink-night: #0F1813;

  /* Ink ramp */
  --ink-900: #14201A;
  --ink-800: #1F2D24;
  --ink-700: #3A4540;
  --ink-500: #6B756F;
  --ink-300: #A5AAA7;
  --ink-200: #C7CCC9;
  --ink-100: #E2E5E2;
  --paper-ink: #FBF6E9;        /* ink-on-dark */

  /* Hairlines */
  --line:    rgba(20, 32, 26, 0.08);
  --line-2:  rgba(20, 32, 26, 0.14);
  --line-d:  rgba(251, 246, 233, 0.10);
  --line-d2: rgba(251, 246, 233, 0.20);

  /* Semantic */
  --good-50: #E8F7EE;  --good-700: #0E6F3F;  --good-500: #1AA35A;
  --warn-50: #FDF1DD;  --warn-700: #8A5A0C;  --warn-500: #D69323;
  --bad-50:  #FCEBEA;  --bad-700:  #9B2622;  --bad-500:  #D43A33;
  --info-50: #EBF1FB;  --info-700: #103E80;

  /* Type scale (editorial) */
  --display:   42px;
  --h1:        28px;
  --h2:        20px;
  --h3:        16px;
  --body:      15.5px;
  --caption:   13px;
  --micro:     11px;

  /* Spacing (4px base) */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px;  --s8: 40px; --s9: 56px;

  /* Radius */
  --r-sm:  10px;
  --r-md:  16px;
  --r-lg:  24px;
  --r-xl:  32px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(20,32,26,0.06), 0 2px 8px rgba(20,32,26,0.04);
  --shadow-2: 0 4px 14px rgba(20,32,26,0.08), 0 12px 36px rgba(20,32,26,0.08);
  --shadow-3: 0 12px 40px rgba(20,32,26,0.18);
  --shadow-brand: 0 10px 30px rgba(10,77,51,0.28);
  --shadow-coral: 0 10px 26px rgba(230,107,71,0.30);

  /* Layout heights */
  --nav-h:    78px;
  --action-h: 96px;
  --top-h:    64px;

  /* Motion */
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ─────────── Reset / base ─────────── */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--shell);
  color: var(--ink-900);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { background: none; border: 0; cursor: pointer; }

a { color: inherit; text-decoration: none; }

img, svg, video { display: block; max-width: 100%; }

/* ─────────── Phone shell ─────────── */

.phone-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--canvas);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,0.35);
  isolation: isolate;
}

/* ─────────── View layout ─────────── */

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--canvas);
}

.view.active { display: flex; }

.view.dark-screen { background: var(--ink-night); color: var(--paper-ink); }

/* Top bar */
.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: calc(env(safe-area-inset-top) + var(--s4)) var(--s5) var(--s4);
  background: var(--canvas);
  position: relative;
  z-index: 5;
}
.top > div { flex: 1; min-width: 0; }
.top .eyebrow {
  margin: 0 0 2px;
  font-size: var(--micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
}
.top h2 {
  margin: 0;
  font-size: var(--h1);
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--ink-900);
}
.top.dark { background: transparent; color: var(--paper-ink); }
.top.dark .eyebrow { color: rgba(251,246,233,0.65); }
.top.dark h2 { color: var(--paper-ink); }

.top .icon {
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--paper);
  color: var(--ink-900);
  box-shadow: var(--shadow-1);
  font-size: 18px;
  transition: transform 0.15s var(--ease);
}
.top .icon:active { transform: scale(0.94); }
.top.dark .icon {
  background: rgba(251,246,233,0.10);
  color: var(--paper-ink);
  box-shadow: none;
  backdrop-filter: blur(8px);
}

/* Content area */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--s4) var(--s5) calc(var(--nav-h) + var(--s5));
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.content.no-nav { padding-bottom: calc(var(--action-h) + var(--s5)); }
.content.dark-content { background: var(--ink-night); color: var(--paper-ink); }

/* Fixed actions (always sit above the bottom nav) */
.fixed-actions {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  padding: var(--s4) var(--s5) calc(env(safe-area-inset-bottom) + var(--s4));
  background: linear-gradient(to top, var(--canvas) 70%, rgba(251,246,233,0));
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.fixed-actions.split {
  flex-direction: row;
  flex-wrap: wrap;
}
.fixed-actions.split > * { flex: 1 1 0; min-width: 130px; }
.fixed-actions.dark-actions {
  background: linear-gradient(to top, var(--ink-night) 70%, rgba(15,24,19,0));
}

/* ─────────── Bottom nav ─────────── */

/* The .hidden attribute (set by the router) must win over display:grid */
.bottom-nav[hidden] { display: none !important; }

/* CSS fallback: hide on pre-app and full-screen views even if router hasn't fired */
.phone-shell:has(#view-auth.active) .bottom-nav,
.phone-shell:has(#view-onboarding.active) .bottom-nav,
.phone-shell:has(#view-plan.active) .bottom-nav,
.phone-shell:has(#view-avatar.active) .bottom-nav {
  display: none;
}

.bottom-nav {
  position: absolute;
  left: var(--s4); right: var(--s4);
  bottom: calc(env(safe-area-inset-bottom) + var(--s3));
  height: var(--nav-h);
  background: rgba(20,32,26,0.92);
  backdrop-filter: blur(20px) saturate(1.4);
  border-radius: var(--r-pill);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  padding: 6px;
  z-index: 20;
  box-shadow: var(--shadow-3);
}
.bottom-nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: rgba(251,246,233,0.55);
  border-radius: calc(var(--r-pill) - 6px);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.bottom-nav button i { font-size: 22px; }
.bottom-nav button.active {
  color: var(--canvas);
  background: var(--brand-600);
  box-shadow: 0 6px 18px rgba(15,110,86,0.45);
}
.bottom-nav button.active i { color: var(--canvas); }
.bottom-nav button:not(.active):active { background: rgba(251,246,233,0.06); }

/* ─────────── Buttons ─────────── */

button.primary,
button.secondary,
button.danger,
button.ghost {
  height: 56px;
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  transition: transform 0.15s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

button.primary {
  background: var(--brand-800);
  color: var(--canvas);
  box-shadow: var(--shadow-brand);
}
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.45; box-shadow: none; }

button.secondary {
  background: var(--paper);
  color: var(--ink-900);
  border: 1px solid var(--line-2);
}
button.secondary:active { transform: scale(0.98); background: var(--sand); }

button.danger {
  background: var(--bad-50);
  color: var(--bad-700);
}
button.danger:active { transform: scale(0.98); }

button.ghost {
  background: transparent;
  color: var(--canvas);
  border: 1px solid var(--line-d2);
}
.dark-actions button.secondary {
  background: rgba(251,246,233,0.10);
  color: var(--paper-ink);
  border-color: var(--line-d2);
  backdrop-filter: blur(10px);
}

.btn-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(251,246,233,0.15);
  font-size: 14px;
  margin-left: 4px;
  transition: transform 0.2s var(--ease);
}
button.primary:hover .btn-arrow { transform: translateX(2px); }

/* Wide action button (home shortcut cards) */
.wide-action {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s5);
  background: var(--paper);
  border-radius: var(--r-lg);
  font-weight: 600;
  font-size: 15px;
  text-align: left;
  color: var(--ink-900);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
  transition: transform 0.15s var(--ease);
}
.wide-action i {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  display: grid; place-items: center;
  font-size: 20px;
  flex: 0 0 44px;
}
.wide-action:active { transform: scale(0.98); }
.wide-action.admin-link i { background: var(--coral-50); color: var(--coral-600); }

/* ─────────── Auth (sign in) — editorial hero + sheet ─────────── */

#view-auth {
  background: var(--ink-night);
  /* display intentionally inherited from .view (none) so router can toggle it */
  flex-direction: column;
}

.auth-hero {
  position: relative;
  flex: 0 0 auto;
  min-height: 36vh;
  padding: calc(env(safe-area-inset-top) + var(--s5)) var(--s6) var(--s6);
  background:
    radial-gradient(120% 80% at 20% 15%, rgba(45,190,133,0.16) 0%, transparent 60%),
    radial-gradient(80% 60% at 90% 85%, rgba(230,107,71,0.14) 0%, transparent 70%),
    linear-gradient(160deg, #0B201A 0%, #0F1813 60%, #0A4D33 200%);
  color: var(--paper-ink);
  overflow: hidden;
}
.auth-hero .hero-shape {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: 0.95;
  mix-blend-mode: screen;
  pointer-events: none;
}
.auth-hero .hero-grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.30;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  mix-blend-mode: overlay;
}

.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  height: 100%;
  justify-content: flex-end;
}

.logo-mark {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: rgba(251,246,233,0.10);
  border: 1px solid var(--line-d2);
  display: grid; place-items: center;
  margin-bottom: var(--s3);
  backdrop-filter: blur(8px);
}
.logo-mark svg { width: 34px; height: 34px; }

.hero-eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(251,246,233,0.70);
}

.display {
  margin: 4px 0 0;
  font-size: 36px;
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--paper-ink);
}

.lede {
  margin: var(--s3) 0 0;
  font-size: 16px;
  line-height: 1.5;
  color: rgba(251,246,233,0.78);
  max-width: 30ch;
}

.auth-sheet {
  position: relative;
  flex: 1 1 auto;
  margin-top: calc(-1 * var(--s6));
  padding: var(--s3) var(--s5) calc(env(safe-area-inset-bottom) + var(--s5));
  background: var(--canvas);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  overflow-y: auto;
  z-index: 3;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.25);
}

.grab-handle {
  align-self: center;
  width: 44px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--ink-100);
  margin: var(--s1) 0 var(--s2);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--paper-2);
  border-radius: var(--r-pill);
  margin: 0 0 var(--s2);
}
.segmented button {
  padding: 10px 12px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-500);
  letter-spacing: -0.01em;
  transition: all 0.18s var(--ease);
}
.segmented button.active {
  background: var(--ink-900);
  color: var(--canvas);
  box-shadow: var(--shadow-1);
}

.sheet { display: none; flex-direction: column; gap: var(--s3); }
.sheet.active { display: flex; }

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
  padding-left: 4px;
}
.field input {
  height: 54px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--paper);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-900);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field input::placeholder { color: var(--ink-300); font-weight: 400; }
.field input:focus {
  outline: 0;
  border-color: var(--brand-700);
  box-shadow: 0 0 0 4px rgba(15,110,86,0.10);
}

.form-msg {
  margin: 0;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--bad-50);
  color: var(--bad-700);
}
.form-msg.good { background: var(--good-50); color: var(--good-700); }

.auth-foot {
  margin: var(--s2) 0 0;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-500);
}

/* ─────────── Setup / onboarding ─────────── */

.setup-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: var(--s2) 0 var(--s3);
}
.setup-progress span {
  width: 26px; height: 4px;
  border-radius: var(--r-pill);
  background: var(--ink-100);
}
.setup-progress span.active { background: var(--brand-800); }

.card {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: var(--s5);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.card.compact { padding: var(--s4); }

.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3) var(--s4); }
.grid.two label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
}
.grid.two input,
.grid.two select {
  height: 48px;
  padding: 0 var(--s3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-900);
}
.grid.two input:focus,
.grid.two select:focus {
  outline: 0;
  border-color: var(--brand-700);
  background: var(--paper);
}

.section-title {
  margin: var(--s3) 0 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px;
  margin: 0 -4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: var(--paper);
  border: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.chips button i { font-size: 16px; line-height: 1; opacity: 0.8; }
.chips button.active {
  background: var(--brand-800);
  color: var(--canvas);
  border-color: var(--brand-800);
}
.chips button.active i { opacity: 1; }
/* Setup chips (multi-select health flags) stay wrapped */
#setup-conditions { flex-wrap: wrap; overflow: visible; }

.goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.goal-grid button {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s4);
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
  transition: all 0.15s var(--ease);
}
.goal-grid button i {
  font-size: 18px;
  color: var(--brand-700);
}
.goal-grid button.active {
  background: var(--brand-50);
  border-color: var(--brand-500);
  color: var(--brand-800);
}
.goal-grid button.active i { color: var(--brand-800); }

/* ─────────── Plan ─────────── */

.target-card {
  background: var(--ink-900);
  color: var(--paper-ink);
  border-radius: var(--r-lg);
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.target-card::after {
  content: '';
  position: absolute;
  top: -40%; right: -20%;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45,190,133,0.35) 0%, transparent 70%);
}
.target-card p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(251,246,233,0.65);
}
.target-card strong {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 6px 0 4px;
}
.target-card span { font-size: 13px; color: rgba(251,246,233,0.65); }

.macro-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s3);
}
.macro-row > div {
  background: var(--paper);
  border-radius: var(--r-md);
  padding: var(--s4) var(--s3);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.macro-row span {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
}
.macro-row strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.info-list .info {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.5;
  background: var(--info-50);
  color: var(--info-700);
}
.info-list .warn { background: var(--warn-50); color: var(--warn-700); }
.info-list .good { background: var(--good-50); color: var(--good-700); }
.info-list .bad  { background: var(--bad-50);  color: var(--bad-700); }

/* ─────────── Home dashboard ─────────── */

.dashboard {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: var(--s4);
  align-items: center;
  background: var(--paper);
  padding: var(--s5);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.avatar-mini {
  width: 90px; height: 90px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--brand-100), var(--brand-400));
  box-shadow: inset 0 -10px 24px rgba(10,77,51,0.18);
  overflow: hidden;
  display: grid; place-items: center;
  color: var(--brand-800);
  font-size: 28px;
  font-weight: 700;
}
.rings {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rings p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
}
.rings strong {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink-900);
}
.rings span { font-size: 12px; color: var(--ink-500); }

.list-empty {
  padding: var(--s5);
  border-radius: var(--r-md);
  background: var(--paper-2);
  color: var(--ink-500);
  text-align: center;
  font-size: 14px;
  border: 1px dashed var(--line-2);
}

/* ─────────── Profile ─────────── */

.profile-name {
  margin: 0;
  font-size: var(--h1);
  font-weight: 700;
  letter-spacing: -0.018em;
}
.muted { color: var(--ink-500); margin: 4px 0 0; font-size: 14px; }

/* ─────────── Recipe / workout cards ─────────── */

.recipe-card,
.workout-card,
.list-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--s5);
  border-radius: var(--r-lg);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  text-align: left;
  width: 100%;
  transition: transform 0.15s var(--ease);
}
.recipe-card:active,
.workout-card:active,
.list-card:active { transform: scale(0.98); }

.recipe-card h3,
.workout-card h3,
.list-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink-900);
}
.recipe-card .meta,
.workout-card .meta,
.list-card .meta {
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-500);
  font-weight: 500;
}
.recipe-card .pill,
.workout-card .pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  align-self: flex-start;
}

#recipe-list, #workout-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

#recipe-body, #workout-body {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
#recipe-body h3, #workout-body h3 {
  margin: 0 0 var(--s2);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-700);
}
#recipe-body ul, #workout-body ul,
#recipe-body ol, #workout-body ol {
  margin: 0;
  padding-left: var(--s5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-800);
}

/* ─────────── Camera (avatar / scan) ─────────── */

.camera-box {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line-d2);
}
.camera-box video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.camera-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(251,246,233,0.40);
  font-size: 64px;
  background:
    radial-gradient(60% 60% at 50% 35%, rgba(251,246,233,0.05) 0%, transparent 70%),
    var(--ink-night);
}

.avatar-preview {
  display: flex;
  justify-content: center;
  padding: var(--s3) 0;
}
.avatar-preview canvas {
  width: 200px !important;
  height: 200px !important;
  border-radius: var(--r-pill);
  background: rgba(251,246,233,0.06);
}

.hair-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}
.hair-controls button {
  padding: var(--s3);
  background: rgba(251,246,233,0.08);
  color: var(--paper-ink);
  border: 1px solid var(--line-d2);
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(8px);
}
.hair-controls button i { font-size: 18px; }

.scan-result {
  padding: var(--s4);
  border-radius: var(--r-md);
  background: rgba(251,246,233,0.08);
  border: 1px solid var(--line-d2);
  color: var(--paper-ink);
  font-size: 14px;
  min-height: 80px;
}
.scan-result.good { background: rgba(26,163,90,0.18); border-color: rgba(26,163,90,0.4); }
.scan-result.warn { background: rgba(214,147,35,0.16); border-color: rgba(214,147,35,0.4); }
.scan-result.bad  { background: rgba(212,58,51,0.18); border-color: rgba(212,58,51,0.4); }

/* ─────────── Toast ─────────── */

.toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--s5) + env(safe-area-inset-bottom));
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--ink-900);
  color: var(--canvas);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  z-index: 30;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ─────────── Misc / forms ─────────── */

label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-500);
}
label input,
label select {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: 48px;
  padding: 0 var(--s3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-900);
}

label input:focus,
label select:focus {
  outline: 0;
  border-color: var(--brand-700);
  background: var(--paper);
}

.content::-webkit-scrollbar,
.auth-sheet::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb,
.auth-sheet::-webkit-scrollbar-thumb {
  background: rgba(20,32,26,0.15);
  border-radius: var(--r-pill);
}

@media (min-width: 480px) {
  body { background: linear-gradient(160deg, #0F1813, #0A2A1F); }
  .phone-shell {
    height: min(100dvh, 940px);
    border-radius: 40px;
    margin-top: max(0px, calc((100dvh - 940px) / 2));
  }
}

/* ─────────── Profile pill (top bar avatar chip) ─────────── */

.profile-pill {
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-800));
  color: var(--canvas);
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-1), 0 0 0 2px var(--canvas);
  border: 0;
  cursor: pointer;
  flex: 0 0 40px;
  overflow: hidden;
  position: relative;
  transition: transform 0.15s var(--ease);
}
.profile-pill:active { transform: scale(0.94); }
.profile-pill canvas,
.profile-pill img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.profile-pill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 -6px 14px rgba(0,0,0,0.12);
  pointer-events: none;
}
.top.dark .profile-pill { box-shadow: 0 0 0 2px rgba(251,246,233,0.20); }

/* ─────────── Shopping list (Listronic-style) ─────────── */

.shop-add {
  display: flex;
  gap: var(--s2);
  background: var(--paper);
  border-radius: var(--r-pill);
  padding: 6px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.shop-add input {
  flex: 1 1 auto;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-900);
}
.shop-add input::placeholder { color: var(--ink-300); }
.shop-add button {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  background: var(--brand-800);
  color: var(--canvas);
  display: grid; place-items: center;
  font-size: 20px;
  flex: 0 0 44px;
  transition: transform 0.12s var(--ease);
}
.shop-add button:active { transform: scale(0.92); }

.shop-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.shop-section-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: var(--s2) 0 4px;
  padding: 0 4px;
}
.shop-section-head i {
  width: 26px; height: 26px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  display: grid; place-items: center;
  font-size: 14px;
}
.shop-section-head h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-700);
  flex: 1;
}
.shop-section-head .count {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-500);
  background: var(--paper-2);
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.shop-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 14px var(--s4);
  background: var(--paper);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease);
}
.shop-item.checked { opacity: 0.55; background: var(--paper-2); }
.shop-item.checked .shop-name { text-decoration: line-through; color: var(--ink-500); }

.shop-check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--ink-200);
  background: transparent;
  display: grid; place-items: center;
  color: transparent;
  font-size: 14px;
  flex: 0 0 26px;
  transition: all 0.15s var(--ease);
}
.shop-item.checked .shop-check {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: var(--canvas);
}
.shop-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-900);
}
.shop-qty {
  font-size: 12px;
  color: var(--ink-500);
  font-weight: 600;
  margin-right: 4px;
}
.shop-del {
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  color: var(--ink-300);
  display: grid; place-items: center;
  font-size: 16px;
  flex: 0 0 32px;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.shop-del:active { color: var(--bad-700); background: var(--bad-50); }

.shop-empty {
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--ink-500);
  font-size: 14px;
}
.shop-empty i {
  font-size: 48px;
  color: var(--ink-200);
  display: block;
  margin-bottom: var(--s3);
}

.shop-bulk {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s2);
}
.shop-bulk button {
  flex: 1;
  height: 42px;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  color: var(--ink-700);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.shop-bulk button i { font-size: 16px; }
.shop-bulk button:active { background: var(--sand); }

/* ─────────── Discover (TheMealDB suggestions) ─────────── */

.discover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--s3) 0 var(--s2);
}
.discover-head h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-700);
}
.discover-head button {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-700);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--r-pill);
}
.discover-head button i { font-size: 14px; }

.discover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.discover-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  text-align: left;
  transition: transform 0.15s var(--ease);
}
.discover-card:active { transform: scale(0.97); }
.discover-card .thumb {
  aspect-ratio: 1 / 1;
  background: var(--paper-2) center/cover no-repeat;
  position: relative;
}
.discover-card .thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(20,32,26,0.45));
}
.discover-card .tag {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: rgba(251,246,233,0.92);
  color: var(--ink-900);
  backdrop-filter: blur(6px);
}
.discover-card .body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.discover-card h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-900);
  line-height: 1.25;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.discover-card .meta {
  font-size: 11px;
  color: var(--ink-500);
  font-weight: 500;
}

/* Recipe detail "Add to shopping" inline button */
.inline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  font-size: 13px;
  font-weight: 600;
  align-self: flex-start;
}
.inline-action i { font-size: 16px; }
.inline-action:active { background: var(--brand-100); }
