/* Grammar Detective — 英文作文批改台 */

:root {
  --paper: #f6f5f1;
  --card: #ffffff;
  --ink: #1b1b19;
  --ink-2: #55554e;
  --ink-3: #8b8b82;
  --line: #e4e2da;
  --line-strong: #cdcabf;

  --red: #b03a2e;
  --red-soft: #fbf0ee;
  --green: #2f6f4e;
  --green-soft: #edf5ef;
  --navy: #1e3352;
  --amber: #9a6b12;

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", "Songti SC", serif;

  --radius: 3px;
  --shadow: 0 1px 2px rgba(27, 27, 25, 0.04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 245, 241, 0.92);
  backdrop-filter: saturate(140%) blur(6px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 1px solid var(--navy);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.04em;
  border-radius: 2px;
}

.brand-name {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.14em;
  line-height: 1.4;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-chip {
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--card);
  white-space: nowrap;
}

.mode-chip.live {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

/* ---------- 按钮 ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  padding: 9px 20px;
  font-size: 13.5px;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s;
}

.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line-strong);
}

.btn.ghost:hover { border-color: var(--ink-3); color: var(--ink); }

.btn.small { padding: 5px 12px; font-size: 12.5px; }

/* ---------- 布局 ---------- */

main {
  max-width: 940px;
  margin: 0 auto;
  padding: 34px 28px 90px;
}

.view[hidden] { display: none; }

/* ---------- 输入页 ---------- */

.hero h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin: 0 0 8px;
}

.hero p {
  color: var(--ink-2);
  margin: 0 0 26px;
  max-width: 620px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 20px 22px; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
}

.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 4px;
  margin-right: 20px;
  font-size: 13.5px;
  color: var(--ink-3);
  cursor: pointer;
  letter-spacing: 0.03em;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--navy);
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 6px;
}

input.text, textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: #fcfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

input.text:focus, textarea:focus {
  border-color: var(--navy);
  background: #fff;
}

textarea#textInput {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.85;
  min-height: 230px;
  resize: vertical;
}

.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fcfcfa;
}

.dropzone:hover, .dropzone.over {
  border-color: var(--navy);
  background: #fbfbf8;
  color: var(--ink-2);
}

.dropzone strong {
  display: block;
  color: var(--ink);
  font-weight: 500;
  font-size: 14.5px;
  margin-bottom: 4px;
}

.dropzone .hintline { font-size: 12px; }

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.actions .spacer { flex: 1; }

.note {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
}

.ocr-status {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  display: none;
}

.ocr-status.show { display: block; }

.history {
  margin-top: 30px;
}

.section-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.history-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.history-item:hover .h-title { color: var(--navy); text-decoration: underline; }

.h-title {
  font-family: var(--serif);
  font-size: 15px;
}

.h-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-left: auto;
  white-space: nowrap;
}

.h-score {
  font-family: var(--serif);
  font-size: 15px;
  min-width: 54px;
  text-align: right;
}

