/*
 * Back on Track visual system: "Sunlit Handout".
 * A warm, friendly care kit for older adults: cream paper, soft rounded cards,
 * real icons paired with words, and drawn mood faces. Calm on a phone, a real
 * desktop app in Chrome. Meaning is never carried by color alone.
 */

:root {
  /* ---- type ---- */
  --font: "Aptos", "Segoe UI Variable", "Segoe UI", "Avenir Next", Verdana, system-ui, sans-serif;
  --fs-base: clamp(19px, 1rem + 0.3vw, 20px);
  --fs-2xs: 14px;
  --fs-xs: 15px;
  --fs-sm: 16px;
  --fs-md: 18px;
  --fs-lg: 21px;
  --fs-xl: 24px;
  --fs-2xl: 29px;
  --fs-3xl: 34px;
  --fs-4xl: 42px;
  --fs-lead: 23px;
  --lh-body: 1.5;
  --lh-head: 1.1;
  --measure: 38rem;

  /* ---- warm neutrals ---- */
  --page: oklch(94% 0.025 82);
  --paper: oklch(99% 0.008 86);
  --panel: oklch(96% 0.018 83);
  --ink: oklch(22% 0.018 70);
  --muted: oklch(43% 0.022 70);
  --subtle: oklch(53% 0.02 70);
  --line: oklch(86% 0.026 82);
  --tint: color-mix(in oklch, var(--ink) 5%, var(--paper));

  /* ---- signature accent (terracotta): primary "safe to tap" actions ---- */
  --brand: oklch(52% 0.12 47);
  --brand-press: oklch(46% 0.12 47);
  --brand-soft: oklch(93% 0.04 64);
  --on-accent: #fffdf7;

  /* ---- section accents (AA as text-on-white AND white-on-accent) ---- */
  --move: oklch(48% 0.1 162);
  --move-soft: oklch(94% 0.038 162);
  --learn: oklch(47% 0.095 245);
  --learn-soft: oklch(94% 0.034 244);
  --plan: oklch(52% 0.11 62);
  --plan-soft: oklch(93% 0.05 72);
  --goal: oklch(50% 0.085 110);
  --goal-soft: oklch(93% 0.04 110);
  --safe: oklch(50% 0.13 30);
  --safe-soft: oklch(93% 0.04 32);

  /* ---- radius ---- */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  /* ---- elevation (warm, never grey; always with a 1px border) ---- */
  --shadow-xs: 0 2px 6px rgba(74, 56, 33, 0.07);
  --small-shadow: 0 8px 20px rgba(74, 56, 33, 0.09);
  --shadow: 0 20px 46px rgba(74, 56, 33, 0.13);

  /* ---- focus (accent-independent) ---- */
  --focus-halo: oklch(64% 0.15 64);

  --tap: 58px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

a {
  color: inherit;
}

svg {
  display: block;
}

/* ---- app shell ---- */

.app {
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  position: relative;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  position: sticky;
  top: 0;
  background: color-mix(in oklch, var(--paper), white 30%);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.back-btn {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
}

.back-btn.show {
  display: inline-flex;
}

.back-btn .icon {
  width: 28px;
  height: 28px;
}

.brand {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  min-width: 50px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.theme-btn .icon {
  width: 24px;
  height: 24px;
  color: var(--brand);
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  margin-left: 0;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 800;
  box-shadow: var(--shadow-xs);
}

.lang-btn .icon {
  width: 20px;
  height: 20px;
  color: var(--brand);
}

main {
  flex: 1;
  padding: 16px 18px 140px;
}

.screen {
  animation: fade 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- per-section color context ---- */

.screen-body[data-c="move"] {
  --c: var(--move);
  --c-soft: var(--move-soft);
}

.screen-body[data-c="learn"] {
  --c: var(--learn);
  --c-soft: var(--learn-soft);
}

.screen-body[data-c="plan"] {
  --c: var(--plan);
  --c-soft: var(--plan-soft);
}

.screen-body[data-c="goal"] {
  --c: var(--goal);
  --c-soft: var(--goal-soft);
}

.screen-body[data-c="safe"] {
  --c: var(--safe);
  --c-soft: var(--safe-soft);
}

.screen-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 10px;
  color: var(--c, var(--ink));
  font-size: var(--fs-2xl);
  line-height: var(--lh-head);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.screen-title .title-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--c-soft);
  color: var(--c);
  border: 1px solid color-mix(in oklch, var(--c), var(--paper) 60%);
}

.screen-title .title-icon .icon {
  width: 30px;
  height: 30px;
}

.screen-intro {
  max-width: var(--measure);
  margin: 0 0 20px;
  color: var(--muted);
  font-size: var(--fs-md);
}

/* ---- home hero ---- */

.hero {
  margin: 0 0 20px;
  padding: 24px 22px;
  background:
    radial-gradient(120% 90% at 88% -10%, color-mix(in oklch, var(--brand-soft), transparent 35%), transparent 60%),
    var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--small-shadow);
}

.hello {
  margin: 0 0 6px;
  font-size: var(--fs-3xl);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.sub {
  max-width: 28rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-lead);
}

.goal-pinned {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 20px;
  padding: 16px;
  color: var(--ink);
  text-decoration: none;
  background: var(--goal-soft);
  border: 1px solid color-mix(in oklch, var(--goal), var(--paper) 62%);
  border-radius: var(--radius-lg);
}

.token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  color: var(--on-accent);
  background: var(--goal);
}

