:root {
  color-scheme: light;
  --bg: #22252a;
  --bg-2: #2b3035;
  --panel: #f7f5ef;
  --panel-strong: #ffffff;
  --ink: #1d2228;
  --muted: #68707a;
  --line: #d8d6ce;
  --teal: #0f766e;
  --teal-2: #e0f2ef;
  --green: #168044;
  --green-bg: #e3f4e9;
  --amber: #a35b00;
  --amber-bg: #fff1d6;
  --red: #ba2d2d;
  --red-bg: #fde7e5;
  --blue: #245c9c;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  align-items: center;
  color: #f9fbfb;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto 14px;
  max-width: 1500px;
}

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

.brand-mark {
  background: #d7f2eb;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  color: var(--teal);
  flex: 0 0 auto;
  height: 42px;
  padding: 8px;
  width: 42px;
}

.brand-mark path:first-child {
  fill: currentColor;
  opacity: 0.18;
  stroke: currentColor;
  stroke-width: 1.6;
}

.brand-mark path:last-child,
.empty-state path,
.empty-state rect,
.icon-button svg path,
.primary-button svg path,
.mini-button svg path,
.flag-button svg path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.eyeline {
  color: #b9c4bf;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.brand h1 {
  font-size: 1.25rem;
  line-height: 1.1;
  margin: 0;
}

.top-actions,
.quiz-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timer-box {
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  color: #f8fbfa;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 42px;
  min-width: 108px;
  padding: 5px 10px;
}

.timer-box span {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1.05;
}

.timer-box small {
  color: #b9c4bf;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.timer-box.warning {
  border-color: #f1c97f;
  color: #ffe0a1;
}

.timer-box.expired {
  border-color: #eda8a2;
  color: #ffb7b0;
}

.remember-toggle {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  color: #dde5e2;
  display: flex;
  font-size: 0.84rem;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
}

.remember-toggle input {
  accent-color: var(--teal);
}

.workspace {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(250px, 310px);
  margin: 0 auto;
  max-width: 1500px;
  min-height: calc(100vh - 92px);
}

.left-rail,
.right-rail,
.quiz-area {
  min-width: 0;
}

