:root {
  --bg: #f8faf8; --card: #ffffff; --ink: #192523; --mute: #62726d; --line: #e2e8e4;
  --brand: #0f766e; --brand-2: #14b8a6; --brand-ink: #ffffff; --soft: #eaf5f2;
  --good: #16a34a; --good-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7; --bad: #ea580c; --bad-soft: #ffedd5;
  --gold: #eab308; --silver: #94a3b8; --bronze: #c2733b;
  --shadow: 0 2px 4px rgba(15, 118, 110, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1412; --card: #15221e; --ink: #eaf3f0; --mute: #8ca099; --line: #223530;
    --brand: #2dd4bf; --brand-2: #5eead4; --brand-ink: #042f2c; --soft: #13332c;
    --good-soft: #12321f; --warn-soft: #3a2a0c; --bad: #f97316; --bad-soft: #381f12;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1412; --card: #15221e; --ink: #eaf3f0; --mute: #8ca099; --line: #223530;
  --brand: #2dd4bf; --brand-2: #5eead4; --brand-ink: #042f2c; --soft: #13332c;
  --good-soft: #12321f; --warn-soft: #3a2a0c; --bad: #f97316; --bad-soft: #381f12;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 500 16px/1.45 Nunito, "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 10% 12%, color-mix(in srgb, var(--brand) 4%, transparent) 0%, transparent 40%),
    radial-gradient(circle at 90% 88%, color-mix(in srgb, var(--brand-2) 4%, transparent) 0%, transparent 40%);
  background-attachment: fixed;
}
.zh, [lang="zh"] { font-family: "Noto Sans SC", Nunito, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
#app { max-width: 540px; margin: 0 auto; padding: 18px 16px calc(128px + env(safe-area-inset-bottom)); position: relative; }
#app.wide { max-width: 980px; }
#app.full { padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 800; letter-spacing: -0.2px; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.mute { color: var(--mute); }
.row { display: flex; gap: 10px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.card {
  background: var(--card);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--line);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 20px; border-radius: 16px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; letter-spacing: .2px; min-height: 52px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--brand) 65%, #000); transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--brand) 65%, #000); }
.btn.ghost { background: var(--soft); color: var(--brand); box-shadow: none; border: 1.5px solid transparent; }
.btn.ghost:hover { border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.btn.ghost:active { transform: translateY(1px); }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px;
  background: var(--soft); color: var(--brand); font-weight: 800; font-size: 13px; letter-spacing: .2px;
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.good { background: var(--good-soft); color: var(--good); }
input, select {
  font: inherit; color: var(--ink); background: var(--card); border: 2px solid var(--line);
  border-radius: 14px; padding: 13px 14px; width: 100%; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--soft); }

/* nav */
#nav {
  position: fixed; left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 508px; margin: 0 auto; display: flex; justify-content: space-around; gap: 6px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid var(--line); border-radius: 24px; padding: 7px 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 10;
}
#nav[hidden] { display: none; }
#nav a {
  flex: 1; max-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; border-radius: 14px; color: var(--mute); font-size: 11px; font-weight: 800;
  transition: all .15s ease;
}
#nav a:hover { color: var(--ink); }
#nav a.on { color: var(--brand); background: var(--soft); }
#nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }

/* home */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.stat {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 99px;
  background: var(--card); border: 1.5px solid var(--line); font-weight: 800; font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.03); transition: transform .15s ease;
}
.stat:hover { transform: scale(1.04); }
.stat:first-of-type {
  background: color-mix(in srgb, var(--warn) 10%, var(--card));
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
  color: var(--warn);
}
.stat:last-of-type {
  background: color-mix(in srgb, var(--gold) 12%, var(--card));
  border-color: color-mix(in srgb, var(--gold) 35%, transparent);
  color: color-mix(in srgb, var(--gold) 80%, #92400e);
}
:root[data-theme="dark"] .stat:last-of-type { color: #fde047; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stat:last-of-type { color: #fde047; }
}
.stat .ico { font-size: 17px; display: inline-block; }
.stat:first-of-type .ico { animation: flame-bob 2.4s ease-in-out infinite; }
@keyframes flame-bob { 0%, 100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.15) translateY(-2px); } }

.course { display: flex; gap: 14px; align-items: center; text-decoration: none; cursor: pointer; }
.course:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.course .flag {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  font-weight: 800; font-size: 24px; background: var(--soft); color: var(--brand); flex: none;
  box-shadow: 0 3px 8px rgba(0,0,0,.04); border: 2px solid color-mix(in srgb, currentColor 20%, transparent);
}
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; position: relative; }
.bar > i {
  display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 99px; transition: width .5s cubic-bezier(.34, 1.56, .64, 1); position: relative;
}
.bar > i::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: bar-shine 2.8s infinite;
}
@keyframes bar-shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }

