:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #eef4f3;
  --ink: #17212b;
  --muted: #657284;
  --line: #d9e0ea;
  --accent: #006d77;
  --accent-strong: #00545c;
  --accent-soft: #d7f0ee;
  --good: #147a49;
  --good-soft: #dff4e8;
  --bad: #b3261e;
  --bad-soft: #fde3df;
  --warn: #a15c00;
  --shadow: 0 18px 45px rgba(35, 52, 69, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(0, 109, 119, 0.11), transparent 36%),
    linear-gradient(315deg, rgba(215, 116, 79, 0.12), transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}

.quiz-panel,
.side-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 224, 234, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quiz-panel {
  min-height: calc(100vh - 64px);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.topbar,
.status-row,
.question-meta,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 2.7vw, 2.35rem);
  line-height: 1.1;
}

.scorebox {
  min-width: 88px;
  min-height: 70px;
  padding: 10px 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.scorebox span {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

.scorebox small {
  color: var(--muted);
}

.progress-wrap {
  height: 10px;
  flex: 1;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4ec;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #d7744f);
  transition: width 180ms ease;
}

.counter,
.topic-pill,
.streak {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.topic-pill,
.streak {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
}

.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-area h2 {
  max-width: 980px;
  margin-bottom: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.question-media {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.question-media img {
  display: block;
  width: 100%;
  max-height: min(340px, 42vh);
  object-fit: contain;
  background: #ffffff;
}

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

.option-button {
  width: 100%;
  min-height: 58px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease, box-shadow 130ms ease;
}

.option-button:hover:not(:disabled),
.option-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(0, 109, 119, 0.12);
  outline: none;
}

.option-button.correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.option-button.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(0, 109, 119, 0.1);
}

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

.option-button:disabled {
  cursor: default;
}

.option-title {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.multi-answer .option-title::before {
  content: "";
  width: 18px;
  height: 18px;
  margin-right: 10px;
  display: inline-block;
  vertical-align: -3px;
  border: 2px solid var(--line);
  border-radius: 5px;
  background: #ffffff;
}

.multi-answer .option-button.selected .option-title::before,
.multi-answer .option-button.correct .option-title::before {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, transparent 48%, var(--accent) 50%, var(--accent) 62%, transparent 64%),
    linear-gradient(45deg, transparent 52%, var(--accent) 54%, var(--accent) 66%, transparent 68%),
    #ffffff;
}

.check-button {
  width: min(220px, 100%);
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.check-button:hover,
.check-button:focus-visible {
  background: var(--accent-strong);
  outline: 3px solid rgba(0, 109, 119, 0.18);
}

.check-button:disabled {
  cursor: default;
  opacity: 0.65;
}

.feedback {
  min-height: 28px;
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

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

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

.actions {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.primary-button,
.danger-button,
.mode-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.primary-button {
  min-width: 145px;
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
}

.icon-button {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.primary-button:focus-visible,
.danger-button:focus-visible,
.mode-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(0, 109, 119, 0.18);
}

.side-panel {
  min-height: calc(100vh - 64px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.mode-button {
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
}

.mode-button.active {
  background: var(--accent);
  color: #ffffff;
}

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

.stats div {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stats dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.stats dd {
  margin: 4px 0 0;
  font-size: 1.45rem;
  font-weight: 800;
}

.review-list-wrap {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-list-wrap h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.review-list {
  min-height: 160px;
  max-height: 100%;
  margin: 0;
  padding: 0 0 0 22px;
  overflow: auto;
  color: var(--muted);
}

.review-list li {
  margin-bottom: 8px;
  padding-right: 4px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.review-list li:hover {
  color: var(--accent-strong);
}

.danger-button {
  width: 100%;
  padding: 0 14px;
  border-color: #f0c7c3;
  background: #fff7f6;
  color: var(--bad);
}

.danger-button:hover,
.danger-button:focus-visible {
  background: var(--bad-soft);
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100% - 20px, 760px);
    min-height: auto;
    padding: 10px 0 20px;
    grid-template-columns: 1fr;
  }

  .quiz-panel,
  .side-panel {
    min-height: auto;
  }

  .quiz-panel {
    padding: 18px;
  }

  .side-panel {
    padding: 16px;
    gap: 12px;
  }

  .question-media img {
    max-height: min(280px, 36vh);
  }

  .review-list {
    max-height: 150px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 12px, 760px);
    padding-top: 6px;
  }

  .quiz-panel {
    gap: 16px;
    padding: 14px;
  }

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

  h1 {
    font-size: 1.45rem;
  }

  .scorebox {
    min-width: 70px;
    min-height: 62px;
  }

  .question-meta {
    flex-wrap: wrap;
  }

  .question-area {
    gap: 12px;
  }

  .question-area h2 {
    font-size: 1.12rem;
  }

  .question-media img {
    max-height: min(230px, 34vh);
  }

  .option-button {
    min-height: 52px;
    padding: 12px;
  }

  .check-button {
    width: 100%;
  }

  .actions {
    display: grid;
    grid-template-columns: 44px minmax(120px, 1fr) 44px;
    gap: 8px;
  }

  .primary-button {
    min-width: 0;
    padding: 0 10px;
  }

  .icon-button {
    width: 44px;
  }

  .stats {
    gap: 6px;
  }

  .stats div {
    min-height: 64px;
    padding: 8px;
  }

  .stats dd {
    font-size: 1.25rem;
  }

  .review-list {
    min-height: 96px;
    max-height: 130px;
  }
}
