/* Kamnae — Clean iOS / One UI book-style math solution reader */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --fg: #1c1c1e;
  --muted: #6e6e73;
  --sep: rgba(60, 60, 67, .16);
  --fill: #e8e8ed;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, .10);
  --ok: #248a3d;
  --ok-soft: rgba(52, 199, 89, .14);
  --warn: #c93400;
  --warn-soft: rgba(255, 149, 0, .12);
  --purple: #5856d6;
  --purple-soft: rgba(88, 86, 214, .11);
  --g7: #007aff;
  --g8: #5856d6;
  --g9: #ff9500;
  --bar: rgba(242, 242, 247, .85);
  --q-bg: #f6f8fb;
  --q-border: #d5dfec;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  --font: "Kantumruy Pro", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans Khmer", sans-serif;
  --font-book: "Khmer OS Siemreap", "Siemreap", "Kantumruy Pro", sans-serif;
  --font-moul: "Khmer OS Muol Light", "Khmer OS Muol", "Moul", serif;
  --font-math: "STIX Two Math", "Cambria Math", "Latin Modern Math", math, serif;
  --nav-h: 48px;
  --subbar-h: 46px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --fg: #f5f5f7; --muted: #98989d; --sep: rgba(84, 84, 88, .55);
    --fill: #2c2c2e; --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .18); --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .16); --warn: #ff9f0a; --warn-soft: rgba(255, 159, 10, .16);
    --purple: #7d7aff; --purple-soft: rgba(125, 122, 255, .18);
    --g7: #0a84ff; --g8: #5e5ce6; --g9: #ff9f0a;
    --bar: rgba(0, 0, 0, .78); --q-bg: #252528; --q-border: rgba(255, 255, 255, .15); --shadow: none; color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --fg: #f5f5f7; --muted: #98989d; --sep: rgba(84, 84, 88, .55);
  --fill: #2c2c2e; --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .18); --ok: #30d158;
  --ok-soft: rgba(48, 209, 88, .16); --warn: #ff9f0a; --warn-soft: rgba(255, 159, 10, .16);
  --purple: #7d7aff; --purple-soft: rgba(125, 122, 255, .18);
  --g7: #0a84ff; --g8: #5e5ce6; --g9: #ff9f0a;
  --bar: rgba(0, 0, 0, .78); --q-bg: #252528; --q-border: rgba(255, 255, 255, .15); --shadow: none; color-scheme: dark;
}

