:root {
  --ink: #102235;
  --muted: #607285;
  --line: #d9e3ea;
  --paper: #ffffff;
  --soft: #f4f8fb;
  --cyan: #166f88;
  --cyan-strong: #0f5e75;
  --green: #168968;
  --amber: #c7771b;
  --red: #bd3f3f;
  --shadow: 0 18px 45px rgba(16, 34, 53, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 42%, #f7f3ec 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(18px, 3vw, 44px);
  border-bottom: 1px solid rgba(217, 227, 234, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border: 2px solid #bde8e6;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, rgba(15, 94, 117, 0.8) 48%, rgba(15, 94, 117, 0.8) 52%, transparent 53%),
    linear-gradient(0deg, transparent 47%, rgba(22, 137, 104, 0.8) 48%, rgba(22, 137, 104, 0.8) 52%, transparent 53%),
    radial-gradient(circle at 35% 30%, #fff 0 12%, #9be1d5 13% 46%, #166f88 47% 100%);
  box-shadow: 0 8px 22px rgba(22, 111, 136, 0.22);
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topnav a,
.ghost-btn,
.secondary-btn,
.primary-btn,
.bookmark-btn {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 13px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.topnav a {
  color: var(--muted);
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--cyan-strong);
}

.primary-btn {
  background: var(--cyan-strong);
  border-color: var(--cyan-strong);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 94, 117, 0.22);
}

.secondary-btn {
  background: #e9f7f2;
  border-color: #b9e6d6;
  color: #0f684f;
}

.ghost-btn,
.bookmark-btn {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--line);
  color: var(--ink);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.bookmark-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.bookmark-btn:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(242, 165, 65, 0.45);
  outline-offset: 2px;
}

main {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
}

.hero-band {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 24px;
  align-items: stretch;
  padding: 30px 0 22px;
}

.hero-copy {
  min-height: 270px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 4vw, 54px);
  border: 1px solid rgba(217, 227, 234, 0.8);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(241, 249, 249, 0.9)),
    radial-gradient(circle at 12% 14%, rgba(242, 165, 65, 0.18), transparent 30%);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: 48px;
  line-height: 1.08;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.lead {
  max-width: 740px;
  margin: 16px 0 0;
  color: #385065;
  font-size: 17px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.visual-panel {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  border: 1px solid rgba(217, 227, 234, 0.8);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.visual-panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stat-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-strip div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.stat-strip strong {
  color: var(--cyan-strong);
  font-size: 26px;
}

.stat-strip span {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin: 8px 0 30px;
}

.control-panel {
  position: sticky;
  top: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

label,
.label {
  display: block;
  margin-bottom: 8px;
  color: #31485f;
  font-size: 13px;
  font-weight: 750;
}

input[type="search"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cddbe3;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segmented button {
  min-height: 38px;
  border: 1px solid #cddbe3;
  border-radius: var(--radius);
  background: #ffffff;
  color: #31485f;
  padding: 7px 8px;
}

.segmented button.active {
  border-color: #93d8cf;
  background: #e8f8f5;
  color: #0f684f;
  font-weight: 750;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  color: var(--ink);
  font-weight: 500;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.note {
  color: var(--muted);
  background: #fbf8f0;
}

.note strong {
  display: block;
  margin-bottom: 6px;
  color: #7b4a0e;
}

.note p {
  margin: 0;
  font-size: 13px;
}

.question-area {
  min-width: 0;
}

.question-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
  margin: 0 0 12px;
}

.filter-chip,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid #cde4e4;
  border-radius: 999px;
  background: #effaf8;
  color: #0f684f;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.question-list {
  display: grid;
  gap: 14px;
}

.question-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 26px rgba(16, 34, 53, 0.08);
  padding: 18px;
}

body.compact .question-card {
  padding: 13px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.qid {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.bookmark-btn {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--muted);
  flex: 0 0 auto;
}

.bookmark-btn.active {
  border-color: #f0c985;
  background: #fff8e9;
  color: #7b4a0e;
}

.passage-box,
.transcript-box {
  margin: 12px 0;
  border: 1px solid #d9e3ea;
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
  background: #f7fbfd;
  color: #31485f;
  padding: 14px;
}

.passage-box strong,
.transcript-box strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.transcript-box {
  white-space: pre-line;
}

.stem {
  margin: 12px 0 14px;
  font-size: 17px;
  font-weight: 700;
}

.choices {
  display: grid;
  gap: 9px;
}

.choice-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 48px;
  border: 1px solid #d4e0e7;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.choice-letter {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eef5f8;
  color: var(--cyan-strong);
  font-weight: 850;
  font-size: 13px;
}

.choice-btn:hover {
  border-color: #9dd4d1;
}

.choice-btn.correct {
  border-color: #7ac8a6;
  background: #effbf5;
}

.choice-btn.incorrect {
  border-color: #e3a1a1;
  background: #fff3f2;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.answer-box {
  margin-top: 12px;
  border: 1px solid #cfe4d8;
  border-radius: var(--radius);
  background: #f1fbf5;
  padding: 13px;
  color: #244d3d;
}

.answer-box strong {
  color: #0f684f;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 6px;
}

.pager button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.section-heading {
  max-width: 860px;
}

.section-heading p:last-child {
  color: var(--muted);
}

.empty-state {
  border: 1px dashed #adc0ca;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

@media (max-width: 1020px) {
  .hero-band {
    grid-template-columns: 1fr;
  }

  .visual-panel {
    min-height: 220px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

}

@media (max-width: 720px) {
  main {
    width: min(100% - 18px, 1480px);
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    width: 100%;
    justify-content: flex-start;
  }

  h1 {
    font-size: 34px;
  }

  .hero-copy {
    min-height: auto;
    padding: 22px;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .choice-btn {
    grid-template-columns: 30px minmax(0, 1fr);
  }
}

@media print {
  .topbar,
  .control-panel,
  .hero-actions,
  .toolbar-actions,
  .pager {
    display: none;
  }

  body {
    background: #ffffff;
  }

  main,
  .workspace,
  .hero-band {
    width: 100%;
    display: block;
  }

  .question-card,
  .hero-copy {
    box-shadow: none;
    break-inside: avoid;
  }
}
