:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #16213a;
  --muted: #6b7690;
  --line: #e3e8f2;
  --brand: #1f5fd1;
  --brand-dark: #1b3358;
  --brand-soft: #e8f0fd;
  --heart: #e0364f;
  --ok: #1e9e5a;
  --lyric: 18px;
  --space: 1.7;
}
[data-theme="dark"] {
  --bg: #0f1522; --card: #18202f; --text: #e8edf7; --muted: #93a0b8; --line: #273247;
  --brand: #6ea2ff; --brand-dark: #0b1220; --brand-soft: #1d2a42;
}
[data-theme="sepia"] {
  --bg: #f3ead8; --card: #fbf5e8; --text: #40311c; --muted: #86735a; --line: #e2d5bb;
  --brand: #8a5a1f; --brand-dark: #5b3d18; --brand-soft: #eee0c3;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--brand-dark); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Myanmar", "Myanmar Text", "Padauk", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { max-width: 480px; height: 100%; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }

/* Top bar */
#top { display: flex; align-items: center; gap: 6px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
#top h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.icon-btn:hover { background: var(--brand-soft); }
.icon-btn.on { color: var(--heart); }
.icon-btn.on svg { fill: var(--heart); }
.spacer { width: 36px; flex: none; }

/* View */
#view { flex: 1; overflow-y: auto; padding: 16px 14px 24px; -webkit-overflow-scrolling: touch; }
h2 { font-size: 22px; margin: 0 0 2px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 20px 2px 8px; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; font-size: 14px; line-height: 1.6; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 2px 0; line-height: 1.5; }

.hero { text-align: center; padding: 14px 0 6px; }
.hero h2 { font-size: 30px; }
.hero .logo { width: 132px; height: 132px; margin: 0 auto 10px; border-radius: 30px; display: block; box-shadow: 0 6px 18px rgba(20, 40, 90, .25); }

.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--muted); width: 100%; text-align: left; }
.search input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); min-width: 0; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 4px; font-size: 12px; display: grid; gap: 6px; justify-items: center; }
.quick svg { color: var(--brand); }

