/* =====================================================================
   PRO100 TEST — оформление в стиле портала технического департамента
   Нейтральная основа, тонкие линии, цвет только там, где он что-то значит.
   ===================================================================== */

:root {
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --bg-muted: #eceef2;
  --line: #e3e6eb;
  --line-strong: #cdd1da;
  --ink: #1a1c2b;
  --ink-2: #4d5366;
  --ink-3: #868b9b;

  --brand: #2b2e4a;
  --brand-hover: #3b3f62;
  --brand-soft: #eceef6;
  --on-brand: #ffffff;
  --lime: #9cc23c;
  --lime-hover: #8db234;
  --lime-ink: #557a0c;
  --lime-soft: #eef5dc;
  --star: #c98a12;

  --ok: #287a3e;       --ok-soft: #e7f4ea;
  --warn: #9a5800;     --warn-soft: #fff3df;
  --danger: #b42318;   --danger-soft: #fdecea;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-pop: 0 8px 28px rgba(20, 22, 40, 0.14), 0 1px 3px rgba(20, 22, 40, 0.08);
  --topbar-h: 56px;
  --content-w: 880px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #15171e;
  --bg-subtle: #1b1e27;
  --bg-muted: #252935;
  --line: #2b2f3b;
  --line-strong: #3b4051;
  --ink: #e7e9ef;
  --ink-2: #a9afbf;
  --ink-3: #7b8193;

  --brand: #b3d25a;
  --brand-hover: #c3de72;
  --brand-soft: #262b1c;
  --on-brand: #15171e;
  --lime: #b3d25a;
  --lime-hover: #c3de72;
  --lime-ink: #b3d25a;
  --lime-soft: #232a17;
  --star: #e0a64b;

  --ok: #6fc284;       --ok-soft: #1c2a20;
  --warn: #e0a64b;     --warn-soft: #2d2415;
  --danger: #f07b6f;   --danger-soft: #331d1b;

  --shadow-pop: 0 10px 32px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------- основа ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* общий вид кнопок */
.back-btn, .nav-btn, .restart-exam-btn, .review-btn, .reset-hard-btn, .reset-wrong-btn,
.nav-square, .train-btn, .test-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.back-btn:hover:not(:disabled), .nav-btn:hover:not(:disabled), .restart-exam-btn:hover,
.reset-hard-btn:hover, .reset-wrong-btn:hover, .nav-square:hover,
.train-btn:hover {
  background: var(--bg-subtle); border-color: var(--ink-3);
}
.nav-btn:disabled { opacity: .45; }

/* главные действия */
.review-btn, .test-btn,
#check-btn, #hard-check-btn, #wrong-check-btn, #test-confirm-btn, #exam-next-btn {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
}
.review-btn:hover, .test-btn:hover,
#check-btn:hover:not(:disabled), #hard-check-btn:hover:not(:disabled),
#wrong-check-btn:hover:not(:disabled), #test-confirm-btn:hover:not(:disabled),
#exam-next-btn:hover:not(:disabled) {
  background: var(--brand-hover); border-color: var(--brand-hover);
}

/* ---------- каркас ---------- */
.container { min-height: 100vh; }

.top-panel {
  position: sticky; top: 0; z-index: 100;
  min-height: var(--topbar-h);
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.panel-left {
  max-width: 1120px; margin: 0 auto;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 8px 20px;
}
.panel-left h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; letter-spacing: 0.02em; white-space: nowrap;
}
.panel-left h3::before {
  content: "";
  width: 8px; height: 18px;
  border-radius: 3px;
  background: var(--lime);
}
.nav-buttons-panel { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.nav-square { height: 34px; padding: 0 12px; font-size: 13.5px; }
.theme-btn { width: 34px; padding: 0; color: var(--ink-2); }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }

