/* ---------- fonts (self-hosted, work offline) ---------- */
@font-face { font-family: 'Noto Sans Telugu'; font-weight: 400; font-display: swap; src: url(../assets/fonts/NotoSansTelugu-400.woff2) format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0C00-0C7F, U+1CDA, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Telugu'; font-weight: 600; font-display: swap; src: url(../assets/fonts/NotoSansTelugu-600.woff2) format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0C00-0C7F, U+1CDA, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans'; font-weight: 400; font-display: swap; src: url(../assets/fonts/NotoSans-400.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Sans'; font-weight: 600; font-display: swap; src: url(../assets/fonts/NotoSans-600.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- design tokens ---------- */
:root {
  --bg: #FFF8F0; --surface: #FFFFFF; --surface-2: #FBEFE2; --text: #2B2118; --muted: #6B5B4D;
  --primary: #B85A0C; --primary-dark: #8F450A; --primary-soft: #FCE3CB; --on-primary: #FFFFFF;
  --accent: #2E7D6B; --accent-soft: #DDF0EA; --border: #EADBC8; --success: #2E7D32; --success-soft: #E3F2E4;
  --danger: #B3261E; --shadow: 0 1px 2px rgba(60, 35, 10, .06), 0 4px 14px rgba(60, 35, 10, .06);
  --radius: 18px; --radius-sm: 12px;
  --night-bg: #120E0B; --night-surface: #1E1813; --night-text: #F3E9DF; --night-muted: #B9A897; --night-border: #3A2F25;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120E; --surface: #221B15; --surface-2: #2B231B; --text: #F3E9DF; --muted: #B9A897;
    --primary: #F0A35A; --primary-dark: #F6BD85; --primary-soft: #3C2A19; --on-primary: #1B130C;
    --accent: #6CC3AE; --accent-soft: #1B3730; --border: #3A2F25; --success: #7BC67E; --success-soft: #1D3320;
    --danger: #F28B82; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17120E; --surface: #221B15; --surface-2: #2B231B; --text: #F3E9DF; --muted: #B9A897;
  --primary: #F0A35A; --primary-dark: #F6BD85; --primary-soft: #3C2A19; --on-primary: #1B130C;
  --accent: #6CC3AE; --accent-soft: #1B3730; --border: #3A2F25; --success: #7BC67E; --success-soft: #1D3320;
  --danger: #F28B82; --shadow: none; color-scheme: dark;
}

html { font-size: 18px; -webkit-text-size-adjust: 100%; }
html[data-size="large"] { font-size: 20px; }
html[data-size="xl"] { font-size: 23px; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Noto Sans', 'Noto Sans Telugu', system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.6; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
html[lang="te"] body { line-height: 1.75; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; margin-top: 1.4rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary-dark); }
.ic { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- layout ---------- */
.view { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(110px + env(safe-area-inset-bottom)); min-height: 100vh; }
body[data-screen="today"] .view, body[data-screen="goal"] .view, body[data-screen="learn"] .view { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
body[data-screen="onboarding"] .view, body[data-screen="sos"] .view, body[data-screen="visualize"] .view, body[data-screen="night"] .view { padding-bottom: 40px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.gap { gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; justify-content: center; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.full { width: 100%; }

/* ---------- top bars ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; min-height: 52px; }
.topbar h1 { flex: 1; text-align: center; font-size: 1.1rem; margin: 0; }
.icon-btn, .icon-btn-space { width: 48px; height: 48px; flex: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 0; background: transparent; color: var(--text); cursor: pointer; text-decoration: none; }
.icon-btn:active { background: var(--surface-2); }
.home-head { display: flex; justify-content: space-between; align-items: center; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .logo { width: 34px; height: 34px; }
.hello { margin: 6px 0 14px; }
.hello h1 { margin-bottom: 2px; }

/* ---------- cards ---------- */
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.card h2:first-child { margin-top: 0; }
.card-label { font-size: .78rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--primary-dark); margin-bottom: 4px; }
html[lang="te"] .card-label { text-transform: none; letter-spacing: 0; font-size: .85rem; }
.goal-card { background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%); border-color: transparent; }
.goal-label { display: flex; gap: 6px; align-items: center; color: var(--primary-dark); font-weight: 600; font-size: .85rem; }
.goal-text { font-size: 1.3rem; font-weight: 600; line-height: 1.35; margin: 6px 0 8px; }
.goal-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; background: var(--surface-2); font-size: .82rem; font-weight: 600; }
.pill.strong { background: var(--primary); color: var(--on-primary); }
.pill.flame { color: var(--primary-dark); background: var(--primary-soft); }
.nudge { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); text-decoration: none; margin-bottom: 14px; font-weight: 600; }
.nudge span { flex: 1; }
.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 600; }
.banner.success { background: var(--success-soft); color: var(--success); }
.quote-line { font-style: italic; color: var(--primary-dark); }
.attention { border-color: var(--accent) !important; }
.attention-text { color: var(--accent); font-weight: 600; }

/* ---------- buttons, inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.ghost { background: transparent; }
.btn.link { border: 0; background: transparent; color: var(--primary-dark); min-height: 44px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.big { min-height: 56px; font-size: 1.05rem; margin-top: 8px; }
.btn.ghost-light { background: transparent; color: var(--night-text); border-color: var(--night-border); }
.btn:disabled { opacity: .5; }
.file-btn { position: relative; }
.input { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; min-height: 48px; margin-bottom: 10px; }
.input:focus, .btn:focus-visible, .chip:focus-visible, .tab:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; border-color: var(--primary); }
.input.big { font-size: 1.05rem; }
textarea.input { resize: vertical; line-height: 1.6; }
.input.time { width: auto; min-width: 9em; flex: none; margin: 0; }
.label { display: block; font-weight: 600; font-size: .9rem; margin: 8px 0 6px; }
.time-row { padding: 8px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.time-row label { font-weight: 600; flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { min-height: 44px; padding: 8px 16px; border-radius: 99px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
details.more { margin: 6px 0 12px; }
details.more summary { cursor: pointer; color: var(--primary-dark); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; margin: 4px 0; }
.check-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: transparent; flex: none; background: var(--surface); }
.check-row input:checked + .check-box { background: var(--success); border-color: var(--success); color: #fff; }
.check-row input:focus-visible + .check-box { outline: 3px solid var(--primary-soft); }
.step-text { font-weight: 600; }
.step-text.done { text-decoration: line-through; color: var(--muted); }
.link-row { text-decoration: none; color: inherit; min-height: 44px; }

/* ---------- rhythm ---------- */
.section-head h2 { margin: 6px 0; }
.rhythm { display: flex; flex-direction: column; gap: 10px; }
.rhythm-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.r-ic { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-dark); flex: none; }
.r-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.r-title { font-weight: 600; }
.rhythm-item.done .r-ic { background: var(--success); color: #fff; }
.rhythm-item.done .r-title { color: var(--success); }
.mini-stats { margin: 12px 0 16px; gap: 10px; flex-wrap: wrap; }
.lesson-card .lesson-title { font-size: 1.15rem; font-weight: 600; }
.affirm-mini { margin-top: 8px; font-style: italic; color: var(--primary-dark); }

/* ---------- lessons ---------- */
.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: inherit; min-height: 64px; }
.lesson-row.locked { opacity: .55; }
.l-num { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.l-num.done { background: var(--success); color: #fff; }
.l-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.l-title { font-weight: 600; }
.lesson-h { font-size: 1.5rem; margin-top: 4px; }
.points, .steps { padding-left: 1.3rem; margin: 0 0 12px; }
.points li, .steps li { margin-bottom: 8px; }
.story { background: var(--surface-2); border: 0; }
.exercise { border-color: var(--accent); }
.affirm { text-align: center; }
.affirm-big { font-size: 1.2rem; font-weight: 600; line-height: 1.5; color: var(--text); }
.affirm .btn { margin-top: 4px; }
.quote { margin: 0 0 16px; padding: 14px 16px; border-left: 4px solid var(--primary); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.quote p { font-style: italic; margin-bottom: 4px; }
.quote cite { color: var(--muted); font-style: normal; font-size: .85rem; }
.lesson-nav { margin-top: 8px; }
.affirm-card.said { border-color: var(--success); }

/* ---------- SOS ---------- */
.sos-body { padding: 10px 0 20px; }
.cancel-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: min(78vw, 300px); aspect-ratio: 1; margin: 20px auto; border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, #E4572E, #B3261E); color: #fff; font: inherit; font-weight: 600; font-size: 1.3rem; cursor: pointer; box-shadow: 0 10px 30px rgba(179, 38, 30, .35); }
.cancel-btn .ic { width: 64px; height: 64px; }
.cancel-btn:active { transform: scale(.96); }
.cancel-btn.pulse { animation: pulse .5s ease; }
.cb-taps { font-size: .85rem; opacity: .9; font-weight: 400; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.option { text-align: left; padding: 14px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; min-height: 56px; }
.option:active { border-color: var(--primary); }
.say-line { margin: 24px 0; font-size: 1.35rem; }
.help-line { color: var(--muted); font-size: .82rem; text-align: center; margin-top: 24px; }

/* ---------- visualization + night closing (always dark) ---------- */
.viz { position: fixed; inset: 0; z-index: 50; background: radial-gradient(circle at 50% 30%, #2A1C10, var(--night-bg) 70%); color: var(--night-text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); text-align: center; overflow-y: auto; }
.viz .btn.primary { background: #F0A35A; border-color: #F0A35A; color: #1B130C; max-width: 360px; }
.viz-ring { position: relative; width: min(64vw, 260px); aspect-ratio: 1; }
.viz-ring svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 8; }
.ring-fg { fill: none; stroke: #F0A35A; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.viz-time { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-time.small-time { position: static; font-size: 1.6rem; }
.viz-phase { font-weight: 600; color: #F0A35A; font-size: 1.05rem; }
.viz-text { font-size: 1.3rem; line-height: 1.6; max-width: 480px; min-height: 5.5em; }
.viz .affirm-big { color: var(--night-text); max-width: 480px; }
.muted-light { color: var(--night-muted); }
.end-badge { width: 84px; height: 84px; border-radius: 50%; background: rgba(240, 163, 90, .15); color: #F0A35A; display: flex; align-items: center; justify-content: center; }
.end-badge .ic { width: 44px; height: 44px; }
body.immersive .nav, body.immersive .fab { display: none !important; }

/* Night screen uses the dark palette regardless of system setting */
body[data-screen="night"] {
  --bg: var(--night-bg); --surface: var(--night-surface); --surface-2: #2B231B; --text: var(--night-text); --muted: var(--night-muted);
  --border: var(--night-border); --primary: #F0A35A; --primary-dark: #F6BD85; --primary-soft: #3C2A19; --on-primary: #1B130C;
  --success: #7BC67E; --success-soft: #1D3320; --accent: #6CC3AE; --accent-soft: #1B3730; --shadow: none; color-scheme: dark;
}
.person-row .input:first-child { flex: 0 0 38%; }
.score-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; flex: none; }
.seg-btn { min-width: 56px; min-height: 44px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.seg-btn.on { background: var(--success); color: #fff; font-weight: 600; }
.seg-btn.on.no { background: var(--surface-2); color: var(--text); }
.score-total { margin: 12px 0 0; font-weight: 600; text-align: center; }

/* ---------- Me ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; }
.stat .num { font-size: 1.5rem; font-weight: 600; color: var(--primary-dark); line-height: 1.2; }
.grid35 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 10px; }
.cell { aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); display: block; }
.legend .cell { width: 16px; }
.cell.l1 { background: #F6C79A; } .cell.l2 { background: #E8913F; } .cell.l3 { background: var(--success); }
.jday { border-bottom: 1px solid var(--border); padding: 4px 0; }
.jday summary { display: flex; justify-content: space-between; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; }
.jday ul { padding-left: 1.1rem; margin: 0 0 10px; }
.jday li { margin-bottom: 4px; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.hist li.done .h-ic { color: var(--success); }
.h-ic { width: 22px; text-align: center; flex: none; }
.about p { margin-bottom: 8px; }

/* ---------- onboarding ---------- */
.onb { max-width: 520px; margin: 0 auto; }
.onb-top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dots span.on { background: var(--primary); width: 22px; border-radius: 99px; }
.onb-hero { text-align: center; margin: 20px 0 24px; }
.onb-hero .logo { width: 84px; height: 84px; margin-bottom: 10px; }
.onb-hero h1 { font-size: 1.6rem; }
.onb-body h2 { font-size: 1.3rem; margin-top: 10px; }

/* ---------- nav + FAB ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav[hidden] { display: none; }
.tab { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 56px; color: var(--muted); text-decoration: none; font-size: .78rem; border-radius: 12px; }
.tab.active { color: var(--primary-dark); font-weight: 600; }
.tab.active .ic { stroke-width: 2.4; }
.fab { position: fixed; right: max(16px, calc(50vw - 264px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 21; display: inline-flex; align-items: center; gap: 6px; padding: 0 18px; height: 52px; border-radius: 99px; border: 0; background: #C2361F; color: #fff; font: inherit; font-weight: 600; box-shadow: 0 6px 18px rgba(179, 38, 30, .35); cursor: pointer; }
.fab[hidden] { display: none; }

/* ---------- toast + modal ---------- */
#toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60; background: #2B2118; color: #FFF8F0; padding: 12px 16px; border-radius: 14px; max-width: calc(100vw - 32px); width: max-content; display: flex; align-items: center; gap: 12px; transition: .25s; font-size: .92rem; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-btn { background: #F0A35A; color: #1B130C; border: 0; border-radius: 10px; padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.modal-wrap { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; }

/* ---------- splash ---------- */
.splash { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.splash .logo { width: 72px; height: 72px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
