:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #626a73;
  --line: #d9dee4;
  --paper: #ffffff;
  --wash: #f3f6f8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --gold: #c27a12;
  --wrong: #b42318;
  --right: #137333;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fbfc 0%, #eef3f5 100%);
}

button,
input,
select {
  font: inherit;
}

.appShell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(320px, 1.2fr);
  gap: 28px;
  align-items: start;
  padding: 28px 0 24px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 8vw, 88px);
  line-height: 0.94;
  letter-spacing: 0;
}

.lead {
  max-width: 420px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(31, 41, 55, 0.08);
}

label,
fieldset {
  min-width: 0;
}

label span,
legend {
  display: block;
  margin-bottom: 7px;
  color: #3d454d;
  font-size: 13px;
  font-weight: 700;
}

input[type="url"],
input[type="number"],
select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid #cfd6dd;
  border-radius: 6px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.controlGrid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
}

.typePicker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.typePicker legend {
  width: 100%;
}

.typePicker label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  background: #eef7f5;
  border: 1px solid #c4ded9;
  border-radius: 6px;
  color: #244642;
  font-size: 14px;
  font-weight: 650;
}

.primaryButton,
.secondaryButton,
.scoreButton {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.primaryButton:hover,
.secondaryButton:hover,
.scoreButton:hover {
  background: var(--accent-dark);
}

.secondaryButton {
  color: var(--accent-dark);
  background: #dff1ed;
  border: 1px solid #b9dcd4;
}

.secondaryButton:hover {
  color: white;
}

.primaryButton:disabled {
  background: #8aa5a1;
  cursor: wait;
}

.secondaryButton:disabled {
  color: #5f7571;
  background: #e8efed;
  cursor: wait;
}

.status {
  grid-column: 2;
  min-height: 24px;
  margin: -12px 0 0;
  color: var(--muted);
}

.quizPanel {
  display: grid;
  gap: 16px;
}

.articleHeader,
.questionCard,
.scoreBox {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.articleHeader {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
}

.articleHeader h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.articleHeader a {
  color: var(--accent-dark);
  font-weight: 700;
}

.articleSubline {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.seed {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.sectionPanel {
  display: grid;
  gap: 12px;
}

.sectionHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sectionHeader span {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

.sectionHeader strong {
  display: block;
}

.sectionHeader a {
  color: var(--accent-dark);
  font-weight: 800;
}

.sectionList {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.sectionOption {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px 11px calc(12px + var(--indent) * 16px);
  background: #fbfcfd;
  border: 1px solid #d5dde3;
  border-radius: 6px;
  cursor: pointer;
}

.sectionOption input {
  margin-top: 3px;
}

.sectionOption strong,
.sectionOption small,
.sectionOption em {
  display: block;
}

.sectionOption small {
  margin-top: 2px;
  color: var(--gold);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.sectionOption em {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.55;
}

.questionCard {
  padding: 18px 20px;
}

.questionMeta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.questionText {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.65;
}

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

.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid #cfd6dd;
  border-radius: 6px;
  background: #fbfcfd;
  cursor: pointer;
}

.choice input {
  margin-top: 4px;
}

.freeAnswer {
  margin-top: 4px;
}

.result {
  display: none;
  margin-top: 14px;
  padding: 12px;
  border-radius: 6px;
  background: var(--wash);
  line-height: 1.65;
}

.questionCard.correct {
  border-color: rgba(19, 115, 51, 0.55);
}

.questionCard.incorrect {
  border-color: rgba(180, 35, 24, 0.55);
}

.questionCard.correct .result,
.questionCard.incorrect .result {
  display: block;
}

.markRight {
  color: var(--right);
  font-weight: 800;
}

.markWrong {
  color: var(--wrong);
  font-weight: 800;
}

.scoreBox {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
}

.scoreBox strong {
  font-size: 24px;
}

.scoreButton {
  padding: 0 18px;
}

@media (max-width: 820px) {
  .appShell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

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

  .status {
    grid-column: 1;
  }

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

  .articleHeader,
  .scoreBox {
    align-items: flex-start;
    flex-direction: column;
  }
}
