/* НМТ-А — стилі. Значення кольорів і розмірів підібрано під інтерфейс пробного НМТ. */
:root {
  --red: #c61036;
  --red-hover: #a00d2b;
  --bg-gray: #f5f5f5;
  --border: #e0e0e0;
  --text: #333;
  --ok: #2e7d32;
  --ok-bg: #e5f4e4;
  --bad-bg: #fbebeb;
  --q-font: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Open Sans', Arial, sans-serif;
  background: #fff;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}
input, textarea { user-select: text; -webkit-user-select: text; font-family: inherit; }
button { font-family: inherit; }
@media print { body { display: none !important; } }

.hidden { display: none !important; }
.center { text-align: center; }
.red { color: var(--red); }
.muted { color: #888; }
.link-red { color: var(--red); text-decoration: underline; cursor: pointer; }
.w100 { width: 100%; }
.fs14 { font-size: 14px; }
.fs16 { font-size: 16px; }

/* ---------- повноекранні екрани ---------- */
.overlay-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; background: #fff; overflow-y: auto; padding: 20px; z-index: 1000;
}
.page { min-height: 100vh; background: #fff; }
.z-top { z-index: 100000; }
.z-max { z-index: 200000; }
.red-screen { background: rgba(198, 16, 54, 0.98); color: #fff; }
.dark-screen { background: rgba(0, 0, 0, 0.97); color: #fff; }

.big-btn {
  background: var(--red); color: #fff; border: none; padding: 12px 60px; font-size: 20px;
  border-radius: 4px; cursor: pointer; font-weight: 700; transition: background .2s;
}
.big-btn:hover { background: var(--red-hover); }
.big-btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-md { padding: 12px 25px; font-size: 16px; }
.btn-sm { padding: 10px 20px; font-size: 14px; }
.btn-outline {
  background: #fff; border: 1px solid var(--red); color: var(--red); padding: 10px 20px;
  border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.btn-outline:hover { background: #fdf0f2; }
.btn-white { background: #fff; color: var(--red); border: none; padding: 12px 40px; font-size: 18px; font-weight: 700; border-radius: 4px; cursor: pointer; }
.btn-white-outline { background: transparent; color: #fff; border: 2px solid #fff; padding: 10px 30px; font-size: 16px; font-weight: 600; border-radius: 4px; cursor: pointer; }

/* ---------- помилка ---------- */
.error-title { color: var(--red); font-size: 28px; }
.error-text { max-width: 760px; text-align: left; font-size: 15px; line-height: 1.6; }
.error-text code { background: #f5f5f5; padding: 1px 5px; border-radius: 3px; }

/* ---------- вхід ---------- */
.login-title { font-size: 32px; font-weight: 700; margin: 0 0 20px; max-width: 1000px; }
.login-sub { font-size: 18px; color: #555; margin: 0 0 20px; }
.form-error { color: var(--red); font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.name-input {
  padding: 15px; font-size: 20px; width: 500px; max-width: 90%; border: 1px solid #ccc;
  border-radius: 8px; margin-bottom: 20px; text-align: center;
}
.name-input:focus { outline: none; border-color: var(--red); }
.agree-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: #555; max-width: 500px; text-align: left; margin-bottom: 25px; }
.agree-row input { width: 18px; height: 18px; margin-top: 2px; cursor: pointer; flex-shrink: 0; }
.agree-row label { cursor: pointer; line-height: 1.4; }
.login-btn-wrap { display: inline-block; }
.login-btn-wrap.blocked { cursor: not-allowed; }
.login-btn-wrap.blocked .big-btn { pointer-events: none; }
.login-footer { position: absolute; bottom: 20px; left: 0; right: 0; font-size: 11px; color: #888; margin: 0; padding: 0 20px; }

/* ---------- шапка ---------- */
.header { display: flex; justify-content: space-between; align-items: center; padding: 15px 40px; border-bottom: 1px solid var(--border); background: #fff; }
.header-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #555; }
.header-logo img { height: 35px; }
.header-user { font-weight: 600; font-size: 14px; position: relative; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.logout-menu {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 10px; background: #fff; border: 1px solid #ccc;
  padding: 10px 20px; box-shadow: 0 2px 10px rgba(0,0,0,.1); border-radius: 4px; z-index: 100; white-space: nowrap; color: #333;
}
.logout-menu.open { display: block; }
.logout-menu:hover { background: #f5f5f5; color: var(--red); }

/* ---------- правила ---------- */
.rules-box { max-width: 80%; margin: 40px auto; padding: 40px 50px; border: 1px solid #dcdcdc; border-radius: 4px; line-height: 1.6; font-size: 15px; }
.rules-box h3 { margin: 25px 0 15px; }
.rules-actions { text-align: right; margin-top: 25px; border-top: 1px solid #eee; padding-top: 15px; }

/* ---------- вступні випробування / запуск ---------- */
.prestart-box { border: 1px solid var(--border); padding: 30px; width: 800px; max-width: 90%; text-align: left; background: #fff; box-shadow: 0 4px 10px rgba(0,0,0,.1); }
.prestart-header { font-size: 20px; font-weight: 700; margin-bottom: 20px; border-bottom: 2px solid var(--red); padding-bottom: 10px; display: inline-block; }
.test-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; border: 1px solid #ccc; padding: 20px; border-left: 10px solid var(--red); background: #fafafa; }
.prestart-line { font-size: 18px; font-weight: 700; }
.launch-box { background: #f0f7f4; border-color: #cce3d8; }
.launch-box h2 { margin-top: 0; }
.launch-box p { line-height: 1.6; }

/* ---------- навігація ---------- */
.top-nav { display: flex; gap: 20px; padding: 0 40px; border-bottom: 1px solid var(--border); }
.top-nav a { color: #555; font-size: 14px; padding: 15px 5px; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.top-nav a.active { color: var(--red); border-bottom-color: var(--red); }
.top-nav a:hover:not(.active) { color: var(--red); }

/* ---------- плашка з таймером ---------- */
.info-plashka-container { padding: 20px 40px; background: #fff; }
.info-plashka { background: var(--bg-gray); border-left: 4px solid var(--red); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; gap: 20px; min-height: 66px; }
.info-text { font-size: 13px; color: #444; max-width: 65%; line-height: 1.5; }
.hide-link { color: var(--red); font-weight: 700; cursor: pointer; text-decoration: none; margin-left: 5px; }
.timer-controls, .review-controls { display: flex; align-items: center; gap: 15px; margin-left: auto; }
.btn-finish { background: var(--red); color: #fff; border: none; padding: 10px 20px; border-radius: 20px; font-weight: 600; cursor: pointer; font-size: 14px; }
.btn-finish:hover { background: var(--red-hover); }
.timer-display { font-weight: 700; font-size: 16px; width: 70px; text-align: center; font-variant-numeric: tabular-nums; }
.timer-display.low { color: var(--red); }
.timer-display.invisible { visibility: hidden; }
.btn-eye { background: var(--red); border: none; padding: 6px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; }

/* ---------- інструкція ---------- */
#instruction-area { padding: 40px; line-height: 1.6; font-size: 15px; max-width: 900px; margin: 0 auto; }

/* ---------- основний макет ---------- */
.main-layout { display: flex; padding: 0 40px 40px; gap: 20px; align-items: flex-start; }
.left-panel { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,.05); }
.breadcrumbs { padding: 15px 20px; font-size: 13px; color: #888; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.active-bread { color: var(--red); }
.expand-btn { cursor: pointer; color: #666; display: flex; align-items: center; }
.expand-btn:hover { color: var(--red); }
.subject-tabs { display: flex; border-bottom: 1px solid var(--border); background: #fafafa; }
.subject-tabs div { flex: 1; text-align: center; padding: 15px 0; font-size: 14px; font-weight: 600; color: #555; border-right: 1px solid var(--border); position: relative; overflow: hidden; }
.subject-tabs div.active { background: #fff; border-bottom: 3px solid var(--red); color: var(--text); }
.subject-tabs div.bookmarked::after { content: ''; position: absolute; top: 0; right: 0; border-width: 0 14px 14px 0; border-style: solid; border-color: transparent var(--red) transparent transparent; }
.content-area { padding: 30px; min-height: 500px; }
.subject-title { font-size: 24px; margin: 0 0 5px; font-weight: 400; }
.bookmark { color: var(--red); font-size: 13px; display: inline-flex; align-items: center; gap: 5px; margin-bottom: 20px; cursor: pointer; font-weight: 700; }
.bookmark.saved { color: #888; }

/* ---------- завдання ---------- */
.instr-block { background: #fdf5f6; border-left: 4px solid var(--red); padding: 10px 15px; margin-bottom: 15px; font-size: 14px; color: #555; }
.question-slide { margin-bottom: 50px; padding-bottom: 40px; border-bottom: 2px dashed var(--border); scroll-margin-top: 70px; }
.question-slide:last-child { border-bottom: none; }
.question-number { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.question-text { font-size: var(--q-font); margin-bottom: 20px; line-height: 1.5; overflow-x: auto; }
.question-text img, .answer-item img, .drag-item img { max-width: 100%; height: auto; }
.shared-text { font-size: var(--q-font); line-height: 1.6; background: #fafafa; border: 1px solid var(--border); border-radius: 4px; padding: 15px 20px; margin-bottom: 15px; }
.shared-text p { margin: 0 0 8px; }
.answers-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 30px; }
.answer-item { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px; border-radius: 4px; transition: background .2s; font-size: var(--q-font); }
.answer-item:hover { background: #f0f0f0; }
.answer-item input { transform: scale(1.3); cursor: pointer; margin: 0 10px 0 2px; flex-shrink: 0; }
.answer-item .marker { display: none; font-weight: 700; background: #eee; padding: 2px 8px; border-radius: 4px; }
.btn-save { background: #fff; color: #666; border: 1px solid #ccc; padding: 10px 20px; border-radius: 4px; font-weight: 600; cursor: pointer; transition: all .2s; font-size: 14px; }
.btn-save.ready { border-color: var(--red); color: var(--red); }
.btn-save.saved { background: var(--red); color: #fff; border-color: var(--red); }
.saved-msg { color: var(--red); font-size: 13px; font-weight: 700; margin-top: 10px; }

/* ---------- відповідність ---------- */
.match-wrapper { display: flex; gap: 20px; align-items: stretch; margin-bottom: 30px; }
.match-left-col { flex: 2; background: #e0f2f7; padding: 20px; border-radius: 8px; border: 1px solid #bce8f1; }
.match-right-col { flex: 1; background: #e8f5e9; padding: 20px; border-radius: 8px; border: 1px solid #c8e6c9; }
.match-row { display: flex; gap: 15px; align-items: stretch; margin-bottom: 25px; }
.match-row:last-child { margin-bottom: 0; }
.match-q-block { flex: 1; background: #cce5f5; padding: 15px; border-radius: 6px; border: 1px solid #99cbee; font-size: calc(var(--q-font) - 2px); line-height: 1.4; }
.match-arrow { display: flex; align-items: center; color: #888; font-size: 20px; }
.drop-zone { flex: 1; background: #fff; border: 2px dashed #ccc; border-radius: 6px; position: relative; min-height: 70px; display: flex; flex-direction: column; padding: 8px; transition: .2s; }
.drop-zone.over { border-color: var(--red); background: #ffe6eb; }
.drag-slot { margin-bottom: 12px; min-height: 10px; }
.drag-slot:last-child { margin-bottom: 0; }
.drag-item { background: #a5dfa5; padding: 15px 40px 15px 15px; border-radius: 6px; border: 1px solid #8cc68c; cursor: grab; font-size: calc(var(--q-font) - 2px); font-weight: 600; line-height: 1.4; box-shadow: 0 2px 4px rgba(0,0,0,.1); flex-grow: 1; }
.drag-item:active { cursor: grabbing; opacity: .8; }
.drag-item.dragging { opacity: .4; }
.remove-match-btn { position: absolute; bottom: 15px; right: 15px; width: 22px; height: 22px; background: #fff; border: 1px solid #ccc; border-radius: 4px; display: flex; justify-content: center; align-items: center; font-size: 14px; cursor: pointer; z-index: 10; font-weight: 700; }
.remove-match-btn:hover { background: #185abc; color: #fff; border-color: #185abc; }

/* ---------- права панель ---------- */
.right-panel { width: 280px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,.05); position: sticky; top: 20px; background: #fff; }
.grid-title { text-align: center; padding: 15px; font-weight: 600; border-bottom: 1px solid var(--border); }
.grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 20px; }
.grid-btn { background: #fff; border: 1px solid #ccc; padding: 10px 0; text-align: center; border-radius: 4px; font-weight: 600; cursor: pointer; transition: all .2s; position: relative; overflow: hidden; }
.grid-btn:hover { border-color: var(--red); }
.grid-btn.current { border: 2px solid #333; box-shadow: inset 0 0 0 1px #fff; padding: 9px 0; }
.grid-btn.saved { background: var(--red); color: #fff; border-color: var(--red); }
.grid-btn.saved.current { border: 2px solid #000; opacity: .9; }
.grid-btn.r-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.grid-btn.r-bad { background: var(--red); color: #fff; border-color: var(--red); }
.grid-btn.r-none { background: #e6e6e6; color: #666; border-color: #ccc; }
.grid-btn.current.r-ok, .grid-btn.current.r-bad, .grid-btn.current.r-none { border: 2px solid #000; padding: 9px 0; }
.grid-legend { display: flex; flex-direction: column; gap: 6px; padding: 0 20px 20px; font-size: 12px; color: #555; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.lg-ok { background: var(--ok); } .lg-bad { background: var(--red); } .lg-none { background: #e6e6e6; border: 1px solid #ccc; }

/* ---------- розбір ---------- */
.review-summary { background: var(--bg-gray); border-left: 4px solid var(--red); padding: 12px 16px; margin-bottom: 20px; font-size: 14px; }
.review-badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 12px; margin-left: 10px; vertical-align: 3px; }
.review-badge.ok { background: var(--ok-bg); color: var(--ok); }
.review-badge.bad { background: var(--bad-bg); color: var(--red); }
.review-badge.none { background: #eee; color: #666; }
.answer-item.review { cursor: default; }
.answer-item.review:hover { background: transparent; }
.answer-item.review .marker { display: inline-block; }
.answer-item.is-correct { background: var(--ok-bg); }
.answer-item.is-wrong { background: var(--bad-bg); }
.answer-item .tag { font-size: 12px; font-weight: 700; margin-left: auto; white-space: nowrap; }
.answer-item.is-correct .tag { color: var(--ok); }
.answer-item.is-wrong .tag { color: var(--red); }
.review-match { width: 100%; border-collapse: collapse; margin: 10px 0 25px; font-size: calc(var(--q-font) - 2px); }
.review-match th, .review-match td { border: 1px solid #ddd; padding: 8px 10px; text-align: left; vertical-align: top; }
.review-match th { background: #fafafa; }
.review-match td.ok { background: var(--ok-bg); }
.review-match td.bad { background: var(--bad-bg); }
.review-options { list-style: none; padding: 0; margin: 0 0 10px; font-size: calc(var(--q-font) - 2px); line-height: 1.5; }

/* ---------- модалки ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; justify-content: center; align-items: center; z-index: 50000; }
.small-modal { background: #fff; padding: 30px; border-radius: 8px; max-width: 500px; width: 90%; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,.3); }
.small-modal-text { font-size: 16px; margin-bottom: 25px; }
.small-modal-buttons { display: flex; justify-content: center; gap: 15px; }
.terms-modal { background: #fff; padding: 30px; border-radius: 8px; max-width: 750px; width: 90%; max-height: 85vh; display: flex; flex-direction: column; position: relative; }
.terms-modal h2 { font-size: 22px; margin: 0 0 20px; text-align: center; }
.terms-close { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; color: #888; line-height: 1; }
.terms-body { font-size: 15px; line-height: 1.6; color: #444; overflow-y: auto; }
.terms-actions { text-align: center; margin-top: 25px; border-top: 1px solid #eee; padding-top: 20px; }
.finish-modal { background: #fff; padding: 30px; border-radius: 8px; width: 600px; max-width: 95%; box-shadow: 0 4px 15px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 15px; }
.modal-title-sm { font-size: 18px; }
.modal-text { margin-bottom: 20px; line-height: 1.5; font-size: 14px; }
.modal-buttons { display: flex; gap: 15px; margin-bottom: 20px; }
.unanswered-box { border: 2px solid var(--red); padding: 15px; display: flex; gap: 15px; align-items: flex-start; font-size: 14px; }
.unanswered-box.center-items { align-items: center; }
.unanswered-list { display: block; margin-top: 5px; font-size: 13px; }
.excl { background: var(--red); color: #fff; border-radius: 50%; min-width: 24px; height: 24px; display: flex; justify-content: center; align-items: center; font-weight: 700; }

/* ---------- обробка / результат ---------- */
.processing { font-weight: 700; }
.processing-offline { max-width: 560px; text-align: center; margin-top: 20px; font-size: 16px; }
.processing-offline p { margin-bottom: 16px; }
.launch-box .form-error { margin: 10px 0; }
.result-box { max-width: 900px; margin: 40px auto; padding: 20px; border: 1px solid #ccc; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.result-head { padding: 20px; background: #f8f9fa; border-radius: 4px; margin-bottom: 20px; font-size: 18px; font-weight: 700; }
.result-table-wrap { border: 2px solid var(--red); padding: 15px; display: flex; align-items: flex-start; gap: 15px; }
.result-table-wrap .excl { margin-top: 10px; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-table th, .result-table td { padding: 10px; border: 1px solid #ddd; text-align: left; }
.result-table .score-cell { background: #a8f0a8; font-weight: 700; text-align: center; }
.result-table .score-cell.fail { background: var(--bad-bg); color: var(--red); }
.scale-note { font-size: 12px; color: #888; margin: 10px 0 0; }
.result-actions { display: flex; justify-content: center; gap: 15px; margin-top: 25px; flex-wrap: wrap; }
.result-reminder { text-align: center; margin-top: 20px; font-weight: 700; color: var(--red); font-size: 16px; }

/* ---------- червоні екрани ---------- */
.big-emoji { font-size: 56px; margin: 0 0 10px; }
.warning-text { font-size: 20px; margin-bottom: 40px; }
.annul-score { font-size: 24px; font-weight: 700; margin-bottom: 40px; }
.annul-actions { display: flex; gap: 15px; flex-wrap: wrap; justify-content: center; }
.offline-title { font-size: 50px; color: #ff4444; }
.offline-text, .mobile-text { font-size: 20px; max-width: 600px; line-height: 1.6; }
.logout-screen { background: #f9f9f9; }
.logout-screen h1 { font-size: 36px; font-weight: 400; margin-bottom: 20px; }
.logout-screen p { font-size: 14px; color: #555; }

/* ---------- водяні знаки ---------- */
#watermarks { position: fixed; inset: 0; pointer-events: none; z-index: 900; opacity: .03; display: flex; flex-wrap: wrap; overflow: hidden; }
.wm-text { font-size: 24px; font-weight: 700; transform: rotate(-45deg); padding: 40px; white-space: nowrap; }

/* ---------- розгорнутий режим ---------- */
body.expanded #test-header, body.expanded #test-nav, body.expanded #plashka { display: none; }
body.expanded #test-area { padding-top: 40px; }
