/* ToothTruth — styles */
:root {
  --teal: #0f6d75;
  --teal-deep: #0b4f57;
  --teal-soft: #f0f8f8;
  --teal-line: #d8ebeb;
  --ink: #12262b;
  --slate: #5f7a80;
  --slate-2: #5f7a80;
  --line: #eceff1;
  --bg: #ffffff;
  --card: #ffffff;
  --gold: #c98a17;
  --green: #1f9d6b;
  --red: #d1544b;
  --coral: #e56f4a;
  --sun: #f0a541;
  --sky: #3f9dd4;
  --shadow-sm: 0 1px 2px rgba(18, 60, 66, 0.04), 0 2px 8px rgba(18, 60, 66, 0.05);
  --shadow-md: 0 4px 24px rgba(15, 79, 87, 0.09);
  --radius: 16px;
  --tabbar-h: 66px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
button, a, input, textarea { font-family: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.serif { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; }
#app { max-width: 480px; margin: 0 auto; min-height: 100%; background: var(--bg); position: relative; }
svg.icon { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  padding: calc(env(safe-area-inset-top) + 13px) 18px 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand .mark { width: 34px; height: 34px; padding: 6px; border-radius: 10px; background: #fff; border: 1px solid var(--teal-line); box-shadow: var(--shadow-sm); color: var(--teal); flex-shrink: 0; }
.brand .name { font-weight: 700; font-size: 19px; letter-spacing: -0.4px; color: var(--ink); white-space: nowrap; }
.brand .name b { color: var(--teal); font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.streak { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12.5px; font-weight: 700; color: var(--teal-deep); background: var(--teal-soft); padding: 6px 11px; border-radius: 999px; border: 1px solid var(--teal-line); cursor: pointer; }
.streak svg { width: 14px; height: 14px; color: var(--gold); }
.streak.pulse svg { animation: flame .6s ease; }
@keyframes flame { 0% { transform: scale(1); } 40% { transform: scale(1.6) rotate(-8deg); } 100% { transform: scale(1); } }
.lang-btn { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--slate); background: var(--card); border: 1px solid var(--line); padding: 6px 9px; border-radius: 999px; cursor: pointer; }
.lang-btn svg { width: 14px; height: 14px; }
.lang-menu { position: absolute; right: 18px; top: calc(env(safe-area-inset-top) + 54px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; z-index: 40; display: none; min-width: 200px; max-height: 62vh; overflow-y: auto; }
.lang-menu.open { display: block; }
.lang-menu button { display: flex; justify-content: space-between; gap: 14px; width: 100%; padding: 10px 12px; border: none; background: none; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; text-align: start; }
.lang-menu button.on { background: var(--teal-soft); color: var(--teal-deep); }

/* ---------- Views ---------- */
main { padding: 20px 22px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 26px); }
.view { display: none; }
.view.active { display: block; animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-title { font-size: 27px; letter-spacing: -0.5px; margin-bottom: 5px; font-weight: 600; }
.subtle { color: var(--slate); font-size: 14.5px; line-height: 1.5; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--teal); }
.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--slate-2); margin: 28px 2px 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.note { font-size: 12.5px; color: var(--slate-2); line-height: 1.5; }
.note a { color: var(--teal); font-weight: 600; text-decoration: none; }

/* Hero — bright, airy */
.hero {
  background: linear-gradient(155deg, #f2fafa, #e1f2f3);
  color: var(--ink); border: 1px solid var(--teal-line); border-radius: 20px; padding: 24px 22px;
  position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
}
.ring { position: absolute; border-radius: 50%; border: 1.5px solid rgba(15,109,117,0.10); pointer-events: none; }
.ring.a { width: 180px; height: 180px; right: -60px; top: -70px; }
.ring.b { width: 110px; height: 110px; right: -20px; top: -30px; }
.hero .eyebrow { color: var(--teal); position: relative; }
.hero h2 { font-size: 23px; letter-spacing: -0.4px; margin: 8px 0 8px; position: relative; font-weight: 600; }
.hero p { font-size: 14.5px; color: var(--slate); line-height: 1.55; position: relative; }
.hero .cta {
  margin-top: 16px; display: inline-flex; align-items: center; gap: 8px; position: relative;
  background: var(--teal); color: #fff; font-weight: 700; font-size: 14px;
  padding: 11px 16px; border-radius: 12px; border: none; cursor: pointer; box-shadow: var(--shadow-md);
}
.hero .cta svg { width: 16px; height: 16px; }

/* Daily challenge */
.daily {
  border-radius: 20px; padding: 22px; position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--teal-line); box-shadow: var(--shadow-md); margin-top: 16px;
}
.daily-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.daily-top .date { font-size: 12.5px; color: var(--slate-2); font-weight: 600; }
.daily-stmt { font-size: 20px; line-height: 1.4; letter-spacing: -0.3px; font-weight: 500; min-height: 84px; display: flex; align-items: center; }
.tf-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.tf {
  padding: 15px 0; border-radius: 13px; border: 1.5px solid var(--teal-line); background: var(--card);
  font-size: 16px; font-weight: 700; color: var(--teal-deep); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: all .14s ease;
}
.tf:active { transform: scale(0.97); }
.tf svg { width: 19px; height: 19px; }
.reveal { margin-top: 18px; display: none; animation: fade .35s ease; }
.reveal.show { display: block; }
.verdict { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 8px 14px; border-radius: 999px; }
.verdict.correct { color: var(--green); background: #e7f6ef; }
.verdict.wrong { color: var(--red); background: #fbecea; }
.verdict svg { width: 17px; height: 17px; }
.answer-tag { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-left: 4px; }
.answer-tag.t { color: var(--green); }
.answer-tag.f { color: var(--red); }
.explain { font-size: 14.5px; line-height: 1.55; color: var(--slate); margin-top: 12px; }
.explain b { color: var(--ink); }
.source-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--teal); text-decoration: none; }
.source-link svg { width: 14px; height: 14px; }
.come-back { margin-top: 16px; font-size: 13.5px; color: var(--slate-2); display: flex; align-items: center; gap: 8px; }
.come-back svg { width: 16px; height: 16px; color: var(--teal); }
.milestone { margin-top: 14px; background: linear-gradient(135deg, #fff7e6, #ffeccc); border: 1px solid #f3d9a4; border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 600; color: #7a4f05; display: none; }
.milestone.show { display: block; animation: fade .4s ease; }

/* Stats tiles */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-top: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px 8px; text-align: center; box-shadow: var(--shadow-sm); cursor: pointer; }
.stat .num { font-size: 21px; font-weight: 700; color: var(--teal); letter-spacing: -0.5px; }
.stat .lbl { font-size: 11px; color: var(--slate-2); margin-top: 3px; font-weight: 600; }

/* Brush-today card */
.brush-card { display: flex; align-items: center; gap: 14px; margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-sm); cursor: pointer; }
.brush-card .ico { width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(140deg, var(--sky), #2f7fb0); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.brush-card .ico svg { width: 23px; height: 23px; }
.brush-card .b-title { font-weight: 700; font-size: 15.5px; letter-spacing: -0.2px; }
.brush-card .b-sub { font-size: 12.5px; color: var(--slate); margin-top: 2px; }
.brush-dots { margin-left: auto; display: flex; gap: 5px; }
.brush-dots span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--teal-line); }
.brush-dots span.on { background: var(--green); border-color: var(--green); }

/* Rows */
.lesson {
  display: flex; align-items: center; gap: 15px; padding: 16px 17px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 11px;
  cursor: pointer; transition: transform .13s ease; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); text-align: start;
}
.lesson:active { transform: scale(0.985); }
.lesson .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex-shrink: 0; }
.lesson .ico svg { width: 22px; height: 22px; }
.lesson .body { flex: 1; min-width: 0; }
.lesson .l-title { font-weight: 600; font-size: 15.5px; letter-spacing: -0.2px; display: block; }
.lesson .l-sub { font-size: 12.5px; color: var(--slate); margin-top: 3px; line-height: 1.4; display: block; }
.lesson .chev { color: var(--slate-2); }
.lesson .chev svg { width: 20px; height: 20px; }

/* Research library */
.source-pill { font-size: 11px; font-weight: 700; color: var(--teal-deep); background: var(--teal-soft); padding: 5px 10px; border-radius: 999px; letter-spacing: 0.4px; border: 1px solid var(--teal-line); white-space: nowrap; }
.lib-meta { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.lib-meta .count-pill { font-size: 12.5px; font-weight: 700; color: #fff; background: var(--teal); padding: 6px 13px; border-radius: 999px; }
.lib-meta .count-note { font-size: 12.5px; color: var(--slate-2); font-weight: 600; }
.lib-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 12px; overflow: hidden; }
.lib-head { width: 100%; display: flex; align-items: center; gap: 14px; padding: 17px 18px; background: none; border: none; cursor: pointer; text-align: start; }
.lib-head .ico { width: 40px; height: 40px; border-radius: 11px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex-shrink: 0; }
.lib-head .ico svg { width: 20px; height: 20px; }
.lib-head .t { flex: 1; }
.lib-head .t .h { display: block; font-size: 15.5px; font-weight: 600; letter-spacing: -0.2px; color: var(--ink); }
.lib-head .t span { font-size: 12px; color: var(--slate-2); font-weight: 600; }
.lib-head .chev { color: var(--slate-2); transition: transform .25s ease; }
.lib-head .chev svg { width: 19px; height: 19px; }
.lib-section.open .lib-head .chev { transform: rotate(90deg); }
.lib-body { display: none; border-top: 1px solid var(--line); }
.lib-section.open .lib-body { display: block; }
.lib-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); text-decoration: none; }
.lib-item:last-child { border-bottom: none; }
.lib-item:active { background: var(--teal-soft); }
.lib-item .li-body { flex: 1; }
.lib-item .li-title { font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -0.15px; line-height: 1.35; display: block; }
.lib-item .li-desc { font-size: 12.5px; color: var(--slate); line-height: 1.5; margin-top: 3px; display: block; }
.lib-item .li-out { color: var(--slate-2); flex-shrink: 0; margin-top: 2px; }
.lib-item .li-out svg { width: 14px; height: 14px; }
.lib-item .source-pill { font-size: 10px; padding: 4px 8px; margin-top: 1px; }

