:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #66727e;
  --paper: #f4f6f8;
  --panel: #ffffff;
  --line: #d8e0e7;
  --line-strong: #bac7d3;
  --navy: #102a43;
  --blue: #246b9f;
  --green: #168058;
  --green-soft: #eaf8f1;
  --amber: #b26a16;
  --amber-soft: #fff4df;
  --red: #b43d34;
  --red-soft: #fff0ef;
  --shadow: 0 18px 45px rgba(16, 42, 67, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.exam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 18px max(20px, calc((100vw - 1440px) / 2));
}

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

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
}

.exam-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 8px;
}

.status-cell {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.status-cell span {
  display: block;
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 1.28rem;
  font-weight: 900;
}

.status-cell small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.status-cell.emphasis {
  border-color: rgba(36, 107, 159, 0.38);
  background: #edf6fc;
}

.exam-brief {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1440px;
  margin: 18px auto 0;
  padding: 0 20px;
}

.exam-brief h2 {
  max-width: 720px;
}

.brief-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.brief-strip span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.app-shell {
  display: grid;
  grid-template-columns: clamp(220px, 22vw, 300px) minmax(0, 1fr) clamp(210px, 18vw, 280px);
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 20px 36px;
}

body[data-section="reading"] .app-shell {
  grid-template-columns: clamp(220px, 20vw, 286px) minmax(0, 1fr) clamp(190px, 15vw, 220px);
  gap: 16px;
}

body[data-section="reading"] .dashboard,
body[data-section="reading"] .review-panel {
  padding: 14px;
}

body[data-section="reading"] .section-card {
  padding: 11px;
}

body[data-section="reading"] .section-card p {
  font-size: 0.8rem;
}

body[data-section="reading"] .practice-panel {
  padding: 20px;
}

@media (max-width: 1280px) {
  .app-shell,
  body[data-section="reading"] .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .review-panel,
  body[data-section="reading"] .review-panel {
    grid-column: 1 / -1;
  }
}

.dashboard,
.practice-panel,
.review-panel {
  min-width: 0;
}

.dashboard,
.practice-panel,
.review-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.dashboard,
.review-panel {
  padding: 16px;
}

.practice-panel {
  padding: 18px;
}

.section-heading,
.practice-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.compact {
  align-items: start;
}

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

.section-card {
  display: grid;
  gap: 9px;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 13px;
  text-align: left;
}

.section-card.active {
  border-color: rgba(22, 128, 88, 0.42);
  border-left-color: var(--green);
  background: var(--green-soft);
}

.section-card:disabled {
  cursor: default;
}

.section-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.section-card h3 {
  font-size: 0.96rem;
  line-height: 1.2;
}

.section-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.42;
}

.range-tag,
.status-tag,
.badge-tag,
.progress-pill,
.review-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 850;
  white-space: nowrap;
}

.range-tag {
  background: #eef4f8;
  color: var(--navy);
}

.status-tag {
  width: fit-content;
  background: #edf6fc;
  color: var(--blue);
}

.badge-tag {
  width: fit-content;
  border: 1px solid rgba(178, 106, 22, 0.35);
  background: var(--amber-soft);
  color: var(--amber);
}

.progress-pill,
.review-count {
  background: var(--navy);
  color: #fff;
}

.progress-track {
  height: 10px;
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: #e6edf3;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 180ms ease;
}

