:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #eef2f6;
  --surface-warm: #fff8ed;
  --text: #17212f;
  --muted: #617082;
  --line: #d9e0e8;
  --line-strong: #b8c4d2;
  --primary: #1f6feb;
  --primary-dark: #174ea6;
  --aws: #ff9900;
  --good: #137333;
  --bad: #b3261e;
  --flag: #9a5b00;
  --focus: rgba(31, 111, 235, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft JhengHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 8px 0 18px;
}

.center-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
  color: #4f46e5;
  font-weight: 900;
  text-decoration: none;
}

.center-link:hover {
  color: #372ac8;
}

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--flag);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h1,
.section-title h2,
.quiz-toolbar h2,
.dialog h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  color: #0b1533;
  font-size: clamp(2rem, 3.2vw, 2.75rem);
  line-height: 1.1;
}

.topbar p,
.section-title p {
  color: var(--muted);
}

#bankMeta {
  margin: 10px 0 0;
  font-size: 1rem;
}

.exam-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  min-width: min(590px, 48vw);
  gap: 14px;
  border: 0;
  background: transparent;
  overflow: visible;
}

.exam-facts div {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-content: center;
  gap: 2px 12px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.04);
}

.exam-facts div:first-child {
  border-left: 1px solid var(--line);
}

.exam-facts span,
.timer-card span,
.nav-stats span {
  color: var(--muted);
  font-size: 0.82rem;
}

.exam-facts strong {
  grid-column: 2;
  color: #0b1533;
  font-size: 1.02rem;
}

.fact-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f0edff;
  color: #4f46e5 !important;
  font-size: 0.76rem !important;
  font-weight: 900;
}

.setup-panel,
.question-panel,
.navigator-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.setup-panel,
.result-panel {
  padding: 18px;
}

.setup-stage {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.exam-profile-card,
.setup-stage > .setup-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.exam-profile-card {
  display: flex;
  flex-direction: column;
}

.profile-hero {
  min-height: 272px;
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.96), rgba(67, 56, 202, 0.96)),
    radial-gradient(circle at 86% 28%, rgba(255, 255, 255, 0.22), transparent 28%);
  color: #fff;
  padding: 32px 30px;
}

.profile-icon {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  color: #4f46e5;
  font-weight: 900;
}

.profile-hero h2 {
  margin: 22px 0 12px;
  font-size: 1.7rem;
  line-height: 1.35;
}

.profile-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
}

.profile-list {
  display: grid;
  gap: 0;
  padding: 18px 28px 8px;
}

.profile-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #edf0f6;
  padding: 14px 0;
}

.profile-list span {
  color: #647086;
}

.profile-list strong {
  color: #111a33;
}

.profile-tip {
  margin: auto 28px 28px;
  border-radius: 8px;
  background: #f1efff;
  padding: 16px;
}

.profile-tip strong {
  display: block;
  margin-bottom: 6px;
  color: #4f46e5;
}

.profile-tip span {
  color: #3f4e66;
  font-size: 0.92rem;
}

.setup-stage > .setup-panel {
  padding: 34px 36px 36px;
}

.section-title,
.quiz-toolbar,
.answer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  margin-bottom: 28px;
}

.section-title h2,
.quiz-toolbar h2 {
  font-size: 1.45rem;
}

.setup-help {
  color: #4f46e5;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: 24px 76px 1fr;
  gap: 8px 18px;
  align-items: center;
  min-height: 178px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 24px;
}