/* Search */
.search-wrap { position: relative; margin-top: 18px; }
.search-wrap svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--slate-2); stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; }
.search { width: 100%; padding: 14px 16px 14px 45px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-size: 15px; box-shadow: var(--shadow-sm); }
.search::placeholder { color: var(--slate-2); }
.search:focus { border-color: var(--teal); outline: none; }
.no-results { text-align: center; color: var(--slate-2); font-size: 14px; padding: 30px 10px; display: none; }

/* Topic explorer */
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; }
.topic-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px; cursor: pointer; box-shadow: var(--shadow-sm); text-align: start; transition: transform .12s ease; }
.topic-card:active { transform: scale(0.97); }
.topic-card .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; margin-bottom: 10px; }
.topic-card .ico svg { width: 19px; height: 19px; }
.topic-card .tt { font-weight: 600; font-size: 14px; letter-spacing: -0.2px; color: var(--ink); display: block; }
.topic-card .tc { font-size: 10.5px; color: var(--slate-2); margin-top: 3px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; display: block; }
.back-btn { display: inline-flex; align-items: center; gap: 7px; border: none; background: none; color: var(--teal); font-weight: 700; font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 14px; }
.back-btn svg { width: 17px; height: 17px; }
.topic-hero { display: flex; align-items: center; gap: 15px; margin-bottom: 4px; }
.topic-hero .ico { width: 52px; height: 52px; border-radius: 15px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex-shrink: 0; }
.topic-hero .ico svg { width: 26px; height: 26px; }
.topic-hero .cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--slate-2); }
.t-section { margin-top: 20px; }
.t-section h3 { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.9px; color: var(--teal); margin-bottom: 9px; }
.t-section p { font-size: 14.5px; line-height: 1.68; color: var(--slate); }
.t-section p b { color: var(--ink); }
.t-list { list-style: none; }
.t-list li { display: flex; gap: 11px; font-size: 14px; line-height: 1.55; color: var(--slate); padding: 8px 0; border-bottom: 1px solid var(--line); }
.t-list li:last-child { border-bottom: none; }
.t-list li svg { width: 16px; height: 16px; color: var(--teal); flex-shrink: 0; margin-top: 3px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--teal-line); background: var(--card); color: var(--teal-deep); font-size: 13px; font-weight: 700; padding: 8px 13px; border-radius: 999px; cursor: pointer; }
.chip:active { background: var(--teal-soft); }

