/* ============================================================
   Квизы «Звеньев знаний» — публичная страница и админка.
   Дизайн-код «Спокойный интроверт»: токены скопированы из
   game.css v19, чтобы страницы жили независимо от игры.
   ============================================================ */

:root {
    --bg: #F7F4EF;
    --bg-elevated: #FFFDF9;
    --bg-soft: #F9F6F1;
    --text: #2C2A26;
    --muted: #6B6560;
    --border: #E8E2D9;
    --gold: #C9A96E;
    --green: #3E8F57;
    --red: #B07A6A;
    --btn-primary: #3A3530;
    --btn-secondary: #EDE8E0;
    --font: 'Noto Sans', 'Segoe UI', Roboto, Arial, sans-serif;
    --font-hand: 'Caveat', cursive;
    --shadow-card: 0 2px 12px rgba(44, 42, 38, 0.06);
    --shadow-lift: 0 6px 20px rgba(44, 42, 38, 0.10);
    --shadow-modal: 0 20px 50px rgba(44, 42, 38, 0.16);
    --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; }

.quiz-shell { max-width: 900px; margin: 0 auto; padding: 20px 16px 70px; }

.quiz-topbar { display: flex; align-items: baseline; gap: 10px; padding: 6px 2px 18px; }
.quiz-brand { font-family: var(--font-hand); font-size: 27px; font-weight: 700; color: var(--text); text-decoration: none; }
.quiz-brand:hover { color: var(--gold); }
.quiz-topbar .sub { color: var(--muted); font-size: 13px; }

/* ── статусные экраны ── */
.quiz-state { text-align: center; padding: 60px 12px; }
.quiz-state h1 { font-size: 22px; margin-bottom: 10px; }
.quiz-state p { color: var(--muted); line-height: 1.5; }

/* ── карточки и поля ── */
.q-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 22px; margin-bottom: 16px; }
.q-quiz-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.q-quiz-desc { color: var(--muted); font-size: 15px; white-space: pre-line; line-height: 1.5; }
.q-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin: 0 0 8px; }

.q-input, .q-textarea, .q-select {
    width: 100%; font: inherit; font-size: 15px; color: var(--text);
    background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; outline: none;
}
.q-textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.q-input:focus, .q-textarea:focus, .q-select:focus { border-color: var(--gold); background: var(--bg-elevated); }

.q-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.q-question { margin-bottom: 16px; }
.q-qhead { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.q-qnum { color: var(--gold); font-weight: 700; white-space: nowrap; }
.q-qtext { font-weight: 600; line-height: 1.4; }
.q-maxscore { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.q-counter { text-align: right; color: var(--muted); font-size: 12px; margin-top: 4px; }

.q-checkbox { display: flex; gap: 8px; align-items: center; font-size: 15px; margin-bottom: 14px; cursor: pointer; user-select: none; }
.q-checkbox input { width: 17px; height: 17px; accent-color: var(--gold); }

.q-hint { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 6px; }

/* ── кнопки ── */
.btn { font: inherit; font-weight: 600; border: none; border-radius: 10px; padding: 11px 20px; cursor: pointer; transition: transform .06s, box-shadow .12s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn-primary); color: #FFFDF9; }
.btn-primary:hover { box-shadow: var(--shadow-lift); }
.btn-primary:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn-secondary { background: var(--btn-secondary); color: var(--text); }
.btn-secondary:hover { box-shadow: var(--shadow-card); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); padding: 9px 14px; }
.btn-danger:hover { background: rgba(176, 122, 106, .1); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 9px 14px; }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { width: 100%; padding: 14px; font-size: 17px; }

/* ── экран успеха ── */
.q-success { text-align: center; padding: 30px 12px; }
.q-success .mark { font-size: 54px; margin-bottom: 14px; }
.q-success h1 { font-size: 24px; margin-bottom: 10px; }
.q-success p { color: var(--muted); line-height: 1.55; }

/* ── админка: список ── */
.qa-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.qa-actions h2 { font-size: 22px; margin-right: auto; }
.qa-table { width: 100%; border-collapse: collapse; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 15px; }
.qa-table th, .qa-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.qa-table th { background: var(--bg-soft); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); white-space: nowrap; }
.qa-table tr:last-child td { border-bottom: none; }
.qa-table .num { text-align: center; }
.qa-empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-open { background: rgba(62, 143, 87, .12); color: var(--green); }
.chip-closed { background: rgba(176, 122, 106, .15); color: var(--red); }

.qa-linkcode { font-family: Consolas, monospace; color: var(--gold); font-weight: 700; }
.qa-rowbtns { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── админка: редактор ── */
.q-edit-head { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.q-edit-head .grow { flex: 1; }
.q-edit-q { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--bg-soft); }
.q-edit-q .row { display: flex; gap: 10px; margin-top: 10px; align-items: flex-end; }
.q-edit-q .row .grow { flex: 1; }
.q-edit-q .scorebox { width: 150px; }
.q-edit-q textarea.q-textarea { min-height: 64px; }
.q-edit-q textarea.ref { min-height: 52px; }

/* ── админка: результаты ── */
.qa-results-wrap { overflow-x: auto; }
.qa-res-table td.score { text-align: center; font-weight: 600; white-space: nowrap; cursor: pointer; }
.qa-res-table td.score:hover { background: var(--bg-soft); }
.score-none { color: var(--muted); font-weight: 400; }
.score-full { color: var(--green); }
.score-part { color: var(--gold); }
.score-zero { color: var(--red); }
.qa-sum { font-weight: 700; text-align: center; white-space: nowrap; }
.qa-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.qa-stats { color: var(--muted); font-size: 14px; margin: 8px 0 14px; }

.qa-progress { height: 8px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.qa-progress > div { height: 100%; background: var(--gold); width: 0; transition: width .3s; }
.qa-progress-line { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* ── модалка ── */
.qmodal-overlay { position: fixed; inset: 0; background: rgba(44, 42, 38, .45); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.qmodal-overlay.active { display: flex; }
.qmodal { background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--shadow-modal); max-width: 660px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 22px; }
.qmodal h3 { margin-bottom: 12px; font-size: 18px; }
.qmodal .block { margin-bottom: 12px; }
.qmodal .answer-text { background: var(--bg-soft); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; line-height: 1.5; font-size: 15px; }
.qmodal .ref-text { color: var(--muted); white-space: pre-wrap; line-height: 1.45; font-size: 14px; }
.qmodal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.qmodal .grade-row { display: flex; gap: 10px; align-items: flex-end; }
.qmodal .grade-row .scorebox { width: 130px; }
.qmodal .grade-row .grow { flex: 1; }

/* ── тост ── */
.qtoast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--btn-primary); color: #FFFDF9; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lift); font-size: 14px; z-index: 90; max-width: 90vw; text-align: center; }

/* ── мобильность ── */
@media (max-width: 640px) {
    .q-grid { grid-template-columns: 1fr; }
    .qa-table .hide-m { display: none; }
    .q-edit-q .row { flex-direction: column; align-items: stretch; }
    .q-edit-q .scorebox { width: 100%; }
    .qa-actions { align-items: stretch; flex-direction: column; }
    .qa-actions h2 { margin-right: 0; }
}
