:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --ink: #17201d;
  --muted: #66736f;
  --line: #d6ded9;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --blue: #2457a6;
  --ok: #167447;
  --bad: #b42318;
  --warn: #9a6700;
  --shadow: 0 16px 40px rgba(24, 32, 29, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.brand h1,
.exam-header h2,
.empty-state h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 28px;
  line-height: 1.1;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.segmented,
.secondary-button,
.primary-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

.segmented.is-active,
.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.segmented.is-active:hover {
  background: var(--accent-strong);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 14px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.exam-list {
  overflow: auto;
  padding: 12px;
}

.subject-block + .subject-block {
  margin-top: 14px;
}

.subject-title {
  margin: 8px 8px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.exam-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  min-height: 62px;
  margin-bottom: 8px;
  padding: 12px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}

.exam-button:hover,
.exam-button.is-selected {
  border-color: var(--line);
  background: var(--panel);
}

.exam-button.is-selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

.exam-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

.exam-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  align-self: start;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  background: var(--ok);
}

.pill.missing {
  color: #3b2f00;
  background: #f5d76e;
}

.main {
  min-width: 0;
  padding: 24px;
}

.exam-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.exam-header h2 {
  font-size: 28px;
  line-height: 1.2;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 190px;
}

.status-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.empty-state {
  max-width: 720px;
  padding: 40px 0;
}

.empty-state h2 {
  font-size: 30px;
}

.empty-state p {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.6;
}

.is-hidden {
  display: none !important;
}

.quiz-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.counter {
  display: inline-block;
  margin-bottom: 10px;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe7e3;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 0.72fr);
  gap: 16px;
  align-items: start;
}

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

.question-panel {
  padding: 22px;
}

.question-stem {
  font-size: 22px;
  font-weight: 780;
  line-height: 1.4;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.option-button {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.option-button:hover,
.option-button.is-selected {
  border-color: var(--blue);
  background: #eef4ff;
}

.option-button.is-correct {
  border-color: var(--ok);
  background: #eefaf3;
}

.option-button.is-wrong {
  border-color: var(--bad);
  background: #fff1ef;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #e7ece9;
  font-weight: 850;
}

.option-text {
  overflow-wrap: anywhere;
  line-height: 1.42;
}

.feedback {
  min-height: 34px;
  margin-top: 16px;
  font-weight: 760;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.bad {
  color: var(--bad);
}

.feedback.warn {
  color: var(--warn);
}

.nav-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.source-panel {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  overflow: hidden;
}

.source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.source-header h3 {
  margin: 0;
  font-size: 18px;
}

.source-panel iframe {
  width: 100%;
  min-height: 560px;
  flex: 1;
  border: 0;
  background: #edf1ef;
}

.result-panel {
  padding: 18px;
}

.result-panel h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.result-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.result-panel p + p {
  margin-top: 6px;
}

.result-panel.pass h3 {
  color: var(--ok);
}

.result-panel.fail h3 {
  color: var(--bad);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.score-stat {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.score-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.threshold-card {
  margin-top: 18px;
  overflow-x: auto;
}

.threshold-title {
  display: flex;
  justify-content: space-between;
  min-width: 720px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.threshold-grid {
  display: grid;
  grid-template-columns: 42px repeat(16, minmax(42px, 1fr));
  min-width: 720px;
  border: 1px solid #2f3835;
  background: #2f3835;
  gap: 1px;
}

.threshold-head,
.threshold-row-label,
.threshold-corner,
.threshold-cell,
.threshold-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

.threshold-head,
.threshold-row-label,
.threshold-corner {
  background: #fff;
}

.threshold-cell.bad {
  background: #ee8f95;
}

.threshold-cell.edge {
  background: #f3d85f;
}

.threshold-cell.ok {
  background: #a8cf9c;
}

.threshold-cell.current {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

.threshold-empty {
  background: #fff;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .exam-list {
    max-height: 340px;
  }

  .work-area {
    grid-template-columns: 1fr;
  }

  .source-panel {
    min-height: 480px;
  }

  .source-panel iframe {
    min-height: 430px;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .brand {
    padding: 18px 16px 14px;
  }

  .exam-header {
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
    min-width: 0;
  }

  .exam-header h2,
  .empty-state h2 {
    font-size: 24px;
  }

  .question-panel {
    padding: 16px;
  }

  .question-stem {
    font-size: 19px;
  }

  .nav-row {
    grid-template-columns: 1fr;
  }

  .score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
