:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-2: #eef3fb;
    --text: #18212f;
    --muted: #667085;
    --line: #d8e0ee;
    --primary: #335cff;
    --primary-soft: #e6ebff;
    --success: #1f9d55;
    --success-soft: #e7f8ef;
    --danger: #e03131;
    --danger-soft: #ffe8e8;
    --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
}

:root[data-theme="dark"] {
    --bg: #0e1420;
    --panel: #151d2d;
    --panel-2: #101827;
    --text: #e8eef9;
    --muted: #99a6bd;
    --line: #24314a;
    --primary: #6f8cff;
    --primary-soft: #1a2650;
    --success: #35c16f;
    --success-soft: #123222;
    --danger: #ff6666;
    --danger-soft: #401a1a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.brand {
    font-size: 22px;
    font-weight: 700;
}

.page-content {
    max-width: 1300px;
    margin: 0 auto;
    padding: 28px;
}

.hero,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.hero {
    margin-bottom: 24px;
    padding: 28px;
    background: linear-gradient(135deg, var(--panel), var(--panel-2));
}

.hero h1 {
    margin: 0 0 10px 0;
    font-size: 34px;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.panel {
    padding: 24px;
    margin-bottom: 24px;
}

.panel.narrow {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

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

.panel-header h2 {
    margin: 0;
    font-size: 24px;
}

.category-grid,
.subcategory-grid,
.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.admin-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 18px;
}

.big-category-card,
.subcategory-card,
.test-link-card,
.resume-card,
.stat-card {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    transition: 0.2s;
}

.big-category-card:hover,
.subcategory-card-link:hover .subcategory-card,
.test-link-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.big-category-title,
.subcategory-title,
.test-link-title,
.resume-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.big-category-desc,
.empty-note,
.resume-meta,
.practice-hint,
.mode-desc,
.helper-note {
    color: var(--muted);
}

.resume-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.resume-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.resume-actions,
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.start-summary {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
    color: var(--muted);
}

.mode-form {
    display: grid;
    gap: 14px;
}

.mode-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    cursor: pointer;
}

.mode-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.field-label {
    margin-bottom: 8px;
    font-weight: 700;
}

.text-input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 14px;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn,
.theme-toggle {
    border-radius: 12px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn {
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary,
.theme-toggle {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.user-pill {
    padding: 10px 12px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    font-weight: 700;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.flash-error {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.flash-success {
    background: var(--success-soft);
    border-color: var(--success);
}

.exam-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}

.exam-header h1 {
    margin: 0 0 8px 0;
    font-size: 30px;
}

.exam-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
}

.exam-meta span {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--line);
}

.exam-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
}

.question-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.question-text {
    font-size: 24px;
    line-height: 1.45;
    margin-bottom: 20px;
}

.options-box {
    display: grid;
    gap: 12px;
}

.option-btn {
    width: 100%;
    text-align: left;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    transition: 0.18s;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.95;
}

.option-btn.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.option-btn.correct {
    border-color: var(--success);
    background: var(--success-soft);
}

.option-btn.wrong {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.exam-nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 22px;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.number-btn {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 12px;
    height: 44px;
    font-weight: 700;
    cursor: pointer;
}

.number-btn.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.number-btn.answered {
    background: #00a6d6;
    color: white;
    border-color: #00a6d6;
}

.number-btn.correct {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.number-btn.wrong {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.legend {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    color: var(--muted);
}

.legend-box {
    width: 14px;
    height: 14px;
    display: inline-block;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
}

.legend-box.current {
    background: var(--primary);
}

.legend-box.answered {
    background: #00a6d6;
    border: 1px solid #00a6d6;
}

.legend-box.unanswered {
    background: var(--panel-2);
    border: 1px solid var(--line);
}

.score-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 700;
    margin: 10px auto 20px;
    border: 2px solid var(--primary);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
}

.stat-label {
    color: var(--muted);
}

.center {
    justify-content: center;
}

.review-list {
    display: grid;
    gap: 16px;
}

.review-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    background: var(--panel-2);
}

.review-question {
    margin-bottom: 14px;
    font-size: 17px;
}

.review-options {
    display: grid;
    gap: 10px;
}

.review-option {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

.review-option.is-correct {
    background: var(--success-soft);
    border-color: var(--success);
}

.review-option.is-wrong {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.badge {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--success);
    color: white;
}

.badge-wrong {
    background: var(--danger);
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

.analysis-wrapper {
    display: grid;
    gap: 18px;
}

.analysis-passage-box,
.analysis-question-box,
.analysis-finished-box {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    background: var(--panel-2);
}

.analysis-passage-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analysis-passage {
    font-size: 20px;
    line-height: 1.8;
}

.analysis-passage mark {
    background: #ffe08a;
    color: #111;
    padding: 2px 6px;
    border-radius: 6px;
}

.analysis-progress {
    color: var(--muted);
    margin-bottom: 10px;
    font-weight: 700;
}

.analysis-word {
    margin-bottom: 10px;
    font-size: 18px;
}

.analysis-question {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.analysis-options {
    display: grid;
    gap: 12px;
}

.analysis-feedback {
    margin-top: 14px;
    min-height: 24px;
    font-weight: 700;
}

.feedback-correct {
    color: #28a745;
}

.feedback-wrong {
    color: #dc3545;
}

@media (max-width: 980px) {
    .exam-layout,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .result-stats {
        grid-template-columns: 1fr;
    }

    .resume-card,
    .exam-header,
    .question-topline {
        flex-direction: column;
        align-items: stretch;
    }

    .page-content {
        padding: 18px;
    }

    .topbar {
        padding: 14px 18px;
    }

    .analysis-passage {
        font-size: 18px;
    }

    .analysis-question {
        font-size: 18px;
    }
}
.analysis-wrapper {
    display: grid;
    gap: 18px;
}

.analysis-passage-box,
.analysis-question-box,
.analysis-finished-box {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    background: var(--panel-2);
}

.analysis-passage-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analysis-passage {
    font-size: 20px;
    line-height: 1.8;
}

.analysis-passage mark {
    background: #ffe08a;
    color: #111;
    padding: 2px 6px;
    border-radius: 6px;
}

.analysis-progress {
    color: var(--muted);
    margin-bottom: 10px;
    font-weight: 700;
}

.analysis-word {
    margin-bottom: 10px;
    font-size: 18px;
}

.analysis-question {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.analysis-options {
    display: grid;
    gap: 12px;
}

.analysis-feedback {
    margin-top: 14px;
    min-height: 24px;
    font-weight: 700;
}

.feedback-correct {
    color: #28a745;
}

.feedback-wrong {
    color: #dc3545;
}