:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #14171c;
  --muted: #5d6573;
  --border: #e1e4ea;
  --accent: #e8500f;
  --accent-soft: #fde9df;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --tier-s: #e8500f;
  --tier-a: #2563eb;
  --tier-b: #6b7280;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --text: #eceef2;
    --muted: #9aa3b2;
    --border: #2a2f39;
    --accent: #ff6a2b;
    --accent-soft: #3a2116;
    --ok: #3fbf74;
    --warn: #e0a030;
    --tier-a: #5b8dff;
    --tier-b: #8b93a1;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800; letter-spacing: -.5px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--accent-soft); color: var(--accent); }

main { padding: 24px 0 48px; }
.hero { margin: 8px 0 24px; max-width: 760px; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -.02em; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { color: var(--muted); font-size: 16px; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Planner */
.planner { display: grid; grid-template-columns: 330px 1fr; gap: 20px; align-items: start; }
.form { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.form input, .form select, .filters input, .filters select {
  font: inherit; font-weight: 400; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text); width: 100%;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; margin: 0; }
.opt { font-weight: 400; color: var(--muted); }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; cursor: pointer; background: var(--surface); color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:hover { filter: brightness(1.05); }

.results { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.recs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.rec { cursor: pointer; text-align: left; font: inherit; color: inherit; position: relative; }
.rec.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.rec .match { font-size: 28px; font-weight: 800; color: var(--accent); }
.rec .rank { position: absolute; top: 14px; right: 14px; font-size: 12px; color: var(--muted); }
.rec ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.rec li.caution { color: var(--warn); }
.more-splits { font-size: 13px; color: var(--muted); }
.more-splits button { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0 2px; text-decoration: underline; }

.variety { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.variety select { font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .4; cursor: default; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week div { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.week div.on { background: var(--accent); color: #fff; font-weight: 600; }
.week b { display: block; font-size: 11px; opacity: .85; }

.days { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.day h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day h3 small { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.ex-row { border-top: 1px solid var(--border); padding: 10px 0; }
.ex-row:first-of-type { border-top: none; }
.ex-head { display: flex; gap: 8px; align-items: flex-start; }
.ex-name { flex: 1; font-weight: 600; cursor: pointer; }
.ex-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.ex-presc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-presc b { color: var(--text); }
.swap { background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; padding: 2px 8px; font-size: 12px; }
.swap:hover { color: var(--accent); border-color: var(--accent); }
.ex-detail { font-size: 13px; margin-top: 6px; padding: 10px; background: var(--surface-2); border-radius: 10px; }
.ex-detail p { margin: 0 0 6px; }
.focus-tag { font-size: 11px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 1px; }

.tier { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 800; color: #fff; flex: none; }
.tier.S { background: var(--tier-s); }
.tier.A { background: var(--tier-a); }
.tier.B { background: var(--tier-b); }

.vids { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.vid { font-size: 12px; text-decoration: none; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.vid::before { content: "▶ "; color: #e62117; }
.vid:hover { border-color: var(--accent); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar { position: relative; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 999px; }
.bar i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .5; }
.bar-row .num { text-align: right; color: var(--muted); }

.notes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.note h4 { margin-bottom: 6px; }
.note p, .note ul { margin: 0; font-size: 14px; }
.note ul { padding-left: 18px; }
.cite { font-size: 12px; color: var(--muted); }
.cite a { color: var(--muted); }
.warn { border-left: 3px solid var(--warn); padding-left: 10px; color: var(--warn); font-size: 14px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.section-title h2 { margin: 0; }

/* Libraries */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.filters input { max-width: 260px; }
.filters select { max-width: 220px; }
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.split-card h3 { display: flex; justify-content: space-between; gap: 10px; }
.split-card ul { padding-left: 18px; margin: 4px 0 8px; font-size: 14px; }
.split-card .week-plan { font-size: 13px; background: var(--surface-2); border-radius: 10px; padding: 10px; margin: 8px 0; }
.split-card .week-plan div { margin-bottom: 4px; }
.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pros-cons h4 { font-size: 13px; margin: 0; }
.steps { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; margin: 8px 0; }
.steps span { background: var(--surface-2); padding: 3px 8px; border-radius: 8px; }
.steps span:not(:last-child)::after { content: " →"; color: var(--muted); }
.pose-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.credit { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.credit a { font-weight: 600; }
.channel-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 18px; }
.refs-list { font-size: 13px; padding-left: 20px; }
.refs-list li { margin-bottom: 6px; }
.principles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 24px; }
.stat { font-size: 13px; padding: 8px 10px; background: var(--surface-2); border-radius: 10px; margin: 8px 0; }

.site-footer { border-top: 1px solid var(--border); padding: 20px 0 32px; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 0 0 6px; }

@media (max-width: 860px) {
  .planner { grid-template-columns: 1fr; }
  .form { position: static; }
  .days { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 80px 1fr 60px; }
}
@media (max-width: 480px) {
  .pros-cons { grid-template-columns: 1fr; }
  .week { gap: 3px; }
  .week div { padding: 6px 2px; font-size: 11px; }
}

@media print {
  .site-header, .form, .site-footer, .swap, .recs, .more-splits, .no-print { display: none !important; }
  .planner { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Exercise demos: start and end photos, alternating */
.demo { position: relative; background: #fff; border-radius: 10px; overflow: hidden; }
.demo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.demo img + img { animation: demo-flip 1.6s infinite; }
@keyframes demo-flip { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
.demo--thumb { aspect-ratio: 3 / 2; margin-bottom: 10px; }
.demo--full { aspect-ratio: 3 / 2; max-height: 360px; margin: 12px auto; }
@media (prefers-reduced-motion: reduce) {
  .demo { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .demo img { position: static; height: auto; aspect-ratio: 3 / 2; }
  .demo img + img { animation: none; }
}
.ex-card { cursor: pointer; }
.ex-card:hover, .ex-card:focus-visible { border-color: var(--accent); outline: none; }
.link-like { color: var(--accent); font-weight: 600; }
button.ex-name { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: inherit; text-align: left; }
.demo-tag { color: var(--accent); font-size: 11px; }
.vid.search::before { content: "🔍 "; }
.steps a { background: var(--surface-2); padding: 3px 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.steps a:hover { color: var(--accent); }
.steps a:not(:last-child)::after { content: " →"; color: var(--muted); }

#ex-modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; }
#ex-modal::backdrop { background: rgba(0, 0, 0, .55); }
#ex-modal h2 { margin: 0; font-size: 20px; }
#ex-modal p { font-size: 14px; }
.modal-close { position: absolute; top: 12px; right: 12px; }

/* Native apps: respect notches and system bars; hide web-only links */
.site-header { padding-top: env(safe-area-inset-top); }
.site-footer { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.native .web-only { display: none; }

/* Diet */
.diet-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.diet-filters select { max-width: 240px; }
.food-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.food-head h4 { margin: 0; flex: 1; }
.rank-no { color: var(--muted); font-size: 12px; font-weight: 600; }
.diet-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.diet-vegan { background: #dcf5e3; color: #146c37; }
.diet-veg { background: #e6f0ff; color: #1f4fb8; }
.diet-egg { background: #fff3d6; color: #8a5a00; }
.diet-nonveg { background: #fde3e0; color: #a3261b; }
.macro-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: 8px; }
.mb-p { background: #2563eb; }
.mb-c { background: #f59e0b; }
.mb-f { background: #e8500f; }
.macros { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.macros b { color: var(--text); }
.macros .hl { color: var(--text); font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.food .chips { margin-bottom: 6px; }
.countries { display: flex; gap: 4px; margin: 6px 0 0; }
.countries span { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }
.target { margin: 0 0 14px; }
#food-more button { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .diet-vegan { background: #123d24; color: #7fe0a3; }
  :root:not([data-theme="light"]) .diet-veg { background: #16284d; color: #9dbcff; }
  :root:not([data-theme="light"]) .diet-egg { background: #3d2e0d; color: #f3c766; }
  :root:not([data-theme="light"]) .diet-nonveg { background: #44171a; color: #ff9e95; }
}

/* Recipes */
.recipe h5 { margin: 6px 0 4px; font-size: 13px; }
.ingredients { margin: 0 0 8px; padding-left: 18px; font-size: 13px; columns: 2; column-gap: 18px; }
.ingredients li { break-inside: avoid; margin-bottom: 2px; }
.goal-bulk { background: #fde9df; color: #b5400b; border-color: transparent; }
.goal-lean { background: #dcf5e3; color: #146c37; border-color: transparent; }
.yt-btn { display: inline-block; text-decoration: none; margin-top: 4px; }
.diet-filters input[type="search"], .diet-filters input[type="number"], .diet-filters input[type="time"] { font: inherit; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
label.inline input[type="number"] { width: 72px; font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); }

/* Timers (nap, meditation) */
.timer-box { text-align: center; padding: 14px; border-radius: var(--radius); background: var(--surface-2); margin: 10px 0 14px; }
.timer-big { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.timer-label, .timer-sub, .chant-count { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.timer-box.ringing { animation: ring 1s infinite; }
@keyframes ring { 50% { background: var(--accent-soft); } }

/* Sleep */
.age-table { display: flex; flex-direction: column; gap: 6px; }
.age-row { display: grid; grid-template-columns: 170px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 8px; border-radius: 8px; }
.age-row small { color: var(--muted); }
.age-row.current { background: var(--accent-soft); font-weight: 600; }
.age-bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 999px; }
.age-bar i { position: absolute; top: 0; bottom: 0; background: #6d5bd0; border-radius: 999px; }
.cycle-options { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 6px 0 14px; }
.cycle-opt { font: inherit; text-align: left; cursor: pointer; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.cycle-opt b { font-size: 22px; }
.cycle-opt span { font-size: 12px; color: var(--muted); }
.cycle-opt.good { border-color: #6d5bd0; }
.cycle-opt.selected { box-shadow: 0 0 0 2px #6d5bd0; }
.hypno { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin: 8px 0; }
.st-light { background: #9fb3d9; }
.st-deep { background: #2c3e8c; }
.st-rem { background: #b05bd0; }
.hypno-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.hypno-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.link-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.link-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.link-card:hover { border-color: var(--accent); }
.link-card .small:last-child { color: var(--accent); }

/* Meditation */
.player .timer-box .btn { margin-top: 4px; min-width: 120px; }
.breath-wrap { position: relative; height: 220px; display: grid; place-items: center; }
.breath-circle { width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #c9b8ff, #6d5bd0); transform: scale(0.55); opacity: .85; }
.breath-phase { position: absolute; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

@media (max-width: 560px) {
  .age-row { grid-template-columns: 120px 1fr 56px; }
  .ingredients { columns: 1; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .goal-bulk { background: #3a2116; color: #ff9d6b; }
  :root:not([data-theme="light"]) .goal-lean { background: #123d24; color: #7fe0a3; }
}
