@font-face {
  font-family: "NotoSansTibetanStroke";
  src: url("assets/fonts/NotoSansTibetanStroke.ttf") format("truetype");
  font-display: block;
}
:root {
  --bg: #fff7ed;
  --panel: #ffffff;
  --ink: #1f130d;
  --muted: #6b5a50;
  --brand: #7f1d1d;
  --brand-2: #f59e0b;
  --line: #eadfd4;
  --shadow: 0 14px 40px rgba(78, 32, 12, .12);
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-height: 100vh; }
.app-header { padding: 22px 18px 14px; background: linear-gradient(135deg, #7f1d1d, #b45309); color: white; }
.header-row { display: flex; align-items: center; gap: 14px; max-width: 980px; margin: 0 auto; }
.logo { width: 62px; height: 62px; border-radius: 18px; background: #fff7ed; padding: 6px; }
h1 { margin: 0; font-size: clamp(24px, 5vw, 38px); line-height: 1; }
.subtitle { margin: 6px 0 0; opacity: .9; }
.tabs { max-width: 980px; margin: 16px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tab { border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.14); color: white; padding: 12px; border-radius: 14px; font-weight: 700; font-size: 16px; }
.tab.active { background: white; color: var(--brand); }
main { max-width: 980px; margin: 0 auto; padding: 18px; }
.view { display: none; }
.view.active { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2, .card h3 { margin: 0 0 12px; }
.player-card { display: grid; gap: 12px; }
.seek-panel { display: grid; gap: 6px; }
.time-row { display: flex; justify-content: space-between; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.player-actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.full-width { width: 100%; }
.track-sections { display: grid; gap: 16px; }
.track-section { margin-bottom: 0; }
.track-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-weight: 700; display: grid; gap: 6px; color: var(--muted); }
select, input, button { font: inherit; }
select, input[type="number"] { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fffaf5; color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--brand); }
button { cursor: pointer; }
.primary { background: var(--brand); color: white; border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 800; }
.secondary { background: #fffaf5; color: var(--brand); border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-weight: 800; }
.now-playing { font-weight: 800; font-size: 18px; }
audio { width: 100%; margin: 10px 0; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-top: 12px; }
.track-btn { border: 1px solid var(--line); background: #fffaf5; padding: 10px 8px; border-radius: 12px; font-weight: 800; display: grid; gap: 2px; justify-items: center; }
.track-btn span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.track-btn strong { font-size: 20px; }
.track-btn.active { background: var(--brand); color: white; border-color: var(--brand); }
.track-btn.active span { color: rgba(255,255,255,.82); }
.alphabet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.letter-card { border: 1px solid var(--line); background: #fffaf5; border-radius: 16px; padding: 10px; text-align: center; }
.tibetan { font-family: Kailasa, Kokonor, "Noto Serif Tibetan", serif; font-size: 42px; line-height: 1.15; }
.big-tibetan { font-family: Kailasa, Kokonor, "Noto Serif Tibetan", serif; font-size: clamp(72px, 22vw, 150px); line-height: 1; text-align: center; }
.wylie { font-weight: 800; }
.sound { color: var(--muted); font-size: 13px; }
.tap-hint { margin-top: 4px; color: var(--brand); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.tone-badge { display: inline-flex; margin-top: 6px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.tone-haut { color: #7f1d1d; background: #fee2e2; }
.tone-bas { color: #1e3a8a; background: #dbeafe; }
.builder { display: grid; gap: 14px; }
.builder-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.vowels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.choice { border: 1px solid var(--line); background: #fffaf5; padding: 10px; border-radius: 12px; font-weight: 800; }
.choice.active { background: var(--brand); color: white; }
.result { background: #fffaf5; border: 1px solid var(--line); border-radius: 20px; padding: 16px; text-align: center; }
.notes { color: var(--muted); line-height: 1.55; }
.trace-wrap { position: relative; border: 1px solid var(--line); background: #fffaf5; border-radius: 18px; overflow: hidden; }
#traceCanvas { width: 100%; height: 320px; display: block; touch-action: none; }
.trace-model { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: .18; }
.stroke-panel { display: grid; gap: 12px; margin-bottom: 14px; }
.stroke-stage { position: relative; display: grid; place-items: center; min-height: 330px; border: 1px solid var(--line); background: #fffaf5; border-radius: 18px; overflow: hidden; }
.stroke-glyph { font-family: "NotoSansTibetanStroke"; font-size: min(116vw, 330px); line-height: .95; color: var(--brand); transform: translateY(-4px); }
.stroke-native { position: absolute; right: 14px; bottom: 10px; color: var(--muted); opacity: .45; }
.stroke-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.footer-note { color: var(--muted); font-size: 13px; text-align: center; padding: 10px 0 20px; }
@media (min-width: 760px) {
  .builder-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .player-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .player-actions button { padding: 11px 4px; font-size: 14px; }
}