.ring {
  --p: 0; width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), color-mix(in srgb, var(--brand) 15%, var(--line)) 0);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--brand) 25%, transparent);
}
.ring > span {
  width: 52px; height: 52px; border-radius: 50%; background: var(--card); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: var(--ink); box-shadow: inset 0 2px 4px rgba(0,0,0,.04);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick {
  padding: 18px 14px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow);
  text-align: center; border: 2px solid var(--line); transition: all .15s ease;
}
.pick:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); transform: translateY(-2px); }
.pick.on { border-color: var(--brand); background: var(--soft); box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 20%, transparent); }
.pick .big { font-size: 28px; font-weight: 800; margin-bottom: 4px; }

/* path */
.levels {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; margin: 0 -16px 14px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.levels::-webkit-scrollbar { display: none; }
.levels button {
  white-space: nowrap; padding: 9px 18px; border-radius: 99px; background: var(--card);
  box-shadow: 0 2px 6px rgba(0,0,0,.03); border: 1.5px solid var(--line); font-weight: 800;
  font-size: 14px; color: var(--mute); transition: all .16s ease;
}
.levels button:hover { color: var(--ink); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.levels button.on {
  background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 30%, transparent); transform: translateY(-1px);
}

.path {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 6px 0 24px;
}
.path::before {
  content: ""; position: absolute; left: 38px; top: 24px; bottom: 30px; width: 4px;
  background: color-mix(in srgb, var(--line) 90%, var(--brand)); border-radius: 99px; z-index: 0;
}
:root[data-theme="dark"] .path::before { background: color-mix(in srgb, var(--line) 70%, var(--brand)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .path::before { background: color-mix(in srgb, var(--line) 70%, var(--brand)); }
}

.node {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: 18px; background: var(--card); border: 1.5px solid var(--line);
  box-shadow: var(--shadow); text-align: left; width: 100%; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.node:hover {
  transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
}

.node .dot {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; flex: none; background: var(--card); border: 3px solid var(--line);
  color: var(--mute); box-shadow: 0 2px 6px rgba(0,0,0,.04); position: relative; z-index: 2;
  transition: all .2s ease;
}
.node.done {
  border-color: color-mix(in srgb, var(--good) 28%, var(--line));
}
.node.done .dot {
  background: var(--good); border-color: #ffffff; color: #ffffff;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--good) 45%, transparent);
  font-size: 13px; letter-spacing: -1px;
}
.node.next {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 4%, var(--card));
  box-shadow: 0 6px 22px color-mix(in srgb, var(--brand) 18%, transparent);
}
.node.next .dot {
  background: var(--brand); border-color: var(--brand-ink); color: var(--brand-ink);
  box-shadow: 0 0 0 4px var(--soft), 0 4px 14px color-mix(in srgb, var(--brand) 50%, transparent);
  animation: next-bounce 2.2s ease-in-out infinite;
}
@keyframes next-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 7px var(--soft), 0 6px 18px color-mix(in srgb, var(--brand) 55%, transparent); }
}

.node .words {
  font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  margin-top: 2px;
}
.node > div { min-width: 0; flex: 1; }