.token .icon {
  width: 28px;
  height: 28px;
}

.goal-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.label {
  color: var(--goal);
  font-size: var(--fs-2xs);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.value {
  color: var(--ink);
  font-size: var(--fs-lg);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.goal-pinned.empty .value {
  color: var(--muted);
  font-weight: 600;
}

.home-heading {
  margin: 26px 0 13px;
  font-size: var(--fs-xl);
  line-height: 1.15;
  font-weight: 800;
}

/* ---- section tiles: soft pastel card + colored icon + word ---- */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin: 0 0 24px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 132px;
  padding: 16px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--ink);
  background: var(--c-soft);
  border: 1px solid color-mix(in oklch, var(--c), var(--paper) 56%);
  box-shadow: var(--shadow-xs);
}

.tile.move {
  --c: var(--move);
  --c-soft: var(--move-soft);
}

.tile.learn {
  --c: var(--learn);
  --c-soft: var(--learn-soft);
}

.tile.plan {
  --c: var(--plan);
  --c-soft: var(--plan-soft);
}

.tile.goal {
  --c: var(--goal);
  --c-soft: var(--goal-soft);
}

.tile.safe {
  --c: var(--safe);
  --c-soft: var(--safe-soft);
}

.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: var(--on-accent);
  background: var(--c);
}

.tile-icon .icon {
  width: 28px;
  height: 28px;
}

.tile-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.tile-title {
  font-size: var(--fs-lg);
  line-height: 1.1;
  font-weight: 800;
}

.tile-sub {
  font-size: var(--fs-sm);
  line-height: 1.25;
  color: var(--muted);
  font-weight: 600;
}

