@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,560;9..144,700&family=IBM+Plex+Mono:wght@500;700&family=Noto+Sans+SC:wght@400;500;700&display=swap");

:root {
  --bg: #12100c;
  --bg-2: #1a1611;
  --card: #211c16;
  --line: #3b3329;
  --ink: #f4ead8;
  --mute: #a39480;
  --brass: #e8a54b;
  --brass-2: #f3c27a;
  --vowel: #e07a5f;
  --diphthong: #e8c36a;
  --consonant: #7fb69a;
  --foreign: #7eb8c9;
  --ok: #6fbf8a;
  --bad: #e07a5f;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: calc(64px + var(--safe-b));
  --play-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Noto Sans SC", sans-serif;
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(232,165,75,.1), transparent 46%),
    radial-gradient(700px 380px at 100% 0%, rgba(126,184,201,.06), transparent 40%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, .ph-card:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.app { min-height: 100%; padding: 18px 16px calc(var(--tab-h) + var(--play-h) + 12px); }
.top {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  margin-bottom: 16px;
}
.kicker {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: .22em; text-transform: uppercase; font-size: 10px; color: var(--brass);
}
h1 { font-family: Fraunces, serif; font-size: 1.7rem; line-height: 1.1; font-weight: 700; }
.lede { color: var(--mute); font-size: .9rem; margin-top: 4px; }
.install {
  border: 1px solid var(--brass); background: rgba(232,165,75,.12); color: var(--brass-2);
  border-radius: 999px; padding: 8px 12px; font-size: .8rem; white-space: nowrap;
}
.install[hidden] { display: none; }

.filters, .row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip, .ghost, .solid, .mini {
  border: 1px solid var(--line); background: var(--card); color: var(--mute);
  border-radius: 999px; padding: 8px 13px; font-size: .84rem;
}
.chip.on, .solid { background: var(--brass); border-color: var(--brass); color: #1a1208; font-weight: 700; }
.ghost:active, .chip:active, .mini:active { transform: scale(.98); }
.search {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--ink);
  border-radius: 14px; padding: 12px 14px; margin: 8px 0 14px;
}

.page { display: none; }
.page.on { display: block; }
.h2 { font-family: Fraunces, serif; font-size: 1.25rem; margin-bottom: 4px; }
.hint { color: var(--mute); font-size: .88rem; margin-bottom: 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.ph-card, .word-card, .lesson, .opt {
  background: linear-gradient(180deg, var(--card), #1b1712);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: left;
  color: inherit; position: relative; overflow: hidden;
}
.ph-card::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--line);
}
.ph-card.vowel::before { background: var(--vowel); }
.ph-card.diphthong::before { background: var(--diphthong); }
.ph-card.consonant::before { background: var(--consonant); }
.ph-card.foreign::before { background: var(--foreign); }
.ph-card.playing { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.mw { font-family: "IBM Plex Mono", monospace; font-size: 1.55rem; font-weight: 700; }
.vowel .mw { color: var(--vowel); }
.diphthong .mw { color: var(--diphthong); }
.consonant .mw { color: var(--consonant); }
.foreign .mw { color: var(--foreign); }
.ipa { font-family: "IBM Plex Mono", monospace; color: var(--mute); font-size: .78rem; }
.meta { color: var(--mute); font-size: .8rem; margin-top: 6px; }
.acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mini { padding: 7px 10px; color: var(--ink); }

.player {
  position: fixed; left: 0; right: 0; bottom: var(--tab-h);
  background: rgba(18,16,12,.94); border-top: 1px solid var(--line);
  padding: 10px 14px; z-index: 20; backdrop-filter: blur(12px);
}
.player-in { display: flex; align-items: center; gap: 10px; max-width: 720px; margin: 0 auto; }
.play-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--brass); color: #1a1208;
  font-size: 16px; font-weight: 700; flex: none;
}
.now { min-width: 0; flex: 1; }
.now b { display: block; font-family: "IBM Plex Mono", monospace; }
.now span { color: var(--mute); font-size: .75rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--line); margin-right: 6px; }
.dot.live { background: var(--brass); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #17130f; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  background: none; border: 0; color: var(--mute); padding: 10px 4px 8px; font-size: .72rem;
}
.tab.on { color: var(--brass-2); }
.tab b { display: block; font-family: Fraunces, serif; font-size: 1.05rem; font-weight: 700; }

.sheet {
  position: fixed; inset: 0; background: rgba(8,6,4,.72); display: none; z-index: 30;
  align-items: flex-end; justify-content: center;
}
.sheet.on { display: flex; }
.sheet-card {
  width: min(560px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 22px 18px calc(18px + var(--safe-b));
  max-height: 86vh; overflow: auto;
}
.close { float: right; background: none; border: 0; color: var(--mute); font-size: 1.4rem; }
.big-mw { font-family: "IBM Plex Mono", monospace; font-size: 2.4rem; font-weight: 700; }

.lesson { margin-bottom: 10px; }
.lesson h3 { font-family: Fraunces, serif; margin-bottom: 4px; }
.combo-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.combo-item:first-of-type { border-top: 0; }
.spell { font-family: "IBM Plex Mono", monospace; font-weight: 700; }
.beads { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.bead {
  border: 1px solid var(--line); background: #18140f; color: var(--ink);
  border-radius: 999px; padding: 6px 10px; font-family: "IBM Plex Mono", monospace; font-size: .82rem;
}
.bead.on { border-color: var(--brass); color: var(--brass-2); }

.word-card { width: 100%; margin-bottom: 8px; }
.word-card .en { font-family: Fraunces, serif; font-size: 1.25rem; }
.zh { color: var(--mute); font-size: .88rem; }

.studio { text-align: center; }
.big-play {
  width: 88px; height: 88px; border-radius: 50%; border: 0; background: var(--brass); color: #1a1208;
  font-size: 28px; margin: 8px auto 14px;
}
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.opt.ok { border-color: var(--ok); background: rgba(111,191,138,.1); }
.opt.no { border-color: var(--bad); background: rgba(224,122,95,.12); }
.score { display: flex; justify-content: center; gap: 18px; color: var(--mute); margin: 8px 0; }
.fb { display: none; margin-top: 12px; padding: 10px; border-radius: 10px; }
.fb.on { display: block; }
.fb.ok { background: rgba(111,191,138,.12); }
.fb.no { background: rgba(224,122,95,.12); }
.toast {
  position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  background: #2a241c; border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px;
  z-index: 50; display: none; font-size: .86rem;
}
.toast.on { display: block; }
.banner {
  background: rgba(232,165,75,.1); border: 1px dashed var(--brass); color: var(--brass-2);
  border-radius: 14px; padding: 12px; font-size: .86rem; margin-bottom: 14px;
}
.banner[hidden] { display: none; }

@media (min-width: 800px) {
  .app { max-width: 980px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
