:root {
  --paper: #f1f0ea;
  --surface: #faf9f4;
  --ink: #171817;
  --muted: #6b6d68;
  --line: #c9cac2;
  --line-dark: #91938c;
  --accent: #e5573f;
  --accent-dark: #b73c2b;
  --green: #315d4e;
  --green-soft: #dbe9df;
  --yellow: #f2c34e;
  --blue: #3b6676;
  --shadow: 0 12px 30px rgba(23, 24, 23, 0.08);
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #deded7; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #deded7;
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  max-width: 1540px;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(23, 24, 23, 0.06);
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--surface);
}

.brand { display: inline-flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  overflow: hidden;
  flex: 0 0 auto;
  background: #07100f;
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font: 700 14px/1 Consolas, "SFMono-Regular", monospace; letter-spacing: 0; }
.brand-copy small { color: var(--muted); font-size: 12px; }
.topbar-tools { display: flex; align-items: center; gap: 20px; }
.session-state { display: inline-flex; align-items: center; gap: 8px; font: 12px Consolas, "SFMono-Regular", monospace; color: var(--muted); }
.status-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 3px var(--green-soft); }
.quiet-button {
  border: 0;
  border-bottom: 1px solid var(--line-dark);
  padding: 4px 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
}
.quiet-button:hover { color: var(--accent-dark); border-color: var(--accent-dark); }
.shuffle-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  color: var(--ink);
  background: transparent;
  font-size: 12px;
}
.shuffle-button span { color: var(--accent-dark); font-size: 17px; line-height: 0; }
.shuffle-button:hover, .shuffle-button[aria-pressed="true"] { border-color: var(--ink); background: var(--yellow); }