.question-card {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.question-text {
  min-height: 76px;
  margin-bottom: 18px;
  font-size: 1.38rem;
  font-weight: 850;
  line-height: 1.38;
}

.question-text p {
  margin-bottom: 0;
}

.sign-prompt {
  width: min(100%, 560px);
  margin-bottom: 16px;
  border: 1px solid #e9b08b;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffe4d0, #fff5ea);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.35);
  color: #111827;
  padding: 18px 16px;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  font-weight: 900;
  line-height: 1.18;
  text-transform: uppercase;
}

.cloze-passage {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.cloze-passage,
.transformation-prompt,
.listening-card,
.listening-passage {
  width: 100%;
}

body[data-section="reading"] .cloze-passage,
body[data-section="cloze"] .cloze-passage {
  max-height: 48vh;
  overflow: auto;
  padding: 22px 26px;
}

.cloze-passage h3 {
  margin-bottom: 10px;
  color: var(--navy);
  text-align: center;
  font-size: 1rem;
  font-weight: 900;
}

.passage-subtitle {
  margin-top: -6px;
  margin-bottom: 10px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.cloze-passage p {
  color: #27313b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.62;
}

body[data-section="reading"] .cloze-passage p,
body[data-section="cloze"] .cloze-passage p {
  font-size: 1.08rem;
  line-height: 1.7;
}

.cloze-passage p + p {
  margin-top: 10px;
}

.transformation-prompt {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.original-sentence {
  margin-bottom: 12px;
  color: var(--navy);
  font-size: 1.04rem;
  font-weight: 850;
  line-height: 1.45;
}

.rewrite-line {
  margin-bottom: 0;
  border-top: 1px dashed var(--line-strong);
  padding-top: 12px;
  color: #344251;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1.5;
}

.text-answer {
  display: grid;
  gap: 8px;
}

.text-answer span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.text-answer textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  font: inherit;
  line-height: 1.45;
}

.text-answer textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(36, 107, 159, 0.16);
}

.listening-passage {
  max-height: 280px;
  margin-bottom: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.listening-passage h3 {
  margin-bottom: 10px;
  color: var(--navy);
  text-align: center;
  font-size: 1rem;
  font-weight: 900;
}

.listening-passage p {
  color: #27313b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.6;
}

.listening-passage p + p {
  margin-top: 10px;
}

.listening-card {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.listening-card span {
  display: inline-flex;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #f0e8ff;
  color: #5b2bbf;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.listening-card p {
  margin-bottom: 0;
  color: var(--navy);
  font-size: 1.2rem;
  font-weight: 850;
  line-height: 1.35;
}

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

.option-button {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px 9px 9px;
  text-align: left;
  overflow-wrap: anywhere;
}

.option-button:hover,
.option-button.selected {
  border-color: rgba(36, 107, 159, 0.55);
  background: #f2f8fc;
}

.option-key {
  display: grid;
  width: 38px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 900;
}

.feedback {
  min-height: 76px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.45;
}

.feedback.correct {
  border-color: rgba(22, 128, 88, 0.28);
  background: var(--green-soft);
  color: #0b6040;
}

.feedback.wrong {
  border-color: rgba(180, 61, 52, 0.28);
  background: var(--red-soft);
  color: var(--red);
}

.practice-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 850;
}

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

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--navy);
}

.ghost-button {
  border: 1px solid rgba(36, 107, 159, 0.35);
  background: #fff;
  color: var(--blue);
}

.question-rail {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 7px;
  margin-top: 14px;
}

.question-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.question-chip.current {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.question-chip.answered {
  border-color: rgba(22, 128, 88, 0.3);
  background: var(--green-soft);
  color: #0b6040;
}

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

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

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

.review-item p,
.empty-state {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: clamp(210px, 28vw, 280px) minmax(0, 1fr);
  }

  .review-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .exam-header,
  .exam-brief {
    align-items: stretch;
    flex-direction: column;
  }

  .exam-status {
    grid-template-columns: repeat(3, 1fr);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .dashboard {
    order: 2;
  }

  .practice-panel {
    order: 1;
  }

  .review-panel {
    grid-column: auto;
    order: 3;
  }

  .section-grid {
    grid-template-columns: repeat(8, minmax(168px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .section-card {
    min-height: 132px;
    scroll-snap-align: start;
  }
}

@media (max-width: 560px) {
  body {
    background: #edf2f6;
  }

  .exam-header {
    gap: 12px;
    padding: 12px 12px 10px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    flex-basis: 40px;
    width: 40px;
    font-size: 0.95rem;
  }

  h1 {
    font-size: 1.35rem;
  }

  h2 {
    font-size: 1rem;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 0.64rem;
  }

  .exam-brief,
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .exam-brief {
    gap: 10px;
    margin-top: 10px;
  }

  .exam-brief h2 {
    font-size: 0.95rem;
  }

  .brief-strip {
    flex-wrap: nowrap;
    justify-content: start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .brief-strip span {
    flex: 0 0 auto;
    padding: 7px 9px;
    font-size: 0.76rem;
  }

  .app-shell {
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 20px;
  }

  .exam-status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .status-cell {
    min-height: 54px;
    padding: 8px 7px;
  }

  .status-cell span {
    font-size: 1.02rem;
  }

  .status-cell small {
    display: block;
    font-size: 0.64rem;
    line-height: 1.15;
  }

  .section-heading,
  .practice-topline {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
  }

  .dashboard,
  .practice-panel,
  .review-panel {
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(16, 42, 67, 0.08);
  }

  .dashboard,
  .review-panel {
    padding: 10px;
  }

  .practice-panel {
    padding: 10px;
  }

  .section-grid {
    grid-template-columns: repeat(8, minmax(146px, 1fr));
    gap: 8px;
  }

  .section-card {
    min-height: 118px;
    gap: 7px;
    padding: 10px;
  }

  .section-card header {
    flex-direction: column;
    gap: 7px;
  }

  .section-card h3 {
    font-size: 0.86rem;
  }

  .section-card p {
    font-size: 0.76rem;
    line-height: 1.35;
  }

  .range-tag,
  .status-tag,
  .badge-tag,
  .progress-pill,
  .review-count {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 0.68rem;
  }

  .question-card {
    padding: 12px;
  }

  .question-meta {
    margin-bottom: 12px;
    font-size: 0.76rem;
  }

  .question-text {
    min-height: auto;
    margin-bottom: 14px;
    font-size: 1.04rem;
    line-height: 1.36;
  }

  .cloze-passage,
  .transformation-prompt,
  .listening-card,
  .listening-passage {
    padding: 12px;
  }

  body[data-section="reading"] .cloze-passage,
  body[data-section="cloze"] .cloze-passage {
    max-height: 42vh;
    padding: 14px;
  }

  .cloze-passage p,
  body[data-section="reading"] .cloze-passage p,
  body[data-section="cloze"] .cloze-passage p,
  .listening-passage p {
    font-size: 0.94rem;
    line-height: 1.58;
  }

  .listening-card p {
    font-size: 1rem;
  }

  .options-list {
    gap: 8px;
  }

  .option-button {
    grid-template-columns: 34px 1fr;
    gap: 9px;
    min-height: 50px;
    padding: 8px 10px 8px 8px;
    font-size: 0.92rem;
  }

  .option-key {
    width: 34px;
  }

  .feedback {
    min-height: auto;
    margin-top: 10px;
    padding: 10px;
    font-size: 0.9rem;
  }

  .practice-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .primary-button {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    min-height: 44px;
    padding: 0 10px;
    font-size: 0.9rem;
  }

  .question-rail {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
  }

  .question-chip {
    min-height: 32px;
    font-size: 0.72rem;
  }

  .review-list {
    gap: 8px;
  }

  .review-item {
    padding: 10px;
  }

  .review-item p,
  .empty-state {
    font-size: 0.84rem;
  }
}
