@font-face { font-family: "Tiro Devanagari Sanskrit"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/tiro-devanagari-400-normal.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09; }
@font-face { font-family: "Tiro Devanagari Sanskrit"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/tiro-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Tiro Devanagari Sanskrit"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/tiro-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Tiro Devanagari Sanskrit"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/tiro-latin-ext-400-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Tiro Devanagari Sanskrit"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/tiro-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #0b0a1a;
  --bg-deep: #07060f;
  --ink: #f4efe6;
  --ink-2: rgba(244, 239, 230, 0.70);
  --ink-3: rgba(244, 239, 230, 0.46);
  --line: rgba(244, 239, 230, 0.12);
  --panel: rgba(244, 239, 230, 0.045);
  --gold: #ffd27a;
  --saffron: #f5a524;
  --rose: #e2557a;
  --deva: "Tiro Devanagari Sanskrit", "Noto Serif Devanagari", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --orb: min(76vw, 40vh, 400px);
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  overflow-x: hidden;
}
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vmax 45vmax at 50% 22%, rgba(245, 165, 36, 0.10), transparent 70%),
    radial-gradient(70vmax 60vmax at 80% 90%, rgba(226, 85, 122, 0.07), transparent 70%),
    radial-gradient(90vmax 70vmax at 10% 70%, rgba(90, 80, 200, 0.10), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}
.sky i {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff6e6;
  opacity: 0.5;
  animation: twinkle var(--t, 6s) ease-in-out var(--d, 0s) infinite alternate;
}
@keyframes twinkle { from { opacity: 0.08; } to { opacity: 0.65; } }

a { color: var(--gold); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: #ffe3a8; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 10; background: var(--gold); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.skip:focus { top: 12px; }
kbd { font: 500 0.85em/1 ui-monospace, "SFMono-Regular", Menlo, monospace; padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); }

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 0;
}
.brand { display: inline-flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-latin { font-weight: 650; font-size: 21px; letter-spacing: -0.02em; }
.brand-deva { font-family: var(--deva); font-size: 22px; color: var(--gold); }
.top nav { display: flex; gap: 18px; font-size: 14.5px; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--ink); }

main { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }

/* Stage: orb, verse, controls */
.stage { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 6px; overflow-x: clip; }
.orb-wrap { position: relative; width: var(--orb); height: var(--orb); margin-top: 4px; }
.orb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(150%, 100vw);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.orb-fallback {
  display: none;
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff1d2 0%, var(--gold) 22%, var(--saffron) 52%, var(--rose) 80%, #5a1a46 100%);
  box-shadow: 0 0 calc(40px + 60px * var(--amp, 0)) rgba(255, 210, 122, calc(0.35 + 0.4 * var(--amp, 0)));
  transform: scale(calc(0.96 + 0.06 * var(--amp, 0)));
}
.no-webgl .orb { display: none; }
.no-webgl .orb-fallback { display: block; }
.ring { position: absolute; inset: -3%; width: 106%; height: 106%; transform: rotate(-90deg); pointer-events: none; opacity: 0; transition: opacity 0.6s; }
.loading .ring { opacity: 1; }
.ring circle { fill: none; stroke-width: 0.6; }
.ring-track { stroke: rgba(244, 239, 230, 0.10); }
.ring-fill { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 0.2s linear; }

.play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76px;
  height: 76px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 246, 230, 0.55);
  background: rgba(40, 14, 24, 0.30);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff8ec;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, opacity 0.3s;
}
.play:hover { background: rgba(40, 14, 24, 0.48); transform: translate(-50%, -50%) scale(1.04); }
.play:focus-visible { outline-offset: 5px; border-radius: 50%; }
.play svg { width: 30px; height: 30px; fill: currentColor; }
.play .icon-stop { display: none; }
.speaking .play .icon-play { display: none; }
.speaking .play .icon-stop { display: block; }
.speaking .play { opacity: 0.55; }
.speaking .play:hover, .speaking .play:focus-visible { opacity: 1; }
.play[aria-disabled="true"] { cursor: progress; }

