:root {
  --bg: #f4f6f8;
  --paper: #ffffff;
  --ink: #1d2b3a;
  --ink-soft: #55687d;
  --ink-faint: #8593a6;
  --line: #e6ebf1;
  --brand: #1e6f8f;
  --brand-ink: #14566f;
  --teal: #159a9a;
  --amber: #e0a030;
  --coral: #e2705d;
  --leaf: #4c9a5e;
  --violet: #7c69c9;
  --sky: #4a90c2;
  --danger: #d8574a;
  --shadow-sm: 0 1px 2px rgba(20, 40, 60, 0.05), 0 2px 6px rgba(20, 40, 60, 0.05);
  --shadow-md: 0 4px 14px rgba(20, 40, 60, 0.08);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; background: none; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(30, 111, 143, 0.35); outline-offset: 2px;
}
.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; fill: none; }

.app { max-width: 1180px; margin: 0 auto; min-height: 100vh; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: none; background: var(--paper); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(140deg, var(--brand), var(--teal)); flex: none;
}
.brand-mark .icon { width: 22px; height: 22px; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: 0; }
.brand-sub { font-size: 11px; color: var(--ink-faint); margin-top: 1px; }

.nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; color: var(--ink-faint); padding: 12px 10px 4px; letter-spacing: .3px; }
.nav-btn {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius);
  color: var(--ink-soft); font-weight: 500; text-align: left; width: 100%; transition: background .12s;
}
.nav-btn .icon { width: 19px; height: 19px; }
.nav-btn:hover { background: #f2f5f8; color: var(--ink); }
.nav-btn.on { background: #e7f0f4; color: var(--brand-ink); font-weight: 600; }
.nav-btn .badge {
  margin-left: auto; background: var(--coral); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 1px 7px; min-width: 20px; text-align: center;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.student-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); background: #f7f9fb;
}
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex: none; }
.student-name { font-weight: 700; font-size: 14px; }
.student-grade { font-size: 12px; color: var(--ink-faint); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .burger { display: none; }
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-date { margin-left: auto; font-size: 13px; color: var(--ink-soft); }
.content { padding: 22px 26px 60px; }

/* ---------- Generic ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-h .icon { width: 18px; height: 18px; color: var(--brand); }
.card-h .spacer { margin-left: auto; }
.section-title { font-size: 16px; font-weight: 700; margin: 2px 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title .icon { color: var(--brand); width: 19px; height: 19px; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
  background: #eef2f6; color: var(--ink); transition: filter .12s, transform .04s;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 17px; height: 17px; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { filter: brightness(.93); }
.btn.amber { background: var(--amber); color: #3d2a00; }
.btn.coral { background: var(--coral); color: #fff; }
.btn.leaf { background: var(--leaf); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: var(--radius); color: var(--ink-soft); transition: background .12s;
}
.icon-btn:hover { background: #eef2f6; color: var(--ink); }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn.danger:hover { background: #fceeea; color: var(--danger); }
.icon-btn.tiny { width: 28px; height: 28px; }
.icon-btn.tiny .icon { width: 16px; height: 16px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; font-size: 15px; min-height: 40px;
}
.input[readonly] { background: #f7f9fb; color: var(--ink-soft); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: -4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.row.selects > * { flex: 1; min-width: 120px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* Tabs / pills */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 7px 13px; border-radius: 999px; background: #eef2f6; color: var(--ink-soft);
  font-weight: 600; font-size: 13px;
}
.pill.on { background: var(--brand); color: #fff; }
.chip {
  padding: 5px 10px; border-radius: 999px; background: #edf3f6; color: var(--brand-ink);
  font-size: 12px; font-weight: 600; border: 1px solid #d7e5ec;
}
.chip.amber { background: #fdf3e0; color: #8a5a00; border-color: #f0dda8; }
.chip.coral { background: #fdeeeb; color: #b04430; border-color: #f4cfc8; }
.chip.leaf { background: #e9f5ec; color: #2f7a43; border-color: #cde8d4; }
.chip.violet { background: #f0edfb; color: #5b48a8; border-color: #ddd5f2; }
.chip.sky { background: #e8f2fa; color: #2f6c9a; border-color: #cfe4f3; }
.chip.gray { background: #f0f3f6; color: #5c6b7a; border-color: #e0e6ec; }

/* Segmented */
.seg { display: inline-flex; background: #eef2f6; border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* Stat */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 26px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--ink-soft); }
.stat .ic { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 8px; background: #e8f1f5; color: var(--brand); }
.stat .ic .icon { width: 21px; height: 21px; }

/* Progress */
.progress { background: #eef2f6; border-radius: 999px; height: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .4s; }
.progress.thin { height: 6px; }

/* Lesson list */
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.lesson-tile {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px;
  text-align: left; transition: border-color .12s, box-shadow .12s;
}
.lesson-tile:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.lesson-tile .no { font-size: 12px; color: var(--brand); font-weight: 700; }
.lesson-tile .t { font-weight: 600; font-size: 14px; margin-top: 3px; }
.lesson-tile .c { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.lesson-tile.on { border-color: var(--brand); background: #f0f7f9; }

/* Word chips */
.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word {
  padding: 8px 12px; background: #f2f5f8; border-radius: 6px; font-size: 16px; font-weight: 600;
  border: 1px solid transparent; user-select: none;
}
.word.done { background: #e8f5ec; color: #2f7a43; border-color: #cde8d4; }
.word.wrong { background: #fdeeeb; color: #b04430; border-color: #f4cfc8; }
.word.reveal { border-color: #cfe0ea; }
.word .py { display: block; font-size: 12px; color: var(--ink-faint); font-weight: 400; }

/* Dictation stage */
.dict-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 320px; text-align: center; }
.dict-word { font-size: 54px; font-weight: 700; letter-spacing: .08em; min-height: 78px; display: flex; align-items: center; justify-content: center; }
.dict-word.hidden-txt { color: transparent; text-shadow: 0 0 0 rgba(0,0,0,0); }
.dict-word.hidden-txt::after { content: "••••"; color: var(--ink-faint); letter-spacing: .3em; font-size: 34px; }
.dict-word .blank { color: transparent; }
.dict-count { font-size: 13px; color: var(--ink-faint); }
.dict-controls { display: flex; align-items: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.speed-row { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--ink-soft); font-size: 13px; }

/* Photo upload */
.photo-upload { position: relative; border: 2px dashed #cfdae3; border-radius: var(--radius); padding: 22px; text-align: center; cursor: pointer; transition: border-color .12s, background .12s; }
.photo-upload:hover { border-color: var(--brand); background: #f6fafb; }
.photo-upload .ic { width: 42px; height: 42px; margin: 0 auto 8px; color: var(--brand); }
.photo-upload .ic .icon { width: 42px; height: 42px; }
.photo-upload input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; z-index: 2; font-size: 0;
}
.file-btn { position: relative; }
.file-btn input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.photo-preview { position: relative; margin-top: 12px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.photo-preview img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: #f7f9fb; }
.photo-preview .rm { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; }
.photo-preview .rm .icon { width: 16px; height: 16px; }
.photo-preview .label { position: absolute; left: 8px; bottom: 8px; background: rgba(255,255,255,.9); border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--ink-soft); }

/* OCR progress */
.ocr-bar { margin-top: 12px; }
.ocr-status { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }

/* Wrong question card */
.wq { display: flex; gap: 14px; padding: 16px; border-bottom: 1px solid var(--line); }
.wq:last-child { border-bottom: 0; }
.wq-thumb { width: 74px; height: 74px; flex: none; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #f7f9fb; }
.wq-thumb img, .wq-thumb .noimg { width: 100%; height: 100%; object-fit: cover; }
.wq-thumb .noimg { display: grid; place-items: center; color: var(--ink-faint); font-size: 11px; }
.wq-body { flex: 1; min-width: 0; }
.wq-body h4 { margin: 0 0 4px; font-size: 14px; }
.wq-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.wq-desc { font-size: 13px; color: var(--ink-soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wq-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.wq-photo-main { width: 100%; max-height: 220px; object-fit: contain; background: #f7f9fb; border-radius: 6px; margin-top: 8px; }

/* Analysis cards */
.analysis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.analysis .block { background: #f7f9fb; border-radius: 6px; padding: 12px; }
.analysis .block b { font-size: 12px; color: var(--ink-faint); display: block; margin-bottom: 5px; }
.analysis .block p { margin: 0; font-size: 14px; }

/* Similar questions */
.sim-q { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.sim-q .qs { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.sim-q .ans { font-size: 14px; color: var(--ink-soft); }
.sim-q .ans[hidden] { display: none; }
.sim-q .n { float: right; }

/* Material library */
.mat-quote { border-left: 3px solid var(--teal); padding: 12px 14px; background: #f6fbfb; border-radius: 0 6px 6px 0; }
.mat-quote .q { font-size: 15px; font-weight: 600; }
.mat-quote .src { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }
.mat-quote .note { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-faint); }
.empty .icon { width: 44px; height: 44px; color: #cdd6de; margin-bottom: 10px; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(20,40,60,.4); display: grid; place-items: center; padding: 20px; z-index: 60; }
.modal { width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-md); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 17px; }
.modal-b { padding: 18px 20px 22px; }
.modal-f { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); justify-content: flex-end; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: #1d2b3a; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .25s; z-index: 80; max-width: 90vw; box-shadow: var(--shadow-md); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Empty progress ring */
.ring { width: 96px; height: 96px; position: relative; }
.ring svg { width: 100%; height: 100%; }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 20px; }

/* Legend color dots */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* Scrollbars on webkit (desktop) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d2dae2; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive (tablet/phone) ---------- */
@media (max-width: 960px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .analysis { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 55; transform: translateX(-100%);
    transition: transform .2s; width: 240px; box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .burger { display: inline-flex; }
  .content { padding: 16px 14px 80px; }
  .topbar { padding: 12px 14px; }
  .topbar-title { font-size: 16px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .dict-word { font-size: 40px; }
  .wq { flex-direction: column; }
  .wq-thumb { width: 100%; height: auto; }
}

.scrim { position: fixed; inset: 0; background: rgba(20,40,60,.35); z-index: 54; }

/* 课内学习内容详情 */
.rule-line { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.rule-line:last-child { border-bottom: 0; }
.rule-line b { color: var(--brand); font-size: 14px; }
.rule-line div { font-size: 14px; color: var(--ink-soft); margin-top: 3px; line-height: 1.7; }
.ex-box { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 8px 0; background: #fbfcfd; }
.ex-box summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--brand-ink); }
.ex-box ol { margin: 10px 0 8px; padding-left: 20px; font-size: 14px; color: var(--ink-soft); line-height: 1.8; }
.ex-ans { color: var(--leaf); font-weight: 700; font-size: 14px; }
.sentence-line { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.sentence-line:last-child { border-bottom: 0; }
.sentence-line b { font-size: 15px; font-weight: 600; }
.sentence-line .faint { margin-top: 2px; }
.talk-line { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.talk-line:last-child { border-bottom: 0; }
.talk-line > div:nth-child(2) { font-size: 15px; font-weight: 600; }
.warn-line { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; color: var(--ink-soft); }
.warn-line:last-child { border-bottom: 0; }
.warn-line .icon { color: var(--amber); margin-top: 3px; }

/* 独立听写本 */
.tingxie-app { max-width: 980px; margin: 0 auto; padding: 20px 16px 70px; }
.tingxie-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.tingxie-brand { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.tingxie-brand .icon { color: var(--brand); width: 24px; height: 24px; }
.tingxie-brand span { color: var(--ink-faint); font-size: 12px; }
.tingxie-top .pills { margin-left: auto; }
.tingxie-body { min-height: 55vh; }
.card { margin-bottom: 14px; }
.en-prompt { font-size: 30px; font-weight: 700; color: var(--brand-ink); padding: 10px 0 4px; line-height: 1.45; }
.dict-answer { font-size: 42px; font-weight: 800; letter-spacing: .04em; color: var(--ink); padding: 14px 0 6px; word-break: break-word; }
.dict-result-big { font-size: 64px; font-weight: 800; color: var(--brand); line-height: 1.1; }
.dict-card { max-width: 820px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px 16px; }
.hidden { display: none !important; }
@media (max-width: 720px) {
  .tingxie-top { flex-direction: column; align-items: stretch; gap: 12px; }
  .tingxie-top .pills { margin-left: 0; overflow-x: auto; }
  .tingxie-top .pills .pill { white-space: nowrap; }
  .dict-answer { font-size: 34px; }
  .en-prompt { font-size: 26px; }
}

/* 拍照识别进度 */
.ocr-progress-card { max-width: 460px; }
.ocr-progress-card .ocr-status { font-size: 16px; font-weight: 600; color: var(--ink); }
