.quiz-wrap *,
.quiz-wrap *::before,
.quiz-wrap *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.quiz-wrap {
    --bg: #f8f9fb;
    --bg-white: #ffffff;
    --bg-hover: #f3f4f8;
    --bg-input: #f5f6fa;
    --border: #e5e7ef;
    --border-hover: #c7c9d9;
    --text: #1a1a2e;
    --text-secondary: #5a5b6a;
    --text-muted: #8b8d9a;
    --primary: #4338ca;
    --primary-light: #6366f1;
    --primary-bg: rgba(67, 56, 202, .06);
    --primary-bg-hover: rgba(67, 56, 202, .1);
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, .08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, .08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, .08);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .02);
    --shadow: 0 4px 16px rgba(0, 0, 0, .06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .08);
    --transition: .2s ease;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Quiz Header (content block, not <header>) --- */

.quiz-header {
    background: var(--bg-white);
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.quiz-header--flush {
    margin-bottom: 0;
    border-bottom: none;
}

.quiz-header__title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.quiz-header__title span {
    color: var(--primary);
}

.quiz-header__back {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .875rem;
    margin-bottom: 6px;
    transition: color var(--transition);
}

.quiz-header__back:hover {
    color: var(--primary);
}

.quiz-header__breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    margin-bottom: 6px;
}

.quiz-header__breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.quiz-header__breadcrumbs a:hover {
    color: var(--primary);
}

.quiz-header__breadcrumbs span {
    color: var(--text-muted);
    font-size: .7rem;
}

.quiz-header__subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    margin-top: 4px;
}

/* --- Catalog section --- */

.catalog {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 0 32px;
    margin-bottom: 40px;
}

.catalog__subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 20px;
    line-height: 1.6;
}

.catalog__heading {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.catalog__count {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Cards grid (catalog) --- */

.catalog .card {
    background: var(--bg);
    border-color: var(--border);
}

.catalog .card:hover {
    background: var(--bg-white);
}

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

.card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.card__body {
    flex: 1;
    min-width: 0;
}

.card__title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text);
}