.mode-card.active {
  border-color: #4f46e5;
  background: linear-gradient(180deg, #ffffff, #fbfbff);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.mode-card input {
  align-self: start;
  width: 20px;
  height: 20px;
  margin-top: 8px;
  accent-color: #4f46e5;
}

.mode-title {
  display: block;
  align-self: end;
  color: #0b1533;
  font-size: 1.15rem;
  font-weight: 800;
}

.mode-icon {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 18px;
  background: #f0edff;
  color: #4f46e5;
  font-size: 1.45rem;
  font-weight: 900;
}

.mode-card small {
  grid-column: 3;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.75;
}

.lock-badge {
  position: absolute;
  top: 22px;
  right: 22px;
  border-radius: 999px;
  background: #f1f3f8;
  color: #647086;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.setup-divider {
  height: 1px;
  margin: 10px 0 28px;
  background: #edf0f6;
}

.parameter-title {
  margin: 0 0 18px;
  color: #0b1533;
  font-size: 1.12rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 28px;
}

.field {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 16px;
  font-weight: 700;
}

.stepper-control {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.stepper-field:nth-child(2) .stepper-control {
  grid-template-columns: 44px 1fr 44px;
}

.stepper-field:nth-child(3) .stepper-control {
  grid-template-columns: 1fr auto;
}

.stepper-control input {
  min-height: 56px;
  border: 0;
  border-radius: 0;
}

.stepper-button {
  display: grid;
  place-items: center;
  min-height: 56px;
  border: 0;
  background: transparent;
  color: #53627a;
  font-size: 1.32rem;
  font-weight: 800;
}

.stepper-button:hover {
  background: #f3f6fb;
  color: #4f46e5;
}

.unit-label {
  padding: 0 16px;
  color: #53627a;
  font-weight: 800;
  white-space: nowrap;
}

.range-note {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 46px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f3f1ff, #f9f7ff);
  color: #3f4e66;
  padding: 18px 22px;
}

.note-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #4f46e5;
  color: #fff;
  font-weight: 900;
}

.field input:focus,
.field select:focus,
button:focus-visible,
.option-row:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 34px;
}