.workspace { display: grid; grid-template-columns: 274px minmax(0, 1fr); min-height: calc(100vh - 118px); }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line-dark); background: #e9e9e1; }
.sidebar-intro { padding: 36px 28px 26px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0; color: var(--muted); font: 11px/1.2 Consolas, "SFMono-Regular", monospace; letter-spacing: 0.04em; }
.eyebrow span { color: var(--ink); }
.sidebar h1 { margin: 11px 0 18px; font-size: 31px; line-height: 1; letter-spacing: 0; font-weight: 700; }
.intro-rule { width: 42px; height: 5px; margin-bottom: 17px; background: var(--accent); }
.sidebar-meta { margin: 0; color: var(--muted); font-size: 12px; }
.sidebar-meta span { color: var(--ink); font-weight: 700; }
.section-nav { display: grid; padding: 17px 15px 15px; gap: 2px; }
.section-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
}
.section-link b { color: var(--line-dark); font: 12px Consolas, "SFMono-Regular", monospace; }
.section-link:hover { color: var(--ink); background: rgba(250, 249, 244, 0.65); }
.section-link.is-active { border-color: var(--ink); color: var(--ink); background: var(--surface); box-shadow: 3px 3px 0 var(--ink); }
.section-link.is-active b { color: var(--accent-dark); }
.progress-module { margin: auto 28px 27px; padding-top: 23px; border-top: 1px solid var(--line); }
.progress-heading, .progress-foot { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 12px; }
.progress-heading strong, .progress-foot strong { color: var(--ink); font: 700 12px Consolas, "SFMono-Regular", monospace; }
.progress-track { height: 7px; margin: 13px 0 16px; background: #d4d5cd; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 240ms ease; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 16px 28px; border-top: 1px solid var(--line); color: var(--muted); font: 10px Consolas, "SFMono-Regular", monospace; }
.calibration-mark { width: 12px; height: 12px; border: 2px solid var(--ink); display: inline-block; }

.content-area { min-width: 0; padding: 42px clamp(26px, 5vw, 78px) 52px; }
.content-header { display: flex; justify-content: space-between; align-items: end; gap: 24px; max-width: 1100px; margin: 0 auto 30px; }
.content-header h2 { margin: 11px 0 0; font-size: 25px; line-height: 1; letter-spacing: 0; }
.header-metrics { display: flex; align-items: end; gap: 28px; }
.search-box { display: flex; align-items: center; gap: 8px; min-width: 190px; padding-bottom: 8px; border-bottom: 1px solid var(--line-dark); color: var(--muted); }
.search-box span { font-size: 22px; line-height: 0.7; transform: rotate(-20deg); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: var(--muted); }
.metric-block { min-width: 95px; padding-left: 17px; border-left: 1px solid var(--line); }
.metric-block span { display: block; color: var(--muted); font-size: 11px; }
.metric-block strong { display: block; margin-top: 3px; font: 700 21px Consolas, "SFMono-Regular", monospace; }

.question-layout { display: grid; grid-template-columns: minmax(0, 1fr) 198px; align-items: start; gap: 26px; max-width: 1100px; margin: 0 auto; }
.question-panel { min-width: 0; padding: clamp(25px, 4vw, 42px); border: 1px solid var(--line-dark); background: var(--surface); box-shadow: var(--shadow); }
.question-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 25px; }
.type-tag { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; color: var(--surface); background: var(--green); font: 11px Consolas, "SFMono-Regular", monospace; }
.question-code { color: var(--muted); font: 12px Consolas, "SFMono-Regular", monospace; }
.question-panel h3 { max-width: 810px; margin: 0 0 32px; font-size: clamp(19px, 2.1vw, 26px); line-height: 1.55; font-weight: 600; letter-spacing: 0; }
.answer-area { display: grid; gap: 10px; }
.option-card { display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 14px; min-height: 58px; padding: 9px 15px 9px 9px; border: 1px solid var(--line); background: #f4f3ed; transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease; }
.option-card:hover { border-color: var(--ink); background: #fffef9; }
.option-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option-card.is-correct:has(input:focus-visible) { outline-color: var(--green); }
.option-card:has(input:checked) { border-color: var(--ink); background: #fffef9; box-shadow: 4px 4px 0 var(--yellow); }
.option-card.is-correct { border-color: var(--green); background: #f3fbf3; box-shadow: 4px 5px 0 var(--green) !important; }
.option-card.is-wrong { border-color: var(--accent); background: #fff4f0; box-shadow: 4px 5px 0 var(--accent) !important; }
.option-card.is-correct .option-key { border-color: var(--green); color: #fff; background: var(--green); }
.option-card.is-wrong .option-key { border-color: var(--accent); color: #fff; background: var(--accent); }
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-key { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line-dark); color: var(--muted); font: 700 12px Consolas, "SFMono-Regular", monospace; }
.option-card:has(input:checked) .option-key { border-color: var(--ink); color: var(--surface); background: var(--ink); }
.option-text { color: var(--ink); font-size: 14px; line-height: 1.55; }
.text-answer, .short-answer { width: 100%; padding: 13px 14px; border: 1px solid var(--line-dark); border-radius: 0; outline: 0; color: var(--ink); background: #f4f3ed; font-size: 14px; line-height: 1.7; }
.text-answer:focus, .short-answer:focus { border-color: var(--ink); box-shadow: 4px 4px 0 var(--yellow); }
.short-answer { min-height: 142px; resize: vertical; }
.answer-hint { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 31px; padding-top: 20px; border-top: 1px solid var(--line); }
.primary-button, .next-button { min-height: 43px; padding: 0 16px; border: 1px solid var(--ink); color: var(--surface); background: var(--ink); font-size: 13px; }
.primary-button span, .next-button span { margin-left: 13px; color: var(--yellow); font-family: Consolas, "SFMono-Regular", monospace; }
.primary-button:hover, .next-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.text-button { padding: 8px 0; border: 0; border-bottom: 1px solid var(--line-dark); color: var(--muted); background: transparent; font-size: 12px; }
.text-button:hover { color: var(--ink); border-color: var(--ink); }
.shortcut-guide { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 13px; margin-top: 16px; color: var(--muted); font-size: 11px; }
.shortcut-guide-title { color: var(--ink); font: 700 10px/1 Consolas, "SFMono-Regular", monospace; letter-spacing: 0.04em; text-transform: uppercase; }
.shortcut-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
kbd { min-width: 22px; padding: 3px 6px; border: 1px solid var(--line-dark); color: var(--ink); background: var(--paper); font: 10px/1.1 Consolas, "SFMono-Regular", monospace; text-align: center; }
.feedback { margin-top: 27px; padding-top: 24px; border-top: 3px solid var(--ink); }
.feedback-status { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; font-size: 14px; font-weight: 700; }
.feedback-status b { display: inline-flex; min-height: 23px; align-items: center; padding: 0 8px; color: var(--surface); background: var(--green); font: 11px Consolas, "SFMono-Regular", monospace; }
.feedback--wrong .feedback-status b { background: var(--accent); }
.feedback--review .feedback-status b { color: var(--ink); background: var(--yellow); }
.feedback--neutral .feedback-status b { color: var(--ink); background: var(--yellow); }
.answer-success-pop { animation: answer-success-pop 520ms cubic-bezier(.2,.8,.2,1); }
@keyframes answer-success-pop {
  0% { transform: translateY(0); }
  35% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .answer-success-pop { animation: none; }
}
.feedback-label { margin: 15px 0 5px; color: var(--muted); font: 10px Consolas, "SFMono-Regular", monospace; letter-spacing: 0.03em; }
.feedback-answer, .feedback-explanation { margin: 0; font-size: 13px; line-height: 1.75; }
.feedback-answer { font-weight: 600; }
.self-rate { display: flex; gap: 8px; margin-top: 17px; }
.self-rate button { padding: 8px 11px; border: 1px solid var(--line-dark); color: var(--ink); background: transparent; font-size: 12px; }
.self-rate button:hover { border-color: var(--ink); background: var(--yellow); }

.question-rail { padding: 19px 16px; border-top: 4px solid var(--ink); background: #e9e9e1; }
.rail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 15px; font-size: 12px; font-weight: 700; }
.rail-heading span:last-child { color: var(--muted); font: 10px Consolas, "SFMono-Regular", monospace; }
.question-index {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: 32px;
  align-content: start;
  gap: 5px;
  max-height: min(64vh, 560px);
  min-height: 0;
  padding: 1px 4px 4px 1px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-dark) transparent;
  scrollbar-width: thin;
}
.question-index::-webkit-scrollbar { width: 6px; }
.question-index::-webkit-scrollbar-thumb { background: var(--line-dark); }
.question-index::-webkit-scrollbar-track { background: transparent; }
.index-button { aspect-ratio: 1; min-width: 0; border: 1px solid var(--line); color: var(--muted); background: var(--paper); font: 11px Consolas, "SFMono-Regular", monospace; }
.index-button:hover { border-color: var(--ink); color: var(--ink); }
.index-button.is-current { border-color: var(--ink); color: var(--surface); background: var(--ink); }
.index-button.is-done:not(.is-current) { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.index-button.is-wrong:not(.is-current) { border-color: var(--accent); color: var(--accent-dark); background: #fbe1da; }
.legend { display: grid; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; display: inline-block; border: 1px solid var(--line-dark); }
.legend-dot--done { border-color: var(--green); background: var(--green-soft); }
.legend-dot--current { border-color: var(--ink); background: var(--ink); }

.app-footer { display: flex; justify-content: space-between; padding: 17px 34px; border-top: 1px solid var(--line-dark); color: var(--muted); background: var(--surface); font: 10px Consolas, "SFMono-Regular", monospace; }

.icp-link { color: inherit; text-decoration: none; letter-spacing: .04em; transition: color .18s ease; }
.icp-link:hover, .icp-link:focus-visible { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 980px) {
  .workspace { display: block; }
  .sidebar { display: block; border-right: 0; border-bottom: 1px solid var(--line-dark); }
  .sidebar-intro { display: flex; align-items: center; gap: 16px; padding: 17px 26px; }
  .sidebar-intro h1 { margin: 0; font-size: 22px; }
  .sidebar-intro .eyebrow, .intro-rule { display: none; }
  .sidebar-meta { margin-left: auto; }
  .section-nav { display: flex; overflow-x: auto; padding: 11px 19px 13px; }
  .section-link { flex: 0 0 auto; min-height: 34px; gap: 17px; }
  .progress-module, .sidebar-foot { display: none; }
  .content-area { padding-top: 32px; }
}

@media (max-width: 720px) {
  .topbar { height: 68px; padding: 0 18px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-copy small { display: none; }
  .topbar-tools { gap: 11px; }
  .session-state { display: none; }
  .content-area { padding: 28px 16px 40px; }
  .content-header { display: block; margin-bottom: 22px; }
  .header-metrics { display: flex; margin-top: 20px; justify-content: space-between; }
  .search-box { min-width: 0; flex: 1; max-width: 230px; }
  .question-layout { display: block; }
  .question-panel { padding: 24px 18px; }
  .question-rail { margin-top: 18px; }
  .question-index { grid-template-columns: repeat(10, 1fr); max-height: min(42vh, 360px); }
  .legend { display: flex; }
  .app-footer { display: block; padding: 15px 18px; line-height: 1.9; }
  .app-footer > span { display: block; }
}

@media (max-width: 440px) {
  .sidebar-intro { padding: 15px 18px; }
  .sidebar-meta { font-size: 11px; }
  .content-header h2 { font-size: 22px; }
  .question-panel h3 { font-size: 18px; }
  .form-actions { gap: 11px; }
  .primary-button, .next-button { flex: 1 0 140px; }
  .text-button { margin-left: auto; }
  .shortcut-guide { gap: 8px 11px; line-height: 1.5; }
  .question-index { grid-template-columns: repeat(6, 1fr); }
}