.status { min-height: 1.6em; margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.status.error { color: #ffb4a8; }

.verse { margin: 18px 0 0; width: 100%; }
.verse-text {
  font-family: var(--deva);
  font-size: clamp(24px, 5.6vw, 36px);
  line-height: 1.75;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.verse-text .line { display: block; }
.verse-text .w { transition: color 0.18s, text-shadow 0.18s, opacity 0.25s; }
.playing .verse-text .w { opacity: 0.42; }
.playing .verse-text .w.spoken { opacity: 0.88; }
.playing .verse-text .w.now { opacity: 1; color: #ffe0a3; text-shadow: 0 0 18px rgba(255, 190, 110, 0.75), 0 0 2px rgba(255, 220, 160, 0.9); }
.verse-text .mark { color: var(--ink-3); }
.verse-iast {
  margin-top: 8px;
  font-family: var(--deva);
  font-style: italic;
  font-size: clamp(15px, 3.4vw, 18px);
  line-height: 1.6;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.verse-iast .line { display: block; }
.verse-source { margin-top: 10px; font-size: 13.5px; color: var(--ink-3); }
.verse-source a { color: var(--ink-3); }
.verse-source a:hover { color: var(--ink-2); }

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 122, 0.45);
  background: rgba(255, 210, 122, 0.08);
  color: var(--ink);
  font: 500 15px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.button:hover { background: rgba(255, 210, 122, 0.16); border-color: rgba(255, 210, 122, 0.7); color: var(--ink); }
.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button.ghost { border-color: var(--line); background: transparent; }
.button.ghost:hover { border-color: rgba(244, 239, 230, 0.3); background: var(--panel); }
.button.primary { background: linear-gradient(135deg, var(--gold), var(--saffron)); border: 0; color: #24160a; font-weight: 600; }
.button.primary:hover { background: linear-gradient(135deg, #ffe0a0, #f7b247); color: #24160a; }

.verse-list {
  list-style: none;
  width: 100%;
  margin: 16px 0 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(11, 10, 26, 0.6);
  text-align: left;
  max-height: 340px;
  overflow-y: auto;
}
.verse-list button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: baseline;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.verse-list button:hover { background: var(--panel); }
.verse-list button[aria-current="true"] { background: rgba(255, 210, 122, 0.10); }
.verse-list .first { font-family: var(--deva); font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verse-list .where { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

.timing { min-height: 1.5em; margin: 14px 0 0; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Type your own */
.own {
  margin: 56px auto 0;
  padding: 24px clamp(16px, 4vw, 28px) 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(244, 239, 230, 0.05), rgba(244, 239, 230, 0.02));
}
.own h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.lede { margin: 4px 0 14px; color: var(--ink-2); font-size: 14.5px; }
.own-text {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid rgba(244, 239, 230, 0.2);
  border-radius: 14px;
  background: rgba(7, 6, 15, 0.7);
  color: var(--ink);
  font: 400 22px/1.6 var(--deva);
}
.own-text.latin { font: 400 17px/1.6 var(--sans); }
.own-text::placeholder { color: var(--ink-3); }
.own-text:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-color: transparent; border-radius: 14px; }
.own-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.count { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--ink-2); font: 500 14.5px/1.3 var(--sans); cursor: pointer; text-align: left; }
.switch:hover { color: var(--ink); }
.switch-track { flex: none; width: 40px; height: 24px; border-radius: 999px; background: rgba(244, 239, 230, 0.16); position: relative; transition: background 0.2s; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: transform 0.2s; }
.switch[aria-checked="true"] { color: var(--ink); }
.switch[aria-checked="true"] .switch-track { background: var(--saffron); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); background: #fff8ec; }
.itrans-preview { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 210, 122, 0.06); font: 400 22px/1.6 var(--deva); min-height: 2.2em; overflow-wrap: anywhere; }
.help { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 12px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.help .pair { white-space: nowrap; }
.help .pair [lang="sa"] { font-family: var(--deva); font-size: 16px; color: var(--ink); }
.help .help-note { flex-basis: 100%; }
.note { margin: 10px 0 0; min-height: 1.4em; font-size: 14px; color: #ffcf9e; }
.note:empty { display: none; }
#speak-own { margin-top: 14px; }

/* About, limits, credits */
.prose { margin-top: 64px; }
.prose h2 { font-size: 24px; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 10px; }
.prose h3 { font-size: 17px; font-weight: 600; margin: 28px 0 6px; }
.prose p, .prose li { color: var(--ink-2); }
.prose strong, .prose b { color: var(--ink); }
.facts { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.facts li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; align-items: baseline; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.facts b { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; color: var(--gold); }
.limits { padding-left: 1.2em; }
.limits li { margin: 4px 0; }
.links { margin-top: 26px; }
.credits ul { padding-left: 1.2em; }
.credits li { margin: 6px 0; }
.fine { font-size: 13.5px; color: var(--ink-3); }

.foot {
  max-width: 760px;
  margin: 64px auto 0;
  padding: 20px var(--gutter) max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  font-size: 13.5px;
  color: var(--ink-3);
}
.foot a { color: var(--ink-2); }
.noscript { text-align: center; color: var(--ink-2); }

@media (max-width: 520px) {
  .facts li { grid-template-columns: 1fr; gap: 2px; }
  .play { width: 66px; height: 66px; }
  .own { margin-top: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .sky i { opacity: 0.35; }
}