/* Warm Eye-Friendly Sepia Reading Mode */
:root[data-theme="reading"] {
  --bg: #f3ead8; --card: #fbf6ea; --fg: #2b2318; --muted: #756550; --sep: rgba(117, 101, 80, .24);
  --fill: #e8ddc6; --accent: #8c5a2b; --accent-soft: rgba(140, 90, 43, .13); --ok: #2e6b3e;
  --ok-soft: rgba(46, 107, 62, .14); --warn: #a84800; --warn-soft: rgba(168, 72, 0, .12);
  --purple: #6b4e71; --purple-soft: rgba(107, 78, 113, .13);
  --g7: #8c5a2b; --g8: #6b4e71; --g9: #b5651d;
  --bar: rgba(243, 234, 216, .90); --q-bg: #f2e8d2; --q-border: #d7c7a9;
  --shadow: 0 1px 2px rgba(43, 35, 24, .05), 0 6px 18px rgba(43, 35, 24, .06);
  color-scheme: light;
}
:root[data-theme="reading"] body { line-height: 1.95; }
:root[data-theme="reading"] .inner { max-width: 720px; }
:root[data-theme="reading"] .vote { display: none; }
.iconbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 12; background: var(--bar);
}
math { font-family: var(--font-math); font-size: 1.04em; }
.katex { font-size: clamp(12px, 3.35vw, 16.5px); }
.m-flow { line-height: 2.05; }
.m-seg { display: inline-block; white-space: nowrap; vertical-align: baseline; }
.nowrap { white-space: nowrap; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

.inner {
  max-width: 820px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Sticky Nav bar */
.navbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 11;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent; transition: border-color .2s;
}
.navbar.scrolled { border-bottom-color: var(--sep); }
.navbar .inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--nav-h); padding-block: 0; }
.navback { flex: none; color: var(--accent); display: inline-flex; align-items: center; gap: 3px; font-size: 15px; padding: 6px 2px 6px 0; font-weight: 500; }
.navback svg { width: 11px; height: 18px; flex: none; }
.navback span { white-space: nowrap; }
.navtitle { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.navbar.scrolled .navtitle { opacity: 1; }
.navright { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.navbrand { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.iconbtn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--fill); color: var(--fg); }
.iconbtn svg { width: 17px; height: 17px; }

/* Sticky 2-Part Lesson Section Switcher */
.subbar {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--nav-h)); z-index: 10;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.subbar .inner { padding-block: 7px; }
.subseg {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--fill); border-radius: 11px; padding: 3px; gap: 3px;
}
.pill {
  border: 0; border-radius: 9px; padding: 6px 8px; font-size: 14px; font-weight: 500;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.pill:hover { color: var(--fg); }
.pill.active {
  background: var(--card); color: var(--fg); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.pill .cnt {
  font-size: 11.5px; padding: 0 6px; border-radius: 999px;
  background: rgba(128, 128, 128, .16); color: var(--muted); font-weight: 600;
}
.pill.active .cnt { background: var(--accent-soft); color: var(--accent); }

/* Large title */
.large { padding-block: 10px 14px; }
.large .eyebrow {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  color: var(--accent); margin-bottom: 4px; letter-spacing: .01em;
}
.large h1 { margin: 0; font-size: 32px; line-height: 1.35; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.large p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

/* Clean Book Chapter Header (Lesson Page) */
.lesson-head {
  text-align: center;
  padding: 20px 12px 16px;
}
.lesson-kicker {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.lesson-head h1 {
  margin: 0;
  font-size: clamp(24px, 6.5vw, 32px);
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.01em;
}
.lesson-head p {
  margin: 5px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

.section-h { font-size: 13px; color: var(--muted); margin: 26px 16px 8px; letter-spacing: .02em; font-weight: 600; }
.foot-note { font-size: 13px; color: var(--muted); margin: 8px 16px 0; line-height: 1.55; }

/* Search field */
.searchbox { position: relative; }
.searchbox input {
  width: 100%; border: 0; background: var(--fill); color: var(--fg); font: inherit; font-size: 16px;
  border-radius: 12px; padding: 10px 14px 10px 40px; -webkit-appearance: none; appearance: none;
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.results { margin-top: 10px; }

/* Grouped list (iOS settings style) */
.group { background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 12px 16px; position: relative; min-height: 60px; cursor: pointer; background: var(--card);
  transition: background .15s;
}
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 70px; border-top: .5px solid var(--sep); }
.row:active, .row:hover { background: var(--fill); }
.row .t { font-weight: 500; line-height: 1.45; }
.row .s { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.row .chev { width: 8px; height: 14px; color: var(--muted); opacity: .6; }
.row.soon .t { color: var(--muted); }
.badge {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff; background: var(--accent); flex: none;
}
.row.soon .badge { background: var(--fill); color: var(--muted); }

/* Grade tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border-radius: 24px; padding: 18px; box-shadow: var(--shadow);
  display: grid; gap: 14px; transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: scale(.97); }
.tile .icon {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  color: #fff; font-size: 28px; font-weight: 700; background: var(--c);
}
.tile .t { font-size: 19px; font-weight: 600; line-height: 1.35; }
.tile .s { font-size: 14px; color: var(--muted); line-height: 1.4; }
.tile .chev { display: none; }

/* Segmented control */
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--fill); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 7px 4px; font-size: 14.5px; font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }

/* Switch rows (teacher tools) */
.switchrow { cursor: default; grid-template-columns: minmax(0, 1fr) auto; min-height: 52px; }
.switchrow:hover { background: var(--card); }
.switchrow + .switchrow::before { left: 16px; }
.switch { width: 51px; height: 31px; border-radius: 999px; border: 0; background: var(--fill); position: relative; cursor: pointer; padding: 0; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch[aria-checked="true"] { background: #34c759; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Book Section Divider Header */
.book-section {
  scroll-margin-top: calc(var(--nav-h) + var(--subbar-h) + 16px);
  margin-top: 26px;
}
.book-section:first-of-type { margin-top: 6px; }
.sec-banner {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 0 4px 9px; margin-bottom: 12px; border-bottom: 1px solid var(--sep);
}
.sec-banner h2 { margin: 0; font-size: clamp(17px, 4.5vw, 20px); line-height: 1.35; font-weight: 700; color: var(--fg); }
.sec-banner .meta { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; }

/* Solution Cards (Authentic Cambodian Math Book Style inside clean iOS card) */
.exlist { display: grid; gap: 16px; }
.card {
  position: relative; overflow: hidden; background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 22px 24px 16px;
  scroll-margin-top: calc(var(--nav-h) + var(--subbar-h) + 16px);
  transition: box-shadow .25s;
}
.card.flash { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; background: var(--fg); opacity: .065;
  -webkit-mask-image: var(--wm); mask-image: var(--wm); -webkit-mask-size: 230px 120px; mask-size: 230px 120px;
}
:root[data-theme="dark"] .card::before { opacity: .075; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card::before { opacity: .075; }
}
.card > * { position: relative; }
.present .card { font-size: 1.25em; }

/* Book Exercise Heading (e.g. ប្រតិបត្តិទំព័រទី២ / លំហាត់ទី១) */
.book-ex-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
  margin-bottom: 10px;
}
.book-ex-title {
  margin: 0; font-family: var(--font-moul); font-size: clamp(13.5px, 3.8vw, 15.5px); font-weight: 400; color: var(--fg); line-height: 1.65;
}
.book-ex-page {
  font-size: clamp(12px, 3.2vw, 13px); color: var(--muted); font-weight: 400;
}

/* Problem text (ប្រធាន) — crisp, clean uniform editorial frame in Khmer OS Siemreap */
.book-q {
  font-family: var(--font-book);
  font-size: clamp(12.5px, 3.5vw, 16px);
  padding: 13px 15px; margin: 0 0 18px; color: var(--fg); line-height: 1.9;
  background: var(--q-bg);
  border: 1.25px solid var(--q-border);
  border-radius: 14px;
  min-width: 0; overflow-wrap: break-word;
}
.book-q p { margin: 0 0 6px; }
.book-q p:last-child { margin-bottom: 0; }
.q-subs {
  list-style: none; margin: 6px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 18px;
}
.q-subs.single-col { grid-template-columns: 1fr; }
.q-subs li { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.q-subs li > span:last-child { min-width: 0; overflow-wrap: break-word; }
.q-subs .subk { font-weight: 700; flex: none; }

/* Solution block (ដំណោះស្រាយ) — traditional Khmer math solution book layout */
.book-sol-wrap {
  font-family: var(--font-book);
  font-size: clamp(12.5px, 3.5vw, 16px);
  padding-left: 4px; min-width: 0;
  user-select: none; -webkit-user-select: none;
}
.book-sol-h {
  margin: 0 0 8px; font-family: var(--font-moul); font-size: clamp(13px, 3.6vw, 15px); font-weight: 400; color: var(--fg); line-height: 1.65;
}
.book-sol-goal {
  margin: 0 0 8px; color: var(--fg); line-height: 1.85;
}
.book-line { margin: 0 0 5px; line-height: 1.9; overflow-wrap: break-word; }
.book-line.indent { padding-left: 18px; }
.book-eq {
  padding: 4px 0 4px 18px; line-height: 2.0; max-width: 100%;
}

/* Multi-part solution block (ក., ខ., គ., ...) */
.book-sub { margin-top: 14px; min-width: 0; }
.book-sub:first-of-type { margin-top: 6px; }
.book-sub + .book-sub { padding-top: 14px; border-top: .5px solid var(--sep); }
.book-sub-head {
  margin: 0 0 6px; line-height: 2.0; max-width: 100%; overflow-wrap: break-word;
}
.book-sub-k { font-weight: 700; margin-right: 5px; }
.book-sub-body { padding-left: 16px; min-width: 0; }
.book-sub-body .book-eq { padding-left: 12px; }

/* Signature Boxed Conclusion: ដូចនេះ [ ចម្លើយ ] — always side by side */
.sol-done {
  margin-top: 12px;
  display: flex; flex-wrap: nowrap; align-items: center; gap: 8px;
  line-height: 1.9;
}
.done-lbl { font-family: var(--font-moul); font-size: clamp(12px, 3.2vw, 14px); font-weight: 400; color: var(--fg); flex: none; white-space: nowrap; }
.ans-box {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  border: 1.4px solid var(--fg);
  padding: 4px 10px;
  border-radius: 0;
  color: var(--fg);
  font-size: clamp(11.2px, 3.05vw, 15px);
  line-height: 1.85;
  max-width: 100%;
  overflow-wrap: break-word;
}
.ans-box .katex { font-size: 1em; }

/* Inline SVG Number Line */
.numline-wrap {
  margin: 8px 0 10px; padding: 10px 6px 6px; background: var(--bg); border-radius: 12px;
}
.numline-wrap svg { display: block; width: 100%; height: auto; }

/* Clean Book Summary Table (for rounding) */
.math-table-wrap { overflow-x: auto; margin: 10px 0 4px; }
.math-table {
  width: 100%; border-collapse: collapse; font-size: 14.5px; text-align: center;
  border: 1.2px solid var(--fg);
}
.math-table th, .math-table td {
  padding: 7px 10px; border: .8px solid var(--sep); white-space: nowrap;
}
.math-table th { background: var(--bg); font-weight: 700; font-size: 13.5px; color: var(--fg); }
.math-table td.num { font-family: var(--font-math); font-size: 15.5px; font-weight: 600; }
.math-table td.orig { font-weight: 700; text-align: left; }

.hidden-note {
  padding: 18px 16px; border-radius: 14px; background: var(--bg); color: var(--muted);
  text-align: center; font-size: 15px;
}

.cardfoot {
  margin-top: 16px; padding-top: 10px; border-top: .5px solid var(--sep);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px;
  font-size: 12.5px; color: var(--muted);
}
.vote { display: flex; align-items: center; gap: 6px; }
.vote button {
  border: 0; background: var(--fill); color: var(--muted); border-radius: 999px;
  padding: 5px 11px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.vote button svg { width: 15px; height: 15px; }
.vote button[aria-pressed="true"] { background: var(--ok-soft); color: var(--ok); }

/* Sponsor block */
.sponsor {
  display: flex; align-items: center; gap: 12px; padding: 12px 15px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  transition: transform .15s, background .15s;
}
.sponsor:active { transform: scale(.985); }
.sponsor .sponsor-img {
  width: 48px; height: 48px; border-radius: 12px; object-fit: cover; object-position: center 22%;
  flex: none; border: .5px solid var(--sep);
}
.sponsor .txt { min-width: 0; font-size: 14.5px; line-height: 1.45; }
.sponsor .txt strong { display: block; font-weight: 700; color: var(--fg); }
.sponsor .txt small { display: block; color: var(--muted); font-size: 12.5px; }
.sponsor .tag { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--fill); border-radius: 6px; padding: 2px 8px; flex: none; font-weight: 500; }

.empty { background: var(--card); border-radius: 22px; padding: 36px 22px; text-align: center; box-shadow: var(--shadow); }
.empty .ico { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; background: var(--fill); display: grid; place-items: center; color: var(--muted); }
.empty h2 { margin: 0 0 4px; font-size: 19px; }
.empty p { margin: 0; color: var(--muted); font-size: 15px; }

/* Back to top floating button */
.totop {
  position: fixed; right: max(18px, env(safe-area-inset-right, 0px)); bottom: max(22px, env(safe-area-inset-bottom, 0px));
  z-index: 9; width: 44px; height: 44px; border-radius: 999px; border: .5px solid var(--sep);
  background: var(--card); color: var(--accent); box-shadow: 0 4px 16px rgba(0, 0, 0, .14);
  display: grid; place-items: center; cursor: pointer; transition: transform .15s, opacity .2s;
}
.totop:active { transform: scale(.93); }
.totop svg { width: 20px; height: 20px; }

/* Install App Suggestion Banner */
.install-wrap {
  position: fixed; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom, 0px));
  z-index: 20; padding-inline: max(14px, env(safe-area-inset-left, 0px));
  pointer-events: none; animation: sheetUp .35s cubic-bezier(.2, .85, .25, 1);
}
.install-card {
  max-width: 460px; margin: 0 auto; pointer-events: auto;
  background: var(--card); border-radius: 22px; padding: 14px 16px;
  border: .5px solid var(--sep);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .08);
}
.install-row { display: flex; align-items: center; gap: 12px; }
.install-ico { width: 46px; height: 46px; border-radius: 12px; flex: none; box-shadow: 0 2px 8px rgba(0, 122, 255, .25); }
.install-txt { min-width: 0; flex: 1; line-height: 1.4; }
.install-txt strong { display: block; font-size: 15.5px; font-weight: 700; color: var(--fg); }
.install-txt span { display: block; font-size: 13px; color: var(--muted); }
.install-close {
  border: 0; background: var(--fill); color: var(--muted); width: 28px; height: 28px;
  border-radius: 999px; font-size: 18px; line-height: 1; display: grid; place-items: center;
  cursor: pointer; flex: none; align-self: flex-start;
}
.install-close:hover { color: var(--fg); }
.install-guide {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg);
  font-size: 13.5px; line-height: 1.6; color: var(--fg);
}
.install-guide ol { margin: 4px 0 0; padding-left: 20px; }
.install-guide li { margin-bottom: 2px; }
.install-actions { margin-top: 12px; display: flex; gap: 8px; }
.install-btn {
  flex: 1; border: 0; border-radius: 12px; padding: 10px 14px; font-size: 14.5px; font-weight: 600;
  background: var(--accent); color: #fff; cursor: pointer; transition: opacity .15s, transform .15s;
}
.install-btn:active { transform: scale(.98); opacity: .88; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

footer.site { padding-block: 32px max(56px, env(safe-area-inset-bottom, 0px)); text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.7; }

@media (max-width: 640px) {
  .tiles { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .tile { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 20px; }
  .tile .icon { width: 50px; height: 50px; font-size: 24px; border-radius: 14px; }
  .tile .chev { display: block; width: 8px; height: 14px; color: var(--muted); opacity: .6; }
  .large h1 { font-size: 28px; }
  .card { padding: 18px 14px 14px; border-radius: 20px; }
  .book-q { padding: 12px 13px; border-radius: 12px; }
  .book-sol-wrap { padding-left: 0; }
  .book-sub-body { padding-left: 4px; }
  .book-eq { padding-left: 10px; }
  .q-subs { grid-template-columns: 1fr; }
  .totop { width: 40px; height: 40px; right: 14px; bottom: max(18px, env(safe-area-inset-bottom, 0px)); opacity: .92; }
}

@media (max-width: 520px) {
  .navbar.has-back .navbrand { display: none; }
}

@media (max-width: 420px) {
  body { font-size: clamp(13.5px, 3.7vw, 15px); }
  .navback { font-size: clamp(13px, 3.5vw, 14.5px); }
  .navtitle { font-size: clamp(13px, 3.5vw, 14.5px); }
  .navbrand { font-size: 12px; }
  .pill { font-size: clamp(11.5px, 3.2vw, 13px); padding: 6px 4px; gap: 4px; }
  .pill .cnt { font-size: 10.5px; padding: 0 5px; }
  .sec-banner h2 { font-size: clamp(18px, 5vw, 21px); }
  .ans-box { padding: 3px 7px; word-spacing: -0.06em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile, .switch, .switch::after, .chip { transition: none; }
}