.card__desc {
    font-size: .825rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.card__arrow {
    flex-shrink: 0;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: color var(--transition), transform var(--transition);
}

.card:hover .card__arrow {
    color: var(--primary);
    transform: translateX(4px);
}

/* --- Start page --- */

.start {
    max-width: 520px;
    margin: 0 auto;
}

.start__intro {
    color: var(--text-secondary);
    font-size: .925rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.start__card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.start__desc {
    color: var(--text-secondary);
    font-size: .875rem;
    line-height: 1.55;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.form-group {
    margin-bottom: 20px;
}

.form-group > label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.levels {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.level-option {
    position: relative;
}

.level-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.level-option__label {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.level-option__label:hover {
    border-color: var(--border-hover);
}

.level-option input:checked + .level-option__label {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.level-option__radio {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition);
}

.level-option input:checked + .level-option__label .level-option__radio {
    border-color: var(--primary);
}

.level-option input:checked + .level-option__label .level-option__radio::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
}

.level-option__text {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.level-option__name {
    font-weight: 600;
    font-size: .95rem;
    color: var(--text);
}

.level-option__info {
    font-size: .8rem;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn--primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    margin-top: 8px;
}

.btn--primary:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 12px rgba(67, 56, 202, .25);
}

.btn--outline {
    background: var(--bg-white);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn--outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* --- Test page --- */

.test-container {
    max-width: 680px;
    margin: 0 auto;
}

.test-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.test-header__info {
    font-size: .875rem;
    color: var(--text-secondary);
}

.test-header__right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.test-exit {
    font-size: .8rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    transition: color var(--transition), border-color var(--transition);
}

.test-exit:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.timer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.timer--warning {
    border-color: var(--warning);
    color: var(--warning);
    background: var(--warning-bg);
}

.timer--danger {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-bg);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

/* --- Progress bar --- */

.progress {
    position: relative;
    height: 36px;
    background: var(--bg-white);
    border-radius: var(--radius-xs);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-xs);
    transition: width .4s ease;
}

.progress__text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    mix-blend-mode: difference;
}

/* --- Question --- */

.question-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.question-card__text {
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.55;
    margin-bottom: 20px;
    color: var(--text);
}

.question-card__code {
    background: #1e1e2e;
    border: 1px solid #2a2a3a;
    border-radius: var(--radius-xs);
    padding: 16px 18px;
    margin-bottom: 20px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: .875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: #e4e4e7;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option {
    position: relative;
}

.option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option__label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    line-height: 1.45;
}

.option__label:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.option input:checked + .option__label {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.option__marker {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    border-radius: 50%;
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-white);
    transition: all var(--transition);
}

.option input:checked + .option__label .option__marker {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.option__text {
    flex: 1;
    padding-top: 2px;
    color: var(--text);
}

/* --- Result page --- */

.result {
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
}

.result__score {
    margin: 32px 0;
}

.result__circle {
    width: 160px;
    height: 160px;
    margin: 0 auto 20px;
    position: relative;
}

.result__circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.result__circle-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.result__circle-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.result__circle-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.result__percent {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.result__fraction {
    font-size: .875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.result__grade {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.result__time {
    font-size: .875rem;
    color: var(--text-muted);
}

.result__grade.excellent { color: var(--success); }
.result__grade.good { color: var(--primary); }
.result__grade.satisfactory { color: var(--warning); }
.result__grade.failed { color: var(--danger); }

.result__circle-fill.excellent { stroke: var(--success); }
.result__circle-fill.good { stroke: var(--primary); }
.result__circle-fill.satisfactory { stroke: var(--warning); }
.result__circle-fill.failed { stroke: var(--danger); }

.result__actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* --- Badge --- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.badge--easy {
    background: var(--success-bg);
    color: var(--success);
}

.badge--medium {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge--advanced {
    background: var(--danger-bg);
    color: var(--danger);
}

/* --- Alerts --- */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-xs);
    margin-bottom: 20px;
    font-size: .9rem;
    border: 1px solid;
}

.alert--error {
    background: var(--danger-bg);
    border-color: rgba(220, 38, 38, .2);
    color: var(--danger);
}

.alert--warning {
    background: var(--warning-bg);
    border-color: rgba(217, 119, 6, .2);
    color: var(--warning);
}

/* --- Tab switch warning overlay --- */

.protection-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .85);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: #fff;
}

.protection-overlay.active {
    display: flex;
}

.protection-overlay__icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.protection-overlay__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.protection-overlay__text {
    color: rgba(255, 255, 255, .7);
    max-width: 400px;
}

.protection-overlay__count {
    margin-top: 16px;
    font-size: .9rem;
    color: #f87171;
    font-weight: 600;
}

/* --- Category tabs --- */

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.category-tab {
    display: inline-block;
    padding: 8px 18px;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    transition: all var(--transition);
    white-space: nowrap;
}

.category-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.category-tab--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.category-tab--active:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    color: #fff;
}

/* --- Search --- */

.search-box {
    margin-bottom: 16px;
}

.search-box__input {
    width: 100%;
    padding: 13px 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .95rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box__input::placeholder {
    color: var(--text-muted);
}

.search-box__input:focus {
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.search-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
    font-size: .925rem;
}

/* --- Section title --- */

.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

/* --- Benefits (inline) --- */

.benefits-inline {
    display: flex;
    gap: 20px;
    margin: 0 0 40px;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.benefits-inline__item {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    font-size: .85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.benefits-inline__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--primary-bg);
    border-radius: var(--radius-xs);
}

.benefits-inline__item strong {
    display: block;
    color: var(--text);
    margin-bottom: 2px;
}

.benefits-inline__item span {
    color: var(--text-secondary);
    font-size: .8rem;
}

/* --- FAQ --- */

.faq {
    margin-bottom: 48px;
}

.faq__item {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.faq__item[open] {
    border-color: var(--border-hover);
}

.faq__question {
    padding: 16px 20px;
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: color var(--transition);
    user-select: none;
}

.faq__question::-webkit-details-marker {
    display: none;
}

.faq__question::after {
    content: '+';
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-muted);
    border-radius: 50%;
    background: var(--bg);
    transition: transform var(--transition), background var(--transition), color var(--transition);
}

.faq__item[open] .faq__question::after {
    content: '\2212';
    background: var(--primary-bg);
    color: var(--primary);
}

.faq__question:hover {
    color: var(--primary);
}

.faq__answer {
    padding: 0 20px 18px;
    font-size: .9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* --- Test info section (start page) --- */

.test-info {
    max-width: 680px;
    margin: 48px auto 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.test-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 28px;
    margin-bottom: 10px;
}

.test-info h2:first-child {
    margin-top: 0;
}

.test-info p {
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.65;
    margin-bottom: 10px;
}

.test-info ul {
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.65;
    margin-bottom: 10px;
    padding-left: 20px;
}

.test-info li {
    margin-bottom: 8px;
}

/* --- Info section (index page) --- */

.info-section {
    margin-top: 16px;
    margin-bottom: 48px;
}

.info-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 28px;
    margin-bottom: 10px;
}

.info-section h2:first-child {
    margin-top: 0;
}

.info-section p {
    color: var(--text-secondary);
    font-size: .925rem;
    line-height: 1.65;
    margin-bottom: 10px;
}

.info-section ul {
    color: var(--text-secondary);
    font-size: .925rem;
    line-height: 1.65;
    margin-bottom: 10px;
    padding-left: 20px;
}

.info-section li {
    margin-bottom: 6px;
}

/* --- Responsive --- */

@media (max-width: 600px) {
    .container {
        padding: 0 16px;
    }

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

    .benefits-inline {
        flex-direction: column;
        gap: 10px;
    }

    .category-tabs {
        gap: 6px;
    }

    .category-tab {
        padding: 6px 14px;
        font-size: .8rem;
    }

    .question-card {
        padding: 20px;
    }

    .result__circle {
        width: 130px;
        height: 130px;
    }

    .result__percent {
        font-size: 2rem;
    }

    .test-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
