/* Amma's Sanskrit — warm, calm, big-type, phone-first */
:root {
  --bg: #fbf6ee;
  --bg-2: #f4ead9;
  --card: #fffdf9;
  --ink: #2b2118;
  --ink-2: #5d4c3c;
  --muted: #8a7764;
  --line: #e7dac5;
  --saffron: #c2560e;
  --saffron-2: #e88a2a;
  --glow: #ffe3b8;
  --gold: #b8892c;
  --leaf: #4d7c3a;
  --shadow: 0 1px 2px rgba(60, 35, 10, .06), 0 6px 24px rgba(60, 35, 10, .08);
  --radius: 18px;
  --fs: 1;                     /* user font scale */
  --dev: "Noto Serif Devanagari", "Tiro Devanagari Sanskrit", serif;
  --kn: "Noto Sans Kannada", "Noto Serif Kannada", sans-serif;
  --serif: "Noto Serif", "Georgia", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1510; --bg-2: #241c15; --card: #261e17; --ink: #f5ead9; --ink-2: #d9c6ae;
    --muted: #a8927a; --line: #3b2f24; --saffron: #f39a4a; --saffron-2: #ffb46b;
    --glow: #5a3512; --gold: #e0b45a; --leaf: #9cc77f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1510; --bg-2: #241c15; --card: #261e17; --ink: #f5ead9; --ink-2: #d9c6ae;
  --muted: #a8927a; --line: #3b2f24; --saffron: #f39a4a; --saffron-2: #ffb46b;
  --glow: #5a3512; --gold: #e0b45a; --leaf: #9cc77f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 var(--sans); overflow-x: hidden;
}
a { color: var(--saffron); }
img { max-width: 100%; display: block; }
.dev { font-family: var(--dev); }
.kn { font-family: var(--kn); }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.topbar .brand { font-family: var(--serif); font-weight: 600; color: var(--ink); text-decoration: none; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand span { color: var(--saffron); }
.iconbtn {
  min-width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: 600 15px var(--sans); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; text-decoration: none;
}
.iconbtn:active { transform: scale(.97); }

/* hero */
.hero { position: relative; margin-bottom: -40px; }
.hero picture img {
  width: 100%; height: min(78vh, 560px); object-fit: cover; object-position: 62% 30%;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 98%),
                      linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
          mask-image: linear-gradient(to bottom, #000 55%, transparent 98%),
                      linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
}
@media (max-width: 700px) {
  /* phones: show the whole photo so everyone is in it; only fade the bottom edge */
  .hero picture img {
    height: auto; aspect-ratio: 900 / 506; object-fit: cover;
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
            mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  }
  body .hero { margin-bottom: 0; }
  body .hero-text { margin-top: -14px; }
}
.hero-text { position: relative; margin-top: -120px; text-align: center; padding: 0 16px; }
.hero-text .namaste { font-family: var(--dev); color: var(--saffron); font-size: 1.15rem; letter-spacing: .02em; }
.hero-text h1 { font-size: clamp(2rem, 8vw, 3.2rem); margin: .1em 0 .05em; }
.hero-text .kn-name { font-family: var(--kn); font-size: 1.3rem; color: var(--ink-2); }

.intro { font-size: 1.12rem; color: var(--ink-2); margin: 28px 0 8px; }
.intro p { margin: 0 0 1em; }
.intro .sig { font-family: var(--serif); font-style: italic; color: var(--muted); }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font: 600 1.7rem/1.1 var(--serif); color: var(--saffron); }
.stat span { font-size: .82rem; color: var(--muted); line-height: 1.3; display: block; margin-top: 4px; }

/* sections + cards */
section { margin: 36px 0; }
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head .kn { color: var(--muted); font-size: 1rem; }
.cards { display: grid; gap: 12px; }
.card {
  display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 14px 16px; box-shadow: var(--shadow); min-height: 84px;
}
.card:active { transform: scale(.99); }
.card .play {
  flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--saffron-2), var(--saffron)); color: #fff; font-size: 20px;
}
.card .t { flex: 1; min-width: 0; }
.card .t .dev { font-size: 1.15rem; line-height: 1.35; display: block; }
.card .t .en { font-weight: 600; display: block; }
.card .t small { color: var(--muted); display: block; margin-top: 2px; }
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg-2); color: var(--ink-2); margin-right: 4px; }