.start-quiz-button {
  min-width: 224px;
  min-height: 66px;
  border: 0;
  background: linear-gradient(135deg, #6d42df, #4f46e5);
  box-shadow: 0 18px 34px rgba(79, 70, 229, 0.28);
  font-size: 1.05rem;
}

.start-quiz-button:hover {
  background: linear-gradient(135deg, #5b34cf, #4338ca);
}

.primary-button,
.ghost-button,
.finish-button,
.mark-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.ghost-button,
.mark-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button:hover,
.mark-button:hover {
  background: var(--surface-strong);
}

.mark-button.active {
  border-color: var(--aws);
  background: var(--surface-warm);
  color: var(--flag);
}

.finish-button {
  width: 100%;
  border: 1px solid #8a3b12;
  background: #8a3b12;
  color: #fff;
}

.exam-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.navigator-panel {
  position: sticky;
  top: 14px;
  padding: 14px;
}

.timer-card {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.timer-card strong {
  font-size: 1.65rem;
  line-height: 1.1;
}

.timer-card.warning strong {
  color: var(--bad);
}

.nav-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px;
}

.nav-stats div {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.nav-stats strong {
  font-size: 1.2rem;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: calc(100vh - 310px);
  overflow: auto;
  padding-right: 2px;
  margin-bottom: 12px;
}

.nav-button {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.nav-button.current {
  border-color: var(--primary);
  background: #eaf2ff;
}

.nav-button.answered {
  border-color: rgba(19, 115, 51, 0.4);
  background: #edf7ee;
}

.nav-button.correct {
  border-color: rgba(19, 115, 51, 0.55);
  background: #e6f4ea;
}

.nav-button.incorrect {
  border-color: rgba(179, 38, 30, 0.55);
  background: #fce8e6;
}

.nav-button.unanswered {
  border-color: var(--line-strong);
  background: #f8fafc;
  color: var(--muted);
}

.nav-button.flagged {
  border-color: var(--aws);
  background: var(--surface-warm);
}

.question-panel {
  overflow: hidden;
}

.quiz-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.question-kicker {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  background: var(--surface-strong);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--aws);
  transition: width 160ms ease;
}

.question-body {
  padding: 18px;
}

#questionText {
  margin: 0 0 16px;
  white-space: pre-wrap;
  font-size: 1.02rem;
}

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

.question-copy {
  white-space: pre-wrap;
}

.question-code {
  margin: 2px 0 4px;
  border: 1px solid #d8e1ed;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f1f38;
  padding: 14px 16px;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.96rem;
  line-height: 1.65;
  white-space: pre;
}

.options-list {
  display: grid;
  gap: 10px;
}

.option-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.option-row:hover {
  border-color: var(--line-strong);
  background: #fbfcff;
}

.option-row.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.option-row.correct {
  border-color: rgba(19, 115, 51, 0.55);
  background: #ecf8ee;
}

.option-row.incorrect {
  border-color: rgba(179, 38, 30, 0.55);
  background: #fff1f0;
}

.option-label {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-weight: 900;
}

.option-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.answer-bar {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.answer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.answer-status {
  color: var(--muted);
  font-weight: 800;
}

.answer-status.good {
  color: var(--good);
}

.answer-status.bad {
  color: var(--bad);
}

.result-panel {
  margin-top: 16px;
}

.score-tag {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.score-tag.scored {
  background: #dcfce7;
  color: #15803d;
}

.score-tag.unscored {
  background: #eef1f6;
  color: #64748b;
}

.review-item .score-tag {
  margin: 6px 0 0;
}

.score-card {
  margin: 4px 0 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px 18px;
}

.score-card.pass {
  border-color: #b6e3cf;
  border-left-color: #16a34a;
  background: #f3fbf7;
}

.score-card.fail {
  border-color: #f3c6c6;
  border-left-color: #dc2626;
  background: #fdf5f5;
}

.score-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.score-figure {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.score-value {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  color: #0f1f38;
}

.score-card.pass .score-value {
  color: #15803d;
}

.score-card.fail .score-value {
  color: #b91c1c;
}

.score-scale {
  font-size: 1rem;
  color: var(--muted);
}

.score-verdict {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
}

.score-card.pass .score-verdict {
  background: #16a34a;
  color: #fff;
}

.score-card.fail .score-verdict {
  background: #dc2626;
  color: #fff;
}

.score-meta {
  margin-top: 8px;
  color: #26364d;
  font-size: 0.95rem;
}

.score-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.review-item strong {
  display: block;
  margin-bottom: 4px;
}

.review-item p {
  margin: 0 0 8px;
  color: var(--muted);
}

.review-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  padding: 20px;
  z-index: 20;
}

.dialog {
  width: min(460px, 100%);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.dialog p {
  color: var(--muted);
}

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

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar,
  .section-title,
  .quiz-toolbar,
  .answer-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .exam-facts {
    min-width: 0;
    width: 100%;
  }

  .exam-layout {
    grid-template-columns: 1fr;
  }

  .navigator-panel {
    position: static;
  }

  .question-nav {
    grid-template-columns: repeat(8, 1fr);
    max-height: none;
  }

  .hero-row,
  .setup-stage {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .exam-facts {
    min-width: 0;
    width: 100%;
  }

  .setup-stage > .setup-panel {
    padding: 24px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1260px);
    padding-top: 10px;
  }

  .exam-facts,
  .mode-tabs,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .exam-facts div {
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .exam-facts div:first-child {
    border-top: 0;
  }

  .question-nav {
    grid-template-columns: repeat(5, 1fr);
  }

  .answer-actions,
  .dialog-actions,
  .setup-actions,
  .toolbar-actions {
    flex-direction: column;
    width: 100%;
  }

  .answer-actions button,
  .dialog-actions button,
  .setup-actions button,
  .toolbar-actions button {
    width: 100%;
  }

  .mode-card {
    grid-template-columns: 24px 60px 1fr;
    min-height: 148px;
    padding: 18px;
  }

  .mode-icon {
    width: 60px;
    height: 60px;
  }

  .profile-hero {
    min-height: 220px;
  }

  .range-note {
    align-items: flex-start;
    margin-top: 24px;
  }

  .option-row {
    grid-template-columns: 34px 1fr;
  }
}

/* Exam workspace redesign */
body.in-session {
  background: #f5f7fb;
}

body.in-session .app-shell {
  width: min(100%, 1920px);
  padding: 0;
}

body.in-session .topbar {
  display: none;
}

.exam-workspace {
  min-height: 100vh;
  background: #f5f7fb;
}

.exam-session-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 14px 28px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.session-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.back-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 54px;
  border: 0;
  border-radius: 8px;
  background: #2d66d6;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  font-weight: 800;
  padding: 0;
}

.back-button:hover {
  background: #1f55bf;
}

.back-button:focus-visible {
  outline: 3px solid rgba(45, 102, 214, 0.28);
  outline-offset: 2px;
}

.session-title strong {
  display: block;
  font-size: 1.12rem;
}

.session-title span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-button {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #10213b;
  padding: 8px 10px;
  font-weight: 800;
}

.tool-button:hover {
  background: #eef4ff;
}

.tool-button.active {
  background: #fff7e6;
  color: #9a5b00;
}

.tool-button:disabled {
  opacity: 0.42;
}

.exam-workspace .ghost-button {
  min-height: 40px;
  border-color: #cfd8e5;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.exam-layout {
  display: grid;
  grid-template-columns: 316px minmax(560px, 1fr) 316px;
  gap: 16px;
  align-items: start;
  padding: 20px;
}

.navigator-panel,
.question-panel,
.status-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.04);
}

.navigator-panel,
.status-panel {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.navigator-panel {
  padding: 0;
}

.navigator-heading {
  padding: 18px 18px 16px;
}

.navigator-heading h2,
.status-card h2,
.help-card h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  color: #526174;
  font-size: 0.9rem;
}

.legend-grid span,
.status-row span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #aeb8c5;
}

.answered-dot {
  background: #23a26d;
}

.current-dot {
  background: #1f6feb;
}

.unanswered-dot {
  background: #aeb8c5;
}

.flagged-dot {
  background: #fb8c00;
}

.nav-total {
  border-top: 1px solid var(--line);
  padding: 16px 18px 12px;
  color: #0f1f38;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-height: none;
  overflow: visible;
  padding: 0 18px 20px;
  margin: 0;
}

.nav-button {
  position: relative;
  height: 56px;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  color: #0f1f38;
  font-size: 1.02rem;
}

.nav-button.current {
  border-color: #1f6feb;
  background: linear-gradient(180deg, #2e7df0, #1d66d8);
  color: #fff;
  box-shadow: 0 8px 18px rgba(31, 111, 235, 0.24);
}

.nav-button.answered {
  border-color: #1c9b67;
  background: linear-gradient(180deg, #28b87b, #16965f);
  color: #fff;
}

.nav-button.correct {
  border-color: #1c9b67;
  background: linear-gradient(180deg, #e8f7ef, #d9f0e3);
  color: #11633f;
}

.nav-button.incorrect {
  border-color: #e06d65;
  background: linear-gradient(180deg, #fff1f0, #fde2df);
  color: #8f1f17;
}

.nav-button.unanswered {
  border-color: #cfd8e5;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  color: #667085;
}

.nav-button.flagged::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 0;
  height: 0;
  border-top: 16px solid #fb8c00;
  border-left: 16px solid transparent;
  border-top-right-radius: 8px;
}

.question-panel {
  overflow: hidden;
}

.quiz-toolbar {
  align-items: end;
  padding: 24px 24px 18px;
  border-bottom: 0;
}

.question-kicker {
  color: #516176;
  font-weight: 800;
}

.quiz-toolbar h2 {
  margin-top: 4px;
  font-size: 1.2rem;
}

.question-progress-value {
  color: #0f1f38;
  font-weight: 900;
}

.progress-track {
  width: calc(100% - 48px);
  height: 8px;
  margin: 0 24px;
  border-radius: 999px;
  background: #e7ecf3;
  overflow: hidden;
}

.progress-fill {
  border-radius: inherit;
  background: #1f6feb;
}

.question-body {
  margin: 24px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  padding: 28px 20px 26px;
  background: #fff;
}

#questionText {
  margin-bottom: 22px;
  color: #0f1f38;
  font-size: 1.05rem;
}

.options-list {
  gap: 12px;
}

.option-row {
  grid-template-columns: 34px 1fr;
  min-height: 62px;
  border-color: #d8e1ed;
  background: #fff;
  padding: 14px 16px;
}

.option-row:hover {
  border-color: #8bb7ff;
  background: #fbfdff;
}

.option-row.selected {
  border-color: #76a7ff;
  background: #f3f8ff;
  box-shadow: 0 0 0 1px rgba(31, 111, 235, 0.2);
}

.option-row.correct {
  border-color: #72c28e;
  background: #ecf8ef;
}

.option-row.incorrect {
  border-color: #ef7d75;
  background: #fff0ef;
}

.option-label {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eef3f8;
}

.option-row.selected .option-label {
  background: #1f6feb;
  color: #fff;
}

.ai-explanation-panel {
  margin-top: 18px;
  border: 1px solid #b6e3cf;
  border-radius: 8px;
  background: #f3fbf7;
  overflow: hidden;
}

.ai-explanation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #cdeede;
  padding: 12px 14px;
}

.ai-explanation-header .collapse-heading {
  color: #0b3b29;
}

.ai-explanation-header .collapse-sub {
  color: #3f7a63;
}

.ai-explanation-panel.collapsed .ai-explanation-header {
  border-bottom: none;
}

.ai-explanation-panel.collapsed .ai-explanation-body {
  display: none;
}

.ai-explanation-body {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.ai-block-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0f7a52;
}

.ai-block p {
  margin: 0;
  color: #1f3b2f;
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-option-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.ai-option-item {
  border: 1px solid #cdeede;
  border-left-width: 4px;
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
}

.ai-option-item.correct {
  border-left-color: #1f9d72;
  background: #f0faf5;
}

.ai-option-item.incorrect {
  border-left-color: #c9555a;
  background: #fdf5f5;
}

.ai-option-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ai-option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #0f7a52;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
}

.ai-option-item.incorrect .ai-option-label {
  background: #c9555a;
}

.ai-option-verdict {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0f7a52;
}

.ai-option-item.incorrect .ai-option-verdict {
  color: #c9555a;
}

.ai-option-body {
  margin: 0;
  color: #1f3b2f;
  font-size: 0.92rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.discussion-panel {
  margin-top: 18px;
  border: 1px solid #bfd6ff;
  border-radius: 8px;
  background: #f7fbff;
  overflow: hidden;
}

.discussion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #d7e6ff;
  padding: 12px 14px;
}

.discussion-header .collapse-heading {
  color: #0f1f38;
}

.discussion-header .collapse-sub {
  color: var(--muted);
}

.discussion-panel.collapsed .discussion-header {
  border-bottom: none;
}

.discussion-panel.collapsed .discussion-text {
  display: none;
}

/* 可折疊面板共用樣式 */
.collapse-toggle {
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.collapse-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.collapse-heading {
  font-size: 1rem;
  font-weight: 600;
}

.collapse-sub {
  font-size: 0.86rem;
}

.collapse-chevron {
  flex: none;
  width: 9px;
  height: 9px;
  margin-right: 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  opacity: 0.55;
}

.collapse-toggle[aria-expanded="false"] .collapse-chevron {
  transform: rotate(-45deg);
}

.collapse-toggle:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.discussion-text {
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  color: #26364d;
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.answer-bar {
  margin-top: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 16px 24px;
}

.answer-actions .primary-button,
.answer-actions .ghost-button {
  min-width: 130px;
}

.status-panel {
  display: grid;
  gap: 16px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.timer-card,
.status-card,
.help-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.04);
}

.timer-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px;
}

.timer-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.9rem;
  line-height: 1;
}

.timer-ring {
  --timer-deg: 360deg;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background: conic-gradient(#1f6feb var(--timer-deg), #e7ecf3 0deg);
}

.timer-ring-inner {
  width: 76px;
  height: 76px;
  border-radius: inherit;
  background: #fff;
}

.status-card,
.help-card {
  padding: 18px;
}

.status-row,
.status-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  color: #526174;
}

.status-row strong,
.status-total strong {
  color: #0f1f38;
  font-size: 1.15rem;
}

.status-total {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  color: #0f1f38;
}

.help-card p {
  margin: 12px 0;
  color: #526174;
}

.help-card strong {
  color: #0f1f38;
}

@media (max-width: 1280px) {
  .exam-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .status-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
    position: static;
    max-height: none;
  }
}

