/*
  Stage 3 UI layer: closer to the classic MORKNIGA examenator style.
  Goal: keep the old beige/brown visual language, but improve readability,
  mobile layout, clickable areas and accessibility without changing old IDs/AJAX hooks.
*/
:root {
  --exam-bg: #f7eae3;
  --exam-panel: #fff8f3;
  --exam-panel-soft: #f9eee7;
  --exam-border: #7a4841;
  --exam-border-soft: #ecd6c9;
  --exam-text: #2f2423;
  --exam-muted: #765f59;
  --exam-accent: #325fa2;
  --exam-accent-dark: #174589;
  --exam-good: green;
  --exam-bad: red;
}

body.exam-body {
  background: var(--exam-bg);
  color: var(--exam-text);
  line-height: 1.45;
}

.exam-page {
  color: var(--exam-text);
}

.exam-shell {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 0 15px 42px;
}

.exam-page h1 {
  margin: 12px 0 10px;
  font-size: 27px;
  line-height: 1.18;
  font-weight: bold;
}

.exam-page h2 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

.exam-page h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

/* Instead of modern hero cards, keep a compact classic title block. */
.exam-hero {
  margin: 0 0 10px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.exam-kicker {
  display: block;
  margin: 0 0 5px;
  padding: 0;
  background: transparent;
  color: var(--exam-muted);
  font-size: 13px;
  font-style: italic;
  font-weight: normal;
}

.exam-lead,
.exam-help,
.exam-card p,
.exam-panel p,
.exam-mode-card p {
  color: var(--exam-muted);
}

.exam-lead {
  margin: 0 0 12px;
  font-size: 15px;
}

.exam-form-card,
.exam-panel,
.exam-card,
.exam-mode-card {
  display: block;
  margin: 13px 0;
  padding: 14px 15px;
  background: rgba(255, 248, 243, .45);
  border: 1px solid var(--exam-border);
  border-radius: 0;
  box-shadow: none;
  color: var(--exam-text);
  text-decoration: none;
}

.exam-card:hover,
.exam-mode-card:hover {
  background: #fff8f3;
  border-color: var(--exam-border);
  text-decoration: none;
}

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

.exam-grid .exam-panel,
.exam-grid .exam-card {
  margin: 0;
}

.exam-card h2,
.exam-card h3,
.exam-panel h2,
.exam-panel h3,
.exam-mode-card h2,
.exam-mode-card h3 {
  color: var(--exam-text);
}

.exam-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.exam-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--exam-border-soft);
  background: #f7eae3;
  color: #60453c;
  border-radius: 0;
  font-size: 13px;
}

.exam-field-row {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.exam-field-row label {
  font-weight: bold;
}

.exam-field-row input[type="text"],
.exam-page input[type="text"],
.exam-page input[type="password"] {
  width: 100%;
  max-width: 360px;
  min-height: 38px;
  border-radius: 15px;
  border: 0;
  background: #ecd6c9;
  color: #7a4841;
  font-family: 'PT Serif', serif;
  font-size: 15px;
}

.exam-help {
  margin: 6px 0 10px;
  font-size: 14px;
}

.exam-page fieldset {
  margin: 15px auto;
  padding: 12px 13px 10px;
  border: 1px solid var(--exam-border);
  background: rgba(255, 248, 243, .25);
}

.exam-page legend {
  padding: 0 7px;
  color: #000;
  font-size: 16px;
  font-weight: bold;
}

/* Keep old vertical form feeling, but make every answer easier to tap. */
.exam-choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.exam-option,
#vopros_telo label.ch_label {
  display: flex !important;
  align-items: flex-start;
  gap: 9px;
  min-height: 42px;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--exam-border-soft);
  background: rgba(255, 255, 255, .45);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.exam-option:hover,
#vopros_telo label.ch_label:hover {
  background: #fff8f3;
  border-color: var(--exam-border);
}

