:root {
  color-scheme: light;
  --bg-top: #e8f4ef;
  --bg-bottom: #f4f6fa;
  --panel: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #0d9488;
  --primary-soft: #ccfbf1;
  --primary-hover: #0f766e;
  --primary-ring: rgba(13, 148, 136, 0.18);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning-soft: #fffbeb;
  --option-bg: #f8fafc;
  --option-hover: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.1);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(13, 148, 136, 0.15), transparent),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 45%, #eef2f7 100%);
  font-family:
    "Noto Sans SC",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 880px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: grid;
  place-items: center;
}

.exam-panel,
.result-panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  overflow: hidden;
}

.exam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 32px 24px;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border-bottom: 1px solid var(--line);
}

.exam-header__brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.exam-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-soft), #e0f2fe);
  color: var(--primary);
  font-size: 22px;
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mode-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 8px;
  color: var(--primary-hover);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.mode-link:hover {
  text-decoration: underline;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
}

h2 {
  font-size: 22px;
  line-height: 1.35;
  font-weight: 700;
}

.score-badge {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 88px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid rgba(13, 148, 136, 0.15);
}

.score-badge__label {
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.score-badge__value {
  color: var(--primary-hover);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.progress-section {
  padding: 0 32px 24px;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: #e2e8f0;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #14b8a6);
  transition: width 280ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(13, 148, 136, 0.35);
}

.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 32px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.type-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-full);
  background: #fff;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.type-tab:hover {
  border-color: var(--line-strong);
  background: var(--option-hover);
  color: var(--text);
}

.type-tab.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-hover);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.type-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.06);
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.type-tab.is-active .type-tab__count {
  background: rgba(13, 148, 136, 0.16);
}