/* session & lesson screens */
.sess-top {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.sess-top .x {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-size: 20px; color: var(--mute); background: var(--card); border: 1.5px solid var(--line);
  box-shadow: 0 2px 6px rgba(0,0,0,.03); transition: transform .08s ease, background .15s ease;
}
.sess-top .x:hover { background: var(--soft); color: var(--ink); }
.sess-top .x:active { transform: scale(0.94); }

.blocks { display: flex; gap: 6px; flex: 1; align-items: center; }
.blocks i {
  flex: 1; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden;
  position: relative; box-shadow: inset 0 1px 2px rgba(0,0,0,.05);
}
.blocks i > b {
  position: absolute; inset: 0; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 99px; transition: width .35s cubic-bezier(.34, 1.56, .64, 1);
}
.combo {
  font-weight: 800; font-size: 14px; color: var(--warn); min-width: 48px; text-align: right;
  display: flex; align-items: center; justify-content: flex-end; gap: 3px;
  animation: combo-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes combo-pop { 0% { transform: scale(0.85); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }

.stage {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  min-height: calc(100dvh - 120px); justify-content: flex-start; position: relative;
}
.teacher {
  position: relative; width: 140px; height: 140px; flex: none; margin-top: 4px;
}
.teacher img, .teacher video, .teacher .face-ph {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 4px solid var(--card);
  box-shadow: 0 8px 24px rgba(0,0,0,.08); background: var(--soft);
}
.teacher .face-ph { display: grid; place-items: center; font-size: 52px; font-weight: 800; color: var(--brand); }
.teacher::after {
  content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 4px solid var(--brand-2);
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
}
.teacher.talking::after {
  opacity: 1; border-color: var(--brand-2);
  box-shadow: 0 0 20px color-mix(in srgb, var(--brand-2) 50%, transparent);
  animation: pulse-talking 1s ease-in-out infinite;
}
.teacher.listening::after {
  opacity: 1; border-color: #f97316;
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.45);
  animation: pulse-listening 1.2s ease-in-out infinite;
}
@keyframes pulse-talking {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.06); opacity: 0.5; }
}
@keyframes pulse-listening {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.subtitle {
  min-height: 52px; text-align: center; font-size: 20px; font-weight: 700;
  max-width: 480px; line-height: 1.35; padding: 0 8px;
}
.subtitle .tr { display: block; font-size: 15px; color: var(--mute); font-weight: 600; margin-top: 4px; }

.word {
  width: 100%; text-align: center; padding: 26px 18px; border-radius: 24px;
  background: var(--card); border: 2px solid var(--line); box-shadow: var(--shadow);
}
.word .w { font-size: 48px; font-weight: 800; line-height: 1.2; letter-spacing: -0.5px; }
.word .r { font-size: 22px; color: var(--brand); font-weight: 800; margin-top: 6px; letter-spacing: 0.5px; }
.word .m { font-size: 17px; color: var(--mute); font-weight: 600; margin-top: 6px; }
.word img {
  width: 170px; height: 170px; object-fit: cover; border-radius: 18px;
  box-shadow: 0 6px 16px rgba(0,0,0,.08); margin-bottom: 12px; border: 2px solid var(--line);
}

.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.opt {
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 18px 12px;
  font-weight: 800; font-size: 19px; text-align: center; min-height: 76px; box-shadow: 0 4px 0 var(--line);
  transition: transform .08s ease, border-color .15s ease, background .15s ease; cursor: pointer;
}
.opt:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); transform: translateY(-2px); }
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt small { display: block; font-weight: 600; font-size: 13px; color: var(--mute); margin-top: 4px; }
.opt.right {
  border-color: #22c55e; background: color-mix(in srgb, #22c55e 12%, var(--card));
  box-shadow: 0 4px 0 #16a34a; color: #15803d;
  animation: pop-right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
:root[data-theme="dark"] .opt.right { color: #4ade80; background: color-mix(in srgb, #22c55e 18%, var(--card)); }
@keyframes pop-right { 0% { transform: scale(0.96); } 50% { transform: scale(1.04); } 100% { transform: scale(1); } }

/* Mistake feedback is warm and safe (DESIGN.md §17.3) */
.opt.wrong {
  border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 12%, var(--card));
  box-shadow: 0 4px 0 #d97706; color: #b45309;
  animation: gentle-shake .35s ease-in-out;
}
:root[data-theme="dark"] .opt.wrong { color: #fbbf24; background: color-mix(in srgb, #f59e0b 18%, var(--card)); }
@keyframes gentle-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Big thumb-friendly mic */
.mic {
  width: 90px; height: 90px; border-radius: 50%; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; box-shadow: 0 6px 0 color-mix(in srgb, var(--brand) 65%, #000);
  position: relative; flex: none; cursor: pointer; transition: transform .08s ease, background .15s ease;
  margin: 6px auto;
}
.mic:hover { filter: brightness(1.05); }
.mic:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--brand) 65%, #000); }
.mic svg { width: 40px; height: 40px; fill: currentColor; }
.mic.rec {
  background: #ea580c; box-shadow: 0 6px 0 #9a3412; color: #ffffff;
  animation: mic-pulse 1.4s ease-in-out infinite;
}
@keyframes mic-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.mic .lvl {
  position: absolute; inset: -10px; border-radius: 50%; border: 4px solid #f97316;
  opacity: .6; transform: scale(var(--l, 1)); transition: transform .06s ease; pointer-events: none;
}

.actions {
  margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 10px 0;
}

/* Warm, encouraging feedback */
.feedback {
  width: 100%; border-radius: 20px; padding: 16px 20px; font-weight: 800;
  display: flex; align-items: center; gap: 14px; font-size: 17px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06); animation: feedback-slide .25s ease-out;
}
@keyframes feedback-slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.feedback.good {
  background: var(--good-soft); color: var(--good);
  border: 2px solid color-mix(in srgb, var(--good) 30%, transparent);
}
.feedback.mid {
  background: var(--warn-soft); color: var(--warn);
  border: 2px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.feedback.bad {
  background: color-mix(in srgb, #f97316 12%, var(--card)); color: #c2410c;
  border: 2px solid color-mix(in srgb, #ea580c 25%, transparent);
}
:root[data-theme="dark"] .feedback.bad { color: #fb923c; background: color-mix(in srgb, #f97316 16%, var(--card)); }
.feedback .score { font-size: 32px; font-weight: 800; min-width: 44px; text-align: center; }

.dialog { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.bubble {
  max-width: 85%; padding: 12px 18px; border-radius: 20px; background: var(--card);
  box-shadow: var(--shadow); font-weight: 700; font-size: 16px; line-height: 1.4;
  border: 1.5px solid var(--line);
}
.bubble.B, .bubble.me {
  align-self: flex-end; background: var(--soft);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--ink);
}
.bubble .who {
  display: block; font-size: 12px; color: var(--mute); font-weight: 800; margin-bottom: 2px;
  text-transform: uppercase; letter-spacing: .5px;
}
.bubble.playing {
  outline: 3px solid var(--brand-2); box-shadow: 0 0 16px color-mix(in srgb, var(--brand-2) 40%, transparent);
}
.timer { font-size: 42px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.xpfly {
  position: fixed; left: 50%; top: 40%; transform: translateX(-50%);
  font-size: 32px; font-weight: 800; color: #f59e0b; text-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
  pointer-events: none; animation: fly 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards; z-index: 20;
}
@keyframes fly { from { opacity: 1; transform: translate(-50%, 0) scale(1); } to { opacity: 0; transform: translate(-50%, -80px) scale(1.4); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; }

.big-done {
  text-align: center; padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.big-done .em {
  width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto 8px; font-size: 40px; background: var(--good-soft); color: var(--good);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--good) 30%, transparent);
  animation: pop-done 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-done { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }
.stars {
  font-size: 44px; letter-spacing: 8px; color: #f59e0b; margin-bottom: 6px;
  text-shadow: 0 3px 12px rgba(245, 158, 11, 0.35);
}
.stars .off { opacity: .22; filter: grayscale(1); }

/* talk */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 140px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
.composer .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.composer .mic { width: 56px; height: 56px; box-shadow: none; margin: 0; }
.composer .mic svg { width: 26px; height: 26px; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mute); margin: 0 2px; animation: dot 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: .2; } }

/* album & collectible card tiers */
.album {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--card); border-radius: 18px; padding: 14px 10px; text-align: center;
  box-shadow: var(--shadow); border: 2px solid var(--line); border-top: 6px solid var(--line);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  position: relative; overflow: hidden; cursor: pointer;
}
.tile:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.tile .w { font-size: 24px; font-weight: 800; line-height: 1.2; margin-bottom: 3px; }
.tile .m { font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }

/* Tier: Bronze */
.tile.bronze {
  border-top-color: var(--bronze);
  border-color: color-mix(in srgb, var(--bronze) 30%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--bronze) 10%, var(--card)) 0%, var(--card) 45%);
  box-shadow: 0 3px 10px rgba(180, 83, 9, 0.12);
}
.tile.bronze .w { color: color-mix(in srgb, var(--bronze) 70%, var(--ink)); }

/* Tier: Silver */
.tile.silver {
  border-top-color: var(--silver);
  border-color: color-mix(in srgb, var(--silver) 45%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--silver) 18%, var(--card)) 0%, var(--card) 50%);
  box-shadow: 0 3px 12px rgba(148, 163, 184, 0.22);
}
.tile.silver::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(125deg, transparent 40%, rgba(255, 255, 255, 0.3) 50%, transparent 60%);
  pointer-events: none;
}

