/* ========= Core / Variables (Dark theme) ========= */
:root {
    --bg: #111111; /* page background */
    --paper: #151515; /* cards, panels */
    --ink: #e5e7eb; /* primary text */
    --muted: #9ca3af; /* secondary text */
    --line: #262626; /* borders / dividers */
    --brand: #ff8a3d; /* accent brand */
    --brand-ink: #111111; /* text on brand bg */
    --ok: #10b981; /* yes */
    --no: #ef4444; /* no */

    --radius: 14px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========= Layout ========= */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 30px 16px 16px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    padding: 12px 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.topbar-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 960px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 28px;
    height: 28px;
    display: block;
}

.brand-text {
    font-weight: 700;
    letter-spacing: .2px;
}

/* ========= Language buttons ========= */
.lang-switch {
    display: flex;
    gap: 8px;
}

.lang-btn {
    appearance: none;
    border: 1px solid var(--line);
    background: #1c1c1c;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.lang-btn:hover {
    background: #222;
}

.lang-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 138, 61, .25);
}

.lang-btn.active {
    background: var(--brand);
    color: var(--brand-ink);
    border-color: var(--brand);
}

/* ========= Icon buttons ========= */
.icon-btn {
    appearance: none;
    border: 1px solid var(--line);
    background: #1c1c1c;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.icon-btn:hover {
    background: #1a1a1a;
    border-color: #333;
}

.icon-btn:active {
    transform: translateY(1px);
}

.icon-btn.ghost {
    background: transparent;
}

.icon-btn svg {
    display: block;
}

/* ========= Home ========= */
#view-home h1 {
    margin: 10px 0 6px;
}

.home-disclaimer {
    margin: 0 0 12px;
    color: var(--muted);
}

.home-intro {
    margin: 0 0 16px;
    color: var(--ink);
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));
}

/* Card */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    min-height: 210px;
}

.card .title {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 6px;
}

.card .desc {
    color: var(--muted);
    font-size: 14px;
}

.card .actions {
    margin-top: auto;
    padding-top: 12px;
    display: flex;
    justify-content: flex-end;
}

/* Бейдж лучшего результата на карточке */
.card .best-badge {
    position: absolute;
    left: 10px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1b1b1b;
    border: 1px solid var(--line);
    color: var(--ink);
    font-weight: 700;
    font-size: 12px;
    border-radius: 999px;
    padding: 4px 8px;
}

.card .best-badge .emoji {
    filter: saturate(1.1);
}

/* ========= Buttons ========= */
.btn {
    appearance: none;
    border: 1px solid transparent;
    background: var(--brand);
    color: var(--brand-ink);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    transition: transform .05s ease, box-shadow .15s ease, background .15s ease, filter .15s ease;
    box-shadow: 0 6px 16px rgba(255, 138, 61, .28);
}

.btn:hover {
    filter: saturate(1.05) brightness(1.02);
}

.btn:active {
    transform: translateY(1px);
}

.btn.outline {
    background: transparent;
    color: var(--ink);
    border-color: #343434;
    box-shadow: none;
}

.btn.outline:hover {
    background: #181818;
}

/* ========= Quiz ========= */
.topline {
    display: grid;
    align-items: center;
    gap: 12px;
    grid-template-columns:auto 1fr auto;
    margin-bottom: 30px;
}

.titleline {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#quiz-title {
    font-weight: 800;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.progress {
    height: 6px;
    background: #1e1e1e;
    border-radius: 999px;
    overflow: hidden;
    width: 220px;
    border: 1px solid var(--line);
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--brand), #ffb16f);
}

.question-box {
    position: relative;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 500px;
    margin: 0 auto;
    padding-top: 64px; /* место под бейдж подкатегории */
}

/* Бейдж подкатегории в верхнем левом углу */
.subcat-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    background: #1b1b1b;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
}

.question {
    text-align: center;
    font-size: 22px;
    line-height: 1.35;
    font-weight: 700;
    margin: 10px auto 18px;
    max-width: 820px;
}

.answers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 6px 0 10px;
}

.btn.yes {
    background: var(--ok);
    color: #fff;
    box-shadow: 0 6px 16px rgba(16, 185, 129, .28);
}

.btn.no {
    background: var(--no);
    color: #fff;
    box-shadow: 0 6px 16px rgba(239, 68, 68, .28);
}

/* Низ вопроса: слева иконка-назад, справа счётчик */
.foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.foot #q-count {
    margin-left: auto;
}

/* ========= Result ========= */
.kpis {
    display: grid;
    gap: 12px;
    grid-template-columns:repeat(3, minmax(0, 1fr));
    margin: 8px 0 16px;
}

.kpi {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.kpi-num {
    font-size: 28px;
    font-weight: 800;
}

.kpi-cap {
    color: var(--muted);
    font-size: 12px;
}

.table {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.table .row {
    display: grid;
    grid-template-columns:1fr auto auto;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.table .row:last-child {
    border-bottom: 0;
}

.table .label {
    font-weight: 600;
}

.table .score {
    color: var(--muted);
}

.table .pct {
    font-weight: 700;
}

.result-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 18px 0 6px;
}

/* ========= Utilities ========= */
h1, h2, h3 {
    margin: 0 0 8px;
}

a {
    color: inherit;
}

/* ========= Responsive ========= */
@media (max-width: 640px) {
    .topline {
        grid-template-columns:1fr auto;
        grid-template-rows:auto auto;
    }

    .progress {
        grid-column: 1 / -1;
        width: 100%;
    }

    .question {
        font-size: 20px;
    }

    .answers {
        gap: 12px;
    }

    .btn {
        padding: 10px 12px;
    }

    .grid {
        gap: 12px;
    }

    .card {
        min-height: 220px;
    }

    .kpis {
        grid-template-columns:1fr;
    }
}

/* ========= Focus visibility (accessibility) ========= */
:focus-visible {
    outline: 3px solid rgba(255, 138, 61, .45);
    outline-offset: 2px;
    border-radius: 8px;
}
