:root {
  color-scheme: light;
  --ink: #26322f;
  --muted: #68736e;
  --line: #e3e7df;
  --paper: #fffefa;
  --canvas: #f5f5f0;
  --green: #2c6658;
  --green-dark: #214f44;
  --green-soft: #edf5ef;
  --amber: #93611d;
  --amber-soft: #fff5df;
  --red: #984a42;
  --red-soft: #fff0ed;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 90% 0%, rgba(224, 235, 222, 0.48), transparent 35rem),
    var(--canvas);
}

button,
select {
  font: inherit;
}

button:focus-visible,
select:focus-visible,
.option-card:focus-within {
  outline: 3px solid rgba(44, 102, 88, 0.32);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 max(28px, calc((100vw - 1112px) / 2));
  border-bottom: 1px solid rgba(220, 225, 216, 0.8);
  background: rgba(255, 255, 250, 0.78);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--green);
}

.brand-mark svg {
  width: 23px;
  fill: none;
  stroke: #fffefa;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.topnav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #f0f2ec;
}

.nav-tab {
  min-width: 67px;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  color: #65716b;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.nav-tab.is-active {
  color: var(--green-dark);
  background: #fffefa;
  box-shadow: 0 1px 4px rgba(42, 57, 48, 0.1);
}

.page {
  width: min(1112px, calc(100% - 48px));
  margin: 0 auto;
  padding: 46px 0 52px;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 27px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.intro h1 {
  margin: 0;
  font-size: clamp(27px, 4vw, 36px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.source-note {
  max-width: 480px;
  margin: 0 0 3px;
  color: #66716d;
  font-size: 13px;
  line-height: 1.8;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  grid-template-areas: "question rail";
  align-items: start;
  gap: 22px;
}

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

.question-card,
.rail-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(42, 57, 48, 0.045);
}

.question-card {
  min-height: 456px;
  padding: clamp(24px, 4vw, 38px);
}

.question-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  min-height: 28px;
}

.question-position,
.set-label,
.confidence-label {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.question-position {
  color: var(--green-dark);
  background: var(--green-soft);
}

.set-label {
  color: var(--muted);
  background: #f2f3ef;
}

.confidence-label {
  color: var(--amber);
  background: var(--amber-soft);
}

.confidence-label[hidden] {
  display: none;
}

.question-stem {
  max-width: 760px;
  margin: 25px 0 26px;
  font-size: clamp(20px, 2.6vw, 24px);
  font-weight: 650;
  line-height: 1.8;
  letter-spacing: 0.005em;
  white-space: pre-line;
}

.answer-options {
  display: grid;
  gap: 11px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.option-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  min-height: 54px;
  padding: 14px 16px;
  border: 1px solid #e4e7e0;
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.option-card:hover:not(.is-locked) {
  transform: translateY(-1px);
  border-color: #9bbcaf;
  background: #fbfdfa;
}

.option-card.is-selected {
  border-color: var(--green);
  background: #f0f7f2;
  box-shadow: inset 0 0 0 1px var(--green);
}

.option-card.is-locked {
  cursor: default;
}

.option-card.is-right {
  border-color: #85ac91;
  background: #eff7f0;
}

.option-card.is-wrong {
  border-color: #d89c94;
  background: #fff2ef;
}

.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.option-letter {
  display: inline-grid;
  flex: 0 0 25px;
  width: 25px;
  height: 25px;
  margin-top: -1px;
  place-items: center;
  border: 1px solid #dce2d9;
  border-radius: 8px;
  color: #63716a;
  background: #fbfcf8;
  font-size: 12px;
  font-weight: 700;
}

.is-selected .option-letter {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.option-copy {
  flex: 1;
  min-width: 0;
  color: #394440;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-line;
}

.answer-feedback {
  margin-top: 19px;
  padding: 15px 17px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.7;
}

.answer-feedback.is-correct {
  border-color: #cfe2d2;
  color: #315b3b;
  background: #f1f8f1;
}

.answer-feedback.is-incorrect {
  border-color: #f0d2cc;
  color: #79413b;
  background: #fff4f1;
}

.feedback-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
}

.feedback-detail {
  margin: 0;
}

.review-note {
  margin: 7px 0 0;
  color: var(--amber);
  font-size: 13px;
}

.question-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  color: #fff;
  background: var(--green);
}

.button-primary:hover:not(:disabled) {
  background: var(--green-dark);
}

.button-secondary {
  border-color: #e2e6df;
  color: #47534e;
  background: var(--paper);
}

.button-secondary:hover:not(:disabled) {
  border-color: #b6c9bb;
  color: var(--green-dark);
  background: #f6faf5;
}

.question-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 3px 0;
}

.navigation-status {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.practice-rail {
  grid-area: rail;
  display: grid;
  gap: 14px;
}

.rail-card {
  padding: 21px;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rail-heading .eyebrow {
  margin-bottom: 4px;
}

.rail-heading h2,
.source-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.rail-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 18px;
}

.set-filter {
  width: 100%;
  min-height: 43px;
  padding: 0 34px 0 12px;
  border: 1px solid #dfe4db;
  border-radius: 10px;
  color: #34413c;
  background: #fff;
  font-size: 13px;
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  margin: 23px 0 9px;
  color: #65716b;
  font-size: 12px;
}

.progress-heading span:last-child {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #edf0e9;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4c8a70, #7eaa83);
  transition: width 180ms ease;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 23px;
}

.score-block {
  display: grid;
  gap: 2px;
}

.score-number {
  font-size: 23px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.score-label {
  color: var(--muted);
  font-size: 11px;
}

.score-divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.source-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: #fbfcf8;
  box-shadow: none;
}

.source-icon {
  display: grid;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  margin-top: 1px;
  place-items: center;
  border: 1px solid #a9bcaa;
  border-radius: 50%;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.source-card h2 {
  margin: 0 0 6px;
  font-size: 13px;
}

.source-card p {
  margin: 0;
  color: #6b756f;
  font-size: 12px;
  line-height: 1.75;
}

.bank-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 18px;
}

.bank-list-panel,
.add-panel {
  min-width: 0;
  padding: 22px;
}

.bank-list-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.bank-list-heading .eyebrow {
  margin-bottom: 4px;
}

.bank-list-heading h2,
.add-panel h2 {
  margin: 0;
  font-size: 18px;
}

.bank-count {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.bank-list-heading .set-filter {
  width: auto;
  min-width: 150px;
  max-width: 230px;
}

.bank-list {
  display: grid;
  gap: 9px;
}

.bank-entry {
  overflow: hidden;
  border: 1px solid #e6e9e2;
  border-radius: 12px;
  background: #fff;
}

.bank-entry-meta {
  padding: 11px 14px 0;
  color: #758079;
  font-size: 11px;
}

.bank-entry details {
  padding: 4px 14px 13px;
}

.bank-entry summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 2px;
  color: #34413c;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.7;
  cursor: pointer;
  list-style: none;
}

.bank-entry summary::-webkit-details-marker {
  display: none;
}

.bank-entry summary::after {
  flex: 0 0 auto;
  color: var(--green);
  content: "＋";
  font-size: 16px;
  font-weight: 500;
}

.bank-entry details[open] summary::after {
  content: "−";
}

.bank-options {
  display: grid;
  gap: 5px;
  margin: 12px 0 0;
  padding: 0;
  color: #5d6963;
  font-size: 13px;
  line-height: 1.65;
  list-style: none;
}

.bank-answer {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 9px;
  color: #315b3b;
  background: #f1f8f1;
  font-size: 13px;
  line-height: 1.65;
}

.bank-review {
  margin: 8px 0 0;
  color: var(--amber);
  font-size: 12px;
  line-height: 1.65;
}

.bank-empty {
  margin: 0;
  padding: 20px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.add-panel > .eyebrow {
  margin-bottom: 5px;
}

.local-storage-note {
  margin: 9px 0 18px;
  color: #6e7972;
  font-size: 12px;
  line-height: 1.75;
}

.field-label,
.entry-options legend {
  display: block;
  margin: 15px 0 7px;
  color: #4f5c55;
  font-size: 12px;
  font-weight: 700;
}

.add-panel textarea,
.entry-options input {
  width: 100%;
  border: 1px solid #dfe4db;
  border-radius: 9px;
  color: #34413c;
  background: #fff;
  font: inherit;
  font-size: 13px;
}

.add-panel textarea {
  min-height: 86px;
  padding: 10px 11px;
  line-height: 1.65;
  resize: vertical;
}

.entry-options {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.entry-options legend {
  padding: 0;
}

.entry-options label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.entry-options label span {
  display: inline-grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 7px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 700;
}

.entry-options input {
  min-height: 38px;
  padding: 0 10px;
}

.add-panel .set-filter {
  min-height: 39px;
  font-size: 12px;
}

.add-submit {
  width: 100%;
  margin-top: 20px;
}

.add-message {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--green-dark);
  font-size: 12px;
  line-height: 1.6;
}

.add-message[data-state="error"] {
  color: var(--red);
}

.load-error {
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid #f0d2cc;
  border-radius: 12px;
  color: #79413b;
  background: #fff4f1;
  font-size: 14px;
  line-height: 1.7;
}

.footer {
  width: min(1112px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: #89928c;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr) 235px;
    gap: 15px;
  }

  .rail-card {
    padding: 18px;
  }

  .question-card {
    padding: 25px;
  }

  .bank-layout {
    grid-template-columns: minmax(0, 1fr) 295px;
    gap: 14px;
  }

  .bank-list-panel,
  .add-panel {
    padding: 18px;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 62px;
    padding: 0 20px;
  }

  .nav-tab {
    min-width: 55px;
    padding: 0 9px;
  }

  .page {
    width: min(100% - 32px, 540px);
    padding: 31px 0 38px;
  }

  .intro {
    display: block;
    margin-bottom: 20px;
  }

  .source-note {
    margin-top: 12px;
    font-size: 12px;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "question"
      "rail";
    gap: 18px;
  }

  .question-card {
    min-height: 0;
    padding: 22px 18px;
    border-radius: 17px;
  }

  .question-stem {
    margin: 21px 0;
    font-size: 19px;
    line-height: 1.75;
  }

  .option-card {
    padding: 13px;
  }

  .option-copy {
    font-size: 14px;
  }

  .question-nav {
    padding-top: 13px;
  }

  .button {
    min-height: 42px;
    padding: 0 13px;
    font-size: 13px;
  }

  .navigation-status {
    font-size: 11px;
  }

  .practice-rail {
    grid-template-columns: 1fr;
  }

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

  .bank-list-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .bank-list-heading .set-filter {
    width: 100%;
    max-width: none;
  }

  .rail-card {
    padding: 18px;
  }

  .footer {
    width: min(100% - 32px, 540px);
    padding-bottom: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