/* Tier: Gold */
.tile.gold {
  border-top-color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 16%, var(--card)) 0%, var(--card) 50%);
  box-shadow: 0 4px 18px rgba(234, 179, 8, 0.25);
}
.tile.gold .w { color: color-mix(in srgb, var(--gold) 75%, var(--ink)); }
.tile.gold::before {
  content: ""; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(254, 240, 138, 0.4), transparent);
  transform: skewX(-25deg);
  animation: gold-glint 3.6s infinite;
  pointer-events: none;
}
@keyframes gold-glint {
  0%, 75% { left: -100%; }
  100% { left: 200%; }
}

/* Badges section styling */
.album .tile:has(b) {
  border-top-width: 4px;
}
.album .tile:has(b) .w {
  font-size: 32px; margin-bottom: 6px;
}

/* admin */
.engines { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.eng { padding: 12px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); border: 1.5px solid var(--line); }
.eng b { display: block; }
.vram { height: 22px; border-radius: 8px; background: var(--line); overflow: hidden; }
.vram i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--warn)); }
pre.log { background: var(--card); border-radius: 14px; padding: 12px; font-size: 12px; line-height: 1.5; max-height: 320px; overflow: auto; white-space: pre-wrap; box-shadow: var(--shadow); border: 1.5px solid var(--line); margin: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 14px; font-weight: 700;
  font-size: 14px; z-index: 40; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.spin { width: 28px; height: 28px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; min-height: 50vh; gap: 12px; text-align: center; }

/* Strictly respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------ dashboards: teacher & parent */

/* Responsive tables: clean data table on desktop, tactile cards on mobile (< 600px) */
@media (min-width: 601px) {
  table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
  }
  table tr.mute th {
    padding: 10px 12px;
    font-weight: 800;
    letter-spacing: .2px;
    border-bottom: 1.5px solid var(--line);
  }
  table tr:not(.mute) td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    transition: background .12s ease;
  }
  table tr:not(.mute):hover td {
    background: color-mix(in srgb, var(--brand) 5%, transparent);
  }
  table tr:last-child td {
    border-bottom: none;
  }
}

