.tests-container { max-width: 900px; }

.tests-screen { display: none; padding-bottom: 60px; }
.tests-screen.active { display: block; }

/* ── Дерево ────────────────────────────────────────── */
.tree {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 20px;
}

.tree-class { margin-bottom: 4px; }
.tree-class:last-child { margin-bottom: 0; }

.tree-class > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px; font-weight: 600;
  color: var(--text);
  list-style: none;
  user-select: none;
  transition: border-color .15s, background .15s;
}
.tree-class > summary::-webkit-details-marker { display: none; }
.tree-class > summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--accent);
  transition: transform .15s;
  display: inline-block;
  width: 12px;
}
.tree-class[open] > summary::before { transform: rotate(90deg); }
.tree-class > summary:hover { border-color: var(--border-hi); }

.tree-count {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted-2); font-weight: 400;
}

.tree-lessons {
  padding: 6px 4px 6px 26px;
  display: grid; gap: 2px;
}

.tree-lesson {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px; color: #cdd3e0;
  transition: background .12s;
}
.tree-lesson:hover { background: rgba(106,169,255,.06); }

.tree-lesson input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent-hi);
  cursor: pointer;
  flex-shrink: 0;
}
.tree-lesson input[type="checkbox"]:checked + span {
  color: var(--accent);
  font-weight: 500;
}

/* ── Нижняя панель ─────────────────────────────────── */
.tests-bar {
  display: flex; justify-content: space-between;
  align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky; bottom: 16px;
}

#testsSummary {
  font-size: 14px; color: var(--muted);
}
#testsSummary b { color: var(--accent); font-weight: 700; }

.tests-btn {
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.tests-btn:hover:not(:disabled) {
  background: #1e2330; border-color: var(--border-hi);
}
.tests-btn:active:not(:disabled) { transform: translateY(1px); }
.tests-btn:disabled { opacity: .4; cursor: not-allowed; }

.tests-btn-primary {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  color: #fff;
}
.tests-btn-primary:hover:not(:disabled) {
  background: var(--accent); border-color: var(--accent);
}

/* ── Тест ──────────────────────────────────────────── */
.tests-progress { margin-bottom: 24px; }

.tests-progress-bar {
  height: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.tests-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-hi), var(--accent));
  width: 0;
  transition: width .3s;
}

.tests-progress-text {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 12px;
  color: var(--muted);
}
#progressTopic { color: var(--accent); }

.tests-question {
  padding: 28px 30px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  min-height: 320px;
}

.tests-q-topic {
  display: inline-block;
  font-family: var(--mono); font-size: 11px;
  font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 10px; border-radius: 99px;
  color: var(--accent);
  background: rgba(106,169,255,.1);
  border: 1px solid rgba(106,169,255,.25);
  margin-bottom: 14px;
}

.tests-q-text {
  font-size: 17px; line-height: 1.55;
  color: var(--text); margin-bottom: 22px;
  font-weight: 500;
}

.tests-q-hint {
  font-size: 13px; color: var(--muted-2);
  margin-bottom: 16px;
  font-style: italic;
}

.tests-options { display: grid; gap: 10px; }

.tests-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px; color: #cdd3e0; line-height: 1.5;
  transition: border-color .15s, background .15s;
}
.tests-option:hover { border-color: var(--border-hi); }

.tests-option input {
  width: 18px; height: 18px;
  accent-color: var(--accent-hi);
  cursor: pointer; flex-shrink: 0;
  margin-top: 2px;
}

.tests-option.selected {
  border-color: var(--accent);
  background: rgba(106,169,255,.08);
  color: var(--text);
}
.tests-option.selected input { accent-color: var(--accent); }

.tests-text-input {
  width: 100%;
  padding: 14px 18px;
  font-family: inherit; font-size: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.tests-text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(106,169,255,.12);
}

.tests-nav {
  display: flex; gap: 10px; justify-content: space-between;
}
.tests-nav #testsNext { margin-left: auto; }

/* ── Результаты ────────────────────────────────────── */
.tests-result-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 20px;
}

.tests-overall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.tests-stat {
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.tests-stat-label {
  font-size: 11px; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 8px;
}
.tests-stat-value {
  font-family: var(--mono); font-size: 30px; font-weight: 700;
  color: var(--accent); line-height: 1;
}
.tests-stat.good .tests-stat-value { color: var(--ok); }
.tests-stat.bad .tests-stat-value { color: var(--err); }

.tests-by-topic {
  display: grid; gap: 10px;
  margin-bottom: 26px;
}

.tests-topic-result {
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.tests-topic-result.good { border-left-color: var(--ok); }
.tests-topic-result.bad { border-left-color: var(--err); }

.tests-topic-head {
  display: flex; justify-content: space-between;
  align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.tests-topic-name {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.tests-topic-score {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
}
.tests-topic-score.good { color: var(--ok); }
.tests-topic-score.mid { color: var(--warn); }
.tests-topic-score.bad { color: var(--err); }

.tests-topic-bar {
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
}
.tests-topic-bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent);
}
.tests-topic-result.good .tests-topic-bar-fill { background: var(--ok); }
.tests-topic-result.bad .tests-topic-bar-fill { background: var(--err); }

.tests-topic-detail {
  font-size: 13px; color: var(--muted);
  margin-top: 10px;
}

.tests-result-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
}

.tests-loading {
  padding: 40px; text-align: center;
  color: var(--muted); font-size: 15px;
}
/* ── Кнопка отправки учителю ── */
.tests-btn-accent {
  background: linear-gradient(135deg, #7b5cff, #4d8ef7);
  border-color: #7b5cff;
  color: #fff;
}
.tests-btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #8f70ff, #6aa9ff);
  border-color: #8f70ff;
}

/* ── Модальное окно ── */
.tests-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.tests-modal.hidden { display: none; }

.tests-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}

.tests-modal-box {
  position: relative;
  width: min(760px, 100%);
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.tests-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--text);
}

.tests-modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.tests-modal-close:hover {
  color: var(--err);
  border-color: var(--err);
  background: rgba(252,165,165,.08);
}

.tests-modal-body {
  overflow-y: auto;
  padding: 16px 20px 20px;
  background: #ffffff;
}

.tests-modal-hint {
  font-size: 13px;
  color: #4a5163;
  margin: 0 0 12px;
  line-height: 1.6;
}

.tests-modal-body iframe {
  display: block;
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 600px) {
  .tests-modal-box { max-height: 95vh; }
  .tests-modal-body iframe { height: 520px; }
}
/* Нижняя панель модального окна с кнопками */
.tests-modal-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.tests-modal-actions .tests-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* ── Таймер ─────────────────────────────────────────── */
.tests-timer {
  margin-left: auto;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: color .2s, border-color .2s, background .2s;
}

.tests-timer.warn {
  color: var(--warn);
  border-color: rgba(255,216,102,.4);
  background: rgba(255,216,102,.08);
}

.tests-timer.danger {
  color: var(--err);
  border-color: rgba(252,165,165,.5);
  background: rgba(252,165,165,.08);
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* Индикатор «скопировано в буфер» */
.tests-toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 99px;
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  z-index: 600;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}   