:root {
  --ink: #17212b;
  --muted: #657281;
  --line: #d9e1e8;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --green: #16745f;
  --green-soft: #e6f4ee;
  --red: #b4413c;
  --red-soft: #fae9e7;
  --gold: #e0a72f;
  --blue: #246b9f;
  --shadow: 0 18px 50px rgba(23, 33, 43, .10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #eef5f2 0%, #f9fbf4 42%, #edf4fa 100%);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px 18px;
  background: rgba(255,255,255,.82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 14px;
  background: #173b36;
  color: #f7f2df;
  font-weight: 800;
  font-size: 25px;
}
.brand h1 { margin: 0; font-size: 25px; letter-spacing: 0; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.search-wrap input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 15px;
  background: #fff;
}

.section-title {
  margin: 22px 0 8px;
  color: #44515d;
  font-size: 13px;
  font-weight: 800;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 11px 10px;
  cursor: pointer;
}
.nav-item:hover { background: #eef6f1; }
.nav-item.active { background: #173b36; color: #fff; }
.nav-item span:first-child { overflow-wrap: anywhere; line-height: 1.35; }
.pill {
  min-width: 30px;
  text-align: center;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(36,107,159,.14);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}
.active .pill { background: rgba(255,255,255,.18); color: #fff; }

.workspace { min-width: 0; padding: 28px clamp(18px, 4vw, 56px); }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
}
.topbar h2 { margin: 0; font-size: clamp(26px, 4vw, 42px); letter-spacing: 0; }
.score-card {
  min-width: 112px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.84);
  text-align: right;
}
.score-card span { display: block; font-size: 24px; font-weight: 850; }
.score-card small { color: var(--muted); }

.content { max-width: 980px; }
.resource-card, .question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.resource-card { padding: 22px; margin-bottom: 18px; }
.resource-meta { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: #edf4fa;
  color: #1d5f8e;
  font-size: 12px;
  font-weight: 700;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  background: #173b36;
  color: #fff;
  text-decoration: none;
  font-weight: 750;
}
.link-button.secondary { background: #eef3f4; color: #173b36; }
.preview {
  margin: 14px 0 0;
  color: #4c5965;
  line-height: 1.75;
  white-space: pre-wrap;
  max-height: 210px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.question-list { display: grid; gap: 14px; }
.image-group {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.image-group + .question-card {
  margin-top: -4px;
}
.question-card { padding: 18px; }
.question-card.has-compact-image {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.compact-image {
  align-self: start;
  position: sticky;
  top: 18px;
}
.compact-image img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}
.question-main { min-width: 0; }
.question-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.q-number {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: #173b36;
  color: #fff;
  font-weight: 850;
}
.stem { margin: 4px 0 0; line-height: 1.7; font-size: 16px; }
.option-grid { display: grid; gap: 9px; }
.option {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
}
.option:hover { border-color: #8aa69d; background: #f6fbf8; }
.option .label {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #edf4fa;
  color: #1d5f8e;
  font-weight: 850;
}
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.correct .label { background: var(--green); color: #fff; }
.option.wrong .label { background: var(--red); color: #fff; }
.feedback {
  min-height: 24px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
}
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }
.source-images {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}
.source-images img {
  width: 100%;
  max-height: 720px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(14, 24, 30, .78);
}
.image-lightbox.open { display: grid; }
.image-lightbox img {
  max-width: min(94vw, 1180px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.image-lightbox button {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: #173b36;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}
.fill-body {
  line-height: 2.25;
  font-size: 17px;
}
.fill-input {
  width: min(210px, 42vw);
  min-width: 92px;
  margin: 0 5px;
  border: 0;
  border-bottom: 3px solid #799a8f;
  background: #f6faf8;
  border-radius: 6px 6px 0 0;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 16px;
  text-align: center;
}
.fill-input:focus {
  outline: 2px solid rgba(22, 116, 95, .22);
  border-bottom-color: var(--green);
}
.fill-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 15px;
}
.action-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #173b36;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
}
.action-button.secondary {
  background: #eef3f4;
  color: #173b36;
}
.answer-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 4px 6px 0 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}
.question-card.is-correct { animation: popCorrect .22s ease-out; }
.question-card.is-wrong { animation: shakeWrong .28s ease-in-out; }
.completion-panel {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid #cbdcd5;
  border-radius: 8px;
  background: #f7fbf8;
  color: #173b36;
  font-weight: 800;
}
@keyframes popCorrect {
  0% { transform: scale(.99); }
  60% { transform: scale(1.012); }
  100% { transform: scale(1); }
}
@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.empty {
  padding: 28px;
  border: 1px dashed #b8c6cf;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.64);
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .score-card { text-align: left; }
  .question-card.has-compact-image { grid-template-columns: 1fr; }
  .compact-image { position: static; max-width: 320px; }
}