@media (max-width: 600px) {
  table, thead, tbody, th, td, tr {
    display: block;
    width: 100%;
  }
  table tr.mute {
    display: none !important;
  }
  table tr:not(.mute) {
    background: var(--card);
    border: 1.5px solid var(--line) !important;
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,.03);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform .12s ease, border-color .12s ease;
  }
  table tr:not(.mute):hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line)) !important;
    transform: translateY(-1px);
  }
  table td {
    padding: 2px 0 !important;
    border: none !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
  }
  table td:first-child {
    font-size: 17px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line) !important;
    padding-bottom: 8px !important;
    color: var(--ink);
  }
  table td:nth-child(2)::before { content: "Days / 7"; color: var(--mute); font-size: 13px; font-weight: 600; }
  table td:nth-child(3)::before { content: "Answers"; color: var(--mute); font-size: 13px; font-weight: 600; }
  table td:nth-child(4)::before { content: "Accuracy"; color: var(--mute); font-size: 13px; font-weight: 600; }
  table td:nth-child(5)::before { content: "Verified score"; color: var(--mute); font-size: 13px; font-weight: 600; }
  table td:nth-child(6)::before { content: "Confidence"; color: var(--mute); font-size: 13px; font-weight: 600; }
  table td:nth-child(7)::before { content: "Streak"; color: var(--mute); font-size: 13px; font-weight: 600; }
  table td:nth-child(8)::before { content: "Last active"; color: var(--mute); font-size: 13px; font-weight: 600; }
}

/* Dashboard stat & summary cards */
.grid2 .card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.grid2 .card b[style*="font-size:26px"],
.grid2 .card .big {
  letter-spacing: -.5px;
  line-height: 1.15;
}

/* 30-day activity graph styling */
.card[style*="align-items:flex-end"] {
  padding: 16px 14px 10px;
  border-radius: var(--r);
  background: var(--card);
}
.card[style*="align-items:flex-end"] > div {
  background: linear-gradient(180deg, var(--brand-2), var(--brand)) !important;
  border-radius: 4px 4px 0 0;
  transition: transform .12s ease, filter .12s ease;
  cursor: pointer;
}
.card[style*="align-items:flex-end"] > div:hover {
  transform: scaleY(1.06);
  filter: brightness(1.15);
}