@media (max-width: 860px) {
  .exam-session-bar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .session-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .exam-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .question-panel { order: 1; }
  .navigator-panel { order: 2; }
  .status-panel { order: 3; }

  .navigator-panel {
    position: static;
    max-height: 320px;
    overflow: auto;
  }

  .status-panel {
    position: static;
    max-height: none;
    grid-template-columns: 1fr;
  }

  .question-nav {
    grid-template-columns: repeat(5, 1fr);
  }

  .question-body {
    margin: 16px;
    padding: 18px 14px;
  }
}

@media (max-height: 700px) and (min-width: 861px) {
  .exam-session-bar {
    min-height: 56px;
    padding: 8px 20px;
  }

  .back-button {
    height: 44px;
  }

  .session-title strong {
    font-size: 1rem;
  }

  .session-title span {
    font-size: 0.82rem;
  }

  .quiz-toolbar {
    padding: 12px 20px 8px;
  }

  .question-body {
    margin: 14px 20px;
    padding: 18px;
  }

  #questionText {
    margin-bottom: 14px;
    font-size: 1rem;
  }

  .option-row {
    min-height: 50px;
    padding: 10px 14px;
  }

  .options-list {
    gap: 8px;
  }

  .answer-bar {
    padding: 12px 20px;
  }

  .navigator-panel,
  .status-panel {
    top: 72px;
    max-height: calc(100vh - 88px);
  }

  .navigator-heading {
    padding: 12px 16px 10px;
  }

  .nav-total {
    padding: 10px 16px 8px;
  }

  .question-nav {
    gap: 8px;
    padding: 0 16px 14px;
  }

  .nav-button {
    height: 44px;
    font-size: 0.95rem;
  }

  .timer-card {
    padding: 14px;
  }

  .timer-card strong {
    font-size: 1.4rem;
  }

  .timer-ring {
    width: 60px;
    height: 60px;
  }

  .timer-ring-inner {
    width: 46px;
    height: 46px;
  }

  .status-card,
  .help-card {
    padding: 14px;
  }

  .status-row,
  .status-total {
    padding: 8px 0;
  }
}