.tile.wide {
  grid-column: 1 / -1;
  min-height: 0;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.tile.wide .tile-copy {
  gap: 2px;
}

/* ---- daily mood check-in: drawn faces ---- */

.checkin {
  margin: 24px 0 12px;
}

.checkin h2 {
  margin: 0 0 12px;
  font-size: var(--fs-xl);
  font-weight: 800;
}

.faces {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}

.face-graphic {
  width: 100%;
  max-width: 48px;
  height: auto;
}

.face-label {
  font-size: var(--fs-2xs);
  font-weight: 750;
  line-height: 1.1;
  color: var(--ink);
}

.face[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 2px var(--ink);
}

/* Drawn mood faces: a self-contained light disc with dark features,
 * readable in light and dark themes. Valence = mouth shape, never color alone. */
.face-graphic,
.trend-face {
  color: #2a241c;
}

.face-bg {
  fill: #f6f0e2;
  stroke: rgba(40, 33, 24, 0.22);
  stroke-width: 1.5;
}

.m0 .face-bg {
  fill: oklch(90% 0.045 300);
}

.m1 .face-bg {
  fill: oklch(91% 0.04 280);
}

.m2 .face-bg {
  fill: oklch(93% 0.035 95);
}

.m3 .face-bg {
  fill: oklch(92% 0.05 158);
}

.m4 .face-bg {
  fill: oklch(92% 0.075 92);
}

/* ---- friendly progress chips ---- */

.home-progress,
.today-progress {
  display: block;
  margin: 16px 0;
  padding: 15px 16px;
  border-radius: var(--radius-md);
  color: var(--move);
  background: var(--move-soft);
  border: 1px solid color-mix(in oklch, var(--move), var(--paper) 60%);
  font-weight: 800;
  font-size: var(--fs-md);
  text-align: center;
  text-decoration: none;
}

/* ---- cards ---- */

.card {
  margin-bottom: 16px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.exercise .media {
  position: relative;
  height: 168px;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  background: var(--c-soft, var(--move-soft));
  color: var(--c, var(--move));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.exercise .media .stepno {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--paper), white 30%);
  border: 1px solid color-mix(in oklch, var(--c, var(--move)), var(--paper) 60%);
  color: var(--ink);
  font-size: var(--fs-2xs);
  font-weight: 800;
}

.exsvg {
  width: 100%;
  height: 100%;
}

.exsvg .floor {
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.22;
}

.exsvg .pose-a {
  animation: poseBlink 2.6s steps(1, end) infinite;
}

.exsvg .pose-b {
  animation: poseBlink 2.6s steps(1, end) infinite;
  animation-delay: -1.3s;
}

@keyframes poseBlink {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

.exercise h3 {
  margin: 2px 0 6px;
  font-size: var(--fs-xl);
  line-height: 1.15;
  font-weight: 800;
}

.cue,
.why {
  margin: 0 0 8px;
}

.cue {
  font-size: var(--fs-md);
}

.reps {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--c-soft, var(--move-soft));
  color: var(--c, var(--move));
  font-weight: 800;
  font-size: var(--fs-sm);
}

.why {
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ---- buttons ---- */

.done-btn,
.primary-btn,
.share-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: var(--fs-md);
  cursor: pointer;
}

.done-btn .icon,
.primary-btn .icon,
.share-btn .icon {
  width: 24px;
  height: 24px;
}

.done-btn {
  border: 2px solid var(--c, var(--move));
  background: var(--paper);
  color: var(--c, var(--move));
}

.done-btn[aria-pressed="true"] {
  border-color: var(--c, var(--move));
  background: var(--c, var(--move));
  color: var(--on-accent);
}

.primary-btn,
.share-btn {
  border: 2px solid var(--brand);
  background: var(--brand);
  color: var(--on-accent);
}

.secondary-btn {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

/* ---- lessons (Understand) ---- */

.lesson summary {
  min-height: var(--tap);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--learn);
  font-size: var(--fs-lg);
  font-weight: 800;
}

.lesson summary::-webkit-details-marker {
  display: none;
}

.lesson summary .lesson-mark {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--learn-soft);
  color: var(--learn);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.lesson summary .lesson-mark::after {
  content: "+";
}

.lesson[open] summary .lesson-mark::after {
  content: "\2013";
}

.lesson summary .lesson-dot {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--learn-soft);
  color: var(--learn);
}

.lesson summary .lesson-dot .icon {
  width: 24px;
  height: 24px;
}

.lesson p {
  margin: 10px 0 4px;
  font-size: var(--fs-md);
  max-width: var(--measure);
}

/* ---- banners, flare, safety ---- */