/* Verified level source bars */
.card .bar.grow {
  height: 9px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

/* Details and expandable exam review */
details summary {
  cursor: pointer;
  padding: 6px 0;
  font-weight: 700;
  color: var(--mute);
  transition: color .12s ease;
}
details summary:hover {
  color: var(--ink);
}
details[open] summary {
  margin-bottom: 8px;
  color: var(--brand);
}

/* Parent dashboard children cards */
a.card.col {
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
a.card.col:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

/* ------------------------------------------------------------ v2 UI Polish (Job 025 / REDESIGN.md §2–§4) */

/* Subject color palette variables */
:root {
  --subj-zh: #dc2626;
  --subj-zh-soft: #fef2f2;
  --subj-en: #2563eb;
  --subj-en-soft: #eff6ff;
  --subj-math: #7c3aed;
  --subj-math-soft: #f5f3ff;
  --subj-physics: #0891b2;
  --subj-physics-soft: #ecfeff;
  --subj-chemistry: #16a34a;
  --subj-chemistry-soft: #f0fdf4;
}
:root[data-theme="dark"] {
  --subj-zh: #f87171;
  --subj-zh-soft: #2a1215;
  --subj-en: #60a5fa;
  --subj-en-soft: #121e36;
  --subj-math: #a78bfa;
  --subj-math-soft: #201338;
  --subj-physics: #22d3ee;
  --subj-physics-soft: #0c2530;
  --subj-chemistry: #4ade80;
  --subj-chemistry-soft: #0f2b1d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --subj-zh: #f87171;
    --subj-zh-soft: #2a1215;
    --subj-en: #60a5fa;
    --subj-en-soft: #121e36;
    --subj-math: #a78bfa;
    --subj-math-soft: #201338;
    --subj-physics: #22d3ee;
    --subj-physics-soft: #0c2530;
    --subj-chemistry: #4ade80;
    --subj-chemistry-soft: #0f2b1d;
  }
}

/* 1. Onboarding & selection rows */
body .onb {
  animation: onb-fade .24s ease-out;
}
@keyframes onb-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
body .pick-row {
  cursor: pointer;
  border: 2px solid var(--line);
  transition: transform .14s cubic-bezier(0.16, 1, 0.3, 1), border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  position: relative;
  overflow: hidden;
}
body .pick-row:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
body .pick-row:active {
  transform: scale(0.985) translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
body .pick-row:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
body .pick-row .ico {
  background: var(--soft);
  transition: transform .18s ease;
}
body .pick-row:hover .ico {
  transform: scale(1.08);
}
body .pick-row .grow b {
  font-size: 17px;
  color: var(--ink);
}
body .chip-btn {
  cursor: pointer;
  transition: transform .12s cubic-bezier(0.16, 1, 0.3, 1), border-color .15s ease, background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
body .chip-btn:hover {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--soft) 50%, var(--card));
  transform: translateY(-1px);
}
body .chip-btn:active {
  transform: scale(0.95);
}
body .chip-btn.on {
  border-color: var(--brand);
  background: var(--soft);
  color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 3px 12px color-mix(in srgb, var(--brand) 22%, transparent);
}

/* 2. Hero card: depth and motion */
body .hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 24px;
  padding: 22px 20px;
  background: linear-gradient(135deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 65%, #4338ca) 52%, color-mix(in srgb, var(--brand) 40%, #312e81) 100%);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--brand) 38%, transparent);
  border: 1.5px solid color-mix(in srgb, #ffffff 22%, transparent);
  transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .2s cubic-bezier(0.16, 1, 0.3, 1), border-color .2s ease;
  text-decoration: none;
}
:root[data-theme="dark"] body .hero,
body[data-theme="dark"] .hero {
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 75%, #042f2c) 0%, color-mix(in srgb, var(--brand) 55%, #1e1b4b) 52%, #0f172a 100%);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body .hero {
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 75%, #042f2c) 0%, color-mix(in srgb, var(--brand) 55%, #1e1b4b) 52%, #0f172a 100%);
    border-color: color-mix(in srgb, var(--brand) 30%, transparent);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  }
}
body .hero::before {
  content: "";
  position: absolute;
  top: -45px;
  right: -35px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  transition: transform .35s ease, opacity .35s ease;
}
body .hero::after {
  content: "";
  position: absolute;
  bottom: -65px;
  left: -45px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand-2) 35%, transparent) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
body .hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--brand) 46%, transparent);
  border-color: color-mix(in srgb, #ffffff 35%, transparent);
}
body .hero:hover::before {
  transform: scale(1.18);
  opacity: 0.95;
}
body .hero:active {
  transform: translateY(0);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 32%, transparent);
}
body .hero .kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 11px;
  border-radius: 99px;
  backdrop-filter: blur(8px);
  margin-bottom: 6px;
  width: fit-content;
  position: relative;
  z-index: 1;
}
body .hero .hero-title {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.25;
  margin: 4px 0 16px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  position: relative;
  z-index: 1;
}
body .hero .hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 15px;
  padding: 11px 22px;
  position: relative;
  z-index: 1;
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
body .hero:hover .hero-btn {
  transform: translateX(2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

/* Home secondary cards (Sprint & Goal) */
body .sprint-card {
  border: 1.5px solid color-mix(in srgb, var(--brand) 25%, var(--line));
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
body .sprint-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}
body .goal-card {
  border: 1.5px solid var(--line);
}
body .wk i {
  transition: background-color .2s ease, transform .2s ease;
}
body .wk.on i {
  box-shadow: 0 2px 6px color-mix(in srgb, var(--brand) 35%, transparent);
}

/* 3. Smooth .qdots progress */
body .qdots {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}
body .qdots i {
  height: 8px;
  border-radius: 99px;
  background: var(--line);
  transition: background-color .3s ease, transform .25s ease, box-shadow .25s ease;
}
body .qdots i.done {
  background: var(--brand);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--brand) 35%, transparent);
}
body .qdots i.now {
  background: color-mix(in srgb, var(--brand) 65%, var(--line));
  transform: scaleY(1.3);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--brand) 28%, transparent);
  animation: qdot-pulse 1.8s ease-in-out infinite alternate;
}
@keyframes qdot-pulse {
  0% { opacity: 0.75; transform: scaleY(1.15); }
  100% { opacity: 1; transform: scaleY(1.35); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 38%, transparent); }
}