.feature { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; border-radius: 14px; padding: 18px 16px; }
[data-theme="dark"] .feature { background: linear-gradient(135deg, #1d2a42, #2c4f94); }
.feature b { display: block; font-size: 18px; }
.feature span { font-size: 13px; opacity: .85; }
.feature .go { margin-left: auto; width: 38px; height: 38px; border-radius: 50%; background: #fff; color: #1b3358; display: grid; place-items: center; }
.feature .go svg { fill: currentColor; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .chip.on, [data-theme="dark"] .btn { color: #0b1220; }

.seg { display: flex; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.seg button { flex: 1; padding: 10px 2px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.seg button.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }

/* Lists */
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .num { width: 30px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.row .body { flex: 1; min-width: 0; }
.row .body b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .body span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .tail { color: var(--muted); display: flex; align-items: center; gap: 2px; font-size: 13px; }
.row .tail svg { width: 18px; height: 18px; }
.row .badge { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.row select { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 8px; max-width: 170px; }
.letter { font-size: 13px; font-weight: 700; color: var(--brand); margin: 16px 4px 6px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 600; margin-top: 14px; }
.btn.ghost { background: none; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.danger { background: none; color: var(--heart); border: 1.5px solid var(--heart); }
.btn:disabled { opacity: .4; }
.btns { display: flex; gap: 10px; }

.toggle { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .15s; }
.toggle.on { background: var(--brand); }
.toggle.on::after { left: 21px; }
.toggle:disabled { opacity: .5; }

/* Hymn detail */
.hymn-head { text-align: center; padding: 4px 0 12px; }
.hymn-head small { color: var(--muted); font-size: 13px; }
.hymn-head h2 { font-size: 21px; text-transform: uppercase; margin: 6px 0; line-height: 1.5; }
.hymn-head p { margin: 0; color: var(--muted); font-size: 14px; }
.tools { display: flex; justify-content: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tools button { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 13px; }
.tools svg { width: 16px; height: 16px; }
.lyrics { font-size: var(--lyric); line-height: var(--space); }
.verse { display: flex; gap: 12px; margin-bottom: 22px; white-space: pre-line; }
.verse i { font-style: normal; color: var(--muted); width: 20px; flex: none; text-align: right; }
.verse.chorus { font-style: italic; padding-left: 32px; color: var(--brand); }
.info { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 2px 14px; }
.info div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info div:last-child { border: 0; }
.info span { color: var(--muted); flex: none; }
.info b { font-weight: 500; text-align: right; }
.pd { color: var(--ok); }
textarea, .field { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; outline: 0; }
textarea { min-height: 110px; resize: vertical; }

/* Player */
.player { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-top: 8px; }
.pbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.pbtn svg { fill: currentColor; stroke: none; }
.pbtn.big { width: 62px; height: 62px; }
.pbtn.big svg { width: 28px; height: 28px; }
.bar { flex: 1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); }
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.now { text-align: center; }
.cover { width: 170px; height: 170px; margin: 6px auto 16px; border-radius: 38px; display: block; box-shadow: 0 6px 18px rgba(20, 40, 90, .25); }
.controls { display: flex; align-items: center; justify-content: center; gap: 26px; margin: 14px 0 6px; }
.controls .icon-btn svg { fill: currentColor; stroke: none; }
.radio { display: flex; align-items: center; gap: 12px; padding: 11px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.radio:last-child { border: 0; }
.radio::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.radio.on::before { border: 5px solid var(--brand); }
.radio.right { background: rgba(30, 158, 90, .14); }
.radio.wrong { background: rgba(224, 54, 79, .12); }
.vol { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.vol:last-child { border: 0; }
.vol span { width: 70px; flex: none; }
input[type=range] { flex: 1; accent-color: var(--brand); min-width: 0; }

/* Sheet music */
.sheet-box { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 12px; overflow: auto; padding: 10px 6px; }
.sheet-box svg { width: 100%; height: auto; display: block; stroke-width: 1; }
.sheet-box img { display: block; width: 100%; height: auto; filter: grayscale(1) contrast(1.25); }
.zoom { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; font-size: 14px; }
.zoom button { width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 18px; }

/* Device photos, recordings, forms */
.ph { position: relative; }
.ph .icon-btn { position: absolute; top: 6px; right: 6px; background: rgba(255, 255, 255, .92); color: #c22; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.ph .pend { position: absolute; left: 6px; top: 6px; background: #b26a00; color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 999px; }
.rec { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.rec-h { display: flex; align-items: center; gap: 8px; }
.rec-h b { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec audio { width: 100%; margin-top: 6px; }
select.field { appearance: auto; }
input[type=file].field { padding: 9px; font-size: 14px; }
label.btn { cursor: pointer; }

/* Learning + quiz */
.step { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); font-size: 15px; }
.step:last-child { border: 0; }
.step .tick { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: #fff; }
.step.done .tick { background: var(--ok); border-color: var(--ok); }
.step .tick svg { width: 14px; height: 14px; stroke-width: 3; }
.progress { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin: 18px 2px 8px; }
.quote { text-align: center; font-size: 19px; font-style: italic; padding: 22px 10px 6px; line-height: 1.5; }
.center { text-align: center; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; text-align: center; font-size: 12px; color: var(--muted); }
.stats b { display: block; font-size: 20px; color: var(--text); }

/* Bottom tabs */
#tabs { display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; padding: 8px 0 7px; font-size: 11px; color: var(--muted); display: grid; gap: 3px; justify-items: center; }
#tabs button.on { color: var(--brand); font-weight: 600; }

/* Bottom sheet */
#sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
#sheet .panel { width: 100%; max-width: 480px; background: var(--bg); border-radius: 18px 18px 0 0; padding: 18px 14px 22px; max-height: 72vh; overflow-y: auto; }
#sheet h3 { margin: 0 0 12px; font-size: 16px; }

/* Presentation */
#present { position: fixed; inset: 0; background: #06080d; color: #fff; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8vh 7vw; text-align: center; }
#present .p-title { font-size: clamp(15px, 2.2vw, 26px); opacity: .7; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4vh; }
#present .p-text { font-size: clamp(21px, 4.4vw, 58px); line-height: 1.45; white-space: pre-line; }
#present .p-bar { position: absolute; bottom: 3vh; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 28px; opacity: .75; }
#present .p-close { position: absolute; top: 2vh; right: 2vw; opacity: .7; }
#present button { color: #fff; padding: 10px; }

#toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); background: #16213a; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13px; z-index: 40; white-space: nowrap; }
