@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&display=swap');

:root {
  color-scheme: light;
  --bg: #f7f5ff;
  --panel: #fff;
  --text: #241c48;
  --muted: #61577a;
  --line: #e9e0f5;
  --red: #6947ca;
  --mint: #247862;
  --purple: #6947ca;
  --gold: #8c5219;
  --clay-shadow: inset 0 2px 0 #ffffffd9, inset 0 -4px 0 #3320590b, 0 8px 22px #513e7d0e;
}
body { font-family: "Nunito", "Segoe UI", sans-serif; }
button, a, input, textarea, select { outline-color: #6040bb; }
button:focus-visible, a:focus-visible { outline-color: #6040bb; }
button { transition: background-color .18s ease, box-shadow .18s ease, translate .18s ease; }
button:hover, .tile:hover { filter: none; }
button:active:not(:disabled) { translate: 0 2px; }
header { background: #fffdff; border-color: var(--line); }
.top, main { width: min(1160px, calc(100% - 8vw)); }
.top { gap: clamp(20px, 4vw, 50px); }
.brand { color: #312158; font-weight: 900; }
.brand > span:last-child { color: #704ed0; }
.seal { background: linear-gradient(145deg,#a186ff,#6b4bd0); color: #fff; box-shadow: inset 0 2px 2px #fff7, inset 0 -4px 0 #3e228f45, 0 4px 8px #6647bd35; font-weight: 800; }
nav a { color: #54466d; font-weight: 800; min-height: 42px; }
nav a.on { color: #542eae; background: #eee5ff; box-shadow: inset 0 -2px 0 #8d5bd718; }
nav a:hover { background: #f4efff; }
.xp { color: #784811; border-color: #f2dbad; background: #fff2ce; }
.avatar { background: #ffe1d2; border-color: #f4c8b9; }
main { padding: 30px 0 60px; }
h1, h2, h3 { font-weight: 900; }
h2 { font-size: clamp(22px, 2.3vw, 27px); }
h3 { font-size: 18px; }
.landing-section { margin: 34px 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading a { color: #5839af; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; }
.section-heading p { margin-top: 3px; }
.hero.learning-hero {
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center;
  margin: 0; min-height: 368px; padding: 20px clamp(22px,4vw,56px);
  overflow: hidden; border: 1px solid #e5d9ff; border-radius: 30px;
  background: radial-gradient(ellipse at 98% 0,#e8dbff 0,transparent 68%), linear-gradient(135deg,#fcf9ff,#f2eaff);
  box-shadow: inset 0 2px 0 #fff, inset 0 -5px 0 #9e6ae018, 0 14px 30px #8061c21c;
}
.learning-hero::before { display: none; }
.learning-hero h1 { margin: 12px 0; font-size: clamp(36px,5.35vw,72px); line-height: 1.04; letter-spacing: -.065em; color: #261846; }
.learning-hero em { color: #6741c6; font-style: normal; }
.learning-hero p { max-width: 420px; color: #55466f; font-size: 17px; }
.learning-hero .eyebrow { min-height: 30px; padding: 4px 11px; border-radius: 30px; background: #e9dfff; color: #5b379e; letter-spacing: .3px; text-transform: none; font-size: 13px; font-weight: 850; }
.hero-ctas, .hero-metrics { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.hero-metrics { gap: 16px; margin-top: 14px; font-size: 14px; font-weight: 800; color: #554770; }
.hero-metrics button { padding: 0; color: inherit; }
.hero-metrics .icon { width: 16px; color: #704bc2; }
.hero-visual { min-width: 0; }
.learning-hero img { position: static; width: 112%; max-width: none; margin-left: -5%; height: auto; display: block; opacity: 1; mask-image: none; }
.primary, .soft { min-height: 44px; border-radius: 12px; font-weight: 850; }
.primary { color: #fff; background: #6945cf; box-shadow: inset 0 2px 0 #ffffff45,inset 0 -3px 0 #36216f40,0 5px 12px #6a45cc30; }
.primary:hover { background: #5734bc; }
.hero-ctas .primary, .landing-cta .primary { background: #a93c19; color: #fff; padding-inline: 19px; box-shadow: inset 0 2px 0 #ffffff45,inset 0 -3px 0 #78260965,0 5px 10px #ac592930; }
.soft, .filterbar button { color: #56389c; background: #f5efff; border-color: #e2d4f9; }
.soft:hover, .filterbar button:hover { background: #eae0ff; }
.filterbar button.on { background: #6945cf; color: #fff; border-color: #6945cf; }
.course-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.course-card { position: relative; display: grid; gap: 5px; justify-items: start; text-align: left; padding: 16px; border: 1px solid var(--tint-line); border-radius: 20px; background: var(--tint); box-shadow: var(--clay-shadow); overflow: hidden; }
.course-card:hover { box-shadow: inset 0 2px 0 #fff9,inset 0 -4px 0 #33205915,0 10px 23px #513e7d24; translate: 0 -2px; }
.course-card strong { color: var(--text); font-size: 18px; font-weight: 900; }
.course-card small { color: #52456a; font-size: 13px; }
.course-level { color: var(--tint-ink); font-weight: 900; font-size: 13px; }
.course-glyph { width: 42px; height: 42px; margin-bottom: 4px; display: grid; place-items: center; border-radius: 13px; background: #fff9; color: var(--tint-ink); box-shadow: inset 0 -3px 0 #33205912, 0 3px 7px #33205914; font: 800 23px "Microsoft YaHei", sans-serif; }
.mint-course { --tint: #dcf8ed; --tint-line: #b8ebd9; --tint-ink: #1b7056; }
.rose-course { --tint: #ffe7f3; --tint-line: #f3cde2; --tint-ink: #983568; }
.gold-course { --tint: #fff0d1; --tint-line: #f6dda9; --tint-ink: #865023; }
.violet-course { --tint: #ece4ff; --tint-line: #e0d0fa; --tint-ink: #5b36a7; }
.panel { border-radius: 22px; box-shadow: var(--clay-shadow); }
.count, .chip { color: #60489c; background: #f0e9ff; border-radius: 9px; font-weight: 800; }
.badge { color: #206851; background: #dff7ed; border-color: #c3eadd; }
.box { box-shadow: inset 0 2px 0 #fff9,inset 0 -3px 0 #37274b12; }
.coral { color: #9d4167; background: #ffe4ef; }
.teal { color: #247762; background: #d9f7ea; }
.violet { color: #6742be; background: #eee4ff; }
.amber { color: #8c531b; background: #fff0cd; }
.track, .progress-bar { background: #ede6f5; }
.track i, .progress-bar i:first-child { background: #35a987; }
.progress-bar i:nth-child(2) { background: #9a72e3; }
.day i { background: #f6efff; border-color: #e6d9f9; }
.day.today { color: #6542b7; }
.day.today i { background: #714ed1; border-color: #714ed1; color: white; }
.day .icon { color: #6542b7; }
.study-card { border-color: #e7dcfc; background: radial-gradient(circle at 94% 6%,#f0e4ff,transparent 62%),#fdfaff; box-shadow: var(--clay-shadow); border-radius: 18px; }
.study-card.is-back { background: radial-gradient(circle at 95% 10%,#ffe3f2,transparent 65%),#fdf9ff; }
.study-toolbar { border-color: #e7dbf4; }
select.study-level { background: #ece1ff; color: #533499; border-color: #ded0fa; }
.study-toolbar button, .study-footer button { color: #563792; border-color: #e4d6f7; background: #fff; }
.study-toolbar .study-sound { background: #efe1ff; }
.study-card button:focus-visible { outline-color: #6841c6; }
.study-hanzi { color: #51308e; }
.study-pinyin { color: #883c73; }
.study-card.is-back .study-hanzi { color: #8e3264; }
.is-back .study-hanzi span:nth-child(even) { color: #7144bd; }
.study-meaning { color: #2b2049; }
.study-pattern { color: #743b23; background: #fff0d0; border-inline-start-color: #c69352; }
.study-footer { background: #f2e9ff; }
.study-navigation .study-next { color: #fff; background: #6945cf; border-color: #6945cf; }
.study-footer .study-known { color: #1e664f; background: #daf5e6; border-color: #b9e6cf; }
.study-footer .study-again { color: #8f315e; background: #fce1ef; border-color: #edc5db; }
.study-card .word-relations section { background: #fffcff; border-color: #e8dcf5; color: #372752; }
.study-card .word-relations small { color: var(--muted); }
.study-card .relation-word, .relation-word { background: #f4ebff; }
.quick { gap: 10px; }
.tile { background: #faf6ff; border-color: #e9dff7; border-radius: 14px; box-shadow: var(--clay-shadow); }
.tile:hover, .word:hover { border-color: #bba1ed; }
.progress-card { background: #faf6ff; border-color: #e9dff7; border-radius: 16px; box-shadow: var(--clay-shadow); }
.progress-card:nth-child(1) { background: #e8f9f1; border-color: #d2eddf; }
.progress-card:nth-child(3) { background: #fff6e2; border-color: #f5e7bc; }
.progress-card:nth-child(4) { background: #fff0f6; border-color: #f3dce7; }
.learner-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.learner-card { margin: 0; background: #fffcff; padding: 18px; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--clay-shadow); }
.learner-card blockquote { margin: 10px 0 5px; font-weight: 800; }
.learner-card figcaption { color: var(--muted); font-size: 14px; }
.landing-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 25px; background: #eae0ff; border: 1px solid #daccf6; border-radius: 22px; box-shadow: var(--clay-shadow); }
.landing-cta p { color: var(--muted); }
input, select, textarea { background: white; color: var(--text); border-color: #cfc1e6; }
input::placeholder, textarea::placeholder { color: #776b89; }
.word { background: #fffcff; border-color: #eadff6; border-radius: 15px; box-shadow: var(--clay-shadow); }
.kicker { color: #28715e; }
.example, .info { background: #f2eaff; color: var(--text); }
dialog { background: #fffdff; color: var(--text); border-color: #dfd1f1; border-radius: 21px; box-shadow: 0 24px 80px #30214d4f; }
dialog::backdrop { background: #2a1a4869; }
.radial-map .leaf, .node { background: #eef8f7; border-color: #addbd4; }
.radial-map .leaf b { background: #f9fffe; color: #244342; border-color: #92c6c1; }
.radial-map .leaf span { color: #244342; }
.radial-map mark { color: #a74325; }
.radial-map .maproot { background: #f1e7ff; border-color: #c9aaf1; }
.radial-map svg { color: #8e79ae; }
.pair-tile { background: #f9f3ff; border-color: #e0d1f7; box-shadow: var(--clay-shadow); }
.pair-tile[aria-pressed="true"] { background: #e6d7ff; border-color: #936ad6; }
.pair-tile.matched { background: #e1f6ea; color: #22624d; border-color: #97cfb8; }
.match-base { border-color: var(--line); }
#toast { background: #2b594d; color: white; }
#progress, #card { scroll-margin-top: 16px; }
@media (max-width: 760px) {
  .top, main { width: 94%; }
  .hero.learning-hero { min-height: 0; padding: 19px; grid-template-columns: 1.25fr 1fr; }
  .learning-hero h1 { font-size: clamp(29px,6.2vw,48px); }
  .learning-hero p { max-width: none; font-size: 14px; }
  .hero-visual img { width: 125%; margin-left: -9%; }
  .course-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .course-card { padding: 12px; }
  .landing-section { margin: 24px 0; }
  .learner-grid { gap: 9px; }
}
@media (max-width: 460px) {
  .hero.learning-hero { grid-template-columns: 1fr; position: relative; }
  .hero-copy { position: relative; z-index: 1; }
  .hero-copy p { max-width: 250px; }
  .hero-visual { position: absolute; width: 50%; right: -9%; top: 15%; opacity: .28; pointer-events: none; }
  .hero-visual img { width: 100%; margin-left: 0; }
  .learner-grid { grid-template-columns: 1fr; }
  .section-heading a { font-size: 13px; }
  .landing-cta { flex-wrap: wrap; padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
  button:active { translate: none; }
}

.word-relations section:only-child { grid-column: 1 / -1; }
.quiz-option { position: relative; width: 100%; padding-inline: 35px; }
.quiz-option > .icon { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); }
.quiz-option:disabled { cursor: default; opacity: 1; }
.quiz-option:disabled:hover { background: #f5efff; }
.quiz-option.is-correct, .quiz-option.is-correct:hover {
  background: #dff5e7; border-color: #72af90; color: #175a3c;
}
.quiz-option.is-incorrect, .quiz-option.is-incorrect:hover {
  background: #fbe3e7; border-color: #d28494; color: #922b45;
}
.quiz-pinyin { color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: panel-enter .22s ease-out both; }
  .study-face > *, .quiz-feedback { animation: content-enter .20s ease-out both; }
  .quiz-option.is-correct { animation: answer-confirm .30s ease-out; }
  .quiz-option.is-incorrect { animation: answer-shake .24s ease-out; }
}
@keyframes panel-enter {
  from { opacity: 0; transform: translateY(7px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes content-enter {
  from { opacity: .6; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes answer-confirm {
  45% { transform: scale(1.018); }
}
@keyframes answer-shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.modal-controls { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.modal-controls .close { min-height: 44px; min-width: 44px; }
.game-expand { padding-inline: 10px; }
.game-dialog.game-expanded {
  inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none;
  margin: 0; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 0; border-radius: 0;
}
.game-expanded #modal { width: min(100%, 1050px); margin-inline: auto; }
.game-expanded .modal-heading {
  position: sticky; top: 0; z-index: 1; padding-block: 8px;
  background: #fffdff; border-bottom: 1px solid var(--line);
}
.game-expanded .pair-board { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(7px, 1.5vw, 16px); }
.game-expanded .pair-tile { min-height: clamp(78px, 16vh, 155px); font-size: clamp(16px, 2.8vw, 28px); }
.game-expanded .pair-tile b { font-size: clamp(24px, 5vw, 52px); }
.game-expanded .pair-tile small { font-size: clamp(13px, 2vw, 19px); }
.game-expanded .modalbody > .center .han { font-size: clamp(66px, 13vw, 120px); }
.game-expanded .quiz-option { min-height: 58px; font-size: clamp(17px, 2.8vw, 28px); }
.game-expanded #typed-hanzi { min-height: 52px; font-size: clamp(23px, 5vw, 38px); }
.pair-tile.is-incorrect { background: #fbe3e7; border-color: #c56a82; color: #922b45; }
.pair-tile.is-incorrect small { color: #922b45; }
@media (max-width: 540px) {
  .game-expanded .pair-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-dialog .modal-heading h2 { font-size: clamp(17px, 4.5vw, 22px); }
  .game-expand { font-size: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  .pair-tile.is-incorrect { animation: answer-shake .24s ease-out; }
}
.site-footer { background: #fffdff; border-top: 1px solid var(--line); }
.footer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: min(1160px, calc(100% - 8vw)); margin-inline: auto; padding-block: 22px;
}
.footer-inner strong { font-size: 17px; font-weight: 900; }
.footer-inner p { margin-top: 4px; color: var(--muted); }
.footer-contact { display: inline-flex; align-items: center; justify-content: center; border: 1px solid #e2d4f9; flex-shrink: 0; }
.game-expanded :is(#answer, #free) { min-height: 140px; font-size: clamp(19px, 3vw, 26px); }
.game-expanded .typing-row { padding-block: 14px; }
.game-expanded .typing-row input { min-height: 48px; font-size: clamp(20px, 3.5vw, 28px); }
@media (max-width: 560px) {
  .footer-inner { width: 94%; align-items: flex-start; flex-direction: column; }
}
.ai-panel {
  padding: 15px; background: #faf6ff; border: 1px solid #e9dff7; border-radius: 16px;
}
.ai-panel > .primary { justify-self: start; }
.ai-key-controls { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fffcff; }
.ai-key-controls input, #ai-question { width: 100%; }
#ai-conversation[hidden] { display: none; }
#ai-status:empty, #ai-thread:empty { display: none; }
#ai-status { color: var(--muted); }
.ai-grade p { margin-top: 5px; }
.ai-issues { margin-block: 12px; padding-inline-start: 22px; }
.ai-issues li + li { margin-top: 10px; }
.ai-correction { display: grid; gap: 4px; margin-top: 12px; padding: 11px; background: #e1f6ea; border-radius: 9px; }
.ai-correction b { font-size: clamp(19px, 3vw, 27px); }
.ai-message p { white-space: pre-wrap; overflow-wrap: anywhere; }