/* 4. Level reveal: scale-in & glow behind the number */
body .reveal {
  animation: reveal-fade .35s ease-out;
}
@keyframes reveal-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
body .reveal .mascot {
  animation: mascot-pop .55s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes mascot-pop {
  0% { transform: scale(0.65); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
body .reveal .lvl-big {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-size: 72px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
  margin: 10px 0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 32px color-mix(in srgb, var(--brand) 45%, transparent), 0 2px 8px color-mix(in srgb, var(--brand) 25%, transparent);
  animation: lvl-pop .65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes lvl-pop {
  0% { transform: scale(0.75); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
body .reveal .lvl-big::before {
  content: "";
  position: absolute;
  inset: -22px -34px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 25%, transparent) 0%, color-mix(in srgb, var(--brand-2) 12%, transparent) 45%, transparent 72%);
  filter: blur(14px);
  z-index: -1;
  pointer-events: none;
  animation: lvl-pulse 2.2s ease-in-out infinite alternate;
}
@keyframes lvl-pulse {
  0% { opacity: 0.65; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.08); }
}
body .reveal #start {
  border: 2px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  border-radius: var(--r);
  padding: 16px 20px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 14%, transparent);
}
body .reveal #go {
  box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 35%, transparent);
}

/* 5. Level celebration card: .lvl-card.up */
body .lvl-card {
  margin: 14px 0;
  padding: 18px 16px;
  border-radius: 20px;
  background: var(--soft);
  text-align: center;
  border: 1.5px solid transparent;
  transition: all .25s ease;
}
body .lvl-card.up {
  background: linear-gradient(135deg, color-mix(in srgb, var(--good-soft) 85%, var(--card)), color-mix(in srgb, var(--soft) 60%, var(--card)));
  border-color: color-mix(in srgb, var(--good) 45%, var(--line));
  box-shadow: 0 12px 32px color-mix(in srgb, var(--good) 22%, transparent);
  animation: lvl-card-bounce .6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  position: relative;
  overflow: hidden;
}
@keyframes lvl-card-bounce {
  0% { transform: scale(0.92); opacity: 0; }
  60% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); }
}
body .lvl-card.up::before {
  content: "";
  position: absolute;
  inset: -30px;
  background: radial-gradient(circle, color-mix(in srgb, var(--good) 16%, transparent) 0%, transparent 68%);
  pointer-events: none;
  z-index: 0;
}
body .lvl-card.up .lvl-big {
  color: var(--ink);
  text-shadow: 0 2px 10px color-mix(in srgb, var(--good) 30%, transparent);
  position: relative;
  z-index: 1;
}
body .lvl-card.up .lvl-delta {
  background: var(--good);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 16px;
  margin: 6px auto;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--good) 40%, transparent);
  animation: delta-pop .45s .25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
  z-index: 1;
}
@keyframes delta-pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
body .lvl-card.up .band {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

/* 6. Level rings with subject colour (Home & Profile) */
body [data-subject="zh"] .lvl-ring,
body a[href*="/subject/zh"] .lvl-ring {
  background: conic-gradient(var(--subj-zh) calc(var(--p) * 1%), color-mix(in srgb, var(--subj-zh) 16%, var(--line)) 0);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--subj-zh) 24%, transparent);
}
body [data-subject="en"] .lvl-ring,
body a[href*="/subject/en"] .lvl-ring {
  background: conic-gradient(var(--subj-en) calc(var(--p) * 1%), color-mix(in srgb, var(--subj-en) 16%, var(--line)) 0);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--subj-en) 24%, transparent);
}
body [data-subject="math"] .lvl-ring,
body a[href*="/subject/math"] .lvl-ring {
  background: conic-gradient(var(--subj-math) calc(var(--p) * 1%), color-mix(in srgb, var(--subj-math) 16%, var(--line)) 0);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--subj-math) 24%, transparent);
}
body [data-subject="physics"] .lvl-ring,
body a[href*="/subject/physics"] .lvl-ring {
  background: conic-gradient(var(--subj-physics) calc(var(--p) * 1%), color-mix(in srgb, var(--subj-physics) 16%, var(--line)) 0);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--subj-physics) 24%, transparent);
}
body [data-subject="chemistry"] .lvl-ring,
body a[href*="/subject/chemistry"] .lvl-ring {
  background: conic-gradient(var(--subj-chemistry) calc(var(--p) * 1%), color-mix(in srgb, var(--subj-chemistry) 16%, var(--line)) 0);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--subj-chemistry) 24%, transparent);
}