/* выбор теста */
.test-selector { position: relative; flex: 1; min-width: 0; max-width: 560px; }
.test-selector-btn {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14px; font-weight: 500;
  cursor: pointer; user-select: none;
}
.test-selector-btn:hover, .test-selector-btn.active { border-color: var(--ink-3); }
#selectedTestDisplay { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-selector-btn .arrow { font-size: 10px; color: var(--ink-3); transition: transform .2s; }
.test-selector-btn.active .arrow { transform: rotate(180deg); }
.test-dropdown {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  z-index: 200;
  max-height: min(480px, 70vh); overflow-y: auto;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.test-dropdown.show { display: block; }
.test-group { padding: 10px 10px 4px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.test-item {
  position: relative;
  display: grid; grid-template-columns: 64px 1fr auto; align-items: baseline; gap: 4px 10px;
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.test-item:hover { background: var(--bg-subtle); }
.test-item.selected { background: var(--lime-soft); }
.test-item.selected .test-code { color: var(--lime-ink); }
.test-item.disabled { opacity: .45; cursor: default; }
.test-item.disabled:hover { background: none; }
.test-code { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.test-name { font-size: 14px; }
.test-desc { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* уведомления */
#notificationContainer {
  position: fixed; top: calc(var(--topbar-h) + 12px + env(safe-area-inset-top)); right: 16px;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.notification {
  display: flex; align-items: flex-start; gap: 12px;
  min-width: 240px; max-width: min(360px, calc(100vw - 32px));
  padding: 10px 10px 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--lime);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  pointer-events: auto;
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.notification-content { flex: 1; }
.notification-title { display: none; }
.notification-message { color: var(--ink); }
.notification-close {
  border: none; background: none; color: var(--ink-3);
  font-size: 18px; line-height: 1; padding: 0 4px; border-radius: 4px;
}
.notification-close:hover { background: var(--bg-muted); color: var(--ink); }

/* ---------- экраны ---------- */
#menu-screen, #quiz-screen, #test-screen, #exam-screen, #exam-review-screen,
#hard-mode-screen, #wrong-mode-screen {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 24px 20px 56px;
  padding-bottom: max(56px, env(safe-area-inset-bottom));
}

/* меню */
#testTitle {
  font-size: 22px; line-height: 1.3;
  margin-bottom: 20px;
}
.menu-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  margin-bottom: 12px;
}
.block-card {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.block-card:hover { border-color: var(--line-strong); }
.block-card h3 { font-size: 15px; }
.block-card p { margin-top: 2px; color: var(--ink-3); font-size: 13px; }
.block-actions { display: flex; gap: 8px; margin-top: 14px; }
.block-actions button { flex: 1; height: 34px; font-size: 13.5px; }

.exam-card {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 20px;
  margin-bottom: 12px;
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  cursor: pointer;
}
.exam-card:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.exam-card h3 { font-size: 16px; }
.exam-card p { color: inherit; opacity: .75; font-family: var(--font-ui); font-size: 13.5px; }
.exam-card::after { content: "→"; font-size: 20px; opacity: .8; }

.special-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.special-card {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 44px 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s;
}
.special-card:hover { border-color: var(--line-strong); }
.special-card h3 { font-size: 14.5px; font-weight: 500; }
.special-count {
  display: inline-block; min-width: 26px; padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; text-align: center;
  background: var(--bg-muted); color: var(--ink-2);
}
.special-card.hard .special-count { background: var(--warn-soft); color: var(--warn); }
.special-card.wrong .special-count { background: var(--danger-soft); color: var(--danger); }
.reset-special-btn {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none; border-radius: 5px; background: none;
  color: var(--ink-3); font-size: 13px;
}
.reset-special-btn:hover { background: var(--bg-muted); color: var(--danger); }

.footer-note {
  margin-top: 28px; padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center; font-size: 12.5px; color: var(--ink-3);
}

/* шапка экрана вопроса */
.quiz-header, .test-header, .review-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.stats { display: flex; gap: 6px; margin-left: auto; }
.stat-item {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.stat-icon { font-family: var(--font-ui); color: var(--ink-3); }
.reset-hard-btn, .reset-wrong-btn { height: 32px; font-size: 13px; color: var(--ink-2); }

.timer-container {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.timer-icon { font-size: 14px; color: var(--ink-3); }
.timer-warning { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.timer-warning .timer-icon { color: var(--danger); }

.progress-container {
  height: 4px; margin-bottom: 18px;
  background: var(--bg-muted);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0;
  background: var(--lime);
  border-radius: 2px;
  transition: width .3s ease;
}
.exam-progress, .test-progress { background: var(--brand); }

/* вопрос */
.question-container {
  position: relative;
  padding: 18px 52px 18px 20px;
  margin-bottom: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#q-text, #test-q-text, #exam-q-text, #review-q-text, #hard-q-text, #wrong-q-text {
  font-size: 16.5px; font-weight: 500; line-height: 1.5;
}
.star-btn, .star-btn-small, .result-star-btn {
  border: none; background: none;
  color: var(--line-strong);
  line-height: 1;
  transition: color .15s, transform .15s;
}
.star-btn {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 6px;
  font-size: 20px;
}
.star-btn:hover, .star-btn-small:hover, .result-star-btn:hover { color: var(--star); }
.star-btn.active, .star-btn-small.active, .result-star-btn.active { color: var(--star); }
.star-btn-small { font-size: 16px; }

/* варианты ответа */
.options-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.option-btn {
  position: relative;
  width: 100%;
  padding: 12px 14px 12px 44px;
  text-align: left;
  font-size: 15px; line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: background .12s, border-color .12s;
}
.option-btn::before {
  content: "";
  position: absolute; left: 14px; top: 14px;
  width: 18px; height: 18px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg);
}
.option-btn:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--ink-3); }
.option-btn:disabled { cursor: default; }
.option-btn.selected, .option-btn.review-selected { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.option-btn.selected::before, .option-btn.review-selected::before {
  border-color: var(--brand);
  background: radial-gradient(circle, var(--brand) 0 4px, var(--bg) 5px);
}
.option-btn.correct, .option-btn.review-correct {
  background: var(--ok-soft); border-color: var(--ok); box-shadow: none;
}
.option-btn.correct::before, .option-btn.review-correct::before {
  content: "✓"; border-color: var(--ok); background: var(--ok); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 15px; text-align: center;
}
.option-btn.wrong, .option-btn.review-wrong {
  background: var(--danger-soft); border-color: var(--danger); box-shadow: none;
}
.option-btn.wrong::before, .option-btn.review-wrong::before {
  content: "✕"; border-color: var(--danger); background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
[data-theme="dark"] .option-btn.correct::before, [data-theme="dark"] .option-btn.review-correct::before,
[data-theme="dark"] .option-btn.wrong::before, [data-theme="dark"] .option-btn.review-wrong::before { color: var(--bg); }

/* пояснение */
.explanation-box, .test-explanation-box {
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--lime-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--lime);
  border-radius: var(--radius);
  font-size: 14.5px; line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;
}
.explanation-box strong { font-weight: 600; }

/* нумерация вопросов */
.pagination {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pagination:empty { display: none; }
.page-btn {
  min-width: 32px; height: 30px; padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.page-btn:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); }
.page-btn.answered { background: var(--brand-soft); border-color: var(--line-strong); color: var(--ink); }
.page-btn.correct { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.page-btn.wrong { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.page-btn.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); color: var(--ink); font-weight: 600; }

/* навигация */
.nav-buttons { display: flex; gap: 8px; }
.nav-buttons .nav-btn { flex: 1; height: 42px; }
#exam-next-btn { width: 100%; height: 44px; }

/* ---------- результаты ---------- */
.result-box {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.result-title {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.03em;
}
.result-pass { background: var(--ok-soft); color: var(--ok); }
.result-fail { background: var(--danger-soft); color: var(--danger); }
.result-score {
  margin: 12px 0 6px;
  font-family: var(--font-mono); font-size: 44px; font-weight: 500; letter-spacing: -0.02em;
}
.result-details { color: var(--ink-2); font-size: 14px; line-height: 1.7; margin-bottom: 18px; }
.result-box > div:last-child, .result-actions {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.result-nav { margin: 0 0 18px; text-align: left; }
.result-nav h4 { margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
#exam-result-questions { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
#exam-result-questions:empty { display: none; }
.result-question-item {
  display: grid; grid-template-columns: 82px 1fr auto auto; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.result-question-item:last-child { border-bottom: none; }
.result-question-item:hover { background: var(--bg-subtle); }
.result-question-number { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); }
.result-question-text { min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-question-status { width: 8px; height: 8px; border-radius: 50%; }
.status-correct { background: var(--ok); }
.status-wrong { background: var(--danger); }
.result-star-btn { font-size: 17px; padding: 2px 4px; }

/* разное */
.answered-status { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.answered-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-correct { background: var(--ok); }
.dot-wrong { background: var(--danger); }
.dot-pending { background: var(--warn); }
.dot-unanswered { background: var(--line-strong); }
.loading, .empty-message { padding: 48px 16px; text-align: center; color: var(--ink-3); }
.error-message { padding: 14px 16px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); }

/* ---------- телефон ---------- */
@media (max-width: 720px) {
  .panel-left { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .test-selector { order: 3; flex-basis: 100%; max-width: none; }
  #menu-screen, #quiz-screen, #test-screen, #exam-screen, #exam-review-screen,
  #hard-mode-screen, #wrong-mode-screen { padding: 16px 12px 40px; }
  #notificationContainer { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  .notification { max-width: none; }
  #testTitle { font-size: 18px; }
  .menu-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .block-card { padding: 12px; }
  .block-actions { flex-direction: column; gap: 6px; margin-top: 10px; }
  .block-actions button { flex: none; height: 34px; }
  .special-grid { gap: 8px; }
  .special-card { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 36px 12px 12px; }
  .special-card h3 { font-size: 13.5px; }
  .reset-special-btn { top: 8px; right: 6px; transform: none; }
  .question-container { padding: 14px 44px 14px 14px; }
  #q-text, #test-q-text, #exam-q-text, #review-q-text, #hard-q-text, #wrong-q-text { font-size: 15.5px; }
  .star-btn { top: 6px; right: 6px; }
  .option-btn { font-size: 14.5px; padding: 11px 12px 11px 40px; }
  .option-btn::before { left: 12px; top: 13px; }
  .nav-buttons { position: sticky; bottom: 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); background: var(--bg); }
  .nav-buttons .nav-btn { padding: 0 8px; font-size: 13.5px; }
  .result-box { padding: 18px 14px; }
  .result-question-item { grid-template-columns: 70px 1fr auto auto; gap: 8px; }
}
@media (max-width: 380px) {
  .menu-grid { grid-template-columns: 1fr; }
  .nav-square { padding: 0 9px; }
}