/* ---------- 批改页 ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0 16px;
  flex-wrap: wrap;
}

.toolbar .work-title {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  flex: 1;
  min-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.progress-track {
  width: 120px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.25s ease;
}

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(27, 27, 25, 0.05);
  padding: 46px 56px 56px;
  position: relative;
}

.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--navy);
}

.sheet-kicker {
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.sheet-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin: 0 0 6px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-meta {
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 10px;
  margin-bottom: 26px;
}

.essay {
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 2.15;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

.essay del.err {
  color: var(--red);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(176, 58, 46, 0.75);
  background: var(--red-soft);
  border-radius: 2px;
  padding: 0 1px;
}

.slot {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  margin: 0 1px;
}

input.fix {
  font-family: var(--serif);
  font-size: inherit;
  line-height: 1.35;
  color: var(--red);
  background: rgba(176, 58, 46, 0.045);
  border: 1px solid rgba(176, 58, 46, 0.26);
  border-radius: 2px;
  padding: 0 3px 1px;
  height: 1.62em;
  min-width: 38px;
  text-align: center;
  outline: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

input.fix:hover { border-color: rgba(176, 58, 46, 0.5); }

input.fix:focus {
  background: #fff;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(176, 58, 46, 0.1);
}

input.fix.ok {
  color: var(--green);
  background: #e4f1e8;
  border-color: #bfdccb;
  font-weight: 400;
}

input.fix.bad {
  background: #fdf3f2;
  border-color: var(--red);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.delbtn {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--red);
  background: transparent;
  border: 1px dashed rgba(176, 58, 46, 0.5);
  border-radius: 2px;
  padding: 1px 7px;
  cursor: pointer;
  vertical-align: 2px;
  margin-left: 3px;
}

.delbtn.ok {
  color: var(--green);
  border: 1px solid transparent;
  background: var(--green-soft);
  cursor: default;
}

.slot .hint {
  position: absolute;
  top: -0.62em;
  right: -0.75em;
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-3);
  font-size: 9px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}

.slot:hover .hint,
body.show-hints .slot .hint { opacity: 1; }

.slot .hint:hover { border-color: var(--navy); color: var(--navy); }

.slot.ok .hint { display: none; }

.slot.deleted .delbtn { display: none; }

.hintbar {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
  color: var(--ink-2);
  min-height: 22px;
  line-height: 1.7;
  display: none;
}

.hintbar.show { display: block; }

.hintbar b { font-weight: 600; color: var(--ink); }

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ---------- 报告页 ---------- */

.report-head {
  display: flex;
  gap: 34px;
  align-items: flex-end;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.score-num {
  font-family: var(--serif);
  font-size: 66px;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.score-num .den {
  font-size: 22px;
  color: var(--ink-3);
  letter-spacing: 0;
}

.score-cap {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.score-grade {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--green);
  margin-top: 6px;
}

.stat-row {
  display: flex;
  gap: 30px;
  padding-bottom: 4px;
  flex-wrap: wrap;
}

.stat { min-width: 76px; }
.stat .v {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.2;
}
.stat .k {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}

.block { margin-top: 34px; }

.block h2 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.02em;
}

.cat-row {
  display: grid;
  grid-template-columns: 88px 1fr 46px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
}

.cat-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.cat-bar span {
  display: block;
  height: 100%;
  background: var(--ink-2);
}

.cat-row .cnt {
  text-align: right;
  font-size: 12px;
  color: var(--ink-3);
}

table.fixes {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.fixes th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
}

table.fixes td {
  padding: 11px 10px 11px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.fixes tr:last-child td { border-bottom: 0; }

td.orig {
  font-family: var(--serif);
  color: var(--red);
  text-decoration: line-through;
  text-decoration-color: rgba(176, 58, 46, 0.7);
  white-space: nowrap;
}

td.ans {
  font-family: var(--serif);
  white-space: nowrap;
}

td.ans.ok { color: var(--green); }
td.ans.no { color: var(--red); }

td.why {
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
}

td.st { white-space: nowrap; font-size: 12px; color: var(--ink-3); }

.corrected {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 2;
  white-space: pre-wrap;
  background: #fcfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.corrected mark {
  background: var(--green-soft);
  color: var(--green);
  padding: 0 2px;
  border-radius: 2px;
}

.corrected s {
  color: var(--red);
  opacity: 0.55;
  text-decoration-thickness: 1px;
}

ul.advice {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-2);
  line-height: 1.9;
  font-size: 13.5px;
}

ul.advice li { margin-bottom: 4px; }

/* ---------- 弹层 ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 27, 25, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 26px 28px;
  box-shadow: 0 12px 40px rgba(27, 27, 25, 0.18);
}

.modal-box h3 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  margin: 0 0 6px;
}

.modal-box .note { margin-bottom: 18px; }

.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.checkline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 4px;
  line-height: 1.6;
}

.checkline input { margin-top: 3px; }

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 打印 ---------- */

@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .toolbar, .actions, .modal, .toast, .sheet-foot, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .card, .sheet { border: 0; box-shadow: none; padding: 0; }
  .sheet::before { display: none; }
  .block { break-inside: avoid; }
  table.fixes tr { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ---------- 窄屏 ---------- */

@media (max-width: 640px) {
  main { padding: 22px 14px 70px; }
  .topbar { padding: 12px 14px; }
  .brand-sub { display: none; }
  .hero h1 { font-size: 24px; }
  .sheet { padding: 30px 20px 34px; }
  .essay { font-size: 17px; line-height: 2.05; }
  .score-num { font-size: 52px; }
  .report-head { gap: 20px; }
  .tabs { padding: 0 14px; }
  .card-pad { padding: 16px 14px; }
  .toolbar { gap: 8px 10px; }
  .toolbar .work-title { min-width: 0; font-size: 15px; }
  .toolbar .btn.small { padding: 5px 10px; font-size: 12px; }
  .progress-wrap { order: 5; width: 100%; }
  .progress-track { flex: 1; width: auto; }
}

/* ================= 登录 ================= */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--paper);
}

