:root {
  --ink: #182638;
  --muted: #728094;
  --line: #dfe5ec;
  --paper: #fff;
  --bg: #f3f6f8;
  --navy: #17283d;
  --blue: #2b6de5;
  --blue-soft: #eaf1ff;
  --green: #168a68;
  --green-soft: #ecf8f3;
  --red: #cf4d5c;
  --red-soft: #fff0f2;
  --gold: #c68a22;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}

.topbar {
  height: 72px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 35px; height: 35px; border: 1px solid #7892b1; display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.brand strong { display: block; font-size: 16px; line-height: 1.2; }
.brand small { display: block; color: #aabbd0; font-size: 11px; margin-top: 3px; }
.top-stats { display: flex; gap: 10px; align-items: center; }
.stat { display: flex; align-items: center; gap: 9px; padding: 5px 13px; border: 1px solid #43566d; color: #b8c6d6; font-size: 12px; }
.stat b { color: #fff; font-size: 15px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid #53677e; background: transparent; color: #d8e1ec; font-size: 18px; cursor: pointer; }

.layout { display: grid; grid-template-columns: 228px minmax(480px, 1fr) 255px; gap: 26px; max-width: 1460px; margin: 0 auto; padding: 28px 32px; }
.sidebar { min-height: calc(100vh - 128px); display: flex; flex-direction: column; }
.side-block { margin-bottom: 28px; }
.side-label { font-size: 11px; letter-spacing: 1.3px; color: #99a7b8; margin: 0 0 9px 12px; }
.nav-btn { width: 100%; height: 43px; border: 0; background: transparent; color: #526276; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; margin: 3px 0; cursor: pointer; text-align: left; }
.nav-btn:hover { background: #e8edf4; }
.nav-btn.active { background: var(--blue-soft); color: var(--blue); font-weight: 650; }
.nav-btn em { font-style: normal; color: #a3afbf; font-size: 12px; }
.nav-btn.active em { color: var(--blue); }
.select-label { display: flex; flex-direction: column; gap: 6px; color: #627186; padding: 0 12px 10px; font-size: 12px; }
.select-label select { height: 35px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0 9px; font: inherit; }
.bank-block .select-label { padding-bottom: 0; }
.switch-row { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: #627186; font-size: 13px; }
.switch-row input { display: none; }
.switch-row i { width: 34px; height: 19px; border-radius: 20px; background: #cbd4df; position: relative; cursor: pointer; transition: .2s; }
.switch-row i:after { content: ""; width: 15px; height: 15px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; box-shadow: 0 1px 3px #9ca8b7; transition: .2s; }
.switch-row input:checked + i { background: var(--blue); }
.switch-row input:checked + i:after { left: 17px; }
.source-note { margin-top: auto; padding: 0 12px 6px; display: flex; align-items: center; gap: 8px; color: #8592a3; font-size: 11px; }
.source-note b, .source-note small { display: block; }
.source-note b { color: #68778a; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.practice-head { display: flex; justify-content: space-between; align-items: flex-end; margin: 6px 0 19px; }
.eyebrow { font-size: 12px; color: var(--blue); font-weight: 650; margin: 0 0 3px; }
.practice-head h1 { font-size: 25px; margin: 0; letter-spacing: 0; }
.progress-wrap { width: 190px; text-align: right; color: var(--muted); font-size: 12px; }
.progress { height: 5px; background: #dce3ec; margin-top: 7px; }
.progress i { display: block; height: 100%; background: var(--blue); width: 0; transition: .25s; }
.question-card { background: var(--paper); border: 1px solid var(--line); padding: 31px 35px 25px; min-height: 470px; }
.question-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.q-index { font-size: 12px; color: #8996a7; }
.type-tag, .topic-tag { font-size: 11px; padding: 2px 8px; background: #eff3f7; color: #657589; }
.topic-tag { background: #f5f1e8; color: #98712d; }
.question-title { font-size: 18px; line-height: 1.75; font-weight: 650; margin: 0 0 24px; }
.question-media { display: block; max-width: 100%; max-height: 320px; object-fit: contain; margin: -6px 0 22px; border: 1px solid var(--line); background: #f8fafc; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { border: 1px solid var(--line); min-height: 50px; display: flex; align-items: center; padding: 10px 14px; gap: 12px; cursor: pointer; transition: .15s; background: #fff; }
.option:hover { border-color: #aac3f5; background: #fafcff; }
.option.selected { border-color: var(--blue); background: var(--blue-soft); }
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.incorrect { border-color: var(--red); background: var(--red-soft); }
.option input { display: none; }
.option-key { width: 26px; height: 26px; border: 1px solid #cbd5e1; display: grid; place-items: center; color: #718096; font-size: 12px; flex: 0 0 auto; }
.option.selected .option-key { background: var(--blue); border-color: var(--blue); color: #fff; }
.option.correct .option-key { background: var(--green); border-color: var(--green); color: #fff; }
.option.incorrect .option-key { background: var(--red); border-color: var(--red); color: #fff; }
.option-text { color: #344054; word-break: break-word; }
.option-image { display: block; max-width: min(100%, 360px); max-height: 190px; object-fit: contain; }
.result-note { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 15px; font-size: 13px; color: var(--muted); }
.result-note strong { color: var(--green); }
.result-note.error strong { color: var(--red); }
.question-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 12px; border-top: 1px dashed #e5e9ef; color: #a0aaba; font-size: 11px; }

.bottom-actions { display: flex; justify-content: center; gap: 10px; margin: 20px 0; }
.primary-btn, .secondary-btn { height: 42px; padding: 0 23px; border: 1px solid transparent; font-size: 14px; cursor: pointer; }
.primary-btn { background: var(--blue); color: #fff; }
.primary-btn:hover { background: #1f5dcc; }
.secondary-btn { background: #fff; border-color: var(--line); color: #526276; }
.secondary-btn:hover { border-color: #afc2de; }
.secondary-btn:disabled, .primary-btn:disabled { opacity: .45; cursor: not-allowed; }

.palette-panel, .analysis-panel { background: #fff; border: 1px solid var(--line); padding: 18px; }
.analysis-panel { margin-top: 16px; }
.palette-head { display: flex; justify-content: space-between; align-items: center; }
.palette-head strong { font-size: 14px; }
.palette-head span { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 12px; margin: 15px 0 13px; color: #8994a5; font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; background: #e2e7ef; }
.legend-dot.current { background: var(--blue); }
.legend-dot.done { background: #9bb8f4; }
.legend-dot.wrong { background: #ec8993; }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-height: calc(100vh - 240px); overflow: auto; }
.palette button { height: 29px; border: 0; background: #f0f3f7; color: #788598; font-size: 11px; cursor: pointer; }
.palette button.current { background: var(--blue); color: #fff; }
.palette button.done { background: #d9e5fc; color: #3f6fc9; }
.palette button.wrong { background: #f9dfe2; color: #c24c5b; }
.panel-title { font-size: 13px; font-weight: 650; margin-bottom: 15px; }
.bar-row { display: grid; grid-template-columns: 35px 1fr 34px; gap: 8px; align-items: center; color: #68778a; font-size: 11px; margin: 10px 0; }
.bar-row > div { height: 7px; background: #edf1f5; }
.bar-row i { display: block; height: 100%; background: var(--blue); }
.bar-row:nth-of-type(3) i { background: var(--gold); }
.bar-row b { font-size: 11px; text-align: right; color: #7d8998; }
.analysis-panel p { color: #9aa5b3; font-size: 11px; margin: 14px 0 0; line-height: 1.5; }
.empty-state { min-height: 360px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 5px; }
.shake { animation: shake .22s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 190px minmax(0, 1fr); gap: 20px; }
  .right-rail { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 260px; gap: 20px; }
  .analysis-panel { margin-top: 0; }
  .palette { grid-template-columns: repeat(10, 1fr); max-height: 150px; }
  .sidebar { min-height: 0; }
  .source-note { margin-top: 20px; }
}

@media (max-width: 700px) {
  .topbar { height: 62px; padding: 0 15px; }
  .brand small { display: none; }
  .top-stats { gap: 5px; }
  .stat { padding: 5px 8px; }
  .layout { display: block; padding: 16px 15px; }
  .sidebar { display: block; margin-bottom: 17px; }
  .sidebar > .bank-block { display: block; margin-bottom: 9px; }
  .sidebar > .side-block:nth-child(2) { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 9px; }
  .side-label, .settings, .source-note { display: none; }
  .nav-btn { width: auto; min-width: 88px; padding: 0 12px; background: #fff; border: 1px solid var(--line); margin: 0; flex: 0 0 auto; }
  .nav-btn.active { border-color: #c7d8fb; }
  .practice-head { align-items: center; margin-top: 0; }
  .practice-head h1 { font-size: 21px; }
  .progress-wrap { width: 130px; }
  .question-card { padding: 22px 18px; min-height: 410px; }
  .question-title { font-size: 16px; }
  .question-media { max-height: 240px; }
  .option-image { max-width: 100%; max-height: 150px; }
  .question-foot { display: block; }
  .question-foot span { display: block; margin-top: 3px; }
  .bottom-actions { justify-content: space-between; }
  .primary-btn, .secondary-btn { padding: 0 13px; }
  .right-rail { display: block; }
  .analysis-panel { display: none; }
  .palette-panel { margin-top: 17px; padding: 14px; }
  .palette { grid-template-columns: repeat(10, 1fr); max-height: 145px; }
}