/* Subject sparkline trend colors in profile */
body .prof[data-subject="zh"] .spark polyline { stroke: var(--subj-zh); }
body .prof[data-subject="en"] .spark polyline { stroke: var(--subj-en); }
body .prof[data-subject="math"] .spark polyline { stroke: var(--subj-math); }
body .prof[data-subject="physics"] .spark polyline { stroke: var(--subj-physics); }
body .prof[data-subject="chemistry"] .spark polyline { stroke: var(--subj-chemistry); }

/* Subject next-band progress bars on Home */
body a[href*="/subject/zh"] .next-band .bar i { background: var(--subj-zh); }
body a[href*="/subject/en"] .next-band .bar i { background: var(--subj-en); }
body a[href*="/subject/math"] .next-band .bar i { background: var(--subj-math); }
body a[href*="/subject/physics"] .next-band .bar i { background: var(--subj-physics); }
body a[href*="/subject/chemistry"] .next-band .bar i { background: var(--subj-chemistry); }

/* 7. Profile cards & readable strong / to-grow chips */
body .prof {
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  gap: 12px;
}
body .chip.good,
body .prof .chip.good {
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid color-mix(in srgb, var(--good) 35%, transparent);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}
body .chip.warn,
body .prof .chip.warn {
  background: var(--warn-soft);
  color: #9a3412;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}
:root[data-theme="dark"] body .chip.warn,
:root[data-theme="dark"] body .prof .chip.warn {
  background: var(--warn-soft);
  color: #fbbf24;
  border-color: color-mix(in srgb, var(--warn) 60%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body .chip.warn,
  :root:not([data-theme="light"]) body .prof .chip.warn {
    background: var(--warn-soft);
    color: #fbbf24;
    border-color: color-mix(in srgb, var(--warn) 60%, transparent);
  }
}
body button.chip {
  cursor: pointer;
  transition: transform .12s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .12s ease, border-color .15s ease;
  border-radius: 99px;
  padding: 6px 13px;
}
body button.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}
body button.chip:active {
  transform: scale(0.96);
}

/* 8. Me → "find my level" chips wrap inline */
body .row.wrap,
body #prof .row.wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}
body #prof .row.wrap a.chip,
body .row.wrap a.chip,
body a.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  white-space: normal;
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 99px;
  background: var(--soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  transition: transform .12s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
body #prof .row.wrap a.chip:hover,
body .row.wrap a.chip:hover,
body a.chip:hover {
  background: color-mix(in srgb, var(--brand) 12%, var(--card));
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 20%, transparent);
}
body #prof .row.wrap a.chip:active,
body .row.wrap a.chip:active,
body a.chip:active {
  transform: scale(0.97);
}

/* 9. Path: start node (.node.next) "Start here" feel and earlier units optional */
body .node.next {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, var(--card));
  box-shadow: 0 8px 26px color-mix(in srgb, var(--brand) 22%, transparent);
  position: relative;
}
body .node.next::after {
  content: "Start here ▸";
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--brand);
  color: var(--brand-ink);
  margin-left: auto;
  flex: none;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 40%, transparent);
}
body .node.next .dot {
  background: var(--brand);
  border-color: var(--card);
  color: var(--brand-ink);
  box-shadow: 0 0 0 4px var(--soft), 0 4px 14px color-mix(in srgb, var(--brand) 50%, transparent);
}
body .node:has(~ .node.next):not(.done) {
  opacity: 0.72;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  border: 1.5px dashed color-mix(in srgb, var(--line) 90%, var(--brand));
  box-shadow: none;
  transition: opacity .2s ease, border-color .2s ease, background-color .2s ease;
}
body .node:has(~ .node.next):not(.done)::after {
  content: "Optional";
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--mute);
  background: var(--line);
  padding: 3px 8px;
  border-radius: 99px;
  margin-left: auto;
  flex: none;
}
body .node:has(~ .node.next):not(.done) .dot {
  border-style: dashed;
  opacity: 0.8;
}
body .node:has(~ .node.next):not(.done):hover {
  opacity: 1;
  border-style: solid;
  border-color: var(--brand);
}

/* 10. Motion reduction support */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