.note {
  background: var(--card); border-left: 4px solid var(--gold); border-radius: 12px;
  padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.note .from { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.blessing { text-align: center; font-family: var(--dev); color: var(--saffron); font-size: 1.2rem; margin: 40px 0 8px; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 120px; }

/* ---------- verse page ---------- */
.verse-head { padding-top: 18px; }
.verse-head .kicker { color: var(--saffron); font-size: .85rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.verse-head h1 { font-size: clamp(1.5rem, 5.5vw, 2.1rem); margin: .1em 0; }
.verse-head .cheer .kn { display: inline; margin-left: 6px; }
.verse-head .sub { color: var(--ink-2); font-family: var(--kn); }
.cheer {
  margin: 12px 0; padding: 10px 14px; border-radius: 14px; background: linear-gradient(135deg, var(--glow), transparent 120%);
  color: var(--ink); font-size: 1rem;
}
.cheer .kn { display: block; }

.controls-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; background: var(--card); }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); min-height: 44px; padding: 0 14px;
  font: 600 15px var(--sans); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--saffron); color: #fff; }
.seg button .dev, .seg button .kn { font-size: 16px; }

.take-picker { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.take-picker::-webkit-scrollbar { display: none; }
.take-picker button {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); border-radius: 22px;
  min-height: 44px; padding: 0 14px; font: 600 14px var(--sans); cursor: pointer;
}
.take-picker button[aria-pressed="true"] { border-color: var(--saffron); color: var(--saffron); background: var(--glow); }

