:root {
  --ink: #17211b;
  --muted: #607068;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --line: #dce4df;
  --green: #20715a;
  --green-dark: #14523f;
  --gold: #b7812b;
  --red: #b5473f;
  --blue: #315f93;
  --soft-green: #e8f3ef;
  --soft-gold: #fff1d8;
  --soft-red: #fae7e4;
  --shadow: 0 20px 60px rgba(29, 48, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(232, 243, 239, 0.82), rgba(251, 252, 250, 0.95) 340px),
    var(--paper);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 8px;
  min-width: 340px;
}

.score-strip div,
.status-list div,
.result-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 12px;
}

.score-strip span,
.status-list span,
.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
}

.score-strip strong,
.status-list strong,
.result-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

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

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

.side-panel {
  position: sticky;
  top: 16px;
  padding: 18px;
}

#progressCanvas {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fbf8, #fff7e7);
}

.field {
  margin-bottom: 16px;
}

.field-hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.field label,
.label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.check-field {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.check-field input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--green);
}

.timer-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf8;
  padding: 10px 12px;
}

.timer-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.timer-box strong {
  color: var(--green-dark);
  font-size: 1.1rem;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(32, 113, 90, 0.25);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8f6;
}

.segment {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment.active {
  background: var(--green);
  color: white;
}

.actions,
.footer-actions {
  display: flex;
  gap: 10px;
}

.actions {
  margin: 20px 0 16px;
}

.primary,
.secondary {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  background: var(--green);
  color: white;
}

.primary:hover {
  background: var(--green-dark);
}

.secondary {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.secondary:hover {
  border-color: var(--green);
}

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

.exam-panel {
  min-height: 620px;
  overflow: hidden;
}

.empty-state,
.result-panel {
  padding: clamp(22px, 5vw, 48px);
}

.empty-state {
  min-height: 620px;
  display: grid;
  place-content: center;
  text-align: center;
}

.empty-state p {
  max-width: 540px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.7;
}

.visual-mark {
  display: grid;
  grid-template-columns: repeat(4, 32px);
  gap: 8px;
  justify-content: center;
  align-items: end;
  height: 92px;
  margin-bottom: 18px;
}

.visual-mark span {
  display: block;
  width: 32px;
  border-radius: 6px 6px 0 0;
}

.visual-mark span:nth-child(1) {
  height: 38px;
  background: var(--green);
}

.visual-mark span:nth-child(2) {
  height: 58px;
  background: var(--gold);
}

.visual-mark span:nth-child(3) {
  height: 76px;
  background: var(--blue);
}

.visual-mark span:nth-child(4) {
  height: 48px;
  background: #6b7f72;
}

.question-list {
  padding: 22px;
}

.question-card {
  display: none;
}

.question-card.active {
  display: block;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.question-card h2 {
  margin-bottom: 20px;
  line-height: 1.5;
  font-size: 1.25rem;
}

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

.option {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px 8px 8px;
  background: white;
}

.option:hover {
  border-color: rgba(32, 113, 90, 0.5);
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-key {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #edf2ef;
  color: var(--green);
  font-weight: 800;
}

.option-text {
  line-height: 1.55;
}

.option:has(input:checked) {
  border-color: var(--green);
  background: var(--soft-green);
}

.option:has(input:checked) .option-key {
  background: var(--green);
  color: white;
}

.footer-actions {
  justify-content: flex-end;
  padding-top: 14px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.analytics-panel {
  margin-bottom: 16px;
}

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

.analytics-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf8;
  padding: 10px;
}

.analytics-grid span {
  display: block;
  min-height: 32px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.analytics-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

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

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

.review-item.correct {
  border-color: rgba(32, 113, 90, 0.35);
  background: var(--soft-green);
}

.review-item.incorrect {
  border-color: rgba(181, 71, 63, 0.35);
  background: var(--soft-red);
}

.review-item.notice {
  border-color: rgba(49, 95, 147, 0.28);
  background: #eef5fb;
}

.review-item h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.45;
}

.review-item p {
  margin: 6px 0 0;
  line-height: 1.55;
}

.review-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .score-strip {
    min-width: 0;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .score-strip,
  .status-list,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .actions,
  .footer-actions,
  .result-actions {
    flex-direction: column;
  }

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

  .question-list {
    padding: 16px;
  }
}

@media print {
  body {
    background: white;
  }

  .side-panel,
  .footer-actions,
  .result-actions,
  .empty-state {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .topbar,
  .workspace {
    display: block;
  }

  .exam-panel {
    border: 0;
    box-shadow: none;
  }
}