.gate-box {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.gate-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 20px;
  border: 1px solid var(--navy);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.05em;
}

.gate-box h1 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}

.gate-sub {
  font-size: 11.5px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  margin: 0 0 30px;
}

.gate-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.12em;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.gate-input:focus { border-color: var(--navy); }

.gate-btn {
  width: 100%;
  margin-top: 12px;
  padding: 11px 20px;
}

.gate-err {
  min-height: 20px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--red);
}

.gate-note {
  margin-top: 26px;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}

/* ================= 首页 ================= */

.kid-select {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  max-width: 140px;
}

.start-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}

.start-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }

.start-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--navy);
  color: var(--navy);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 300;
  flex: 0 0 auto;
}

.start-text strong {
  display: block;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 3px;
}

.start-text span { font-size: 12.5px; color: var(--ink-3); }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.quick-grid.three { grid-template-columns: repeat(3, 1fr); }

.quick {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
}

.quick:hover { border-color: var(--line-strong); }
.quick.static { cursor: default; }

.quick-num {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.1;
  color: var(--ink);
}

.quick-label {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ================= 错词本 ================= */

.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.word-row:last-child { border-bottom: 0; }
.word-row.compact { padding: 9px 0; }

.word-pair {
  font-family: var(--serif);
  font-size: 17px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.w-wrong {
  color: var(--red);
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(176, 58, 46, 0.7);
}

.w-arrow { color: var(--ink-3); font-size: 13px; }
.w-fix { color: var(--green); }

.word-meta {
  display: flex;
  gap: 12px;
  font-size: 11.5px;
  color: var(--ink-3);
  align-items: center;
}

.tag-ok {
  color: var(--green);
  border: 1px solid #bfdccb;
  background: var(--green-soft);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10.5px;
}

.word-row.mastered .w-wrong { color: var(--ink-3); text-decoration-color: var(--line-strong); }
.word-row.mastered .w-fix { color: var(--ink-2); }

.empty-state {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ================= 复习 ================= */

.review-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 52px 32px 44px;
  text-align: center;
  max-width: 460px;
  margin: 0 auto;
}

.review-hint {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}

.review-wrong {
  font-family: var(--serif);
  font-size: 40px;
  color: var(--red);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(176, 58, 46, 0.6);
  margin-bottom: 26px;
  word-break: break-word;
}

.review-input {
  width: 100%;
  max-width: 260px;
  font-family: var(--serif);
  font-size: 24px;
  text-align: center;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1.5px solid var(--line-strong);
  background: transparent;
  outline: none;
  transition: border-color 0.15s, color 0.15s;
}

.review-input:focus { border-bottom-color: var(--navy); }
.review-input.ok { color: var(--green); border-bottom-color: var(--green); }
.review-input.bad { border-bottom-color: var(--red); animation: shake 0.3s ease; }

.review-feedback {
  min-height: 24px;
  margin: 16px 0 20px;
  font-size: 13.5px;
}

.review-feedback.ok { color: var(--green); }
.review-feedback.bad { color: var(--red); }

/* ================= 图表 ================= */

.chart {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px 12px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
}

.chart-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.chart-bar {
  width: 100%;
  background: var(--navy);
  border-radius: 1px 1px 0 0;
  opacity: 0.82;
  transition: height 0.3s ease;
}

.chart-bar.empty { background: var(--line); opacity: 1; }

.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* ================= 设置 ================= */

.mini-h {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 400;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.kid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.kid-name { font-size: 14px; }

.link-danger {
  background: none;
  border: 0;
  color: var(--ink-3);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.link-danger:hover { color: var(--red); }

.inline-add {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.inline-add input { flex: 1; }

/* ================= 語言切換 ================= */

.lang-select {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
}

.lang-select:hover { border-color: var(--ink-3); color: var(--ink); }

.gate-box .lang-select {
  margin-top: 22px;
  border-color: transparent;
  color: var(--ink-3);
}

/* ================= 首頁兩張入口卡 ================= */

.start-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0 18px;
}

.start-grid .start-card { margin: 0; }

.start-card.hw .start-icon {
  background: var(--green-soft);
  color: var(--green);
  border-color: #cfe3d6;
}

.start-card.hw:hover { border-color: var(--green); }

@media (max-width: 620px) {
  .start-grid { grid-template-columns: 1fr; }
}

/* ================= 模式標籤 ================= */

.mode-chip {
  margin-left: auto;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* ================= 多圖縮圖條 ================= */

.shot-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.shot-strip:empty { display: none; }

.shot {
  position: relative;
  width: 96px;
  height: 124px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.shot.done { border-color: #bfdccb; }

.shot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: block;
}

.shot-no {
  position: absolute;
  left: 4px;
  top: 4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: rgba(27, 27, 25, 0.72);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  padding: 0 5px;
}

.shot.done .shot-no { background: var(--green); }

.shot-x,
.shot-mv {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 2px;
}

.shot-x {
  right: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  font-size: 14px;
}

.shot-mv {
  bottom: 3px;
  width: 20px;
  height: 20px;
  font-size: 14px;
}

.shot-mv.left { left: 3px; }
.shot-mv.right { right: 3px; }

.shot-x:hover,
.shot-mv:hover { background: #fff; color: var(--ink); }

.shot-add {
  width: 96px;
  height: 124px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  cursor: pointer;
}

.shot-add:hover { border-color: var(--ink-3); color: var(--ink-2); }

/* ================= 作業批改 ================= */

#hwList { display: flex; flex-direction: column; gap: 14px; }

.hw-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px 16px;
  box-shadow: var(--shadow);
}

.hw-card.done { border-color: #cfe3d6; background: #fcfefc; }

.hw-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.hw-no {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--navy);
  min-width: 26px;
}

.hw-type {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.hw-badge {
  margin-left: auto;
  font-size: 17px;
  line-height: 1;
  width: 22px;
  text-align: center;
}

.hw-badge.ok { color: var(--green); }
.hw-badge.bad { color: var(--red); }

.hw-passage {
  margin: 0 0 12px;
  border-left: 2px solid var(--line-strong);
  padding-left: 12px;
}

.hw-passage summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  list-style: none;
}

.hw-passage summary::-webkit-details-marker { display: none; }
.hw-passage summary::before { content: '▸ '; color: var(--ink-3); }
.hw-passage[open] summary::before { content: '▾ '; }

.hw-passage p {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink-2);
  white-space: pre-wrap;
}

.hw-prompt {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 2.1;
  color: var(--ink);
}

.hw-blank { display: inline-block; margin: 0 3px; }

.hw-input {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--red);
  background: rgba(176, 58, 46, 0.04);
  border: 1px solid rgba(176, 58, 46, 0.26);
  border-radius: 2px;
  padding: 1px 4px;
  height: 1.8em;
  text-align: center;
  outline: none;
}

.hw-input:focus {
  background: #fff;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(176, 58, 46, 0.1);
}

.hw-input.ok {
  color: var(--green);
  background: #e4f1e8;
  border-color: #bfdccb;
}

.hw-input.bad {
  border-color: var(--red);
  background: #fdf3f2;
  animation: shake 0.3s ease;
}

.hw-input.warn { border-color: var(--amber); }

.hw-blank.wide { display: block; margin: 6px 0 0; }
.hw-blank.wide textarea {
  width: 100%;
  text-align: left;
  resize: vertical;
  line-height: 1.7;
  padding: 6px 8px;
  height: auto;
  min-height: 2.6em;
}

.hw-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hw-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 14px;
  font-family: var(--serif);
  cursor: pointer;
  color: var(--ink);
}

.hw-opt b {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 5px;
  line-height: 1.5;
}

.hw-opt:hover { border-color: var(--ink-3); }

.hw-opt.ok {
  border-color: #bfdccb;
  background: #e4f1e8;
  color: var(--green);
}

.hw-opt.ok b { border-color: #bfdccb; color: var(--green); }

.hw-opt.bad {
  border-color: var(--red);
  background: #fdf3f2;
  animation: shake 0.3s ease;
}

.hw-feedback {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hw-feedback.ok { color: var(--green); }
.hw-feedback.bad { color: var(--red); }

.hw-feedback.reveal {
  border-top: 1px dashed var(--line-strong);
  padding-top: 10px;
}

.hw-sub { color: var(--ink-3); font-size: 12px; }
.hw-answer {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--navy);
  background: #f0f3f8;
  border-radius: 2px;
  padding: 2px 8px;
}

.hw-card.shake { animation: shake 0.35s ease; }

.hw-reveal { margin-left: 4px; }

/* 作業報告表格 */

.hw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--line);
}

.hw-table th,
.hw-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.hw-table th {
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: #fbfaf7;
}

.hw-table td.c-no { width: 42px; color: var(--ink-3); }
.hw-table td.c-orig { font-family: var(--serif); line-height: 1.7; }
.hw-table td.c-you { color: var(--red); width: 130px; }
.hw-table td.c-fix { color: var(--green); width: 130px; }
.hw-table td.c-state { width: 40px; text-align: center; }
.hw-table tr.ok td.c-state { color: var(--green); }
.hw-table tr.bad td.c-state { color: var(--ink-3); }
.hw-table tr.bad td.c-you { text-decoration: line-through; opacity: 0.6; }
.hw-table tr.ok td.c-you { color: var(--green); }

/* 薄弱點 */

.weak-list { display: flex; flex-direction: column; gap: 2px; }

.weak-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13.5px;
}

.weak-row + .weak-row { border-top: none; }
.weak-name { color: var(--ink); }
.weak-count { color: var(--red); font-size: 12.5px; }

.weak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.weak-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.weak-card:hover { border-color: var(--navy); }
.weak-card .weak-name { font-size: 15px; }
.weak-card .weak-count { color: var(--ink-3); font-size: 12px; }

/* ================= 錯題 ================= */

.mis-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
}