.exam-option.is-selected,
.exam-option:has(input:checked),
#vopros_telo label.ch_label:has(input:checked) {
  background: #fff8f3;
  border-color: var(--exam-accent);
  outline: 2px solid rgba(50, 95, 162, .12);
}

.exam-option input,
#vopros_telo label.ch_label input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--exam-accent);
}

.exam-option span,
#vopros_telo label.ch_label span {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.exam-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 13px;
}

.blue_butt,
.exam-primary-button,
input.blue_butt {
  min-height: 43px;
  height: auto;
  padding: 10px 24px;
  border-radius: 43px;
  line-height: 1.2;
  font-weight: normal;
  box-shadow: 1px 1px 0 2px #153361;
}

.exam-secondary-link {
  color: var(--exam-accent);
  font-weight: bold;
  text-decoration: none;
}

.exam-secondary-link:hover {
  text-decoration: underline;
}

/* Classic navigation blocks based on old .razmer, but readable on phones. */
.exam-link-list,
.razmer.exam-link-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.exam-link-list a {
  text-decoration: none;
}

.exam-link-list li,
.razmer.exam-school-tabs li {
  display: inline-block;
  margin: 4px 4px 6px 0;
  padding: 8px 16px;
  min-height: 40px;
  border: 1px solid var(--exam-border-soft);
  background: rgba(255, 255, 255, .35);
  color: #2f2423;
  cursor: pointer;
}

.exam-link-list li:hover,
.razmer.exam-school-tabs li:hover,
.razmer.exam-school-tabs li.select_razm {
  border-color: var(--exam-border);
  background: #fff8f3;
}

.exam-school-tabs {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

#main.is-loading {
  opacity: .72;
  pointer-events: none;
}

#vopros_list {
  margin: 8px 0 18px;
  padding: 9px;
  border: 1px solid var(--exam-border);
  background: rgba(255, 248, 243, .45);
}

.krug {
  width: 29px;
  height: 29px;
  padding-top: 4px;
  margin: 4px;
  border-radius: 50%;
  background: #d7c3b8;
  color: var(--exam-text);
  font-weight: bold;
}

.krug.green {
  background: var(--exam-good) !important;
  color: #fff;
}

.krug.red {
  background: var(--exam-bad) !important;
  color: #fff;
}

#vopros_telo {
  padding: 14px;
  border: 1px solid var(--exam-border);
  background: rgba(255, 248, 243, .45);
  font-size: 17px;
}

#vopros_telo h2 {
  margin-top: 0;
  font-size: 22px;
  line-height: 1.25;
}

.vimg {
  display: block;
  width: auto;
  max-width: min(100%, 520px);
  max-height: 360px;
  margin: 12px auto 18px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--exam-border-soft);
}

.vimg:hover {
  transform: none;
}

.exam-learning-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--exam-border);
  background: rgba(255, 248, 243, .35);
}

.exam-card-list {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.exam-card-list figure.ink-image {
  position: relative;
  float: none !important;
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  min-width: 0;
  margin: 0 !important;
  box-sizing: border-box;
  overflow: visible;
}

.exam-card-list figure.ink-image > img,
.exam-card-list figure.ink-image > img.card {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
  object-fit: contain;
  object-position: center center;
}

@media (max-width: 520px) {
  .exam-card-list {
    grid-template-columns: 1fr !important;
  }
}

.exam-card-list figure.ink-image > figcaption.light {
  left: 8px;
  right: 8px;
  bottom: 8px;
  background: rgba(255, 248, 243, .96);
  color: var(--exam-text);
  font-size: 14px;
  line-height: 1.35;
}

.exam-result-note {
  padding: 12px;
  border: 1px solid var(--exam-border-soft);
  background: rgba(255, 255, 255, .4);
}

.exam-note-list {
  margin: 8px 0 0 18px;
  padding: 0;
}

.exam-note-list li {
  margin-bottom: 5px;
}

@media (max-width: 760px) {
  .exam-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .exam-page h1 {
    font-size: 22px;
  }

  .exam-grid,
  .exam-grid.exam-grid-2,
  .exam-card-list {
    grid-template-columns: 1fr;
  }

  .exam-page .site_menu {
    white-space: normal;
  }

  body.exam-body {
    font-size: 15px;
  }

  #vopros_telo {
    padding: 12px;
    font-size: 16px;
  }

  .exam-option span,
  #vopros_telo label.ch_label span {
    font-size: 15px;
  }

  .blue_butt,
  .exam-primary-button,
  input.blue_butt {
    width: 100%;
    text-align: center;
  }

  .exam-actions .exam-secondary-link {
    display: block;
    width: 100%;
    text-align: center;
  }

  .exam-learning-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .exam-link-list li,
  .razmer.exam-school-tabs li {
    display: block;
    width: 100%;
    margin-right: 0;
  }
}

