:root {
  --ink: #243a4a;
  --muted: #627789;
  --line: #dceaf3;
  --canvas: #f7fcff;
  --paper: #ffffff;
  --violet-50: #eaf6ff;
  --violet-100: #d4ecfb;
  --violet-300: #9fd2ef;
  --violet-500: #62addb;
  --violet-700: #2d85bb;
  --yellow-50: #fffbe7;
  --yellow-200: #f7e99a;
  --yellow-500: #d3a72e;
  --font-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-fr: "Avenir Next", Avenir, "Helvetica Neue", "PingFang SC", system-ui, sans-serif;
  --font-reading: Georgia, "Times New Roman", "PingFang SC", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 16px/1.6 var(--font-ui); }
button, a { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--yellow-200); outline-offset: 3px; }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; overflow-y: auto; padding: 26px 18px; background: var(--paper); border-right: 1px solid var(--line); }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 9px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--violet-700); color: var(--yellow-50); font: 700 24px/1 var(--font-fr); }
.brand strong { display: block; font-size: 16px; line-height: 1.25; }
.brand small { display: block; color: var(--muted); font: 12px/1.4 var(--font-fr); }
.primary-nav { display: grid; gap: 3px; margin: 38px 0 26px; }
.nav-link { min-height: 44px; display: flex; gap: 11px; align-items: center; padding: 0 10px; border-radius: 10px; color: #596174; font-size: 14px; font-weight: 650; text-decoration: none; }
.nav-link:hover { background: var(--violet-50); color: var(--violet-700); }
.nav-link.active { background: var(--violet-50); color: var(--violet-700); }
.nav-link span { width: 18px; text-align: center; }
.section-label-row { display: flex; justify-content: space-between; align-items: center; padding: 0 9px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.section-label-row p { margin: 0; }
.lesson-list { display: grid; gap: 5px; margin-top: 9px; }
.lesson-choice { width: 100%; display: grid; gap: 2px; padding: 10px 11px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--ink); text-align: left; }
.lesson-choice:hover { background: #f7fcff; border-color: var(--violet-100); }
.lesson-choice.active { background: var(--yellow-50); border-color: var(--yellow-200); }
.lesson-choice time { color: var(--violet-700); font-size: 12px; font-weight: 750; }
.lesson-choice span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.sidebar-note { display: flex; gap: 10px; margin: auto 8px 0; padding: 13px; border: 1px solid var(--yellow-200); border-radius: 12px; background: var(--yellow-50); color: #705918; font-size: 12px; line-height: 1.55; }
.sidebar-note p { margin: 0; }

.workspace { width: min(1160px, 100%); margin: 0 auto; padding: 30px clamp(22px, 4vw, 54px) 70px; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 4px; color: var(--violet-500); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
h1, h2, h3 { margin: 0; letter-spacing: -.025em; }
h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.25; }
h2 { font-size: clamp(20px, 2.5vw, 25px); line-height: 1.3; }
h3 { font-size: 19px; }
.primary-button, .secondary-button, .ghost-button, .text-button { min-height: 43px; border: 0; border-radius: 9px; font-size: 14px; font-weight: 750; }
.primary-button { padding: 0 16px; background: var(--violet-700); color: white; box-shadow: 0 4px 11px rgba(45, 133, 187, .18); }
.primary-button:hover { background: #216f9f; }
.primary-button span { margin-left: 5px; }

.lesson-intro { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 28px; align-items: start; padding: 28px 0 32px; }
.date-line { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
.summary { max-width: 720px; margin: 10px 0 16px; color: #4e5669; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { border-radius: 99px; padding: 4px 10px; background: var(--violet-50); color: var(--violet-700); font-size: 12px; font-weight: 700; }
.progress-card { padding: 17px; border: 1px solid var(--violet-100); border-radius: 13px; background: linear-gradient(135deg, #fff 0%, var(--violet-50) 100%); }
.progress-card p, .progress-card span { display: block; margin: 0; color: var(--muted); font-size: 12px; }
.progress-card strong { display: block; margin: 2px 0; color: var(--violet-700); font: 700 27px/1.25 var(--font-fr); }

.review-section, .content-section, .reading-section { margin-top: 28px; }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 14px; }
.section-note { color: var(--muted); font-size: 13px; }
.review-counter { padding: 4px 10px; border-radius: 99px; background: var(--yellow-50); color: #806416; font-size: 12px; font-weight: 800; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(230px, .75fr); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; background: var(--paper); }
.flashcard { position: relative; min-height: 255px; display: flex; flex-direction: column; padding: 20px 23px; background: linear-gradient(135deg, var(--paper), #f7fcff); cursor: pointer; transition: background .2s ease; }
.flashcard:hover { background: var(--violet-50); }
.card-topline { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.card-topline span:first-child { color: var(--violet-700); }
.card-content { flex: 1; display: grid; place-content: center; text-align: center; }
.card-content > p { margin: 0; }
#card-front { font: 700 clamp(28px, 4vw, 43px)/1.3 var(--font-fr); color: var(--ink); }
.card-hint { margin-top: 10px !important; color: var(--muted); font-size: 14px; }
.card-flip-hint { color: var(--violet-500); font-size: 19px; text-align: right; }
.review-helper { display: flex; flex-direction: column; padding: 24px; background: var(--yellow-50); border-left: 1px solid var(--yellow-200); }
.helper-label { margin: 0; color: #806416; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.review-helper > p:not(.helper-label) { margin: 8px 0; color: #5f542e; font-size: 14px; }
.review-actions { display: grid; gap: 8px; margin-top: auto; }
.secondary-button { background: var(--violet-700); color: #fff; }
.ghost-button { border: 1px solid #d8cb96; background: transparent; color: #6c5516; }
.secondary-button:hover { background: #216f9f; }
.ghost-button:hover { background: #fff7cb; }

.grammar-workbench, .conjugation-workbench { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.grammar-tabs, .conjugation-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 11px; border-bottom: 1px solid var(--line); background: #f7fcff; scrollbar-width: thin; }
.grammar-tab, .conjugation-tab { flex: 0 0 auto; min-height: 38px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 750; }
.grammar-tab:hover, .conjugation-tab:hover { background: var(--violet-50); color: var(--violet-700); }
.grammar-tab[aria-selected="true"], .conjugation-tab[aria-selected="true"] { border-color: var(--violet-100); background: var(--violet-50); color: var(--violet-700); }
.grammar-detail { padding: clamp(20px, 3.2vw, 34px); }
.grammar-detail-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, .7fr); gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.grammar-detail h3 { font-size: clamp(20px, 2.6vw, 26px); }
.grammar-detail h3 + p { margin: 8px 0 0; color: #535d70; }
.memory-card { padding: 15px; border-radius: 11px; background: var(--yellow-50); color: #695719; }
.memory-card span { display: block; font-size: 11px; font-weight: 800; letter-spacing: .07em; }
.memory-card strong { display: block; margin-top: 5px; font: 700 18px/1.45 var(--font-fr); }
.grammar-detail-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .9fr); gap: 30px; padding-top: 24px; }
.grammar-steps h4, .grammar-examples h4, .conjugation-detail h3 { margin: 0; font-size: 14px; }
.grammar-steps ol { display: grid; gap: 10px; margin: 13px 0 0; padding: 0; list-style: none; counter-reset: grammar-step; }
.grammar-steps li { position: relative; min-height: 52px; padding: 9px 11px 9px 46px; border-left: 2px solid var(--violet-100); color: #596174; font-size: 14px; }
.grammar-steps li::before { counter-increment: grammar-step; content: counter(grammar-step); position: absolute; left: 10px; top: 11px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--violet-50); color: var(--violet-700); font: 700 13px/1 var(--font-fr); }
.grammar-steps strong { color: var(--ink); }
.grammar-examples { display: grid; gap: 9px; }
.grammar-example { padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.grammar-example p { margin: 0; }
.grammar-example .fr-example { color: var(--violet-700); font: 17px/1.45 var(--font-fr); }
.grammar-example .zh-example { margin-top: 4px; color: var(--muted); font-size: 13px; }
.grammar-example .why-example { margin-top: 7px; color: #5e4b17; font-size: 12px; font-weight: 650; }
.grammar-alert { display: flex; gap: 10px; grid-column: 1 / -1; margin-top: 4px; padding: 14px 16px; border-left: 3px solid var(--yellow-500); border-radius: 0 9px 9px 0; background: var(--yellow-50); color: #604f19; }
.grammar-alert strong { flex: 0 0 auto; }
.grammar-alert p { margin: 0; font-size: 14px; }

.conjugation-detail { padding: clamp(20px, 3.2vw, 34px); }
.conjugation-detail > p { margin: 6px 0 19px; color: var(--muted); }
.conjugation-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.conjugation-cell { min-height: 72px; display: grid; align-content: center; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #f7fcff; }
.conjugation-cell span { color: var(--muted); font-size: 12px; }
.conjugation-cell strong { color: var(--violet-700); font: 700 19px/1.35 var(--font-fr); }
.conjugation-footer { display: flex; gap: 9px; align-items: center; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); color: #596174; font-size: 13px; }
.conjugation-footer .tip-mark { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--yellow-50); color: var(--yellow-500); font-weight: 800; }

.text-button { padding: 0; background: transparent; color: var(--violet-700); }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.vocabulary-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.vocabulary-item { padding: 14px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.vocabulary-item header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.vocabulary-item h3 { color: var(--ink); font: 700 20px/1.25 var(--font-fr); }
.vocabulary-item .translation { color: var(--violet-700); font-size: 13px; font-weight: 750; }
.vocabulary-item p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.vocabulary-item .vocab-example { color: #596174; font-family: var(--font-fr); }
.vocabulary-item.hidden { display: none; }

.reading-paper { padding: clamp(24px, 4vw, 42px); border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.reading-paper h3 { margin-bottom: 17px; color: var(--violet-700); font: 700 25px/1.3 var(--font-fr); }
.reading-text { max-width: 760px; color: #333b4d; font: 21px/2 var(--font-reading); }
.reading-text p { margin: 0 0 18px; }
.translation-details { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.translation-details summary { color: var(--violet-700); cursor: pointer; font-weight: 750; }
.translation-details p { margin: 9px 0 0; }
.sun-chip { border-radius: 99px; padding: 4px 10px; background: var(--yellow-50); color: #806416; font-size: 12px; font-weight: 800; }

@media (max-width: 850px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 15px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .primary-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 16px 0; }
  .nav-link { justify-content: center; padding: 0 5px; font-size: 12px; }
  .nav-link span { display: none; }
  .date-list { display: none; }
  .sidebar-note { display: none; }
  .workspace { padding: 22px 18px 55px; }
  .grammar-detail-body { grid-template-columns: 1fr; }
}
@media (max-width: 590px) {
  .topbar, .lesson-intro, .section-heading { align-items: start; }
  .topbar { display: grid; }
  .primary-button { width: 100%; }
  .lesson-intro, .review-grid { grid-template-columns: 1fr; }
  .progress-card { max-width: none; }
  .review-helper { border-top: 1px solid var(--yellow-200); border-left: 0; }
  .flashcard { min-height: 225px; }
  .grammar-detail-header { grid-template-columns: 1fr; }
  .conjugation-grid, .vocabulary-list { grid-template-columns: 1fr; }
  .section-heading { gap: 8px; flex-direction: column; }
  .reading-text { font-size: 19px; }
}