.mis-row.mastered { opacity: 0.62; }

.mis-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.mis-no {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--navy);
}

.mis-cat {
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.mis-prompt {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--ink);
}

.mis-given {
  font-size: 12px;
  color: var(--red);
  margin-top: 3px;
}

.mis-body {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.mis-input {
  flex: 1;
  max-width: 280px;
  font-family: var(--serif);
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
}

.mis-input:focus { border-color: var(--navy); }
.mis-input.ok { border-color: #bfdccb; background: #e4f1e8; color: var(--green); }
.mis-input.bad { border-color: var(--red); background: #fdf3f2; animation: shake 0.3s ease; }

.mis-feedback { margin-top: 8px; font-size: 12.5px; }
.mis-feedback.ok { color: var(--green); }
.mis-feedback.bad { color: var(--red); }

.mis-why {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

/* ================= 練習 ================= */

.pr-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  max-width: 720px;
}

.pr-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pr-no {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--navy);
}

.pr-src {
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.pr-actions { margin-top: 16px; }

.pr-done {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 520px;
}

/* 空格旁的确认按钮：只有填了内容才出现 */
.hw-blank { display: inline-flex; align-items: center; gap: 3px; }

.hw-confirm {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-3);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  flex: none;
}

.hw-blank.filled .hw-confirm,
.hw-blank.wide.filled .hw-confirm {
  opacity: 1;
  pointer-events: auto;
}

.hw-confirm:hover { border-color: var(--navy); color: var(--navy); }

.hw-blank.wide .hw-confirm { margin-left: 8px; align-self: flex-end; }

/* 改写题的整句输入用中性边框，避免一大块红 */
.hw-blank.wide textarea.hw-input {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}
.hw-blank.wide textarea.hw-input:focus { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(30, 51, 82, 0.08); }
.hw-blank.wide textarea.hw-input.ok {
  border-color: #bfdccb;
  background: #e4f1e8;
  color: var(--green);
}

/* 作業報告標題 */
.hw-report-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.hw-report-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

/* 表格列寬放寬，避免長句擠成三行 */
.hw-table td.c-you,
.hw-table td.c-fix { width: 22%; min-width: 120px; }
.hw-table td.c-orig { width: auto; }

/* 练习卡居中一点，别缩在左上角 */
#prBody { display: flex; flex-direction: column; align-items: stretch; }
.pr-card { margin: 8px auto 0; width: 100%; }
.pr-done { margin: 8px auto 0; }
.weak-grid {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
#prBody > .note, #prBody > .empty-state { max-width: 720px; margin-left: auto; margin-right: auto; }

/* 首頁：練習入口 */
.home-extra {
  display: flex;
  justify-content: flex-start;
  margin: 2px 0 20px;
}
.home-extra .btn {
  font-size: 13px;
  padding: 8px 16px;
}

/* 手機：頂欄收窄，只留標記 */
@media (max-width: 480px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand-name { display: none; }
  .brand-mark { width: 30px; height: 30px; font-size: 12px; }
  .topbar-right { gap: 6px; }
  .kid-select, .lang-select { max-width: 92px; font-size: 12px; padding: 4px 6px; }
  .topbar-right .btn.small { padding: 4px 8px; font-size: 12px; }
  main { padding: 18px 12px 64px; }
  .hw-card { padding: 14px 13px; }
  .hw-options { grid-template-columns: 1fr 1fr; }
}

/* 手機：逐題回顧改成卡片式（表格在 390px 放不下四欄） */
@media (max-width: 620px) {
  .stat-row { flex-wrap: wrap; gap: 14px 20px; }
  .stat { min-width: 64px; }
  .stat .v { font-size: 18px; white-space: nowrap; }
  .stat .k { font-size: 11px; }

  .hw-table { border: 0; background: transparent; font-size: 13px; }
  .hw-table thead { display: none; }
  .hw-table,
  .hw-table tbody,
  .hw-table tr,
  .hw-table td { display: block; width: auto; }

  .hw-table tr {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    padding: 11px 13px 13px;
    margin-bottom: 8px;
  }

  .hw-table td { border: 0; padding: 0; }

  .hw-table td.c-no {
    width: auto;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    margin-bottom: 5px;
  }

  .hw-table td.c-orig {
    font-size: 14.5px;
    line-height: 1.65;
    margin-bottom: 9px;
    padding-right: 22px;
  }
  .hw-table td.c-orig::before { display: none; }

  .hw-table td.c-you,
  .hw-table td.c-fix {
    width: auto;
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    font-size: 13.5px;
  }
  .hw-table td.c-you::before,
  .hw-table td.c-fix::before {
    content: attr(data-label);
    flex: 0 0 56px;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--ink-3);
  }

  .hw-table td.c-state {
    position: absolute;
    right: 11px;
    top: 9px;
    width: auto;
    font-size: 13px;
  }
}