.text { margin: 8px 0 24px; }
.vline {
  padding: 12px 10px; margin: 0 -10px; border-radius: 14px; line-height: 1.9;
  font-size: calc(1.55rem * var(--fs)); transition: background .3s;
  display: flex; flex-wrap: wrap; column-gap: .38em; row-gap: .1em; align-items: baseline;
}
.vline.current { background: color-mix(in srgb, var(--glow) 55%, transparent); }
.vline .lnum { font-size: .55em; color: var(--muted); font-family: var(--sans); width: 100%; line-height: 1; margin-bottom: 2px; display: flex; justify-content: space-between; align-items: center; }
.loopbtn { border: 0; background: none; color: var(--muted); font: 600 12px var(--sans); cursor: pointer; padding: 6px 8px; border-radius: 10px; min-height: 32px; }
.loopbtn[aria-pressed="true"] { color: var(--saffron); background: var(--glow); }
.w {
  display: inline-flex; flex-direction: column; align-items: center; cursor: pointer; border-radius: 10px;
  padding: 0 .12em; transition: background .15s, color .15s; -webkit-tap-highlight-color: transparent;
}
.w .main { line-height: 1.5; }
.w .alt { font-size: .5em; color: var(--ink-2); line-height: 1.2; font-family: var(--sans); font-weight: 500; }
.w.kn .main { font-family: var(--kn); }
.w.dev .main { font-family: var(--dev); }
.w.iast .main { font-family: var(--serif); font-size: .85em; }
.w.on { background: var(--saffron); color: #fff; box-shadow: 0 0 0 4px var(--glow); }
.w.on .alt { color: #fff; opacity: .85; }
.w.done { color: var(--ink-2); }
.w:active { background: var(--glow); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; box-shadow: var(--shadow); }
.panel p { margin: 0 0 .8em; }
.panel p:last-child { margin-bottom: 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.meaning-kn { font-family: var(--kn); font-size: 1.05rem; line-height: 1.75; }

details.panel summary { cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; list-style: none; min-height: 32px; display: flex; align-items: center; justify-content: space-between; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::after { content: "＋"; color: var(--saffron); }
details.panel[open] summary::after { content: "－"; }
details.panel[open] summary { margin-bottom: 10px; }

.wordlist { display: grid; gap: 8px; }
.wordlist .row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.wordlist .row:last-child { border-bottom: 0; }
.wordlist .row .dev { font-size: 1.2rem; }
.wordlist .row .root { font-size: .85rem; color: var(--gold); }

/* bottom player */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(60, 35, 10, .1);
}
.player .inner { max-width: 720px; margin: 0 auto; }
.player .bar { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.player input[type=range] { flex: 1; accent-color: var(--saffron); height: 28px; }
.player .btns { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.player .main-btns { display: flex; align-items: center; gap: 10px; }
.bigplay {
  width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; font-size: 24px;
  background: linear-gradient(135deg, var(--saffron-2), var(--saffron)); box-shadow: 0 4px 14px rgba(194, 86, 14, .35);
  display: grid; place-items: center;
}
.bigplay:active { transform: scale(.96); }
.speed { display: inline-flex; gap: 4px; }
.speed button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2); border-radius: 12px; min-width: 46px; min-height: 40px;
  font: 600 14px var(--sans); cursor: pointer;
}
.speed button[aria-pressed="true"] { background: var(--saffron); color: #fff; border-color: var(--saffron); }
@media (max-width: 400px) {
  .speed button { min-width: 40px; font-size: 13px; }
  .bigplay { width: 56px; height: 56px; }
}

/* bottom sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(30, 18, 8, .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-bg.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .25s ease;
  max-height: 80vh; overflow-y: auto; max-width: 720px; margin: 0 auto; box-shadow: 0 -10px 40px rgba(0,0,0,.2);
}
.sheet.open { transform: none; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet .big { font-family: var(--dev); font-size: 2.2rem; line-height: 1.3; }
.sheet .bigkn { font-family: var(--kn); font-size: 1.4rem; color: var(--ink-2); }
.sheet .iast { font-family: var(--serif); font-style: italic; color: var(--muted); }
.sheet dl { margin: 14px 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.sheet dt { color: var(--muted); font-size: .85rem; padding-top: 3px; }
.sheet dd { margin: 0; }
.sheet .actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1; min-height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  font: 600 16px var(--sans); cursor: pointer;
}
.btn.primary { background: var(--saffron); color: #fff; border-color: var(--saffron); }

/* sync tool */
.sync { position: fixed; top: 64px; right: 10px; z-index: 50; background: var(--card); border: 2px dashed var(--saffron); border-radius: 14px; padding: 10px; width: min(320px, calc(100vw - 20px)); font-size: .85rem; box-shadow: var(--shadow); }
.sync textarea { width: 100%; height: 120px; font: 12px ui-monospace, monospace; }
.sync .tap { width: 100%; min-height: 64px; margin: 8px 0; font-size: 1.1rem; }

.about h2 { margin-top: 1.2em; }
.about .panel .dev { font-size: 1.25rem; }

.toast {
  position: fixed; left: 50%; bottom: 150px; transform: translate(-50%, 20px); z-index: 45; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 99px; font: 600 1rem var(--kn); transition: .3s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spacer { height: 160px; }

/* teacher tips + sandhi parts */
.w.tip { position: relative; }
.w.tip::after {
  content: ""; position: absolute; top: .2em; right: -.05em; width: .32em; height: .32em; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 2px var(--bg);
}
.w.on.tip::after { box-shadow: 0 0 0 2px var(--saffron); }
.tipbox {
  background: color-mix(in srgb, var(--gold) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 14px; padding: 12px 14px; margin: 12px 0;
}
.tipbox b { display: block; margin-bottom: 4px; color: var(--ink); }
.parts { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.part { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.part:last-child { border-bottom: 0; }
.part .dev { font-size: 1.3rem; }
.part .root, .sheet .root { font-size: .85rem; color: var(--gold); }
.stanza { margin-bottom: 6px; }
.stanza .lnum span:first-child { font-weight: 600; color: var(--saffron); font-size: 1.05em; }

/* script-below-word choice + tip language switch */
.under-row { margin-top: -4px; }
.under-label { font-size: .85rem; }
.w .alt.alt-kn { font-family: var(--kn); font-size: .62em; line-height: 1.4; }
.w .alt.alt-dev { font-family: var(--dev); font-size: .52em; }
.w .alt.alt-iast { font-family: var(--sans); }
.tiphead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.tiphead b { margin: 0; }
.seg-sm button { min-height: 34px; padding: 0 10px; font-size: 13px; }
.tipbox .kn { font-family: var(--kn); line-height: 1.7; }

/* pinch-zoom: keep player + sheet at normal size, pinned to the visible part of the screen */
html.zoomed .player,
html.zoomed .sheet {
  left: 0; right: auto; bottom: auto; top: 0; margin: 0; max-width: none;
  width: var(--lw); transform-origin: 0 0; transition: none;
  transform: translate(var(--vl), calc(var(--vt) + var(--vh))) scale(var(--vs)) translateY(-100%);
}
html.zoomed .sheet:not(.open) { visibility: hidden; }

/* light mode: the line under each word should be clearly readable */
:root:not([data-theme="dark"]) .w .alt { color: #4a3a2c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .w .alt { color: var(--ink-2); } }

/* speed: one cycling button on phones, chips on bigger screens */
.speedcycle {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-width: 76px; height: 56px; padding: 0 12px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.speedcycle span { font: 700 1.25rem/1.1 var(--sans); }
.speedcycle small { font: 500 .68rem var(--sans); color: var(--muted); }
.speedcycle small, .speedcycle small * { font-family: var(--sans), var(--kn); }
.speedcycle.slow { border-color: var(--saffron); background: var(--glow); }
.speedcycle.slow span { color: var(--saffron); }
@media (max-width: 600px) {
  .player .speed { display: none; }
  .speedcycle { display: inline-flex; }
}

/* bigger light/dark button on phones */
.themebtn { font-size: 18px; }
@media (max-width: 600px) {
  .themebtn { min-width: 52px; height: 52px; border-radius: 26px; font-size: 24px; }
}

/* install card */
.install {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); margin: 20px 0 4px;
}
.install[hidden] { display: none; }
.install b { display: block; }
.install .kn { color: var(--ink-2); font-size: .95rem; }
.install .btn { flex: 0 0 auto; padding: 0 18px; }
.installsteps { padding-left: 1.3em; }
.installsteps li { margin-bottom: 14px; line-height: 1.6; }
.shareicon { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.w.on .alt { color: #fff !important; }

/* compact script pickers: two labelled groups on one line */
.scriptbar { display: flex; gap: 10px; margin: 10px 0 4px; }
.scriptbar .pick { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scriptbar .cap { font-size: .72rem; font-weight: 600; letter-spacing: .03em; color: var(--muted); padding-left: 4px; text-transform: uppercase; }
.scriptbar .cap .kn { text-transform: none; letter-spacing: 0; }
.seg-c { display: flex; width: 100%; }
.seg-c button { flex: 1 1 0; min-width: 0; padding: 0 4px; min-height: 42px; font-size: 14px; }
.seg-c button .dev, .seg-c button .kn { font-size: 15px; }

/* player: font size next to speed */
.player .right-btns { display: flex; align-items: center; gap: 8px; }
.fontsize button { min-height: 44px; padding: 0 11px; font: 600 15px var(--sans); }
.fontsize button:first-child { font-size: 13px; }
.fontsize button b { font-size: 19px; }
.fontsize sup { font-size: .65em; margin-left: 1px; }
@media (max-width: 600px) {
  .player .main-btns { gap: 6px; }
  .player .main-btns .iconbtn { min-width: 42px; padding: 0 8px; }
  .fontsize button { padding: 0 9px; }
  .speedcycle { min-width: 64px; padding: 0 8px; }
}
@media (max-width: 360px) {
  .player .main-btns .iconbtn { display: none; }
}

/* long compound words wrap instead of pushing the page wider than the screen (matters at A+) */
.vline { min-width: 0; }
.w { max-width: 100%; }
.w .main, .w .alt { overflow-wrap: anywhere; word-break: break-word; text-align: center; }
/* Kannada on the saffron install button must stay white */
.install .btn.primary, .install .btn.primary .kn { color: #fff; }
