:root {
  --violet: #6c5ce7;
  --violet-deep: #5546d7;
  --violet-soft: #eeeaff;
  --orange: #ff9f43;
  --orange-soft: #fff1dc;
  --mint: #27c9a4;
  --mint-soft: #e2faf4;
  --red: #f25f77;
  --ink: #24233a;
  --muted: #77758d;
  --line: #e9e7f2;
  --card: rgba(255, 255, 255, .94);
  --bg: #f8f7fc;
  --shadow: 0 14px 40px rgba(76, 61, 150, .1);
  --radius: 24px;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100%; color: var(--ink);
  background:
    radial-gradient(circle at 8% 3%, rgba(108,92,231,.18), transparent 26rem),
    radial-gradient(circle at 100% 22%, rgba(255,159,67,.15), transparent 24rem),
    radial-gradient(circle at 4% 82%, rgba(39,201,164,.12), transparent 25rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible { outline: 3px solid rgba(108,92,231,.28); outline-offset: 3px; }

#app {
  width: 100%; max-width: 800px; min-height: 100vh; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(48px, env(safe-area-inset-bottom));
}
.top {
  display: flex; align-items: center; gap: 10px; min-height: 68px; margin-bottom: 12px;
  position: sticky; top: 0; z-index: 20; padding: 9px 0;
}
.top::before {
  content: ""; position: absolute; inset: 0 -16px; z-index: -1;
  background: rgba(248,247,252,.78); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(233,231,242,.55);
}
.brand { min-width: 0; display: flex; align-items: center; gap: 11px; }
.logo {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 15px; display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, #8173f1, var(--violet-deep));
  box-shadow: 0 9px 22px rgba(108,92,231,.28); transform: rotate(-3deg);
}
.logo svg { width: 30px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
h1 { margin: 0; max-width: 66vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.18rem; font-weight: 850; letter-spacing: -.02em; }
#pageSub, .muted { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }

.icon-btn, .ghost, .primary, .chip, .opt, .lesson-card, .speak-btn {
  border: 0; cursor: pointer; touch-action: manipulation;
  transition: transform .16s ease, box-shadow .2s ease, background-color .2s ease;
}
.icon-btn:active, .ghost:active, .primary:active, .chip:active, .opt:active, .lesson-card:active, .speak-btn:active { transform: scale(.96); }
.icon-btn {
  width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 14px; background: white; border: 1px solid var(--line); box-shadow: 0 5px 16px rgba(55,47,96,.07);
}
.icon-btn svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.ghost, .primary { min-height: 48px; padding: 12px 20px; border-radius: 16px; font-weight: 750; }
.ghost { background: white; border: 1px solid var(--line); }
.primary {
  color: white; background: linear-gradient(135deg, #8174ef, var(--violet-deep));
  box-shadow: 0 10px 22px rgba(108,92,231,.25);
}
.primary.wide { width: 100%; }

.hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: 1fr auto; gap: 16px;
  min-height: 190px; margin: 4px 0 20px; padding: 24px; border-radius: 30px; color: white;
  background: linear-gradient(135deg, #5b4bd9 0%, #7667ed 53%, #8f7cf5 100%);
  box-shadow: 0 20px 46px rgba(92,75,217,.24);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::before { width: 190px; height: 190px; right: -70px; top: -80px; border: 30px solid rgba(255,255,255,.09); }
.hero::after { width: 90px; height: 90px; left: 38%; bottom: -60px; background: var(--orange); opacity: .35; }
.eyebrow { margin: 0 0 8px; font-size: .75rem; font-weight: 800; letter-spacing: .12em; opacity: .8; }
.hero h2 { margin: 0; max-width: 420px; font-size: clamp(1.45rem, 6vw, 2.05rem); line-height: 1.25; letter-spacing: -.035em; }
.hero-copy { position: relative; z-index: 1; }
.hero-meta { display: flex; align-items: center; gap: 10px; margin-top: 22px; font-size: .8rem; font-weight: 700; }
.hero-progress { width: min(250px, 48vw); height: 8px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.2); }
.hero-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffd36a, #ffad4f); }
.hero-art { align-self: center; width: 96px; height: 96px; position: relative; z-index: 1; }
.hero-art svg { width: 100%; height: 100%; filter: drop-shadow(0 12px 18px rgba(44,28,122,.2)); }

.summary-section { margin: 4px 0 22px; }
.section-title {
  display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 11px;
}
.section-title h2 { margin: 2px 0 0; font-size: 1.08rem; letter-spacing: -.02em; }
.section-title > span {
  flex: 0 0 auto; padding: 5px 9px; border-radius: 9px; color: var(--violet-deep);
  background: var(--violet-soft); font-size: .7rem; font-weight: 800;
}
.eyebrow.violet { margin-bottom: 3px; color: var(--violet); opacity: 1; }
.summary-deck { display: grid; gap: 9px; }
.summary-card {
  overflow: hidden; border: 1px solid var(--line); border-radius: 19px;
  background: rgba(255,255,255,.92); box-shadow: 0 7px 22px rgba(60,48,111,.06);
}
.summary-card summary {
  min-height: 66px; display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center;
  padding: 10px 13px; cursor: pointer; list-style: none;
}
.summary-card summary::-webkit-details-marker { display: none; }
.summary-no {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px;
  color: white; background: linear-gradient(145deg, #8978f5, #5a49d8); font-size: .75rem; font-weight: 900;
  box-shadow: 0 7px 16px rgba(108,92,231,.22);
}
.tone-2 .summary-no { background: linear-gradient(145deg, #ffbd64, #f28b26); box-shadow: 0 7px 16px rgba(242,139,38,.2); }
.tone-3 .summary-no { background: linear-gradient(145deg, #56dbbd, #19a789); box-shadow: 0 7px 16px rgba(25,167,137,.2); }
.tone-4 .summary-no { background: linear-gradient(145deg, #ff8499, #e84f6a); box-shadow: 0 7px 16px rgba(232,79,106,.2); }
.tone-5 .summary-no { background: linear-gradient(145deg, #63b8ff, #4c72df); box-shadow: 0 7px 16px rgba(76,114,223,.2); }
.summary-card summary strong { display: block; font-size: .9rem; }
.summary-card summary small { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; line-height: 1.3; }
.summary-toggle { color: var(--muted); font-size: 1.25rem; transition: transform .2s ease; }
.summary-card[open] .summary-toggle { transform: rotate(45deg); }
.summary-card > p { margin: 0; padding: 2px 16px 10px; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.summary-card ul { margin: 0 16px 13px; padding: 13px 13px 6px 29px; border-radius: 14px; background: #f8f6ff; }
.summary-card li { margin-bottom: 7px; padding-left: 2px; font-size: .8rem; line-height: 1.55; }
.summary-card .source-btn { margin: 0 16px 15px; min-height: 40px; padding: 8px 13px; font-size: .78rem; }

.parts {
  display: flex; gap: 8px; margin: 0 -16px 18px; padding: 0 16px 3px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.parts::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 40px; padding: 9px 15px; border-radius: 14px; scroll-snap-align: start;
  color: var(--muted); background: white; border: 1px solid var(--line); font-size: .86rem; font-weight: 650;
}
.chip.on { color: var(--violet-deep); background: var(--violet-soft); border-color: #cfc7ff; font-weight: 800; }
.grid { display: grid; gap: 12px; }
.lesson-card {
  position: relative; width: 100%; padding: 15px; display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center;
  text-align: left; color: inherit; background: var(--card); border: 1px solid rgba(229,226,240,.9);
  border-radius: 22px; box-shadow: 0 8px 26px rgba(60,48,111,.07); animation: rise .42s both;
}
.lesson-card:nth-child(3n+2) .day-badge { background: var(--orange-soft); color: #d97716; }
.lesson-card:nth-child(3n) .day-badge { background: var(--mint-soft); color: #128a71; }
.lesson-card.completed { border-color: rgba(39,201,164,.3); }
.lesson-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.day-badge {
  width: 50px; height: 56px; border-radius: 16px; display: grid; place-content: center; text-align: center;
  color: var(--violet-deep); background: var(--violet-soft);
}
.day-badge small { font-size: .55rem; font-weight: 800; letter-spacing: .08em; opacity: .65; }
.day-badge strong { font-size: 1.05rem; line-height: 1.1; }
.lesson-card h3 { margin: 0; font-size: .98rem; line-height: 1.35; }
.lesson-card p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.lesson-emoji { margin-right: 5px; font-size: .88rem; }
.card-status { display: grid; justify-items: end; gap: 7px; }
.check {
  width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%;
  color: white; background: var(--mint); font-size: .72rem; font-weight: 900;
}
.arrow { color: #aaa6bd; font-size: 1.35rem; }

.lesson-intro {
  position: relative; overflow: hidden; padding: 22px; margin: 3px 0 14px; border-radius: 26px;
  background: linear-gradient(145deg, #fff, #f2efff); border: 1px solid #e5dfff;
}
.lesson-intro::after { content: ""; position: absolute; width: 110px; height: 110px; right: -48px; bottom: -56px; border-radius: 50%; background: var(--orange); opacity: .17; }
.lesson-intro .tag { display: inline-flex; padding: 5px 9px; border-radius: 9px; color: var(--violet-deep); background: var(--violet-soft); font-size: .72rem; font-weight: 800; }
.lesson-intro h2 { margin: 10px 0 4px; font-size: 1.32rem; line-height: 1.3; }
.source-btn { margin-top: 15px; display: inline-flex; align-items: center; gap: 7px; }
.source-btn svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0 0 15px; padding: 5px; border-radius: 17px; background: #eae7f4; }
.tabs .chip { width: 100%; border: 0; background: transparent; }
.tabs .chip.on { color: var(--ink); background: white; box-shadow: 0 5px 14px rgba(49,40,90,.09); }

.step-card, .panel {
  position: relative; margin-bottom: 13px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); animation: rise .38s both;
}
.step-head { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.step-no {
  width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px;
  color: white; background: linear-gradient(135deg, #8071ed, var(--violet-deep)); font-size: .78rem; font-weight: 850;
}
.step-card:nth-child(2) .step-no { background: linear-gradient(135deg, #ffb55d, #f48b28); }
.step-card:nth-child(3) .step-no { background: linear-gradient(135deg, #4ed8ba, #18a98a); }
.step-card:nth-child(4) .step-no { background: linear-gradient(135deg, #ff8195, #e94f69); }
.step-head h3 { margin: 0; font-size: 1.02rem; }
.learn-item { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.learn-item:last-child { padding-bottom: 0; border-bottom: 0; }
.example-line { display: flex; align-items: center; gap: 8px; }
.learn-item .en { flex: 1; font-weight: 750; font-size: .98rem; line-height: 1.45; }
.speak-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: var(--violet-deep); background: var(--violet-soft); }
.speak-btn svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.item-tip { margin-top: 7px; color: #9a6a19; font-size: .8rem; line-height: 1.5; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table.summary { width: 100%; min-width: 420px; border-collapse: collapse; font-size: .84rem; }
table.summary th, table.summary td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.summary th { color: var(--violet-deep); background: var(--violet-soft); font-size: .76rem; }
table.summary tr:last-child td { border-bottom: 0; }
.mnemonic, .tip { padding: 15px; border-radius: 16px; line-height: 1.65; }
.mnemonic { color: #8a5510; background: linear-gradient(135deg, #fff5df, #ffebc8); font-weight: 700; }
.tip { color: #a43f52; background: linear-gradient(135deg, #fff0f2, #ffe4e8); }
.empty-step { color: var(--muted); font-size: .86rem; }

.quiz-top { margin-bottom: 14px; }
.quiz-progress-row { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.progress-track { height: 9px; overflow: hidden; border-radius: 99px; background: #e8e5f1; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), #927ff6); transition: width .35s ease; }
.q-card { padding: 22px 18px; }
.q-card .prompt { margin: 0 0 20px; font-size: 1.12rem; font-weight: 800; line-height: 1.55; }
.question-kicker { margin-bottom: 7px; color: var(--violet); font-size: .72rem; font-weight: 850; letter-spacing: .1em; }
.opts { display: grid; gap: 10px; }
.opt {
  min-height: 52px; display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 13px; text-align: left; color: var(--ink); background: white; border: 1.5px solid var(--line); border-radius: 16px;
}
.opt-letter { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); background: #f3f2f7; font-size: .75rem; font-weight: 850; }
.opt.correct { color: #11755f; background: var(--mint-soft); border-color: var(--mint); animation: pop .42s both; }
.opt.correct .opt-letter { color: white; background: var(--mint); }
.opt.wrong { color: #ac3e52; background: #fff0f2; border-color: var(--red); animation: shake .38s both; }
.opt.wrong .opt-letter { color: white; background: var(--red); }
.opt.dim { opacity: .58; }
.opt:disabled { cursor: default; }
.feedback { margin-top: 14px; padding: 15px; border-radius: 16px; animation: rise .28s both; }
.feedback.good { color: #11755f; background: var(--mint-soft); }
.feedback.bad { color: #a63d50; background: #fff0f2; }
.feedback strong { display: block; margin-bottom: 4px; }
.feedback p { margin: 0; font-size: .86rem; line-height: 1.55; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 17px; }

.score { overflow: hidden; text-align: center; padding: 36px 18px 25px; }
.score-mark {
  width: 96px; height: 96px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 31px;
  color: white; background: linear-gradient(145deg, #7d6def, #5847d7); box-shadow: 0 15px 32px rgba(108,92,231,.28); transform: rotate(-4deg);
}
.score-mark svg { width: 55px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.score h2 { margin: 0; font-size: 1.5rem; }
.score .big { margin: 7px 0; color: var(--violet-deep); font-size: 2.25rem; font-weight: 900; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -18px; width: 9px; height: 18px; border-radius: 3px; background: var(--violet); animation: fall 2.3s ease-in infinite; }
.confetti i:nth-child(3n) { background: var(--orange); transform: rotate(35deg); }
.confetti i:nth-child(3n+1) { background: var(--mint); border-radius: 50%; }
.confetti i:nth-child(1) { left: 8%; animation-delay: -.4s; }
.confetti i:nth-child(2) { left: 18%; animation-delay: -1.1s; }
.confetti i:nth-child(3) { left: 31%; animation-delay: -.7s; }
.confetti i:nth-child(4) { left: 46%; animation-delay: -1.6s; }
.confetti i:nth-child(5) { left: 61%; animation-delay: -.2s; }
.confetti i:nth-child(6) { left: 73%; animation-delay: -1.2s; }
.confetti i:nth-child(7) { left: 87%; animation-delay: -.8s; }
.confetti i:nth-child(8) { left: 95%; animation-delay: -1.8s; }
.empty { text-align: center; color: var(--muted); padding: 42px 12px; }

.modal { position: fixed; inset: 0; z-index: 100; color: white; background: rgba(20,18,33,.96); animation: fade .2s both; }
.modal[hidden] { display: none; }
.modal-bar {
  height: calc(70px + env(safe-area-inset-top)); padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(20,18,33,.88);
}
.modal-hint { display: block; margin-top: 3px; color: #aaa5bf; font-size: .7rem; }
.modal-tools { display: flex; gap: 7px; }
.modal .icon-btn { color: white; background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.12); }
.source-stage {
  width: 100%; height: calc(100% - 70px - env(safe-area-inset-top)); overflow: auto;
  display: grid; place-items: center; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom;
}
.source-stage img { max-width: none; width: min(100%, 900px); height: auto; display: block; transform-origin: center; transition: width .18s ease; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 50% { transform: scale(1.025); } }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@keyframes fall { to { top: 105%; transform: translateX(18px) rotate(220deg); } }

@media (min-width: 680px) {
  #app { padding-left: 24px; padding-right: 24px; }
  .top::before { inset-inline: -24px; }
  .parts { margin-inline: -24px; padding-inline: 24px; }
  .grid.map { grid-template-columns: 1fr 1fr; }
  .hero { padding: 30px; }
  .hero-art { width: 125px; height: 125px; }
}
@media (max-width: 380px) {
  .hero { padding: 20px; }
  .hero-art { width: 70px; height: 70px; }
  .lesson-card { padding: 13px; }
  .modal-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