.history-panel {
  grid-column: 1 / -1;
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 22px 26px 24px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.06);
}

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

.history-head h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.history-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-clear:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.history-empty {
  padding: 12px 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-empty p {
  margin: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.history-item-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-time {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f1f38;
}

.history-mode {
  display: inline-flex;
  width: max-content;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.history-mode.practice {
  background: #e7f3ee;
  color: #0f7a52;
}

.history-mode.exam {
  background: #fdecec;
  color: #b8434b;
}

.history-item-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-item-score {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-item-score strong {
  font-size: 1.15rem;
  color: #0f1f38;
}

.history-item-score.pass strong {
  color: #1f9d72;
}

.history-item-score.fail strong {
  color: #c9555a;
}

.history-detail-button {
  white-space: nowrap;
}

.history-detail-dialog {
  width: min(680px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.history-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.history-detail-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.history-detail-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.history-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-detail-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  background: #ffffff;
}

.history-detail-item.correct {
  border-left-color: #1f9d72;
  background: #f0faf5;
}

.history-detail-item.incorrect {
  border-left-color: #c9555a;
  background: #fdf5f5;
}

.history-detail-item.unanswered {
  border-left-color: #a5adba;
  background: #f5f6f8;
}

.history-detail-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.history-detail-tag {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 31, 56, 0.08);
  color: #0f1f38;
}

.history-detail-item.correct .history-detail-tag {
  background: #def3e9;
  color: #0f7a52;
}

.history-detail-item.incorrect .history-detail-tag {
  background: #fbe1e3;
  color: #b8434b;
}

.history-detail-flag {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #fff5d6;
  color: #997000;
}

.history-detail-question {
  margin: 6px 0 10px;
  color: #1f3b2f;
  font-size: 0.92rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-detail-blocks {
  display: grid;
  gap: 8px;
}

.history-detail-block {
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 31, 56, 0.08);
}

.history-detail-block.correct-answer {
  background: #ecf8f2;
  border-color: #b6e3cf;
}

.history-detail-block.your-answer {
  background: #f7f9fc;
  border-color: #d3dbe8;
}

.history-detail-item.incorrect .history-detail-block.your-answer {
  background: #fbe7e9;
  border-color: #f0c2c6;
}

.history-detail-item.correct .history-detail-block.your-answer {
  background: #ecf8f2;
  border-color: #b6e3cf;
}

.history-detail-block-label {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.history-detail-block.correct-answer .history-detail-block-label {
  color: #0f7a52;
}

.history-detail-item.incorrect .history-detail-block.your-answer .history-detail-block-label {
  color: #b8434b;
}

.history-detail-option {
  margin: 2px 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #1f3b2f;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .history-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .history-item .history-detail-button {
    justify-self: end;
  }
}

/* ================= Portal（測驗中心） ================= */

.portal-shell {
  padding: 32px 0 60px;
}

.portal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.portal-header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: 0.5px;
}

.portal-sub {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.portal-overview {
  display: flex;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 20px;
  box-shadow: 0 4px 16px rgba(23, 33, 47, 0.04);
}

.portal-overview > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 84px;
}

.portal-overview span {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.portal-overview strong {
  font-size: 22px;
  color: var(--text);
  margin-top: 2px;
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.exam-card {
  --card-accent: var(--primary);
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 22px 22px 26px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 4px 18px rgba(23, 33, 47, 0.05);
}

.exam-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--card-accent);
}

.exam-card:hover,
.exam-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(23, 33, 47, 0.12);
  border-color: var(--card-accent);
  outline: none;
}

.exam-card:focus-visible {
  box-shadow: 0 0 0 3px var(--focus), 0 12px 26px rgba(23, 33, 47, 0.12);
}

.exam-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.exam-card-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exam-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.exam-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: rgba(255, 153, 0, 0.14); /* fallback */
  background: color-mix(in srgb, var(--card-accent) 16%, white);
  color: var(--card-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 16px;
  flex-shrink: 0;
}

.exam-card-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.exam-card-code {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.exam-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.exam-card-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--surface-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.exam-card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.exam-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.exam-card-meta-item {
  background: var(--surface-strong);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.exam-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.exam-card-stats > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.exam-card-stats span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.exam-card-stats strong {
  font-size: 16px;
  color: var(--text);
}

.exam-card-cta {
  color: var(--card-accent);
  font-weight: 800;
  letter-spacing: 0.4px;
  font-size: 14px;
}

@media (max-width: 760px) {
  .exam-grid {
    grid-template-columns: 1fr;
  }
  .portal-header {
    flex-direction: column;
  }
  .portal-overview {
    width: 100%;
    justify-content: space-between;
  }
}

