:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --paper: #fffefa;
  --ink: #242321;
  --muted: #706d66;
  --line: #dedad2;
  --soft: #efede7;
  --accent: #2f6f73;
  --accent-ink: #ffffff;
  --amber: #9a6a1f;
  --green: #55715f;
  --blue: #4b6579;
  --shadow: 0 18px 45px rgba(34, 31, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 26px 26px;
}

.topbar,
.control-band,
.study-layout,
.bottom-actions {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 0 10px;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2.7vw, 32px);
  line-height: 1.08;
  letter-spacing: 0;
}

.counter {
  min-width: 86px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.76);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.answer-switch {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  height: 36px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.answer-switch input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(34, 31, 26, 0.18);
  transition: transform 0.18s ease;
}

.answer-switch input:checked + .switch-track {
  border-color: var(--accent);
  background: var(--accent);
}

.answer-switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.answer-switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.14);
}

.switch-label-short {
  display: none;
}

#currentIndex {
  color: var(--ink);
  font-weight: 700;
}

.counter-divider {
  padding: 0 5px;
}

.control-band {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-top: 16px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}

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

.tab-button,
.ghost-button,
.secondary-button,
.primary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 9px 13px;
}

.compact-button {
  min-height: 36px;
  padding: 7px 12px;
}

.tab-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.filters {
  display: flex;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

select,
input {
  height: 42px;
  padding: 0 12px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.14);
}

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

.question-panel,
.answer-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.question-panel {
  min-height: 500px;
  padding: 28px;
}

.answer-panel {
  position: sticky;
  top: 20px;
  padding: 20px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

.question-meta span,
.warning-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  background: var(--soft);
  padding: 4px 9px;
}

#confidenceBadge.high {
  color: var(--green);
}

#confidenceBadge.medium {
  color: var(--blue);
}

#confidenceBadge.low {
  color: var(--amber);
}

h2 {
  margin: 0 0 24px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.42;
  letter-spacing: 0;
  white-space: pre-line;
}

.blank-slot,
.blank-answer {
  display: inline-flex;
  align-items: center;
  min-height: 1.5em;
  border-bottom: 2px solid var(--line);
  vertical-align: baseline;
}

.blank-answer {
  margin: 0 2px;
  padding: 0 5px;
  border-color: var(--accent);
  border-radius: 6px 6px 0 0;
  background: #edf5f3;
  color: var(--accent);
  font-weight: 800;
}

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

.option-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
  text-align: left;
  line-height: 1.5;
}

.option-item.is-selected {
  border-color: var(--accent);
  background: #edf5f3;
}

.option-item.is-correct {
  border-color: #6d8c72;
  background: #eef5ef;
}

.option-item.is-wrong {
  border-color: #b77a6b;
  background: #f8efec;
}

.option-letter {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--soft);
  font-weight: 700;
}

.thinking-box {
  display: none;
  width: 100%;
  min-height: 150px;
  margin-top: 18px;
  padding: 14px;
  line-height: 1.55;
  resize: vertical;
}

.thinking-box.is-visible {
  display: block;
}

.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.answer-body {
  padding-top: 16px;
  white-space: pre-line;
  line-height: 1.65;
}

.answer-body.is-hidden {
  color: var(--muted);
}

.answer-value {
  margin-bottom: 14px;
  font-size: 24px;
  font-weight: 800;
}

.answer-value.is-long-answer {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.65;
}

.answer-inline-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.explanation {
  color: #3b3934;
}

.warning-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
  color: var(--amber);
  font-size: 12px;
}

.bottom-actions {
  display: flex;
  justify-content: flex-start;
  padding: 18px 0 6px;
}

.primary-button {
  min-width: 144px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.secondary-button {
  min-width: 112px;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .control-band,
  .study-layout {
    grid-template-columns: 1fr;
  }

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

  .answer-panel {
    position: static;
  }

  .question-panel {
    min-height: auto;
    padding: 20px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px 12px 14px;
  }

  .topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
  }

  .title-row {
    flex: 1 1 auto;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .eyebrow {
    display: none;
  }

  .counter {
    min-width: 58px;
    padding: 3px 6px;
    font-size: 13px;
  }

  .counter-divider {
    padding: 0 3px;
  }

  .header-actions {
    display: flex;
    flex: 0 0 auto;
    width: auto;
    gap: 4px;
  }

  .switch-label-full {
    display: none;
  }

  .switch-label-short {
    display: inline;
  }

  h1 {
    font-size: 19px;
    white-space: nowrap;
  }

  .answer-switch {
    height: 30px;
    gap: 4px;
    font-size: 12px;
  }

  .switch-track {
    width: 34px;
    height: 20px;
  }

  .switch-track::after {
    width: 14px;
    height: 14px;
  }

  .answer-switch input:checked + .switch-track::after {
    transform: translateX(14px);
  }

  .compact-button {
    min-height: 30px;
    padding: 4px 7px;
    font-size: 13px;
  }

  .header-actions .primary-button,
  .header-actions .secondary-button {
    width: auto;
    min-width: 0;
  }

  .study-layout {
    gap: 8px;
  }

  .question-panel,
  .answer-panel {
    border-radius: 8px;
    box-shadow: none;
  }

  .question-panel {
    padding: 14px;
  }

  .question-meta {
    gap: 5px;
    margin-bottom: 10px;
    font-size: 12px;
  }

  .question-meta span,
  .warning-list span {
    min-height: 24px;
    padding: 3px 7px;
  }

  h2 {
    margin-bottom: 14px;
    font-size: 20px;
    line-height: 1.34;
  }

  .thinking-box {
    min-height: 84px;
    margin-top: 10px;
    padding: 10px;
  }

  .option-list {
    gap: 7px;
  }

  .option-item {
    grid-template-columns: 26px 1fr;
    gap: 8px;
    min-height: 44px;
    padding: 9px;
    line-height: 1.38;
  }

  .option-letter {
    width: 24px;
    height: 24px;
    border-radius: 7px;
  }

  .answer-panel {
    padding: 0 12px 10px;
  }

  .answer-head {
    min-height: 38px;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .ghost-button {
    min-height: 30px;
    padding: 4px 9px;
  }

  .answer-body {
    padding: 2px 0 0;
    line-height: 1.5;
  }

  .answer-body.is-hidden {
    display: none;
  }

  .answer-value {
    margin-bottom: 6px;
    font-size: 18px;
  }

  .answer-value.is-long-answer {
    font-size: 15px;
    line-height: 1.55;
  }

  .warning-list {
    gap: 5px;
    margin-top: 6px;
    padding-bottom: 0;
  }

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

  .control-band {
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
  }

  .tabs {
    gap: 6px;
  }

  .tab-button {
    flex: 1 1 calc(50% - 8px);
    min-height: 36px;
    padding: 7px 9px;
  }

  select,
  input {
    height: 38px;
  }

  .bottom-actions {
    padding-top: 10px;
  }

  .bottom-actions .primary-button,
  .bottom-actions .secondary-button {
    width: 100%;
    min-width: 0;
  }
}