.banner,
.action-box {
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  font-size: var(--fs-md);
  font-weight: 700;
}

.banner {
  color: var(--c);
  background: var(--c-soft);
  border: 1px solid color-mix(in oklch, var(--c), var(--paper) 60%);
}

.banner.reassure {
  font-size: var(--fs-lead);
  font-weight: 750;
  line-height: 1.3;
}

.action-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--safe);
  color: var(--on-accent);
  font-weight: 750;
}

.action-box .icon {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
}

.action-link a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 800;
}

.section-heading {
  margin: 26px 0 13px;
  font-size: var(--fs-xl);
  font-weight: 800;
}

.steps,
.flags {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.steps li,
.flags li {
  margin-bottom: 12px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  font-size: var(--fs-md);
}

.steps {
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 60px;
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 14px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: var(--on-accent);
  background: var(--c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.flags li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-color: color-mix(in oklch, var(--safe), var(--line) 35%);
  background: var(--safe-soft);
  font-weight: 600;
}

.flags li::before {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 9px;
  border-radius: 999px;
  background: var(--safe);
}

/* ---- goal screen ---- */

.goal-input {
  width: 100%;
  min-height: var(--tap);
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-md);
}

.goal-input:focus {
  border-color: var(--goal);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.chip {
  min-height: 48px;
  padding: 11px 16px;
  border: 1px solid color-mix(in oklch, var(--goal), var(--paper) 46%);
  border-radius: 999px;
  background: var(--goal-soft);
  color: var(--goal);
  font-size: var(--fs-sm);
  font-weight: 750;
  cursor: pointer;
}

.progress-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 8px 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: var(--learn);
  background: var(--learn-soft);
  border: 1px solid color-mix(in oklch, var(--learn), var(--paper) 62%);
  font-weight: 800;
  font-size: var(--fs-md);
  text-decoration: none;
}

.progress-link .icon {
  width: 24px;
  height: 24px;
}

/* ---- progress screen ---- */

.stat {
  margin-bottom: 12px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.num {
  color: var(--c, var(--brand));
  font-size: var(--fs-3xl);
  font-weight: 800;
  line-height: 1.05;
}

.lbl {
  color: var(--muted);
  font-size: var(--fs-md);
}

.feel-trend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.feel-trend .trend-face {
  width: 38px;
  height: 38px;
}

.feel-trend .none {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  color: var(--subtle);
  background: transparent;
  border: 1px dashed var(--line);
  font-weight: 800;
}

.goal-stat {
  font-weight: 750;
  font-size: var(--fs-md);
  overflow-wrap: anywhere;
}

.disclaimer,
.privacy-note,
.safety-net {
  color: var(--muted);
  font-size: var(--fs-2xs);
  line-height: 1.45;
  max-width: var(--measure);
}

.disclaimer,
.privacy-note {
  margin-inline: auto;
  text-align: center;
}

/* ---- bottom nav ---- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  background: color-mix(in oklch, var(--paper), white 30%);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  box-shadow: 0 -10px 24px rgba(74, 56, 33, 0.07);
}

.tabbar a {
  min-height: 58px;
  padding: 7px 4px;
  border-radius: var(--radius-md);
  color: var(--muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: var(--fs-2xs);
  font-weight: 800;
}

.nav-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.nav-code .icon {
  width: 27px;
  height: 27px;
}

.tabbar a[aria-current="page"] {
  color: var(--brand);
  background: var(--brand-soft);
}

/* ---- toast & install hint ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 30;
  max-width: min(92%, 460px);
  padding: 13px 20px;
  border-radius: 999px;
  color: var(--on-accent);
  background: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(16px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.install-hint {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 6px 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--on-accent);
  background: var(--ink);
  font-size: var(--fs-sm);
}

.install-hint.show {
  display: flex;
}

.install-hint button {
  min-height: 44px;
  margin-left: auto;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-accent);
  font-weight: 800;
  cursor: pointer;
}

.copy-buffer {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.demo-fallback {
  color: var(--muted);
  font-weight: 700;
}

/* ---- focus: accent-independent double ring ---- */

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--paper), 0 0 0 10px var(--focus-halo);
}