.question-area {
  min-height: 320px;
  padding: 28px 32px 8px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.question-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.tag--type {
  color: var(--primary-hover);
  background: var(--primary-soft);
  border: 1px solid rgba(13, 148, 136, 0.12);
}

.tag--source {
  color: var(--text-secondary);
  background: var(--option-bg);
  border: 1px solid var(--line);
}

.question-index {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.question-title {
  margin: 0 0 24px;
  font-size: 20px;
  line-height: 1.6;
  font-weight: 600;
  color: var(--text);
}

.question-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -8px 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #b45309;
  font-size: 13px;
  font-weight: 500;
  background: var(--warning-soft);
  border: 1px solid #fde68a;
}

.question-hint::before {
  content: "ℹ";
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fbbf24;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

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

.option {
  position: relative;
  display: grid;
  grid-template-columns: 24px 1fr;
  column-gap: 12px;
  align-items: start;
  min-height: 56px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--option-bg);
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    transform 120ms ease;
}

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

.option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.option__letter {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.option__text {
  grid-column: 2;
  min-width: 0;
  font-size: 15px;
  line-height: 24px;
  color: var(--text);
  word-break: break-word;
}

.option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.option:has(input:checked) .option__letter {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.option.option--correct {
  border-color: var(--success);
  background: var(--success-soft);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.option.option--correct .option__letter {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.option.option--wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.option.option--wrong .option__letter {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.option:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.essay-input-section {
  display: grid;
  gap: 10px;
}

.essay-input-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.essay-input {
  width: 100%;
  min-height: 200px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  color: var(--text);
  background: #fff;
  line-height: 1.75;
  font-size: 15px;
  resize: vertical;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.essay-input::placeholder {
  color: #94a3b8;
}

.essay-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.essay-answer {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.essay-answer > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.answer-text {
  width: 100%;
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  color: var(--text);
  background: var(--option-bg);
  line-height: 1.75;
  white-space: pre-wrap;
  font-size: 15px;
}

.answer-panel {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-soft), #f0fdfa);
  animation: fadeSlideIn 220ms ease;
}

.answer-panel strong {
  color: var(--primary-hover);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.answer-panel p {
  margin: 0;
  line-height: 1.7;
  color: var(--text-secondary);
  font-size: 15px;
}

.message {
  min-height: 0;
  margin: 0 32px 0;
  padding: 0;
  color: transparent;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition:
    padding 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.message:not(:empty) {
  min-height: 44px;
  margin-bottom: 8px;
  padding: 12px 16px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #fecaca;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px 28px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.action-bar__nav,
.action-bar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 100ms ease;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

.primary-button:hover {
  background: linear-gradient(180deg, #14b8a6, #0d9488);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.4);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active {
  transform: scale(0.98);
}

.secondary-button {
  color: var(--text-secondary);
  background: #fff;
  border: 1.5px solid var(--line);
}

.secondary-button:hover:not(:disabled) {
  background: var(--option-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost-button {
  color: var(--primary-hover);
  background: transparent;
  border: 1.5px solid rgba(13, 148, 136, 0.35);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
}

.hidden {
  display: none;
}

.result-panel {
  max-width: 760px;
  padding: 36px 32px 32px;
  text-align: center;
}

.result-panel .eyebrow {
  margin-bottom: 8px;
}

.result-panel h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.result-score-ring {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 28px auto 20px;
}

.result-score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.result-score-ring__track {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 8;
}

.result-score-ring__fill {
  fill: none;
  stroke: url(#scoreGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 408;
  stroke-dashoffset: 408;
  transition: stroke-dashoffset 800ms cubic-bezier(0.4, 0, 0.2, 1);
}

.result-score {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--primary-hover);
}

.result-score span {
  font-size: 48px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-score small {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}

.result-copy {
  margin: 0 auto 28px;
  max-width: 520px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.65;
}

.result-list {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
  text-align: left;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.result-list::-webkit-scrollbar {
  width: 6px;
}

.result-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-full);
}

.result-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--option-bg);
  transition: border-color 160ms ease;
}

.result-item strong {
  line-height: 1.5;
  font-size: 14px;
}

.result-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.result-empty {
  padding: 18px 16px;
  border: 1px solid rgba(5, 150, 105, 0.2);
  border-radius: var(--radius-md);
  background: var(--success-soft);
  color: var(--success);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.result-item.correct {
  border-color: rgba(5, 150, 105, 0.25);
  background: var(--success-soft);
}

.result-item.correct strong {
  color: var(--success);
}

.result-item.wrong {
  border-color: rgba(220, 38, 38, 0.2);
  background: var(--danger-soft);
}

.result-item.wrong strong {
  color: var(--danger);
}

.result-item.essay {
  border-color: rgba(13, 148, 136, 0.2);
  background: var(--primary-soft);
}

.result-item.essay strong {
  color: var(--primary-hover);
}

.full-width {
  width: 100%;
  max-width: 280px;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px 12px 24px;
    align-items: stretch;
  }

  .exam-header {
    padding: 20px 20px 18px;
    align-items: flex-start;
  }

  .exam-icon {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  h1 {
    font-size: 22px;
  }

  .score-badge {
    min-width: 76px;
    padding: 8px 12px;
  }

  .score-badge__value {
    font-size: 18px;
  }

  .progress-section {
    padding: 0 20px 20px;
  }

  .type-tabs {
    gap: 6px;
    padding: 0 20px 16px;
  }

  .type-tab {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .question-area {
    min-height: 300px;
    padding: 22px 20px 4px;
  }

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

  .question-title {
    font-size: 18px;
    margin-bottom: 20px;
  }

  .option {
    grid-template-columns: 22px 1fr;
    column-gap: 10px;
    padding: 12px 14px;
  }

  .option__letter {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .option__text {
    font-size: 14px;
    line-height: 22px;
  }

  .message:not(:empty) {
    margin-left: 20px;
    margin-right: 20px;
  }

  .action-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(250, 251, 252, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
  }

  .action-bar__nav,
  .action-bar__actions {
    display: contents;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    min-height: 42px;
    padding: 0 4px;
    font-size: 12px;
    white-space: nowrap;
  }

  .result-panel {
    padding: 28px 20px 24px;
  }

  .result-score-ring {
    width: 140px;
    height: 140px;
  }

  .result-score span {
    font-size: 40px;
  }

  .result-list {
    max-height: 50vh;
  }
}
