:root {
  --bg: #14110f; --panel: #1e1a17; --panel2: #27221e; --line: #3a322c;
  --text: #f3ece4; --muted: #a8998b; --accent: #e0473c; --gold: #f2b33d;
  --ok: #4cc38a; --bad: #e0473c; --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; padding: 24px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 800; letter-spacing: .08em; margin: 0 10px 20px; }
.brand span { color: var(--accent); margin-left: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--muted); position: relative; }
.nav a i { font-style: normal; }
.nav a.on { background: var(--panel2); color: var(--text); }
.badge { margin-left: auto; background: var(--accent); color: #fff; font-style: normal; font-size: 12px; padding: 1px 7px; border-radius: 99px; }
.sync { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 12px; }
main { padding: 32px clamp(16px, 4vw, 48px) 120px; max-width: 760px; width: 100%; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 5; flex-direction: row; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgba(20,17,15,.92); backdrop-filter: blur(14px); }
  .brand, .sync { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: 12px; padding: 6px 14px; }
  .nav a i { font-size: 20px; }
  .badge { position: absolute; top: 0; right: 4px; }
  main { padding-top: 20px; }
}

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn { border: 0; border-radius: 14px; padding: 13px 20px; font-weight: 700; background: var(--accent); color: #fff; box-shadow: 0 4px 0 #9d2c24; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9d2c24; }
.btn:disabled { background: var(--panel2); color: var(--muted); box-shadow: none; cursor: default; }
.btn.ghost { background: var(--panel2); box-shadow: 0 4px 0 #0c0a09; }
.btn.ok { background: var(--ok); box-shadow: 0 4px 0 #2a8a5d; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.link { background: none; border: 0; color: var(--muted); padding: 4px 6px; }
.link:hover { color: var(--text); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }
.meter { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .4s; }

/* path */
.unit-head { background: linear-gradient(135deg, #b9312a, #e0473c); border-radius: var(--radius); padding: 18px 20px; margin-top: 24px; }
.unit-head small { opacity: .8; letter-spacing: .1em; }
.path { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 28px 0; }
.node { width: 76px; height: 76px; border-radius: 50%; border: 0; font-size: 28px; background: var(--panel2); box-shadow: 0 6px 0 #0c0a09; display: grid; place-items: center; position: relative; }
.node.done { background: var(--gold); box-shadow: 0 6px 0 #b07c1c; }
.node.next { background: var(--accent); box-shadow: 0 6px 0 #9d2c24; animation: pulse 2s infinite; }
.node.locked { opacity: .45; cursor: not-allowed; }
.node-label { text-align: center; font-size: 13px; color: var(--muted); margin-top: -8px; }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* lesson */
.lesson-top { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.lesson-top .meter { flex: 1; height: 14px; margin: 0; }
.lesson-top .meter i { background: var(--ok); }
.q-kind { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.q-prompt { font-size: 24px; font-weight: 700; margin: 0 0 22px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.speak { border: 0; background: var(--panel2); border-radius: 12px; width: 44px; height: 44px; font-size: 20px; }
.speak.big { width: 96px; height: 96px; font-size: 40px; border-radius: 24px; }
.options { display: grid; gap: 10px; }
.opt { text-align: left; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); font-size: 17px; }
.opt.sel { border-color: var(--gold); background: #2e2618; }
.answer-line { min-height: 58px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; margin-bottom: 20px; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); box-shadow: 0 3px 0 #0c0a09; font-size: 16px; }
.chip.used { visibility: hidden; }
.fill-text { font-size: 22px; line-height: 1.6; }
.text-in { width: 100%; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); font-size: 18px; }
.text-in:focus { outline: none; border-color: var(--gold); }
.hint { color: var(--gold); font-size: 14px; }
.accent-keys { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.accent-keys button { border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 6px 10px; }

.feedback { position: fixed; left: 0; right: 0; bottom: 0; padding: 18px clamp(16px, 4vw, 48px) calc(22px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); z-index: 10; }
.feedback .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.feedback.ok { background: #16301f; }
.feedback.bad { background: #3a1714; }
.feedback h3 { margin: 0 0 4px; }
.feedback.ok h3 { color: var(--ok); }
.feedback.bad h3 { color: #ff7a6e; }
@media (min-width: 761px) { .feedback { left: 220px; } }

.result { text-align: center; padding-top: 40px; }
.result .big { font-size: 64px; }

/* words */
.flash { text-align: center; padding: 36px 18px; }
.flash .es { font-size: 32px; font-weight: 800; }
.flash .zh { font-size: 20px; color: var(--gold); margin-top: 16px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 22px; }
.grades button { display: flex; flex-direction: column; gap: 2px; align-items: center; padding: 10px 4px; }
.grades small { font-weight: 400; opacity: .8; font-size: 12px; }
.list { display: grid; gap: 8px; }
.word { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.word .es { font-weight: 700; }
.word .zh { color: var(--muted); flex: 1; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.tag.mistake { color: #ff7a6e; }
.tag.note { color: var(--gold); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }

/* notes */
textarea.note-in { width: 100%; min-height: 110px; resize: vertical; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; line-height: 1.5; }
.note { padding: 14px 16px; }
.note p { margin: 0 0 8px; white-space: pre-wrap; line-height: 1.6; font-size: 16px; }
.note footer { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.sel-pop { position: absolute; z-index: 20; background: var(--gold); color: #1b1408; border: 0; border-radius: 10px; padding: 7px 12px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }

.login { max-width: 360px; margin: 12vh auto; }
.toast { position: fixed; top: 18px; left: 50%; transform: translate(-50%, -80px); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; transition: transform .25s; z-index: 30; }
.toast.show { transform: translate(-50%, 0); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