/* ---- desktop: a wide care desk, not an enlarged phone ---- */

@media (min-width: 720px) {
  .app {
    width: min(100% - 36px, 1120px);
    min-height: calc(100vh - 36px);
    margin: 18px auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .app-header {
    grid-column: 1 / -1;
    position: relative;
    padding: 18px 24px;
  }

  main {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    padding: 26px 30px 36px;
  }

  .tabbar {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    inset: auto;
    width: auto;
    height: 100%;
    padding: 18px 12px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--panel);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
  }

  .tabbar a {
    min-height: 58px;
    padding: 10px 12px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    font-size: var(--fs-sm);
  }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile.wide {
    grid-column: 1 / -1;
  }
}

@media (min-width: 980px) {
  body {
    display: block;
    padding: 0;
  }

  .app {
    width: min(100% - 44px, 1180px);
    min-height: calc(100vh - 44px);
    grid-template-columns: 264px minmax(0, 1fr);
  }

  main {
    padding: 30px 38px 40px;
  }

  .hero {
    padding: 32px;
  }

  .hello {
    font-size: var(--fs-4xl);
  }

  .tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
  }

  .tile {
    min-height: 150px;
  }

  .tile.wide {
    grid-column: 1 / -1;
    min-height: 0;
    flex-direction: row;
    align-items: center;
  }

  .checkin {
    max-width: 760px;
  }

  .screen-body {
    max-width: 880px;
  }

  .exercise.card {
    display: grid;
    grid-template-columns: minmax(260px, 36%) minmax(0, 1fr);
    gap: 18px 24px;
    align-items: start;
  }

  .exercise .media {
    grid-row: span 6;
    height: 210px;
    margin: 0;
  }

  .done-btn {
    max-width: 300px;
  }

  .lesson,
  .stat,
  .banner,
  .action-box,
  .steps li,
  .flags li {
    max-width: 760px;
  }

  .toast {
    bottom: 32px;
  }
}

/* ---- dark mode: a warm lamplit room at night ---- */

/* Dark theme is driven by the data-theme attribute (set by theme.js before
 * first paint), so a manual choice can override the device setting. A neutral
 * cool charcoal, not a warm brown. */
:root[data-theme="dark"] {
  --page: oklch(20% 0.006 260);
  --paper: oklch(24% 0.007 260);
  --panel: oklch(28% 0.008 260);
  --ink: oklch(94% 0.006 250);
  --muted: oklch(77% 0.01 250);
  --subtle: oklch(67% 0.01 250);
  --line: oklch(40% 0.012 258);

  --brand: oklch(72% 0.1 52);
  --brand-soft: oklch(33% 0.045 52);

  --move: oklch(76% 0.085 162);
  --move-soft: oklch(30% 0.04 158);
  --learn: oklch(77% 0.08 245);
  --learn-soft: oklch(30% 0.04 244);
  --plan: oklch(79% 0.095 67);
  --plan-soft: oklch(32% 0.045 72);
  --goal: oklch(78% 0.08 110);
  --goal-soft: oklch(31% 0.04 110);
  --safe: oklch(75% 0.1 30);
  --safe-soft: oklch(32% 0.04 30);

  --on-accent: oklch(21% 0.006 260);
  --focus-halo: oklch(75% 0.13 64);
  --shadow-xs: none;
  --small-shadow: none;
  --shadow: none;
}

[data-theme="dark"] .tile-icon,
[data-theme="dark"] .token,
[data-theme="dark"] .steps li::before {
  color: oklch(21% 0.006 260);
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .screen,
  .toast,
  .exsvg .pose-a,
  .exsvg .pose-b {
    animation: none;
    transition: none;
  }

  .exsvg .pose-b {
    display: none;
  }
}