.left-rail,
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-zone,
.score-strip,
.filter-block,
.quiz-card,
.review-block,
.empty-state {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.import-zone {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.import-zone.dragging {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.import-zone p {
  color: var(--muted);
  font-size: 0.82rem;
  grid-column: 1 / -1;
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
}

.primary-button,
.icon-button,
.ghost-button,
.mini-button,
.flag-button,
.filter-button {
  align-items: center;
  border-radius: var(--radius);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.primary-button {
  background: var(--teal);
  border: 1px solid var(--teal);
  color: #fff;
  padding: 0 13px;
}

.primary-button:hover:not(:disabled) {
  background: #0b625b;
  transform: translateY(-1px);
}

.ghost-button,
.icon-button,
.mini-button,
.flag-button,
.filter-button {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 11px;
}

.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.mini-button:hover:not(:disabled),
.flag-button:hover:not(:disabled),
.filter-button:hover:not(:disabled) {
  border-color: #a9afa8;
}

.danger {
  color: var(--red);
}

.icon-button svg,
.primary-button svg,
.mini-button svg,
.flag-button svg {
  height: 18px;
  width: 18px;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.score-strip div {
  border-right: 1px solid var(--line);
  padding: 12px 8px;
}

.score-strip div:last-child {
  border-right: 0;
}

.score-strip span {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
}

.score-strip p {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  margin: 2px 0 0;
  text-transform: uppercase;
}

.filter-block {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 10px;
}

.filter-button {
  font-size: 0.82rem;
  min-height: 34px;
}

.filter-button.active {
  background: var(--teal-2);
  border-color: #89cfc6;
  color: #075f58;
}

.list-head {
  align-items: center;
  color: #dfe7e4;
  display: flex;
  font-size: 0.82rem;
  font-weight: 700;
  justify-content: space-between;
  padding: 0 2px;
}

.mini-button {
  color: #dfe7e4;
  min-height: 32px;
  padding: 0 8px;
}

.question-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 370px);
  min-height: 190px;
  overflow: auto;
  padding-right: 3px;
}

.question-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  display: grid;
  font-size: 0.86rem;
  gap: 8px;
  grid-template-columns: 40px 1fr auto;
  min-height: 42px;
  padding: 6px 8px;
  text-align: left;
}

.question-button.active {
  border-color: #7fc8c1;
  box-shadow: inset 0 0 0 1px #7fc8c1;
}

.question-button .q-number {
  font-weight: 800;
}

.question-button .q-label {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot.correct {
  background: var(--green);
}

.dot.partial {
  background: var(--amber);
}

.dot.incorrect {
  background: var(--red);
}

.dot.unanswered {
  background: #7a828b;
}

.dot.answered {
  background: var(--blue);
}

.quiz-area {
  display: flex;
}

.quiz-card,
.empty-state {
  min-height: 100%;
  padding: 22px;
  width: 100%;
}

.empty-state {
  align-items: center;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.empty-state svg {
  color: var(--teal);
  height: 140px;
  width: 190px;
}

.empty-state rect {
  fill: #f2fbf8;
}

.empty-state h2 {
  font-size: 1.55rem;
  margin: 8px 0 4px;
}

.empty-state p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 18px;
}

.question-topline {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.domain-label {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.quiz-card h2,
.review-block h2 {
  font-size: 1.35rem;
  line-height: 1.22;
  margin: 0;
}

.question-mode {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 10px 0 0;
  min-height: 30px;
  padding: 6px 10px;
}

.question-mode.single {
  background: var(--teal-2);
  color: #075f58;
}

.question-mode.multi {
  background: var(--amber-bg);
  color: var(--amber);
}

.flag-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 10px;
}

.flag-button.active {
  background: var(--amber-bg);
  border-color: #f1c97f;
  color: var(--amber);
}

.question-stem {
  color: #2e343a;
  font-size: 1.05rem;
  line-height: 1.58;
  margin: 24px 0 16px;
  white-space: pre-wrap;
}

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

.answer-option {
  align-items: flex-start;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr;
  line-height: 1.45;
  padding: 12px;
}

.answer-option input {
  accent-color: var(--teal);
  margin-top: 3px;
}

.answer-option.correct-answer {
  background: var(--green-bg);
  border-color: #93d6ad;
}

.answer-option.wrong-answer {
  background: var(--red-bg);
  border-color: #eda8a2;
}

.answer-option.partial-answer {
  background: var(--amber-bg);
  border-color: #f1c97f;
}

.answer-option.locked {
  cursor: default;
}

.answer-option input:disabled {
  cursor: default;
}

.answer-text {
  overflow-wrap: anywhere;
}

.result-panel {
  background: #fffaf0;
  border: 1px solid #f1d38d;
  border-radius: var(--radius);
  margin-top: 16px;
  padding: 14px;
}

.result-panel > div:first-child {
  align-items: center;
  display: flex;
  gap: 10px;
}

.result-panel p {
  line-height: 1.45;
  margin: 0;
}

.result-badge,
.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  min-height: 24px;
  padding: 4px 9px;
  text-transform: uppercase;
}

.result-badge.correct,
.status-pill.correct {
  background: var(--green-bg);
  color: var(--green);
}

.result-badge.partial,
.status-pill.partial {
  background: var(--amber-bg);
  color: var(--amber);
}

.result-badge.incorrect,
.status-pill.incorrect {
  background: var(--red-bg);
  color: var(--red);
}

.result-badge.unanswered,
.status-pill.neutral {
  background: #eceff1;
  color: #56606a;
}

.rationale-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rationale-item {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  color: #4a5159;
  font-size: 0.9rem;
  line-height: 1.45;
  padding-top: 8px;
}

.quiz-actions {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 14px;
}

.review-block {
  padding: 16px;
}

.review-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.review-grid {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
}

.review-grid div {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.review-grid dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.review-grid dd {
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.session-meter {
  background: #e3e2db;
  border-radius: 999px;
  height: 10px;
  margin-top: 16px;
  overflow: hidden;
}

.session-meter span {
  background: linear-gradient(90deg, var(--teal), #2f8752);
  display: block;
  height: 100%;
  transition: width 180ms ease;
  width: 0;
}

.session-text {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 10px 0 0;
}

.final-report {
  border-color: #93d6ad;
}

.final-score {
  border-bottom: 1px solid var(--line);
  margin-top: 12px;
  padding-bottom: 12px;
}

.final-score span {
  display: block;
  font-size: 2.3rem;
  font-weight: 900;
  line-height: 1;
}

.final-score p {
  color: var(--muted);
  line-height: 1.4;
  margin: 6px 0 0;
}

.final-counts {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.final-counts span {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 8px;
}

.missed-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  max-height: 330px;
  overflow: auto;
}

.missed-list button {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  display: grid;
  gap: 4px;
  grid-template-columns: auto 1fr;
  min-height: 44px;
  padding: 8px;
  text-align: left;
}

.missed-list button strong {
  color: var(--red);
  font-size: 0.78rem;
}

.missed-list button span {
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

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

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

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

  .question-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 250px;
  }

  .quiz-card,
  .empty-state {
    padding: 16px;
  }

  .quiz-actions {
    justify-content: stretch;
  }

  .quiz-actions button {
    flex: 1 1 130px;
  }
}

@media (max-width: 520px) {
  .score-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-strip div:nth-child(2) {
    border-right: 0;
  }

  .question-list {
    grid-template-columns: 1fr;
  }

  .question-topline,
  .review-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
