:root {
  --ink: #24304a;
  --muted: #66718a;
  --paper: #fffdf9;
  --soft: #f5f1ff;
  --line: #e8e3f2;
  --purple: #7557e8;
  --purple-dark: #583ac7;
  --purple-pale: #eee9ff;
  --green: #2da77d;
  --green-pale: #e6f8f1;
  --orange: #f39b42;
  --orange-pale: #fff0df;
  --red: #d84f5f;
  --red-pale: #fff0f2;
  --blue: #4f8edc;
  --blue-pale: #e9f3ff;
  --shadow: 0 18px 50px rgba(65, 48, 103, .11);
  --radius: 24px;
  --font: "Avenir Next", "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 15%, rgba(117, 87, 232, .08), transparent 24rem),
    radial-gradient(circle at 90% 25%, rgba(243, 155, 66, .1), transparent 22rem),
    #fbfaf7;
  font-family: var(--font);
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 4px solid rgba(117, 87, 232, .25);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 999; padding: 12px 18px; background: #fff; border-radius: 12px; }
.skip-link:focus { top: 16px; }
.eyebrow { margin: 0 0 6px; color: var(--purple); font-size: .76rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.logo-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 15px; color: #fff; background: linear-gradient(145deg, #8b70ee, #5d3dcc); font-weight: 950; letter-spacing: -.08em; box-shadow: 0 9px 22px rgba(117,87,232,.24); }
.button { min-height: 48px; padding: 12px 22px; border: 0; border-radius: 15px; cursor: pointer; font-weight: 900; transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease; }
.button:hover { transform: translateY(-2px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button-primary { color: #fff; background: linear-gradient(145deg, #8266ed, #6444d2); box-shadow: 0 10px 22px rgba(117,87,232,.25); }
.button-secondary { color: var(--purple-dark); background: var(--purple-pale); }
.button-wide { width: 100%; }
.text-button { padding: 8px 10px; border: 0; background: transparent; color: var(--purple-dark); cursor: pointer; font-weight: 850; }

/* Caregiver entry */
.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, .85fr) minmax(420px, 1.15fr); }
.auth-art { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 100%; background: linear-gradient(145deg, #6c4fda, #8b70ee); }
.auth-art::before, .auth-art::after { content: ""; position: absolute; width: 450px; height: 450px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; }
.auth-art::after { width: 650px; height: 650px; }
.planet { display: grid; place-items: center; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.13); box-shadow: inset 0 0 0 14px rgba(255,255,255,.06), 0 30px 60px rgba(34,22,85,.25); font-size: 7rem; }
.orbit { position: absolute; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.16); font-size: 2rem; backdrop-filter: blur(8px); }
.orbit-one { transform: translate(-180px,-190px) rotate(-12deg); }
.orbit-two { transform: translate(200px,-80px) rotate(15deg); }
.orbit-three { transform: translate(-180px,190px); }
.auth-card { align-self: center; width: min(560px, calc(100% - 48px)); margin: 48px auto; padding: 38px; background: rgba(255,255,255,.91); border: 1px solid rgba(255,255,255,.8); border-radius: 32px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; font-size: 1.2rem; font-weight: 950; }
.auth-card h1 { max-width: 470px; margin: 4px 0 10px; font-size: clamp(2.05rem, 5vw, 3.3rem); line-height: 1.04; letter-spacing: -.045em; }
.auth-lead { margin: 0 0 28px; color: var(--muted); font-size: 1.05rem; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 5px; margin-bottom: 22px; border-radius: 15px; background: #f0edf7; }
.auth-tab { min-height: 42px; border: 0; border-radius: 11px; background: transparent; cursor: pointer; color: var(--muted); font-weight: 900; }
.auth-tab.active { color: var(--purple-dark); background: #fff; box-shadow: 0 5px 14px rgba(65,48,103,.08); }
.auth-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #38425a; font-size: .87rem; font-weight: 800; }
input, select, textarea { width: 100%; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 13px; color: var(--ink); background: #fff; }
textarea { resize: vertical; }
.consent-row { grid-template-columns: 22px 1fr; align-items: start; line-height: 1.4; }
.consent-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--purple); }
.privacy-note { margin: 20px 0 0; color: var(--muted); text-align: center; font-size: .78rem; }
.form-message { min-height: 1.3em; margin: 12px 0 0; color: var(--red); font-size: .87rem; font-weight: 800; }
.form-message.success { color: var(--green); }

/* Application shell */
.app-shell { min-height: 100vh; padding-top: 86px; }
.topbar { position: fixed; inset: 0 0 auto; z-index: 50; height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(16px, 4vw, 44px); background: rgba(255,253,249,.9); border-bottom: 1px solid rgba(220,214,232,.75); backdrop-filter: blur(18px); }
.brand-button { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.brand-button > span:last-child { display: grid; line-height: 1.05; }
.brand-button strong { font-size: 1.05rem; }
.brand-button small { color: var(--purple); font-size: .72rem; font-weight: 850; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.sound-button { width: 42px; height: 42px; border: 0; border-radius: 14px; background: var(--purple-pale); cursor: pointer; }
.profile-chip { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .84rem; font-weight: 850; }
.main-nav { position: fixed; z-index: 40; left: 50%; bottom: 20px; display: flex; gap: 5px; transform: translateX(-50%); padding: 6px; border: 1px solid rgba(222,216,234,.85); border-radius: 21px; background: rgba(255,255,255,.93); box-shadow: 0 16px 36px rgba(59,42,97,.16); backdrop-filter: blur(16px); }
.nav-item { display: grid; grid-template-columns: auto auto; align-items: center; gap: 7px; min-height: 48px; padding: 9px 16px; border: 0; border-radius: 15px; background: transparent; cursor: pointer; color: var(--muted); font-size: .82rem; font-weight: 900; white-space: nowrap; }
.nav-item span { font-size: 1.15rem; }
.nav-item.active { color: var(--purple-dark); background: var(--purple-pale); }
main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 120px; }
.view { display: none; animation: enter .25s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.hero-card { position: relative; overflow: hidden; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 30px; min-height: 230px; padding: clamp(28px, 5vw, 54px); color: #fff; border-radius: 32px; background: linear-gradient(125deg, #6041ca, #8f75ed); box-shadow: 0 24px 50px rgba(91,63,192,.22); }
.hero-card::before { content: "✦"; position: absolute; right: 40%; top: 15%; color: rgba(255,255,255,.23); font-size: 4rem; transform: rotate(18deg); }
.hero-card::after { content: ""; position: absolute; width: 300px; height: 300px; right: -90px; bottom: -170px; border: 34px solid rgba(255,255,255,.08); border-radius: 50%; }
.hero-card .eyebrow { color: #efeaff; }
.hero-card h1 { max-width: 620px; margin: 0; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 1.04; letter-spacing: -.045em; }
.hero-card p:last-child { margin: 14px 0 0; color: #eeeaff; }
.hero-stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; border-radius: 22px; background: rgba(255,255,255,.13); backdrop-filter: blur(12px); }
.hero-stats div { display: grid; min-width: 86px; place-items: center; padding: 10px; }
.hero-stats span { font-size: 1.45rem; }
.hero-stats strong { font-size: 1.35rem; }
.hero-stats small { color: #eeeaff; font-size: .68rem; }
.safety-strip { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; margin: 20px 0 38px; padding: 15px 18px; border: 1px solid #ccebdd; border-radius: 18px; background: var(--green-pale); }
.safety-strip > span { font-size: 1.6rem; }
.safety-strip div { display: grid; }
.safety-strip small { color: #547466; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2, .page-heading h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.65rem); line-height: 1.1; letter-spacing: -.035em; }
.section-heading > p { margin: 0; color: var(--muted); }
.quest-path { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.quest-card { position: relative; display: grid; grid-template-rows: auto auto 1fr auto; min-height: 280px; padding: 23px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.86); box-shadow: 0 10px 30px rgba(65,48,103,.06); }
.quest-card::after { content: ""; position: absolute; inset: auto -30px -50px auto; width: 125px; height: 125px; border-radius: 50%; background: var(--card-pale, var(--purple-pale)); opacity: .8; }
.quest-card.completed { border-color: #aadfca; background: #fbfffd; }
.quest-card.completed::before { content: "✓"; position: absolute; top: 16px; right: 16px; z-index: 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--green); font-weight: 950; }
.quest-number { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.quest-number > span:first-child { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: var(--card-pale, var(--purple-pale)); font-size: 1.9rem; }
.category-pill { padding: 6px 10px; border-radius: 999px; color: var(--card-ink, var(--purple-dark)); background: var(--card-pale, var(--purple-pale)); font-size: .67rem; font-weight: 950; text-transform: uppercase; letter-spacing: .08em; }
.quest-card h3 { margin: 0 0 8px; max-width: 90%; font-size: 1.18rem; line-height: 1.2; }
.quest-card p { margin: 0 0 20px; color: var(--muted); font-size: .88rem; }
.quest-card button { position: relative; z-index: 2; width: 100%; }
.quest-card:nth-child(4n+2) { --card-pale: var(--green-pale); --card-ink: #197658; }
.quest-card:nth-child(4n+3) { --card-pale: var(--orange-pale); --card-ink: #ad5d16; }
.quest-card:nth-child(4n+4) { --card-pale: var(--blue-pale); --card-ink: #286bae; }
.loading-card, .empty-state { grid-column: 1 / -1; padding: 48px 20px; border: 1px dashed #d8d1e5; border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.6); text-align: center; }
.session-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 24px; padding: 20px 24px; border-radius: 21px; background: var(--orange-pale); }
.session-actions div { display: grid; }
.session-actions span { color: #7b6957; font-size: .88rem; }

/* Progress and adult views */
.page-heading { max-width: 760px; margin: 14px 0 34px; }
.page-heading > p:last-child { color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric-card { display: grid; min-height: 165px; padding: 23px; border-radius: 23px; border: 1px solid var(--line); background: #fff; }
.metric-card span { font-size: 1.6rem; }
.metric-card strong { align-self: end; font-size: 2rem; }
.metric-card small { color: var(--muted); font-weight: 750; }
.metric-card.purple { background: var(--purple-pale); border-color: #ded3ff; }
.metric-card.green { background: var(--green-pale); border-color: #ccebdd; }
.metric-card.blue { background: var(--blue-pale); border-color: #cfE5ff; }
.metric-card.orange { background: var(--orange-pale); border-color: #ffe0bd; }
.content-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
.panel { padding: clamp(22px, 4vw, 32px); border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.88); box-shadow: 0 10px 35px rgba(65,48,103,.05); }
.panel-heading { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.panel-heading h2 { margin: 0; }
.panel-heading > span { font-size: 1.8rem; }
.session-list { display: grid; gap: 10px; }
.session-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; padding: 13px; border-radius: 15px; background: #f8f6fb; }
.session-row > span:first-child { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--purple-pale); }
.session-row div { display: grid; }
.session-row small { color: var(--muted); }
.session-row em { font-style: normal; color: var(--green); font-size: .78rem; font-weight: 850; }
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.badge { display: grid; place-items: center; min-height: 115px; padding: 14px; border-radius: 17px; background: #f8f6fb; text-align: center; }
.badge span { font-size: 2rem; }
.badge strong { font-size: .8rem; }
.alert { display: flex; gap: 12px; margin: 0 0 20px; padding: 16px 18px; border-radius: 17px; font-weight: 750; }
.alert.safe { color: #176b50; background: var(--green-pale); }
.alert.danger { color: #9c3240; background: var(--red-pale); }
.adult-warning { margin-bottom: 16px; padding: 14px 17px; border-radius: 15px; color: #785517; background: #fff5d9; font-weight: 800; }
.assessment-form { max-width: 840px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 17px; }
.assessment-form .button { margin-top: 18px; }
.safety-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.safety-card { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.safety-card > span { font-size: 2.2rem; }
.safety-card h2 { margin: 12px 0 7px; }
.safety-card p { margin: 0; color: var(--muted); }
.safety-card.danger { border-color: #f0c2c7; background: var(--red-pale); }
.emergency-note { display: grid; gap: 4px; margin-top: 18px; padding: 20px 24px; border-radius: 18px; color: #8f2d38; background: #ffe3e7; }

/* Modals and workout */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(32,26,49,.66); backdrop-filter: blur(10px); }
.modal-card { position: relative; width: min(920px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: clamp(24px, 5vw, 38px); border-radius: 30px; background: var(--paper); box-shadow: 0 30px 80px rgba(20,12,50,.3); }
.modal-close { position: absolute; right: 17px; top: 15px; z-index: 4; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: #eeeaf4; cursor: pointer; font-size: 1.7rem; }
.workout-header { display: flex; align-items: center; justify-content: space-between; gap: 70px; margin: 0 40px 22px 0; }
.workout-header h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.3rem); line-height: 1.1; }
.timer { min-width: 110px; padding: 10px 15px; border-radius: 16px; color: var(--purple-dark); background: var(--purple-pale); font-size: 1.55rem; font-weight: 950; text-align: center; font-variant-numeric: tabular-nums; }
.workout-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 24px; }
.mirror-card { position: relative; min-height: 365px; overflow: hidden; border-radius: 22px; background: #342b47; }
.mirror-card video { display: none; width: 100%; height: 100%; min-height: 365px; object-fit: cover; transform: scaleX(-1); }
.mirror-card.active video { display: block; }
.mirror-placeholder { position: absolute; inset: 0; display: grid; align-content: center; place-items: center; gap: 7px; padding: 30px; color: #fff; text-align: center; }
.mirror-placeholder span { font-size: 3rem; }
.mirror-placeholder small { max-width: 250px; color: #cfc7db; }
.camera-toggle { position: absolute; z-index: 2; left: 50%; bottom: 15px; transform: translateX(-50%); min-width: 175px; padding: 10px 14px; border: 1px solid rgba(255,255,255,.3); border-radius: 13px; color: #fff; background: rgba(25,18,39,.72); cursor: pointer; font-weight: 850; backdrop-filter: blur(8px); }
.workout-copy > p { margin-top: 0; color: var(--muted); font-size: 1rem; }
.exercise-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 15px 0; }
.exercise-facts div { padding: 12px; border-radius: 14px; background: #f3f0f8; }
.exercise-facts dt { color: var(--muted); font-size: .69rem; font-weight: 900; text-transform: uppercase; }
.exercise-facts dd { margin: 3px 0 0; font-weight: 850; }
.tip { display: grid; gap: 5px; padding: 14px; border-radius: 15px; font-size: .86rem; }
.tip.safe { color: #276b55; background: var(--green-pale); }
details { margin-top: 9px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px; }
summary { cursor: pointer; font-size: .82rem; font-weight: 900; }
details p { margin: 8px 0 2px; color: var(--muted); font-size: .84rem; }
.workout-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.workout-reminder { margin: 13px 0 0; color: var(--red); text-align: center; font-size: .8rem; font-weight: 850; }
.session-modal { width: min(650px, 100%); }
.session-modal h2 { margin-top: 0; font-size: 2rem; }
.session-modal form { display: grid; gap: 17px; }
fieldset { min-width: 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; font-size: .9rem; font-weight: 900; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-row label { display: block; flex: 1; min-width: 90px; cursor: pointer; }
.choice-row input { position: absolute; opacity: 0; pointer-events: none; }
.choice-row span { display: grid; min-height: 48px; place-items: center; padding: 9px; border: 1.5px solid var(--line); border-radius: 13px; background: #fff; text-align: center; }
.choice-row input:checked + span { color: var(--purple-dark); border-color: var(--purple); background: var(--purple-pale); }
.check-list { display: grid; gap: 8px; }
.check-list label { display: grid; grid-template-columns: 20px 1fr; align-items: center; padding: 12px; border-radius: 12px; background: #f6f3fa; }
.check-list input { width: 18px; height: 18px; accent-color: var(--red); }
.red-flag { padding: 14px; border-radius: 14px; color: #952c3a; background: var(--red-pale); font-weight: 850; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 95px; transform: translate(-50%, 25px); max-width: calc(100% - 30px); padding: 13px 19px; border-radius: 14px; color: #fff; background: #2e2840; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .22s ease; font-weight: 850; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .quest-path { grid-template-columns: 1fr 1fr; }
  .hero-card { grid-template-columns: 1fr; }
  .hero-stats { width: fit-content; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .workout-layout { grid-template-columns: 1fr; }
  .mirror-card { min-height: 300px; }
}

@media (max-width: 620px) {
  .app-shell { padding-top: 72px; }
  .topbar { height: 66px; }
  .top-actions .text-button, .profile-chip span:last-child { display: none; }
  .logo-mark { width: 39px; height: 39px; }
  main { width: min(100% - 24px, 1180px); padding-top: 12px; }
  .hero-card { min-height: 0; padding: 28px 22px; border-radius: 24px; }
  .hero-card h1 { font-size: 2.15rem; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); width: 100%; }
  .hero-stats div { min-width: 0; padding: 7px 3px; }
  .safety-strip { grid-template-columns: auto 1fr; margin-bottom: 28px; }
  .safety-strip .text-button { display: none; }
  .section-heading { align-items: start; flex-direction: column; gap: 5px; }
  .quest-path, .metric-grid, .safety-grid, .form-grid { grid-template-columns: 1fr; }
  .quest-card { min-height: 245px; }
  .session-actions { align-items: stretch; flex-direction: column; }
  .main-nav { bottom: 8px; width: calc(100% - 16px); justify-content: space-around; border-radius: 18px; }
  .nav-item { grid-template-columns: 1fr; gap: 1px; padding: 6px 9px; font-size: .64rem; }
  .nav-item span { text-align: center; }
  .auth-card { width: min(100% - 20px, 560px); margin: 10px auto; padding: 26px 20px; border-radius: 24px; }
  .auth-card h1 { font-size: 2.2rem; }
  .workout-header { align-items: start; flex-direction: column; gap: 12px; margin-right: 32px; }
  .workout-controls { grid-template-columns: 1fr; }
  .modal { padding: 8px; }
  .modal-card { max-height: calc(100vh - 16px); border-radius: 23px; }
  .mirror-card, .mirror-card video { min-height: 260px; }
  .choice-row { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