/* Верхнее меню раздела «Огни и знаки»: ближе к старому стилю, но ровное и адаптивное */
.exam-topnav-wrap {
  width: 100%;
  max-width: 1120px;
  margin: 8px auto 12px;
  padding: 0 12px;
  box-sizing: border-box;
}

.exam-body .exam-topnav {
  float: none;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--exam-border, #d6c5b0);
  background: #f7f1e8;
  box-sizing: border-box;
}

.exam-body .exam-topmenu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  white-space: normal;
}

.exam-body .exam-topmenu li {
  display: block;
  margin: 0;
  padding: 0;
  position: relative;
}

.exam-body .exam-topmenu li:before {
  display: none !important;
}

.exam-body .exam-topmenu a {
  display: block;
  padding: 8px 11px;
  border: 1px solid transparent;
  background: #fffdf8;
  color: #3b2925;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  box-sizing: border-box;
}

.exam-body .exam-topmenu a:hover,
.exam-body .exam-topmenu a:focus {
  border-color: #b79a7a;
  background: #fff7eb;
  color: #7a3b27;
  text-decoration: none;
}

.exam-body .exam-topmenu a.is-active {
  border-color: #8d5b42;
  background: #8d5b42;
  color: #fff;
  font-weight: bold;
}

@media (max-width: 760px) {
  .exam-topnav-wrap {
    margin-top: 6px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .exam-body .exam-topmenu {
    justify-content: stretch;
  }

  .exam-body .exam-topmenu li {
    flex: 1 1 calc(50% - 6px);
  }

  .exam-body .exam-topmenu a {
    min-height: 40px;
    padding: 9px 8px;
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .exam-body .exam-topmenu li {
    flex-basis: 100%;
  }
}

/* Stage 7: normalized question bank runtime */
.exam-question-card {
  margin-top: 12px;
}

.exam-question-meta {
  margin: 0 0 8px;
  color: #7b6b5f;
  font-size: 13px;
  line-height: 1.35;
}

.exam-question-image {
  margin: 12px 0 14px;
}

.exam-answer-list {
  margin: 14px 0;
}

.exam-answer-option {
  display: block;
  margin: 0 0 8px;
  padding: 9px 10px;
  border: 1px solid #dfd1bd;
  background: #fffdf8;
  cursor: pointer;
  line-height: 1.35;
}

.exam-answer-option:hover,
.exam-answer-option:focus-within {
  border-color: #b79a7a;
  background: #fff7eb;
}

.exam-answer-option input {
  margin-right: 8px;
}

@media (max-width: 640px) {
  .exam-answer-option {
    padding: 12px 10px;
    font-size: 16px;
  }
}


/* Stage 8: карточки «Огни и знаки» из общего банка */
.exam-light-question-card .exam-question-image img {
  max-height: 360px;
  object-fit: contain;
}
.exam-card-list .ink-image {
  cursor: pointer;
}