/* Story */
.story-hero { background: linear-gradient(160deg, #f2fafa 0%, #e1f2f3 100%); color: var(--ink); border: 1px solid var(--teal-line); border-radius: 20px; padding: 28px 24px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 4px; }
.story-hero .ring.a { width: 200px; height: 200px; right: -70px; bottom: -90px; top: auto; }
.story-hero .ring.b { width: 120px; height: 120px; right: -20px; bottom: -50px; top: auto; }
.story-hero .eyebrow { color: var(--teal); position: relative; }
.story-hero h1 { font-size: 28px; letter-spacing: -0.6px; margin-top: 9px; line-height: 1.2; font-weight: 600; position: relative; }
.story-lead { font-size: 17px; line-height: 1.6; color: var(--ink); margin: 22px 2px; letter-spacing: -0.2px; }
.story-lead b { color: var(--teal-deep); }
.story-body { font-size: 15px; line-height: 1.72; color: var(--slate); margin: 0 2px 18px; }
.story-body b { color: var(--ink); font-weight: 600; }
.pullquote { border-left: 3px solid var(--teal); padding: 4px 0 4px 20px; margin: 26px 4px; }
.pullquote p { font-size: 20px; line-height: 1.45; color: var(--ink); letter-spacing: -0.3px; font-weight: 500; }
.pillars { display: grid; gap: 12px; margin-top: 14px; }
.pillar { display: flex; gap: 15px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 17px; box-shadow: var(--shadow-sm); }
.pillar .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex-shrink: 0; }
.pillar .ico svg { width: 21px; height: 21px; }
.pillar h3 { font-size: 15.5px; font-weight: 600; letter-spacing: -0.2px; margin-bottom: 3px; }
.pillar p { font-size: 13px; line-height: 1.5; color: var(--slate); }
.signature { margin: 28px 2px 6px; }
.signature .sig-name { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 20px; color: var(--teal-deep); }
.signature .sig-role { font-size: 12.5px; color: var(--slate-2); margin-top: 3px; font-weight: 600; }

/* Give */
.give-hero { background: linear-gradient(155deg, #f2fafa, #e1f2f3); color: var(--ink); border: 1px solid var(--teal-line); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.give-hero .eyebrow { color: var(--teal); }
.give-hero h2 { font-size: 21px; margin: 8px 0 8px; font-weight: 600; }
.give-hero p { font-size: 14px; color: var(--slate); line-height: 1.55; }
.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin: 0 0 18px; }
.amt { padding: 15px 0; text-align: center; font-weight: 700; font-size: 16px; background: var(--card); border: 1.5px solid var(--line); border-radius: 13px; cursor: pointer; transition: all .13s ease; color: var(--ink); }
.amt.selected { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-deep); }
.btn-primary { width: 100%; padding: 16px; border: none; border-radius: 14px; cursor: pointer; background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -0.2px; text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 9px; box-shadow: var(--shadow-md); }
.btn-primary:active { opacity: 0.92; }
.btn-primary svg { width: 18px; height: 18px; }
.give-note { text-align: center; font-size: 12px; color: var(--slate-2); margin-top: 12px; line-height: 1.5; }
.give-note a { color: var(--teal); font-weight: 600; text-decoration: none; }
.impact-row { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.impact-row:last-child { border-bottom: none; }
.impact-row .ico { width: 40px; height: 40px; border-radius: 11px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex-shrink: 0; }
.impact-row .ico svg { width: 20px; height: 20px; }
.impact-row .txt { font-size: 13.5px; line-height: 1.45; color: var(--slate); }
.impact-row .txt b { color: var(--ink); font-weight: 700; }

/* Kids */
.kids-hero { background: linear-gradient(150deg, #fff5e6, #ffe7db); color: var(--ink); border: 1px solid #f7dcc5; border-radius: 20px; padding: 24px 22px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
.kids-hero .eyebrow { color: var(--coral); }
.kids-hero h2 { font-size: 22px; margin-top: 8px; font-weight: 600; letter-spacing: -0.3px; position: relative; }
.kids-hero p { font-size: 14px; margin-top: 7px; color: var(--slate); line-height: 1.5; position: relative; }
.kids-hero .ring { border-color: rgba(229,111,74,0.14); }
.game-card { display: flex; align-items: center; gap: 15px; width: 100%; padding: 16px 17px; margin-bottom: 11px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .12s ease; text-align: start; }
.game-card:active { transform: scale(0.985); }
.game-card .ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.game-card .ico svg { width: 23px; height: 23px; }
.game-card .ico.c1 { background: linear-gradient(140deg, var(--coral), var(--red)); }
.game-card .ico.c2 { background: linear-gradient(140deg, var(--sky), #2f7fb0); }
.game-card .ico.c3 { background: linear-gradient(140deg, var(--sun), #d98a1a); }
.game-card .ico.c4 { background: linear-gradient(140deg, #6fbf73, #3d9a5a); }
.game-card .g-title { font-weight: 700; font-size: 15.5px; letter-spacing: -0.2px; color: var(--ink); display: block; }
.game-card .g-sub { font-size: 12.5px; color: var(--slate); margin-top: 2px; display: block; }
.game-card .chev { margin-left: auto; color: var(--slate-2); }
.game-card .chev svg { width: 20px; height: 20px; }
.kid-fact { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--sun); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; font-size: 14px; line-height: 1.55; color: var(--slate); }
.kid-fact b { color: var(--ink); }

/* Smile Squad collectibles */
.squad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.squad-slot { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px 10px; text-align: center; box-shadow: var(--shadow-sm); cursor: pointer; }
.squad-slot .av { width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 7px; display: grid; place-items: center; color: #fff; }
.squad-slot .av svg { width: 24px; height: 24px; }
.squad-slot.locked .av { background: var(--line); color: var(--slate-2); }
.squad-slot .sq-name { font-size: 11px; font-weight: 700; color: var(--ink); }
.squad-slot.locked .sq-name { color: var(--slate-2); }
.squad-hint { font-size: 12.5px; color: var(--slate-2); margin-top: 10px; text-align: center; min-height: 18px; }

/* Games shared */
.game-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 16px; gap: 8px; flex-wrap: wrap; }
.stat-chip { font-size: 13px; font-weight: 700; color: var(--teal-deep); background: var(--teal-soft); border: 1px solid var(--teal-line); padding: 7px 12px; border-radius: 999px; }
.game-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }
.game-msg { text-align: center; font-size: 15px; font-weight: 600; color: var(--ink); min-height: 24px; margin-top: 14px; }
.btn-game { display: block; width: 100%; margin-top: 14px; padding: 14px; border: none; border-radius: 13px; cursor: pointer; background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: #fff; font-weight: 700; font-size: 15px; }
.btn-game.secondary { background: var(--teal-soft); color: var(--teal-deep); border: 1.5px solid var(--teal-line); }
.btn-game:active { opacity: 0.92; }
.pa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pa-hole { aspect-ratio: 1; background: var(--teal-soft); border: 1.5px solid var(--teal-line); border-radius: 14px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.pa-hole svg { width: 58%; height: 58%; color: #8a4fbf; visibility: hidden; }
.pa-hole.bug svg { visibility: visible; animation: pop .18s ease; }
.pa-hole.bug { background: #f5e9ff; border-color: #d9bdf2; }
@keyframes pop { from { transform: scale(0.4); } to { transform: scale(1); } }
.mem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.mem-card { aspect-ratio: 1; border-radius: 12px; border: 1.5px solid var(--teal-line); cursor: pointer; background: linear-gradient(140deg, var(--teal), var(--teal-deep)); display: grid; place-items: center; color: #fff; padding: 0; }
.mem-card svg { width: 55%; height: 55%; visibility: hidden; }
.mem-card.up { background: var(--card); color: var(--teal); }
.mem-card.up svg { visibility: visible; }
.mem-card.matched { background: var(--teal-soft); color: var(--teal); cursor: default; }
.mem-card.matched svg { visibility: visible; }
.kq-stmt { font-size: 19px; line-height: 1.45; font-weight: 500; letter-spacing: -0.2px; min-height: 76px; display: flex; align-items: center; }
.kq-progress { font-size: 12.5px; font-weight: 700; color: var(--slate-2); text-transform: uppercase; letter-spacing: 0.6px; }
.kq-feedback { font-size: 15px; font-weight: 700; margin-top: 12px; min-height: 22px; }
.kq-feedback.good { color: var(--green); }
.kq-feedback.bad { color: var(--red); }

/* Brush timer */
.timer-wrap { display: grid; place-items: center; margin: 10px 0 6px; }
.timer-ring { position: relative; width: 220px; height: 220px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring .bg { stroke: var(--teal-line); }
.timer-ring .fg { stroke: var(--teal); stroke-linecap: round; transition: stroke-dashoffset .9s linear; }
.timer-ring .t-num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.timer-ring .t-num .big { font-size: 46px; font-weight: 700; letter-spacing: -1.5px; color: var(--ink); line-height: 1; }
.timer-ring .t-num .small { font-size: 12px; font-weight: 700; color: var(--slate-2); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 6px; }
.phase { text-align: center; margin-top: 14px; }
.phase .p-title { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.phase .p-sub { font-size: 13.5px; color: var(--slate); margin-top: 4px; }
.phase-dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.phase-dots span { width: 34px; height: 6px; border-radius: 3px; background: var(--teal-line); }
.phase-dots span.done { background: var(--green); }
.phase-dots span.now { background: var(--teal); }
.timer-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

/* Stats view */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 6px; }
.day { text-align: center; }
.day .d-dot { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; border: 2px solid var(--line); color: #fff; font-size: 12px; font-weight: 700; }
.day .d-dot svg { width: 16px; height: 16px; }
.day .d-dot.ok { background: var(--green); border-color: var(--green); }
.day .d-dot.miss { background: var(--red); border-color: var(--red); }
.day .d-dot.freeze { background: var(--sky); border-color: var(--sky); }
.day .d-dot.today { border-color: var(--teal); border-style: dashed; }
.day .d-lbl { font-size: 11px; font-weight: 700; color: var(--slate-2); }
.big-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; }
.big-stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-sm); }
.big-stat .num { font-size: 26px; font-weight: 700; color: var(--teal); letter-spacing: -0.8px; }
.big-stat .lbl { font-size: 12px; color: var(--slate-2); font-weight: 600; margin-top: 3px; }
.freeze-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; background: #eef6fc; border: 1px solid #cfe3f3; border-radius: 13px; padding: 13px 15px; font-size: 13.5px; color: #244a63; line-height: 1.45; }
.freeze-row svg { width: 22px; height: 22px; color: var(--sky); flex-shrink: 0; }
.freeze-row b { color: #163448; }

/* Care */
.care-item { text-decoration: none; }
.care-item .ico { background: #eef6fc; color: #2f7fb0; }

/* Tab bar */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255,255,255,0.97); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); display: flex; align-items: stretch; z-index: 30; }
.tab { position: relative; flex: 1; border: none; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--slate-2); font-size: 10.5px; font-weight: 600; padding-top: 8px; transition: color .15s ease; }
.tab svg { width: 22px; height: 22px; padding: 4px 13px; border-radius: 999px; box-sizing: content-box; transition: background .15s ease, transform .15s ease; }
.tab.active { color: var(--teal-deep); font-weight: 800; }
.tab.active svg { background: var(--teal-soft); stroke-width: 2.3; transform: translateY(-1px); }
.tab.active::after { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--teal); }

/* Confetti + toast */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: 0.95; animation: fall 1.9s ease-in forwards; }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(105vh) rotate(720deg); opacity: 0; } }
.toast { position: fixed; bottom: calc(var(--tabbar-h) + 24px); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 70; max-width: 320px; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Ask (AI) ---------- */
.fab {
  position: fixed; right: calc(50% - 240px + 18px); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 35; display: flex; align-items: center; gap: 8px; padding: 12px 16px 12px 14px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 79, 87, 0.28);
}
@media (max-width: 480px) { .fab { right: 18px; } }
.fab svg { width: 18px; height: 18px; }
.fab.hide { display: none; }
.ask-hero { background: linear-gradient(155deg, #f2fafa, #e1f2f3); border: 1px solid var(--teal-line); border-radius: 20px; padding: 20px 20px; position: relative; overflow: hidden; }
.ask-hero .eyebrow { color: var(--teal); }
.ask-hero h1 { font-size: 24px; letter-spacing: -0.5px; margin-top: 6px; font-weight: 600; }
.ask-hero p { font-size: 14px; color: var(--slate); line-height: 1.5; margin-top: 6px; }
.ask-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.ask-badges span i { font-style: normal; }
.ask-badges span { font-size: 11.5px; font-weight: 700; color: var(--teal-deep); background: #fff; border: 1px solid var(--teal-line); padding: 5px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.ask-badges svg { width: 13px; height: 13px; }
.thread { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 120px; }
.msg { max-width: 88%; padding: 13px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.55; animation: fade .25s ease; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: #fff; border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm); }
.msg.ai b { color: var(--ink); }
.msg.ai ul { margin: 8px 0 4px 18px; }
.msg.ai li { margin: 3px 0; }
.msg.ai p + p { margin-top: 8px; }
.msg .who { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--teal); margin-bottom: 6px; }
.msg .who svg { width: 13px; height: 13px; }
.msg img { max-width: 100%; border-radius: 10px; margin-bottom: 8px; display: block; }
.msg .demo-tag { display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 700; color: #7a4f05; background: #fff4dd; border: 1px solid #f3d9a4; padding: 4px 9px; border-radius: 999px; }
.msg .urgent { margin-top: 10px; background: #fbecea; border: 1px solid #f3c4bf; color: #8f2f28; border-radius: 10px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.typing { align-self: flex-start; display: flex; gap: 5px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; border-bottom-left-radius: 6px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); opacity: 0.35; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.suggest { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; margin-top: 14px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.suggest::-webkit-scrollbar { display: none; }
.suggest button { flex-shrink: 0; border: 1.5px solid var(--teal-line); background: var(--card); color: var(--teal-deep); font-size: 13px; font-weight: 600; padding: 9px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.composer { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); margin-top: 14px; background: var(--card); border: 1.5px solid var(--teal-line); border-radius: 18px; padding: 10px 10px 10px 12px; box-shadow: var(--shadow-md); }
.composer .preview { display: none; align-items: center; gap: 10px; margin-bottom: 8px; padding: 6px 8px; background: var(--teal-soft); border-radius: 10px; font-size: 12.5px; color: var(--slate); }
.composer .preview.show { display: flex; }
.composer .preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.composer .preview button { margin-left: auto; border: none; background: none; color: var(--slate); cursor: pointer; padding: 4px; }
.composer .preview button svg { width: 16px; height: 16px; }
.composer .row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; border: none; background: transparent; resize: none; font-size: 15px; line-height: 1.45; color: var(--ink); max-height: 120px; padding: 6px 0; }
.composer textarea::placeholder { color: var(--slate-2); }
.composer textarea:focus { outline: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--teal-line); background: var(--card); color: var(--teal); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.send { background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: #fff; border: none; }
.icon-btn.send:disabled { opacity: .45; cursor: default; }
.ask-note { font-size: 12px; color: var(--slate-2); line-height: 1.5; text-align: center; margin-top: 10px; padding: 0 6px; }

/* ---------- Right-to-left languages (Arabic, Farsi, Urdu) ---------- */
[dir="rtl"] .lesson .chev svg, [dir="rtl"] .game-card .chev svg, [dir="rtl"] .back-btn svg, [dir="rtl"] .hero .cta svg, [dir="rtl"] .icon-btn.send svg { transform: scaleX(-1); }
[dir="rtl"] .lib-head .chev svg { transform: scaleX(-1); }
[dir="rtl"] .lib-section.open .lib-head .chev { transform: rotate(-90deg); }
[dir="rtl"] .lang-menu { right: auto; left: 18px; }
[dir="rtl"] .fab { right: auto; left: calc(50% - 240px + 18px); }
@media (max-width: 480px) { [dir="rtl"] .fab { left: 18px; } }
[dir="rtl"] .pullquote { border-left: none; border-right: 3px solid var(--teal); padding: 4px 20px 4px 0; }
[dir="rtl"] .kid-fact { border-left: 1px solid var(--line); border-right: 4px solid var(--sun); }
[dir="rtl"] .search-wrap svg { left: auto; right: 15px; }
[dir="rtl"] .search { padding: 14px 45px 14px 16px; }
[dir="rtl"] .msg.user { align-self: flex-start; border-bottom-right-radius: 16px; border-bottom-left-radius: 6px; }
[dir="rtl"] .msg.ai { align-self: flex-end; border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
[dir="rtl"] .ring.a, [dir="rtl"] .ring.b { right: auto; left: -60px; }

/* ---------------- Settings · share · native polish ---------------- */
.gear-btn { width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--teal-line); background: var(--card); color: var(--teal); display: grid; place-items: center; cursor: pointer; margin-left: 6px; }
.gear-btn svg { width: 18px; height: 18px; }
.gear-btn:active { background: var(--teal-soft); }
.share-btn { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 14px; border-radius: 999px; border: 1.5px solid var(--teal-line); background: var(--card); color: var(--teal-deep); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.share-btn svg { width: 16px; height: 16px; }
.share-btn:active { background: var(--teal-soft); }
.settings-card { padding: 4px 0; margin-top: 14px; }
.set-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: none; border-top: 1px solid var(--line); background: none; color: var(--ink); text-align: left; font: inherit; text-decoration: none; }
.set-row:first-child { border-top: none; }
.set-row.link { cursor: pointer; }
.set-row.link:active { background: var(--teal-soft); }
.set-row.sub { padding-top: 6px; padding-bottom: 14px; border-top: none; }
.set-row .ico { width: 38px; height: 38px; border-radius: 11px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex-shrink: 0; }
.set-row .ico svg { width: 19px; height: 19px; }
.set-row .body { flex: 1; min-width: 0; }
.set-row .l-title { font-weight: 600; font-size: 15px; letter-spacing: -0.2px; display: block; }
.set-row .l-sub { font-size: 12.5px; color: var(--slate); margin-top: 2px; line-height: 1.4; display: block; }
.set-row .chev { color: var(--slate-2); flex-shrink: 0; }
.set-row .chev svg { width: 18px; height: 18px; }
.set-row.danger .ico { background: #fdf0ee; color: var(--red); }
.set-row.danger .l-title { color: var(--red); }
.set-note { padding: 0 16px 14px; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; border: none; background: #d9e1e3; cursor: pointer; flex-shrink: 0; transition: background .2s; padding: 0; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch.on { background: var(--teal); }
.switch.on .knob { transform: translateX(20px); }
[dir="rtl"] .switch.on .knob { transform: translateX(-20px); }
input[type="time"] { font: inherit; font-weight: 700; color: var(--teal-deep); background: var(--teal-soft); border: 1.5px solid var(--teal-line); border-radius: 10px; padding: 8px 10px; min-width: 110px; text-align: center; }
.legal-links { margin-top: 22px; text-align: center; }
/* iOS / native feel */
button, .tab, .lesson, .topic-card, .squad-slot, .mem-card, .pa-hole, .tf, .chip, .amt { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
html { overscroll-behavior-y: none; -webkit-text-size-adjust: 100%; }
html.native-ios .topbar { padding-top: calc(env(safe-area-inset-top) + 10px); }
html.native-ios .tabbar { height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .switch, .switch .knob, .confetti { transition: none; animation: none; } }

/* Narrow phones: keep brand, streak, language, and settings on one line */
@media (max-width: 400px) {
  .brand { gap: 7px; }
  .brand .name { font-size: 17px; }
  .brand .mark { width: 31px; height: 31px; padding: 5px; }
  .streak { padding: 5px 9px; font-size: 11.5px; gap: 4px; }
  .lang-btn { padding: 5px 7px; font-size: 11.5px; }
  .gear-btn { width: 32px; height: 32px; margin-left: 2px; }
  .gear-btn svg { width: 16px; height: 16px; }
}
