* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: var(--kw-font);
    background: var(--kw-bg);
    color: var(--kw-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    color: var(--kw-brand);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

/* ---- App Header ---- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--kw-border);
    background: var(--kw-surface-2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--kw-text);
}

    .app-logo:hover {
        text-decoration: none;
    }

.app-logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.app-logo-text {
    font-size: 15px;
    font-weight: 500;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

    .app-nav a {
        font-size: 13px;
        color: var(--kw-text-secondary);
        text-decoration: none;
        transition: color 0.15s;
    }

        .app-nav a:hover {
            color: var(--kw-text);
            text-decoration: none;
        }

        .app-nav a.active {
            color: var(--kw-brand);
            font-weight: 500;
        }

.theme-toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    color: var(--kw-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    color: var(--kw-text);
    background: var(--kw-surface-1);
    border-color: var(--kw-border);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--kw-brand);
    outline-offset: 2px;
}

.theme-toggle-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle-icon--sun {
    display: none;
}

[data-theme="dark"] .theme-toggle-icon--moon {
    display: none;
}

[data-theme="dark"] .theme-toggle-icon--sun {
    display: block;
}

/* ---- App Footer ---- */

.app-footer {
    background-image: var(--kw-footer-gif-right), var(--kw-footer-gif-left);
    background-repeat: no-repeat, repeat-x;
    background-position: top right, right 700px top 0;
    padding: 130px 24px 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}

.app-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

    .app-footer-links a {
        font-size: 12px;
        color: var(--kw-text-muted);
        text-decoration: none;
    }

        .app-footer-links a:hover {
            color: var(--kw-text-secondary);
        }

.app-footer-copy {
    font-size: 11px;
    color: var(--kw-text-muted);
}

.app-footer-build {
    font-size: 12px;
    color: var(--kw-text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    opacity: 0.7;
}

@media (max-width: 580px) {
    .app-footer {
        flex-direction: column;
        align-items: flex-start;
        padding-top: 16px;
    }

    .app-footer-links {
        flex-direction: column;
        gap: 8px;
    }
}

/* ---- Content area ---- */

.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.app-body-content {
    flex: 1;
}

.app-body--narrow {
    max-width: 720px;
}

/* ---- Page title ---- */

.page-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.page-sub {
    font-size: 14px;
    color: var(--kw-text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ---- Buttons ---- */

.btn {
    padding: 10px 20px;
    font-size: 14px;
    font-family: var(--kw-font);
    font-weight: 500;
    border-radius: var(--kw-radius-md);
    cursor: pointer;
    border: 1px solid var(--kw-border);
    background: var(--kw-surface-2);
    color: var(--kw-text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    text-decoration: none;
}

    .btn:hover {
        border-color: var(--kw-border-strong);
        text-decoration: none;
    }

.btn--primary {
    background: var(--kw-brand-light);
    color: var(--kw-brand);
    border-color: transparent;
}

    .btn--primary:hover {
        opacity: 0.85;
    }

.btn--danger {
    background: var(--kw-danger, #e74c3c);
    color: #fff;
    border-color: transparent;
}

    .btn--danger:hover {
        opacity: 0.85;
    }

.btn--sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
}

/* ---- Topic chips ---- */

.topic-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--kw-surface-2);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-pill);
    font-size: 12px;
    color: var(--kw-text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}

    .topic-chip:hover {
        border-color: var(--kw-border-strong);
        text-decoration: none;
    }

    .topic-chip.active {
        background: var(--kw-brand-light);
        color: var(--kw-brand);
        border-color: transparent;
    }

.topic-chip-count {
    font-size: 11px;
    color: var(--kw-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ---- Search ---- */

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    margin-bottom: 20px;
}

    .search-box input {
        flex: 1;
        border: none;
        background: transparent;
        font-family: var(--kw-font);
        font-size: 14px;
        color: var(--kw-text);
        outline: none;
    }

        .search-box input::placeholder {
            color: var(--kw-text-muted);
        }

/* Admin pages wrap the search box in .admin-filter-form / .admin-search-form, which already
   provide the spacing, so the default bottom margin is dropped there. */
.app-body--admin .search-box {
    margin-bottom: 0;
}

/* ---- Article list ---- */

.article-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.article-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--kw-radius-md);
    text-decoration: none;
    color: var(--kw-text);
    transition: background 0.15s;
}

    .article-item:hover {
        background: var(--kw-surface-1);
        text-decoration: none;
    }

.article-item-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 4px;
}

.article-item-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--kw-text-muted);
    flex-wrap: wrap;
}

.article-item-tag {
    padding: 1px 8px;
    background: var(--kw-surface-2);
    border-radius: var(--kw-radius-sm);
    font-size: 11px;
    color: var(--kw-text-secondary);
}

/* ---- Pagination ---- */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    padding: 16px 0;
}

    .pagination a,
    .pagination span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        font-size: 13px;
        font-variant-numeric: tabular-nums;
        border-radius: var(--kw-radius-sm);
        text-decoration: none;
        color: var(--kw-text-secondary);
        transition: all 0.15s;
    }

        .pagination a:hover {
            background: var(--kw-surface-1);
            text-decoration: none;
        }

    .pagination .active {
        background: var(--kw-brand-light);
        color: var(--kw-brand);
        font-weight: 500;
    }

    .pagination .disabled {
        color: var(--kw-text-muted);
        pointer-events: none;
    }

    .pagination .ellipsis {
        color: var(--kw-text-muted);
        pointer-events: none;
    }

/* ---- Knowledge base article ---- */

.kb-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--kw-text-muted);
    margin-bottom: 16px;
}

    .kb-breadcrumb a {
        color: var(--kw-text-muted);
    }

        .kb-breadcrumb a:hover {
            color: var(--kw-text-secondary);
        }

.kb-article-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.kb-answer-box {
    background: var(--kw-success-light);
    border: 1px solid var(--kw-success);
    border-radius: var(--kw-radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.kb-answer-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--kw-success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.kb-answer-text {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
}

.kb-explanation {
    margin-bottom: 24px;
    line-height: 1.7;
}

    .kb-explanation p {
        margin-bottom: 12px;
        font-size: 14px;
        color: var(--kw-text-secondary);
    }

    .kb-explanation img {
        display: block;
        max-width: 100%;
        max-height: 480px;
        margin: 0 auto 20px;
        border-radius: var(--kw-radius-md);
    }

    .kb-explanation figcaption {
        text-align: center;
    }

    .kb-explanation figure {
        margin: 20px;
    }

.kb-sources {
    margin-bottom: 24px;
}

.kb-sources-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--kw-text);
}

.kb-sources-list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

    .kb-sources-list li.kb-source-item {
        font-size: 13px;
        line-height: 1.5;
        color: var(--kw-text-secondary);
        padding: 2px 0;
    }

.kb-source-title {
    color: var(--kw-text-secondary);
}

.kb-source-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -2px;
    margin-left: 5px;
    color: var(--kw-brand);
    text-decoration: none;
    transition: opacity 0.15s, color 0.15s;
}

    .kb-source-link:hover {
        color: var(--kw-brand-hover, var(--kw-brand));
        opacity: 0.8;
    }

    .kb-source-link svg {
        display: inline-block;
        width: 14px;
        height: 14px;
    }

/* In-text source reference button */
.kb-source-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: 600;
    vertical-align: super;
    line-height: 1;
    color: var(--kw-brand);
    background: transparent;
    border: none;
    padding: 0 3px;
    margin: 0 1px;
    cursor: pointer;
    text-decoration: none;
    border-radius: 3px;
    transition: color 0.15s, background-color 0.15s;
    user-select: none;
}

    .kb-source-ref:hover,
    .kb-source-ref:focus-visible {
        color: var(--kw-brand-hover, var(--kw-brand));
        background-color: var(--kw-surface-2, rgba(0, 0, 0, 0.06));
        outline: none;
    }

/* Source popup tooltip */
.kb-source-popup {
    position: absolute;
    z-index: 9999;
    max-width: 380px;
    min-width: 220px;
    background: var(--kw-surface-1, #ffffff);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md, 8px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 12px 32px 12px 14px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--kw-text);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-sizing: border-box;
}

.kb-source-popup--visible {
    opacity: 1;
    transform: translateY(0);
}

.kb-source-popup-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--kw-text-muted);
    font-size: 13px;
    line-height: 1;
    padding: 0;
    transition: background-color 0.15s, color 0.15s;
}

    .kb-source-popup-close:hover {
        background: var(--kw-surface-2, rgba(0, 0, 0, 0.06));
        color: var(--kw-text);
    }

.kb-source-popup-content {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.kb-source-popup-num {
    font-weight: 600;
    color: var(--kw-text-muted);
    flex-shrink: 0;
    font-size: 12px;
}

.kb-source-popup-title {
    font-weight: 500;
    color: var(--kw-text);
    overflow-wrap: break-word;
    word-break: break-word;
}

.kb-source-popup-link {
    color: var(--kw-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    transition: color 0.15s;
}

    .kb-source-popup-link:hover {
        color: var(--kw-brand);
    }

        .kb-source-popup-link:hover .kb-source-popup-title {
            color: var(--kw-brand);
        }

.kb-source-popup-icon {
    flex-shrink: 0;
    color: var(--kw-brand);
    display: inline-block;
    vertical-align: middle;
}

.kb-related {
    margin-bottom: 24px;
}

.kb-related-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
}

.kb-related-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kb-related-link {
    display: block;
    padding: 10px 14px;
    background: var(--kw-surface-1);
    border-radius: var(--kw-radius-md);
    font-size: 13px;
    color: var(--kw-text);
    text-decoration: none;
    transition: background 0.15s;
}

    .kb-related-link:hover {
        background: var(--kw-surface-2);
        text-decoration: none;
    }

/* ---- Knowledge base: editorial articles ---- */

.kb-articles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.kb-article-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    text-decoration: none;
    color: var(--kw-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .kb-article-card:hover {
        border-color: var(--kw-border-strong);
        box-shadow: var(--kw-shadow-sm);
        text-decoration: none;
    }

.kb-article-card-img {
    width: 104px;
    height: 78px;
    object-fit: cover;
    border-radius: var(--kw-radius-md);
    flex-shrink: 0;
}

.kb-article-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.kb-article-card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.kb-article-card-excerpt {
    font-size: 13px;
    color: var(--kw-text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kb-section-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-text-muted);
    margin: 8px 0 12px;
}

.kb-article-byline {
    font-size: 12px;
    color: var(--kw-text-muted);
}

.kb-article-hero {
    width: 100%;
    max-height: 380px;
    object-fit: cover;
    border-radius: var(--kw-radius-lg);
    margin-bottom: 24px;
}

.kb-article-content {
    font-size: 15px;
    line-height: 1.75;
    color: var(--kw-text);
    margin-bottom: 24px;
}

    .kb-article-content h2 {
        font-size: 20px;
        font-weight: 600;
        margin: 28px 0 10px;
    }

    .kb-article-content h3 {
        font-size: 17px;
        font-weight: 600;
        margin: 22px 0 8px;
    }

    .kb-article-content p {
        margin-bottom: 14px;
    }

    .kb-article-content ul, .kb-article-content ol {
        margin: 0 0 14px 22px;
    }

    .kb-article-content li {
        margin-bottom: 6px;
    }

    .kb-article-content a {
        color: var(--kw-brand);
        text-decoration: underline;
    }

    .kb-article-content img {
        max-width: 100%;
        height: auto;
        border-radius: var(--kw-radius-md);
        margin: 12px 0;
    }

    .kb-article-content blockquote {
        margin: 14px 0;
        padding: 8px 16px;
        border-left: 3px solid var(--kw-border-strong);
        color: var(--kw-text-secondary);
    }

    .kb-article-content code {
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 13px;
        background: var(--kw-surface-2);
        padding: 1px 5px;
        border-radius: var(--kw-radius-sm);
    }

    .kb-article-content pre {
        background: var(--kw-surface-2);
        padding: 14px 16px;
        border-radius: var(--kw-radius-md);
        overflow-x: auto;
        margin-bottom: 14px;
    }

        .kb-article-content pre code {
            background: none;
            padding: 0;
        }

    .kb-article-content table {
        border-collapse: collapse;
        width: 100%;
        margin-bottom: 14px;
        font-size: 14px;
    }

    .kb-article-content th, .kb-article-content td {
        border: 1px solid var(--kw-border);
        padding: 8px 12px;
        text-align: left;
    }

/* ---- Articles: table of contents, sharing, prev/next ---- */

.article-toc {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.article-toc-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-text-muted);
    margin-bottom: 10px;
}

.article-toc-link {
    display: block;
    padding: 4px 0;
    font-size: 14px;
    color: var(--kw-text-secondary);
    text-decoration: none;
}

    .article-toc-link:hover {
        color: var(--kw-brand);
        text-decoration: none;
    }

.article-toc-link--level-3 {
    padding-left: 18px;
    font-size: 13px;
}

.article-share {
    margin-bottom: 20px;
}

.article-pager {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 24px 0;
}

.article-pager-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    text-decoration: none;
    color: var(--kw-text);
    flex: 1;
    min-width: 0;
    transition: border-color 0.15s;
}

    .article-pager-link:hover {
        border-color: var(--kw-brand);
        text-decoration: none;
    }

.article-pager-link--next {
    text-align: right;
}

.article-pager-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-text-muted);
}

.article-pager-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kb-cta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 28px;
}

.kb-cta-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    text-decoration: none;
    color: var(--kw-text);
    transition: all 0.15s;
}

    .kb-cta-card:hover {
        border-color: var(--kw-brand);
        box-shadow: var(--kw-shadow-sm);
        text-decoration: none;
    }

.kb-cta-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--kw-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .kb-cta-icon.exam {
        background: var(--kw-brand-light);
        color: var(--kw-brand);
    }

    .kb-cta-icon.learn {
        background: var(--kw-success-light);
        color: var(--kw-teal);
    }

    .kb-cta-icon.atlas {
        background: var(--kw-warning-light);
        color: var(--kw-coral);
    }

    .kb-cta-icon.regs {
        background: var(--kw-brand-light);
        color: var(--kw-blue);
    }

.kb-cta-body {
    min-width: 0;
}

.kb-cta-title {
    font-size: var(--kw-text-sm, 13px);
    font-weight: 500;
}

.kb-cta-desc {
    font-size: var(--kw-text-xs, 11px);
    color: var(--kw-text-muted);
}

/* ---- Ad banner ---- */

.ad-banner {
    background: var(--kw-surface-1);
    border: 1px dashed var(--kw-border);
    border-radius: var(--kw-radius-md);
    padding: 14px;
    text-align: center;
    margin-bottom: 20px;
    font-size: 11px;
    color: var(--kw-text-muted);
}

/* ---- Exam & Practice ---- */

.exam-panel {
    display: none;
}

    .exam-panel.active {
        display: block;
    }

.count-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.count-card {
    flex: 1;
    text-align: center;
    padding: 20px 16px;
    border: 2px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    cursor: pointer;
    transition: all 0.15s;
    background: var(--kw-surface-1);
}

    .count-card:hover {
        border-color: var(--kw-border-strong);
    }

    .count-card.selected {
        border-color: var(--kw-brand);
        background: var(--kw-brand-light);
    }

.count-num {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 2px;
}

.count-label {
    font-size: 13px;
    color: var(--kw-text-secondary);
}

.count-time {
    font-size: 12px;
    color: var(--kw-text-muted);
    margin-top: 4px;
}

.info-box {
    background: var(--kw-surface-1);
    border-radius: var(--kw-radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.info-row {
    font-size: 13px;
    color: var(--kw-text-secondary);
    padding: 4px 0;
}

.btn--start {
    background: var(--kw-brand);
    color: #fff;
    border: none;
    font-weight: 600;
}

    .btn--start:hover {
        background: var(--kw-brand-hover);
    }

.btn--full {
    width: 100%;
    justify-content: center;
}

/* Progress bar */

.progress-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.progress-counter {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.progress-track {
    flex: 1;
    height: 6px;
    background: var(--kw-surface-2);
    border-radius: 3px;
    overflow: hidden;
    display: flex;
}

.progress-fill {
    height: 100%;
    transition: width 0.3s;
    border-radius: 3px;
}

.progress-fill--brand {
    background: var(--kw-brand);
}

.progress-fill--success {
    background: var(--kw-success);
}

.progress-fill--danger {
    background: var(--kw-danger);
}

/* Question card */

.q-card {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.q-topic {
    font-size: 12px;
    color: var(--kw-text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.q-text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 20px;
}

.q-media {
    display: block;
    max-width: 100%;
    max-height: 320px;
    margin: 0 auto 20px;
    border-radius: var(--kw-radius-md);
}

.kb-media {
    display: block;
    max-width: 100%;
    max-height: 420px;
    margin: 0 auto 24px;
    border-radius: var(--kw-radius-md);
}

.q-multi-hint {
    font-size: 12px;
    color: var(--kw-brand);
    font-weight: 500;
    margin-bottom: 12px;
}

.q-answers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.q-answer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    line-height: 1.5;
}

    .q-answer:hover {
        border-color: var(--kw-border-strong);
        background: var(--kw-surface-2);
    }

    .q-answer.selected {
        border-color: var(--kw-brand);
        background: var(--kw-brand-light);
    }

    .q-answer.correct {
        border-color: var(--kw-success);
        background: var(--kw-success-light);
    }

    .q-answer.wrong {
        border-color: var(--kw-danger);
        background: var(--kw-danger-light);
    }

.q-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--kw-border-strong);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.q-radio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background 0.15s;
}

.q-answer.selected .q-radio {
    border-color: var(--kw-brand);
}

.q-answer.selected .q-radio-dot {
    background: var(--kw-brand);
}

.q-answer.correct .q-radio {
    border-color: var(--kw-success);
}

.q-answer.correct .q-radio-dot {
    background: var(--kw-success);
}

.q-answer.wrong .q-radio {
    border-color: var(--kw-danger);
}

.q-answer.wrong .q-radio-dot {
    background: var(--kw-danger);
}

/* Checkbox (multi_choice) — square variant */

.q-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--kw-border-strong);
    border-radius: var(--kw-radius-sm, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.q-checkbox-mark {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    transition: background 0.15s;
}

.q-answer.selected .q-checkbox {
    border-color: var(--kw-brand);
}

.q-answer.selected .q-checkbox-mark {
    background: var(--kw-brand);
}

.q-answer.correct .q-checkbox {
    border-color: var(--kw-success);
}

.q-answer.correct .q-checkbox-mark {
    background: var(--kw-success);
}

.q-answer.wrong .q-checkbox {
    border-color: var(--kw-danger);
}

.q-answer.wrong .q-checkbox-mark {
    background: var(--kw-danger);
}

.q-answer-label {
    font-weight: 600;
    color: var(--kw-text-muted);
    min-width: 20px;
}

/* Explanation */

.q-explanation {
    border-radius: var(--kw-radius-md);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.q-explanation--success {
    background: var(--kw-success-light);
    border: 1px solid var(--kw-success);
}

.q-explanation--danger {
    background: var(--kw-danger-light);
    border: 1px solid var(--kw-danger);
}

.q-expl-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.q-explanation--success .q-expl-title {
    color: var(--kw-success);
}

.q-explanation--danger .q-expl-title {
    color: var(--kw-danger);
}

.q-expl-text {
    font-size: 14px;
    color: var(--kw-text-secondary);
    line-height: 1.6;
}

.q-expl-source {
    font-size: 12px;
    color: var(--kw-text-muted);
    margin-top: 8px;
}

.q-expl-text img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    margin: 0 auto 20px;
    border-radius: var(--kw-radius-md);
}

.q-expl-text p {
    margin-bottom: 12px;
}

.q-expl-text figcaption {
    text-align: center;
}

.q-expl-text figure {
    margin: 20px;
}
/* Nav dots */

.exam-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
}

.nav-dots {
    display: flex;
    width: 100%;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0 auto 10px;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--kw-surface-2);
    border: 1px solid var(--kw-border);
    cursor: pointer;
    transition: all 0.15s;
}

    .nav-dot.answered {
        background: var(--kw-brand-light);
        border-color: var(--kw-brand);
    }

    .nav-dot.current {
        border-color: var(--kw-brand);
        box-shadow: 0 0 0 2px var(--kw-brand-light);
    }

@media (max-width: 640px) {
    .nav-dots {
        gap: 8px;
        margin-bottom: 14px;
    }

    .nav-dot {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }

    .nav-dot.current {
        box-shadow: 0 0 0 3px var(--kw-brand-light);
    }
}

/* Results */

.res-header {
    text-align: center;
    margin-bottom: 24px;
}

.res-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.res-icon--pass {
    color: var(--kw-success);
}

.res-icon--fail {
    color: var(--kw-danger);
}

.res-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.res-sub {
    font-size: 14px;
    color: var(--kw-text-secondary);
}

.res-score {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.res-score-card {
    flex: 1;
    text-align: center;
    padding: 16px;
    background: var(--kw-surface-1);
    border-radius: var(--kw-radius-lg);
    border: 1px solid var(--kw-border);
}

.res-score-val {
    font-size: 28px;
    font-weight: 700;
}

.res-score-label {
    font-size: 12px;
    color: var(--kw-text-muted);
    margin-top: 4px;
}

.res-wrong-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.res-wrong-item {
    padding: 12px 16px;
    background: var(--kw-surface-1);
    border-radius: var(--kw-radius-md);
    margin-bottom: 8px;
    border: 1px solid var(--kw-border);
}

.res-wrong-q {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.res-wrong-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
}

.res-wrong-your {
    color: var(--kw-danger);
}

.res-wrong-correct {
    color: var(--kw-success);
}

.res-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 24px;
}
/* Learning bar */

.learn-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.learn-stats {
    display: flex;
    gap: 12px;
}

.learn-stat {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.learn-streak {
    font-size: 13px;
    color: var(--kw-text-secondary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
/* Topic grid */

.topic-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

    .topic-grid .topic-chip {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 14px;
        border: 1px solid var(--kw-border);
        border-radius: var(--kw-radius-pill);
        font-size: 13px;
        cursor: pointer;
        transition: all 0.15s;
        color: var(--kw-text-secondary);
        background: var(--kw-surface-1);
    }

        .topic-grid .topic-chip:hover {
            border-color: var(--kw-border-strong);
        }

        .topic-grid .topic-chip:has(.topic-checkbox:checked),
        .topic-grid .topic-chip.selected {
            border-color: var(--kw-brand);
            background: var(--kw-brand-light);
            color: var(--kw-brand);
        }

.topic-check {
    display: none;
    font-size: 11px;
}

.topic-chip:has(.topic-checkbox:checked) .topic-check,
.topic-chip.selected .topic-check {
    display: inline;
    color: var(--kw-brand);
}

.topic-count {
    font-size: 11px;
    color: var(--kw-text-muted);
    margin-left: 2px;
    font-variant-numeric: tabular-nums;
}

.retry-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--kw-warning-light);
    color: var(--kw-warning);
    border-radius: var(--kw-radius-pill);
    font-weight: 500;
}
/* ---- Atlas ---- */

.atlas-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.atlas-title {
    font-size: 20px;
    font-weight: 600;
}

.atlas-count {
    font-size: 13px;
    color: var(--kw-text-muted);
}

.atlas-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    font-size: 13px;
    color: var(--kw-text-muted);
    min-width: 220px;
}

    .atlas-search input {
        flex: 1;
        border: none;
        background: transparent;
        font-family: var(--kw-font);
        font-size: 13px;
        color: var(--kw-text);
        outline: none;
    }

        .atlas-search input::placeholder {
            color: var(--kw-text-muted);
        }

.fish-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.fish-card {
    background: var(--kw-surface-2);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s;
    text-decoration: none;
    color: var(--kw-text);
    display: block;
}

    .fish-card:hover {
        border-color: var(--kw-border-strong);
        text-decoration: none;
    }

.fish-img {
    width: 100%;
    aspect-ratio: 16/10;
    background: var(--kw-surface-1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

    .fish-img img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .fish-img svg {
        width: 60%;
        height: 60%;
        opacity: 0.15;
    }

.fish-badges {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
}

.fish-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
}

.fish-badge--protected {
    background: rgba(209, 60, 48, 0.15);
    color: var(--kw-red, #D13C30);
}

.fish-badge--igo {
    background: rgba(186, 117, 23, 0.15);
    color: var(--kw-amber, #BA7517);
}

.fish-info {
    padding: 10px 12px;
}

.fish-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
}

.fish-latin {
    font-size: 11px;
    color: var(--kw-text-muted);
    font-style: italic;
}

.fish-meta {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--kw-text-secondary);
}

.fish-meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

    .fish-meta-item svg {
        color: var(--kw-text-muted);
        flex-shrink: 0;
    }
/* ---- Atlas detail ---- */

.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--kw-text-secondary);
    margin-bottom: 16px;
    text-decoration: none;
}

    .detail-back:hover {
        color: var(--kw-text);
        text-decoration: none;
    }
/* Admin bar */

.admin-bar {
    position: sticky;
    top: 0;
    z-index: 1001;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--kw-space-4);
    background: #1e293b;
    font-size: var(--kw-text-xxs);
    color: #94a3b8;
    gap: var(--kw-space-4);
}

body:has(.admin-bar) .app-header {
    top: 32px;
}

.admin-bar-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: color 0.15s;
}

    .admin-bar-link:hover {
        color: #fff;
        text-decoration: none;
    }

.admin-bar-left {
    display: flex;
    align-items: center;
    gap: var(--kw-space-4);
}

.admin-bar-toggle {
    display: flex;
    gap: 1px;
    padding: 1px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--kw-radius-sm);
}

.admin-bar-toggle-btn {
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 500;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

    .admin-bar-toggle-btn:hover {
        color: #cbd5e1;
    }

    .admin-bar-toggle-btn.active {
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
    }

.admin-bar-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--kw-radius-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}

    .admin-bar-edit:hover {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.2);
        color: #fff;
        text-decoration: none;
    }

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-img {
    background: var(--kw-surface-1);
    border-radius: var(--kw-radius-lg);
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--kw-border);
    overflow: hidden;
}

    .detail-img img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .detail-img svg {
        width: 50%;
        height: 50%;
        opacity: 0.15;
    }

.detail-img-caption {
    font-size: 10px;
    color: var(--kw-text-muted);
    margin-top: 8px;
    text-align: center;
}

.detail-latin {
    font-size: 14px;
    color: var(--kw-text-muted);
    font-style: italic;
    margin-bottom: 16px;
}

.detail-badges {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.detail-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 500;
}

.detail-badge--predator {
    background: rgba(209, 60, 48, 0.1);
    color: var(--kw-red, #D13C30);
}

.detail-badge--family {
    background: var(--kw-brand-light);
    color: var(--kw-brand);
}

.detail-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    margin-bottom: 16px;
}

    .detail-table tr {
        border-bottom: 1px solid var(--kw-border);
    }

        .detail-table tr:last-child {
            border-bottom: none;
        }

    .detail-table td {
        padding: 8px 0;
    }

        .detail-table td:first-child {
            color: var(--kw-text-muted);
            width: 45%;
        }

        .detail-table td:last-child {
            font-weight: 500;
        }

.detail-section-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.detail-features {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.detail-feature {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--kw-text-secondary);
    line-height: 1.5;
}

.detail-feature-dot {
    color: var(--kw-brand);
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1.2;
}

.detail-desc {
    font-size: 13px;
    color: var(--kw-text-secondary);
    line-height: 1.6;
}

    .detail-desc strong {
        color: var(--kw-text);
        font-weight: 600;
    }

.detail-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-section {
    margin-top: 24px;
}

.detail-badge--introduced {
    background: rgba(186, 117, 23, 0.12);
    color: var(--kw-amber);
}

.detail-badge--igo {
    background: rgba(209, 60, 48, 0.1);
    color: var(--kw-red);
}

.detail-comparison {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--kw-surface-1);
    border-radius: var(--kw-radius-md);
}

.detail-comparison-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-info-item--wide {
    grid-column: 1/-1;
}

.detail-info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.detail-info-text {
    font-size: 13px;
    color: var(--kw-text-secondary);
    line-height: 1.5;
}

.detail-table--compact {
    margin-top: 16px;
}

.detail-reg-scroll {
    overflow-x: auto;
}

.detail-reg-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    min-width: 440px;
}

    .detail-reg-table th {
        text-align: left;
        padding: 8px 10px;
        color: var(--kw-text-muted);
        font-weight: 500;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        border-bottom: 2px solid var(--kw-border);
    }

    .detail-reg-table td {
        padding: 7px 10px;
        border-bottom: 1px solid var(--kw-border);
    }

    .detail-reg-table tr:last-child td {
        border-bottom: none;
    }

    .detail-reg-table td:first-child {
        font-weight: 500;
        white-space: nowrap;
    }

.detail-reg-row--national {
    background: rgba(37, 99, 235, 0.07);
}

    .detail-reg-row--national td:first-child {
        font-weight: 700;
        color: var(--kw-brand);
    }

.detail-reg-diff {
    background: var(--kw-warning-light);
    color: var(--kw-warning);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    display: inline-block;
}


.detail-names-pl {
    background: var(--kw-brand-light);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    padding: 16px 18px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.detail-names-pl-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-brand);
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-names-pl-text {
    font-size: 15px;
    color: var(--kw-text);
    line-height: 1.55;
    font-weight: 500;
}

.detail-names-other-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kw-text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.detail-names-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 6px 20px;
    font-size: 13px;
}

.detail-name-lang {
    color: var(--kw-text-muted);
    text-transform: capitalize;
}

.detail-name-lang-pl {
    text-transform: none;
    opacity: 0.75;
}
/* ---- Mobile burger ---- */

.burger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--kw-text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
/* ---- Responsive ---- */

@media (max-width: 768px) {
    .burger-btn {
        display: block;
    }

    .app-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--kw-bg);
        border-bottom: 1px solid var(--kw-border);
        box-shadow: var(--kw-shadow-md);
        padding: 8px 0;
        z-index: 20;
    }

    .app-header-actions {
        gap: 4px;
    }

    .theme-toggle,
    .burger-btn {
        width: 40px;
        height: 40px;
    }

        .app-nav.open {
            display: flex;
        }

        .app-nav a {
            padding: 12px 24px;
            font-size: 15px;
            width: 100%;
        }

    .app-body {
        padding: 16px;
    }

    .kb-cta {
        grid-template-columns: 1fr;
    }

    .fish-grid {
        grid-template-columns: 1fr;
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }

    .detail-info-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .atlas-top {
        flex-direction: column;
        align-items: stretch;
    }

    .atlas-search {
        min-width: unset;
    }
}
/* ---- Info pages (about, contact, privacy, terms) ---- */

.info-content {
    line-height: 1.7;
}

.info-section {
    margin-bottom: 28px;
}

    .info-section h2 {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 8px;
        color: var(--kw-text);
    }

    .info-section p {
        font-size: 14px;
        color: var(--kw-text-secondary);
        margin-bottom: 10px;
    }

    .info-section ul {
        font-size: 14px;
        color: var(--kw-text-secondary);
        padding-left: 20px;
        margin-bottom: 10px;
    }

    .info-section li {
        margin-bottom: 6px;
    }
/* ---- Admin panel ---- */

.app-body--admin {
    max-width: 1600px;
    padding: 0;
}

.admin-layout {
    display: flex;
    min-height: calc(100vh - 120px);
}

.admin-sidebar {
    width: 220px;
    border-right: 1px solid var(--kw-border);
    padding: 20px 0;
    flex-shrink: 0;
    background: var(--kw-surface-1);
    position: sticky;
    top: 89px;
    height: calc(100vh - 89px);
    overflow-y: auto;
    align-self: flex-start;
}

body:not(:has(.admin-bar)) .admin-sidebar {
    top: 57px;
    height: calc(100vh - 57px);
}

.admin-sidebar::-webkit-scrollbar {
    width: 4px;
}

.admin-sidebar::-webkit-scrollbar-thumb {
    background: var(--kw-border);
    border-radius: 2px;
}

.admin-sidebar-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--kw-text-muted);
    padding: 0 20px 12px;
}

.admin-view-toggle {
    display: flex;
    gap: 2px;
    margin: 0 12px 12px;
    padding: 2px;
    background: var(--kw-surface-2);
    border-radius: 6px;
}

.admin-view-toggle-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--kw-text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

    .admin-view-toggle-btn:hover {
        color: var(--kw-text-secondary);
    }

    .admin-view-toggle-btn.active {
        background: var(--kw-surface);
        color: var(--kw-text);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    }

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    font-size: 13px;
    color: var(--kw-text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}

    .admin-nav-link:hover {
        color: var(--kw-text);
        background: var(--kw-surface-2);
        text-decoration: none;
    }

    .admin-nav-link.active {
        color: var(--kw-brand);
        font-weight: 500;
        background: var(--kw-brand-light);
    }

    .admin-nav-link svg {
        flex-shrink: 0;
    }

.admin-content {
    flex: 1;
    padding: 24px 28px;
    min-width: 0;
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.admin-page-title {
    font-size: 18px;
    font-weight: 600;
}

.admin-count {
    font-weight: 400;
    color: var(--kw-text-muted);
}
/* Admin alerts */

.admin-alert {
    padding: 10px 16px;
    border-radius: var(--kw-radius-md);
    font-size: 13px;
    margin-bottom: 16px;
}

.admin-alert--success {
    background: var(--kw-success-light);
    color: var(--kw-success);
    border: 1px solid var(--kw-success);
}

.admin-alert--error {
    background: var(--kw-danger-light);
    color: var(--kw-danger);
    border: 1px solid var(--kw-danger);
}
/* Admin search */

.admin-search-form {
    margin-bottom: 16px;
}

    .admin-search-form .search-box {
        max-width: 400px;
    }
/* Admin filter */

.admin-filter-form {
    margin-bottom: 16px;
}

.admin-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-filter-search {
    max-width: 300px;
    flex: 1;
}

.admin-filter-select {
    max-width: 180px;
}
/* Align the filter controls to one height with vertically centered text so the search box,
   selects and the button form a neat row. */
.admin-filter-search,
.admin-filter-select,
.admin-filter-row .btn {
    height: 42px;
}
/* Higher specificity than .admin-input (which sets padding: 8px 12px later in this file). */
.admin-input.admin-filter-select {
    padding: 0 12px;
    font-size: 14px;
}
/* Admin table */

.admin-table-wrap {
    overflow-x: auto;
    margin-bottom: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

    .admin-table th {
        text-align: left;
        font-weight: 500;
        color: var(--kw-text-muted);
        padding: 8px 12px;
        border-bottom: 2px solid var(--kw-border);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .admin-table td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--kw-border);
        vertical-align: top;
    }

    .admin-table tbody tr:hover {
        background: var(--kw-surface-1);
    }

.admin-table-id {
    white-space: nowrap;
    color: var(--kw-text-muted);
}

.admin-table-latin {
    font-style: italic;
    color: var(--kw-text-secondary);
}

.admin-table-content {
    max-width: 400px;
    line-height: 1.4;
}

.admin-table-date {
    white-space: nowrap;
    color: var(--kw-text-secondary);
    font-variant-numeric: tabular-nums;
}

.admin-table-empty {
    text-align: center;
    color: var(--kw-text-muted);
    padding: 24px 12px !important;
}

.admin-table-actions {
    white-space: nowrap;
    text-align: right;
}

.admin-action-link {
    font-size: 12px;
    color: var(--kw-brand);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--kw-radius-sm);
    transition: background 0.15s;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--kw-font);
}

    .admin-action-link:hover {
        background: var(--kw-brand-light);
        text-decoration: none;
    }

.admin-action-link--danger {
    color: var(--kw-danger);
}

    .admin-action-link--danger:hover {
        background: var(--kw-danger-light);
    }

.admin-inline-form {
    display: inline;
}
/* Admin status badges */

.admin-status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--kw-radius-pill);
    font-weight: 500;
}

.admin-status-badge--draft {
    background: var(--kw-surface-2);
    color: var(--kw-text-muted);
}

.admin-status-badge--verified {
    background: var(--kw-warning-light);
    color: var(--kw-warning);
}

.admin-status-badge--published {
    background: var(--kw-success-light);
    color: var(--kw-success);
}
/* Admin forms */

.admin-form {
    max-width: 800px;
}

.admin-form-group {
    margin-bottom: 14px;
    flex: 1;
    min-width: 0;
}

.admin-form-group--key {
    flex: 0 0 200px;
}

.admin-form-group--value {
    flex: 1;
}

.admin-form-group--check {
    flex: 0 0 30px;
    display: flex;
    align-items: center;
    padding-top: 6px;
}

.admin-form-group--narrow {
    flex: 0 0 100px;
}

.admin-form-group--fixed {
    flex: 0 0 170px;
}

.admin-form-group--scope {
    flex: 1;
    min-width: 250px;
}

.admin-form-group--code {
    flex: 1;
    max-width: 320px;
}

.admin-media-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.admin-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--kw-text-secondary);
    margin-bottom: 4px;
}

.admin-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

    .admin-label-row .admin-label {
        margin-bottom: 0;
    }

.admin-quick-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-quick-toolbar-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--kw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.admin-quick-insert-btn {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 500;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-sm, 4px);
    color: var(--kw-text-secondary);
    cursor: pointer;
    line-height: 1.3;
    transition: all 0.15s ease;
}

    .admin-quick-insert-btn:hover {
        background: var(--kw-surface-2);
        border-color: var(--kw-brand);
        color: var(--kw-brand);
    }

.admin-quick-btn--image {
    color: var(--kw-brand);
    font-weight: 600;
    border-color: rgba(43, 114, 186, 0.3);
}

    .admin-quick-btn--image:hover {
        background: var(--kw-brand);
        color: #ffffff;
        border-color: var(--kw-brand);
    }

.admin-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--kw-font);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    background: var(--kw-bg);
    color: var(--kw-text);
    outline: none;
    transition: border-color 0.15s;
}

    .admin-input:focus {
        border-color: var(--kw-brand);
    }

.admin-media-preview {
    display: block;
    max-width: 220px;
    max-height: 150px;
    margin-top: 6px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    object-fit: contain;
}

.admin-source-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.admin-source-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    background: var(--kw-surface-1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.admin-source-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: break-word;
    word-break: break-word;
}

.admin-source-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--kw-text);
    text-decoration: none;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
}

a.admin-source-title:hover {
    color: var(--kw-brand);
    text-decoration: underline;
}

.admin-source-kind {
    font-size: 11px;
    color: var(--kw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.admin-source-reference {
    max-width: 240px;
}

.admin-source-key-btn {
    flex-shrink: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 4px 10px;
    white-space: nowrap;
}

.admin-source-row .admin-btn-remove {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
}

.admin-source-add-row {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

.admin-source-add-select {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

#add-source {
    flex-shrink: 0;
    white-space: nowrap;
}

.admin-textarea {
    resize: vertical;
    min-height: 60px;
}

.admin-textarea--lg {
    min-height: 100px;
}
/* Admin article editor (split view: source + live preview) */

.admin-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.admin-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.admin-editor-input {
    min-height: 460px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.admin-editor-preview {
    min-height: 460px;
    max-height: 680px;
    overflow-y: auto;
    padding: 14px 18px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    background: var(--kw-bg);
}

    .admin-editor-preview > :first-child {
        margin-top: 0;
    }

@media (max-width: 1024px) {
    .admin-editor {
        grid-template-columns: 1fr;
    }

    .admin-editor-input, .admin-editor-preview {
        min-height: 300px;
    }
}

.admin-form-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.admin-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--kw-border);
}

.admin-form-actions--top {
    margin-top: 0;
    margin-bottom: 28px;
    padding-top: 0;
    padding-bottom: 16px;
    border-top: none;
    border-bottom: 1px solid var(--kw-border);
}

.admin-fieldset {
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
}

    .admin-fieldset legend {
        font-size: 13px;
        font-weight: 500;
        padding: 0 8px;
        color: var(--kw-text-secondary);
    }

.admin-dynamic-row {
    margin-bottom: 8px;
}

.admin-btn-remove {
    background: none;
    border: none;
    color: var(--kw-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 8px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: var(--kw-radius-sm);
    transition: all 0.15s;
}

    .admin-btn-remove:hover {
        color: var(--kw-danger);
        background: var(--kw-danger-light);
    }

    .admin-btn-remove.active {
        color: #fff;
        background: var(--kw-danger);
    }

.admin-dynamic-row.marked-for-removal {
    opacity: 0.45;
}

    .admin-dynamic-row.marked-for-removal .admin-input, .admin-dynamic-row.marked-for-removal .admin-textarea {
        text-decoration: line-through;
        pointer-events: none;
    }

    .admin-dynamic-row.marked-for-removal .ai-btn {
        pointer-events: none;
        opacity: 0.3;
    }

.admin-btn-add {
    font-size: 12px;
    margin-top: 8px;
}

.admin-validation {
    background: var(--kw-danger-light);
    color: var(--kw-danger);
    padding: 10px 16px 10px 32px;
    border-radius: var(--kw-radius-md);
    margin-bottom: 16px;
    font-size: 13px;
}

    .admin-validation:empty {
        display: none;
    }
    /* The validation summary tag helper always renders a hidden empty <ul>,
   so :empty never matches. Hide via the no-errors marker class instead. */
    .admin-validation.validation-summary-valid {
        display: none;
    }

.admin-field-error {
    font-size: 11px;
    color: var(--kw-danger);
}
/* Admin tag grid (question edit) */

.admin-tag-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-tag-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--kw-text-secondary);
    padding: 4px 10px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-pill);
    cursor: pointer;
    transition: all 0.15s;
}

    .admin-tag-option:hover {
        border-color: var(--kw-border-strong);
    }

    .admin-tag-option input:checked + span {
        color: var(--kw-brand);
        font-weight: 500;
    }

    .admin-tag-option:has(input:checked) {
        border-color: var(--kw-brand);
        background: var(--kw-brand-light);
    }
/* Admin modal (dialog) */

.admin-modal {
    border: none;
    border-radius: var(--kw-radius-lg);
    background: var(--kw-surface-1);
    color: var(--kw-text);
    padding: 0;
    max-width: 680px;
    width: calc(100vw - 32px);
    max-height: calc(100vh - 64px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

    .admin-modal::backdrop {
        background: rgba(0, 0, 0, 0.45);
    }

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--kw-border);
}

.admin-modal-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.admin-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--kw-text-muted);
    border-radius: var(--kw-radius-sm);
}

    .admin-modal-close:hover {
        background: var(--kw-surface-2);
    }

.admin-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.admin-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--kw-border);
}

.admin-modal-footer--top {
    border-top: none;
    border-bottom: 1px solid var(--kw-border);
}

.admin-modal-error {
    background: var(--kw-danger-light);
    color: var(--kw-danger);
    padding: 8px 12px;
    border-radius: var(--kw-radius-md);
    font-size: 13px;
    margin-bottom: 12px;
}

    .admin-modal-error:empty {
        display: none;
    }
/* Admin section (collapsible) */

.admin-section {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    margin-bottom: 16px;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
}

    .admin-section-header:hover {
        background: var(--kw-surface-2);
        border-radius: var(--kw-radius-lg);
    }

.admin-section-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-section-toggle {
    transition: transform 0.2s;
    font-size: 12px;
    color: var(--kw-text-muted);
}

.admin-section.collapsed .admin-section-toggle {
    transform: rotate(-90deg);
}

.admin-section.collapsed .admin-section-body {
    display: none;
}

.admin-section-body {
    padding: 0 20px 16px;
}

    .admin-section-body .admin-table {
        margin: 0;
    }

.admin-section .admin-table-wrap {
    overflow-x: auto;
}
/* Admin tools */

.admin-tool-card {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.admin-tool-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 8px;
}

.admin-tool-desc {
    font-size: 13px;
    color: var(--kw-text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

.admin-tool-subtitle {
    font-size: 14px;
    font-weight: 500;
    margin: 16px 0 8px;
}

.admin-muted {
    color: var(--kw-text-secondary);
    font-weight: 400;
}

.admin-tool-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

    .admin-tool-row .admin-input {
        flex: 1;
        min-width: 240px;
    }

.admin-tool-result {
    margin-top: 14px;
}

.admin-tool-result-list {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--kw-danger);
    line-height: 1.6;
}

.admin-tool-result-list--muted {
    color: var(--kw-text-muted);
}
/* Admin dashboard */

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .dashboard-card:hover {
        border-color: var(--kw-border-strong);
        box-shadow: var(--kw-shadow-sm);
        text-decoration: none;
    }

.dashboard-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-card-icon--brand {
    background: var(--kw-brand-light);
    color: var(--kw-brand);
}

.dashboard-card-icon--amber {
    background: rgba(186, 117, 23, 0.12);
    color: var(--kw-amber);
}

.dashboard-card-icon--teal {
    background: rgba(29, 158, 117, 0.12);
    color: var(--kw-teal);
}

.dashboard-card-icon--purple {
    background: rgba(127, 119, 221, 0.12);
    color: var(--kw-purple);
}

.dashboard-card-icon--coral {
    background: rgba(216, 90, 48, 0.12);
    color: var(--kw-coral);
}

.dashboard-card-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--kw-text);
    font-variant-numeric: tabular-nums;
}

.dashboard-card-label {
    font-size: 13px;
    color: var(--kw-text-muted);
}

.dashboard-shortcuts {
    margin-top: 8px;
}

.dashboard-section-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}

.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dashboard-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--kw-text-secondary);
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    text-decoration: none;
    transition: all 0.15s;
}

    .dashboard-action:hover {
        color: var(--kw-brand);
        border-color: var(--kw-brand);
        background: var(--kw-brand-light);
        text-decoration: none;
    }

    .dashboard-action svg {
        flex-shrink: 0;
    }
/* Admin AI prompt modal */

.ai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-sm);
    background: var(--kw-surface-1);
    color: var(--kw-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
    padding: 0;
}

    .ai-btn:hover {
        color: var(--kw-brand);
        border-color: var(--kw-brand);
        background: var(--kw-brand-light);
    }

.ai-btn-general {
    width: auto;
    padding: 0 10px;
    gap: 4px;
    font-size: 12px;
    font-family: var(--kw-font);
    height: 28px;
}
/* AI side panel */

.ai-panel {
    width: 380px;
    flex-shrink: 0;
    border-left: 1px solid var(--kw-border);
    background: var(--kw-surface-1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: sticky;
    top: 32px;
    height: calc(100vh - 32px);
}

body:not(:has(.admin-bar)) .ai-panel {
    top: 0;
    height: 100vh;
}

.admin-layout:has(.ai-panel[style*="display: none"]) .admin-content,
.admin-layout:not(:has(.ai-panel)) .admin-content {
    flex: 1;
}

.admin-layout:has(.ai-panel:not([style*="display: none"])) .admin-content {
    flex: 1;
    min-width: 0;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--kw-border);
    flex-shrink: 0;
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--kw-text);
}

.ai-panel-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--kw-text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

    .ai-panel-close:hover {
        color: var(--kw-text);
    }

.ai-panel-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1;
}

.ai-panel-body--result {
    display: flex;
    flex-direction: column;
}

.ai-model-selector {
    padding: 8px 16px 0;
    flex-shrink: 0;
}

.ai-model-select {
    width: 100%;
    font-size: 13px;
    padding: 6px 8px;
}

.ai-panel-field-label {
    font-size: 12px;
    color: var(--kw-text-secondary);
    padding: 8px 16px 0;
    flex-shrink: 0;
}

    .ai-panel-field-label strong {
        color: var(--kw-text);
    }

.ai-panel-result-header {
    font-size: 12px;
    color: var(--kw-text-secondary);
    margin-bottom: 8px;
}

.ai-prompt-group-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--kw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 12px 0 6px;
}

    .ai-prompt-group-label:first-child {
        margin-top: 0;
    }

.ai-prompt-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--kw-font);
    color: var(--kw-text);
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 4px;
    text-transform: capitalize;
}

    .ai-prompt-item:hover {
        border-color: var(--kw-brand);
        background: var(--kw-brand-light);
        color: var(--kw-brand);
    }

.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 0;
    color: var(--kw-text-secondary);
    font-size: 13px;
}

.ai-loading-small {
    font-size: 12px;
    color: var(--kw-text-muted);
    padding: 12px 0;
}

.ai-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--kw-border);
    border-top-color: var(--kw-brand);
    border-radius: 50%;
    animation: ai-spin 0.7s linear infinite;
}

@keyframes ai-spin {
    to {
        transform: rotate(360deg);
    }
}

.ai-result-textarea {
    resize: vertical;
    min-height: 120px;
    flex: 1;
    font-size: 13px;
    line-height: 1.6;
}

.ai-token-info {
    font-size: 11px;
    color: var(--kw-text-muted);
    font-weight: 400;
}

.ai-result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.ai-error {
    font-size: 13px;
    color: var(--kw-danger);
    padding: 12px;
    background: var(--kw-danger-light);
    border-radius: var(--kw-radius-md);
}

.ai-empty {
    font-size: 13px;
    color: var(--kw-text-muted);
    padding: 16px 0;
    text-align: center;
}

.admin-form-group--with-ai {
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

    .admin-form-group--with-ai > .admin-input,
    .admin-form-group--with-ai > .admin-textarea {
        flex: 1;
    }

    .admin-form-group--with-ai > .ai-btn {
        margin-top: 2px;
    }
/* Admin paging info */

.admin-page-info {
    font-size: 13px;
    color: var(--kw-text-secondary);
}
/* ---- Auth pages (register, login, verify, settings) ---- */

.auth-container {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 32px;
}

.auth-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    text-align: center;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--kw-text-secondary);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--kw-text-secondary);
}

.auth-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--kw-font);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    background: var(--kw-bg);
    color: var(--kw-text);
    outline: none;
    transition: border-color 0.15s;
}

    .auth-input:focus {
        border-color: var(--kw-brand);
    }

.auth-hint {
    font-size: 11px;
    color: var(--kw-text-muted);
    line-height: 1.5;
}

.auth-error {
    font-size: 12px;
    color: var(--kw-danger);
}

.auth-field-error {
    font-size: 12px;
    color: var(--kw-danger);
}

.auth-field + .auth-btn {
    margin-top: 8px;
}

.auth-btn {
    width: 100%;
    padding: 10px 20px;
    font-size: 14px;
    font-family: var(--kw-font);
    font-weight: 600;
    border-radius: var(--kw-radius-md);
    cursor: pointer;
    border: none;
    background: var(--kw-brand);
    color: #fff;
    transition: background 0.15s;
}

    .auth-btn:hover {
        background: var(--kw-brand-hover);
    }

.auth-btn--secondary {
    background: var(--kw-surface-2);
    color: var(--kw-text);
    border: 1px solid var(--kw-border);
    font-weight: 500;
}

    .auth-btn--secondary:hover {
        border-color: var(--kw-border-strong);
        background: var(--kw-surface-2);
    }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    font-size: 12px;
    color: var(--kw-text-muted);
}

    .auth-divider::before, .auth-divider::after {
        content: "";
        flex: 1;
        height: 1px;
        background: var(--kw-border);
    }

.auth-logo {
    text-align: center;
    margin-bottom: 16px;
}

.auth-logo-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
}

.auth-error-box {
    padding: 10px 14px;
    border-radius: var(--kw-radius-md);
    font-size: 13px;
    background: var(--kw-danger-light);
    color: var(--kw-danger);
    margin-bottom: 16px;
    text-align: center;
}

.auth-oauth {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--kw-font);
    font-weight: 500;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    background: var(--kw-bg);
    color: var(--kw-text);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

    .auth-oauth-btn:hover {
        border-color: var(--kw-border-strong);
        box-shadow: var(--kw-shadow-sm);
        text-decoration: none;
    }

    .auth-oauth-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

.auth-oauth-btn--facebook svg {
    color: #1877F2;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--kw-text-secondary);
}

    .auth-footer a {
        color: var(--kw-brand);
        font-weight: 500;
    }

.auth-alert {
    padding: 10px 14px;
    border-radius: var(--kw-radius-md);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-alert--error {
    background: var(--kw-danger-light);
    color: var(--kw-danger);
    border: 1px solid var(--kw-danger);
}

.auth-alert--success {
    background: var(--kw-success-light);
    color: var(--kw-success);
    border: 1px solid var(--kw-success);
}

.auth-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--kw-text-secondary);
}

    .auth-check input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: var(--kw-brand);
    }
/* Auth settings page */

.auth-section {
    margin-bottom: 24px;
}

.auth-info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--kw-border);
}

    .auth-info-row:last-child {
        border-bottom: none;
    }

.auth-info-label {
    color: var(--kw-text-muted);
    font-size: 13px;
}

.auth-info-value {
    font-weight: 500;
}

.auth-logout-section {
    margin-top: 8px;
}

.auth-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.auth-link {
    font-size: 13px;
    color: var(--kw-brand);
    text-decoration: none;
    font-weight: 500;
}

    .auth-link:hover {
        text-decoration: underline;
    }

.auth-link-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    color: var(--kw-brand);
    font-family: var(--kw-font);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

    .auth-link-btn:hover {
        text-decoration: underline;
    }

.auth-section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--kw-text);
}

.auth-section-title--danger {
    color: var(--kw-danger);
}

.auth-info-value--actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-provider-email {
    font-weight: 400;
    color: var(--kw-text-secondary);
    font-size: 13px;
}

.auth-link-btn--danger {
    color: var(--kw-danger);
}

    .auth-link-btn--danger:hover {
        text-decoration: underline;
    }

.auth-danger-zone {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--kw-border);
}

.auth-danger-text {
    font-size: 13px;
    color: var(--kw-text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.auth-btn--danger {
    background: var(--kw-danger);
    color: #fff;
}

    .auth-btn--danger:hover {
        background: #c0392b;
    }

.auth-card--wide {
    max-width: 480px;
}
/* Nav login button */

.app-nav .app-nav-btn {
    font-size: 13px;
    font-family: var(--kw-font);
    color: var(--kw-brand);
    background: var(--kw-brand-light);
    border: none;
    border-radius: var(--kw-radius-sm);
    padding: 6px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    transition: filter 0.15s;
}

    .app-nav .app-nav-btn:hover {
        filter: brightness(0.93);
        text-decoration: none;
        color: var(--kw-brand);
    }

.app-nav-btn svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .auth-card {
        padding: 24px 20px;
    }

    .auth-container {
        padding: 20px 12px;
    }

    .app-nav .app-nav-btn {
        padding: 12px 24px;
        font-size: 15px;
        width: 100%;
        text-align: left;
        border-radius: 0;
    }

        .app-nav .app-nav-btn:hover {
            background: var(--kw-surface-1);
        }
}
/* Admin responsive */

@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--kw-border);
        padding: 12px 0;
        position: static;
        height: auto;
        overflow-y: visible;
    }

    .admin-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 0 12px;
        gap: 4px;
    }

    .admin-nav-link {
        padding: 6px 12px;
        white-space: nowrap;
        font-size: 12px;
    }

    .admin-sidebar-header {
        padding: 0 12px 8px;
    }

    .admin-content {
        padding: 16px;
    }

    .admin-form-row {
        flex-direction: column;
        gap: 0;
    }

    .admin-form-group--key {
        flex: 1;
    }

    .admin-form-group--narrow {
        flex: 1;
    }

    .admin-filter-row {
        flex-direction: column;
    }

    .admin-filter-search {
        max-width: 100%;
    }

    .admin-filter-select {
        max-width: 100%;
        width: 100%;
    }

    .ai-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        top: 0;
        height: 100vh;
        z-index: 2000;
        border-left: none;
    }
}

.error-page {
    text-align: center;
    padding: 80px 24px;
    max-width: 520px;
    margin: 0 auto;
}

.error-code {
    font-size: 96px;
    font-weight: 800;
    color: var(--kw-primary);
    line-height: 1;
    margin-bottom: 8px;
    opacity: 0.8;
}

.error-page h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.error-page p {
    color: var(--kw-text-secondary);
    margin-bottom: 28px;
}

.error-request-id {
    margin-top: 32px;
    font-size: 12px;
    color: var(--kw-text-secondary);
}
/* Report error FAB + dialog */

.report-error-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--kw-brand);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--kw-shadow-md);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .report-error-fab:hover {
        transform: scale(1.08);
        box-shadow: var(--kw-shadow-lg);
    }

    .report-error-fab:active {
        transform: scale(0.96);
    }

    .report-error-fab svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.report-error-dialog {
    border: none;
    border-radius: var(--kw-radius-lg);
    background: var(--kw-bg);
    color: var(--kw-text);
    padding: 0;
    max-width: 520px;
    width: calc(100vw - 32px);
    max-height: calc(100vh - 64px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    margin: auto;
    position: fixed;
    inset: 0;
    height: fit-content;
}

    .report-error-dialog::backdrop {
        background: rgba(0, 0, 0, 0.45);
    }

.report-error-context {
    background: var(--kw-surface-2);
    border-radius: var(--kw-radius-sm);
    padding: 8px 12px;
    font-size: var(--kw-text-xs);
    color: var(--kw-text-secondary);
    margin-bottom: 12px;
}

    .report-error-context:empty {
        display: none;
    }

.report-error-selected-text {
    background: var(--kw-surface-2);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-sm);
    padding: 10px 12px;
    font-size: var(--kw-text-sm);
    color: var(--kw-text);
    margin-bottom: 12px;
    max-height: 100px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.report-error-char-count {
    text-align: right;
    font-size: var(--kw-text-xs);
    color: var(--kw-text-muted);
    margin-top: 4px;
}

.report-error-success {
    text-align: center;
    padding: 32px 24px;
}

.report-error-success-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--kw-success-light);
    color: var(--kw-success);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

    .report-error-success-icon svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2.5;
    }

.report-error-success-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.report-error-success-text {
    font-size: var(--kw-text-sm);
    color: var(--kw-text-secondary);
    margin-bottom: 20px;
}

@media (max-width: 767px) {
    .report-error-fab {
        width: 44px;
        height: 44px;
        bottom: 16px;
        right: 16px;
    }

        .report-error-fab svg {
            width: 20px;
            height: 20px;
        }
}
/* ===== Hidden native inputs ===== */
.q-answer-input, .topic-checkbox, .count-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
/* ===== Answer result icons ===== */
.q-answer-icon {
    margin-left: auto;
    font-weight: 700;
    flex-shrink: 0;
}

.q-answer-icon--correct {
    color: var(--kw-success);
}

.q-answer-icon--wrong {
    color: var(--kw-danger);
}
/* ===== Batch badge ===== */
.batch-badge {
    display: inline-block;
    background: var(--kw-brand);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}
/* ===== Practice nav ===== */
.practice-nav {
    margin-top: 16px;
}

.practice-new-session {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.practice-new-session-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    color: var(--kw-text-muted);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    border-radius: var(--kw-radius-sm);
}

.practice-new-session-link:hover {
    color: var(--kw-text);
    background: var(--kw-surface-2);
}

/* ===== Batch summary ===== */
.batch-answer-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 16px 0;
}

.batch-answer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--kw-card-bg);
    border-radius: 8px;
    border: 1px solid var(--kw-border);
}

.batch-answer--correct {
    border-left: 3px solid var(--kw-success);
}

.batch-answer--wrong {
    border-left: 3px solid var(--kw-danger);
}

.batch-answer-icon {
    font-weight: 700;
    flex-shrink: 0;
}

.batch-answer--correct .batch-answer-icon {
    color: var(--kw-success);
}

.batch-answer--wrong .batch-answer-icon {
    color: var(--kw-danger);
}

.batch-answer-text {
    flex: 1;
    font-size: var(--kw-text-sm);
}
/* ===== Review answers (exam results) ===== */
.q-answers--review {
    pointer-events: none;
}

    .q-answers--review .q-answer {
        cursor: default;
    }
/* ===== Answers review section (exam results) ===== */
.res-answers-section, .res-wrong-section {
    margin-top: 24px;
}

.res-answers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.res-answers-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--kw-text);
}

.res-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.res-filter-btn {
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--kw-radius-pill);
    border: 1px solid var(--kw-border);
    background: var(--kw-surface-1);
    color: var(--kw-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

    .res-filter-btn:hover {
        background: var(--kw-surface-2);
        color: var(--kw-text);
    }

    .res-filter-btn.active {
        background: var(--kw-brand);
        border-color: var(--kw-brand);
        color: #ffffff;
        font-weight: 600;
    }

.res-answer-item, .res-wrong-item {
    margin-bottom: 20px;
    padding: 18px;
    background: var(--kw-surface-1);
    border-radius: 10px;
    border: 1px solid var(--kw-border);
    transition: border-color 0.15s ease;
}

.res-answer-item--correct {
    border-left: 4px solid var(--kw-success);
}

.res-answer-item--wrong {
    border-left: 4px solid var(--kw-danger);
}

.res-answer-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.res-answer-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--kw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.res-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--kw-radius-pill);
}

.res-badge--correct {
    background: var(--kw-success-light);
    color: var(--kw-success);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.res-badge--wrong {
    background: var(--kw-danger-light);
    color: var(--kw-danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.res-answer-q, .res-wrong-q {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 14px;
    color: var(--kw-text);
}

.q-explanation--info {
    background: var(--kw-surface-2);
    border: 1px solid var(--kw-border);
}
/* ===== Dashboard ===== */
.dashboard {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

.dash-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.dash-stat-card {
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.dash-stat-val {
    font-size: 28px;
    font-weight: 700;
    color: var(--kw-brand);
}

.dash-stat-label {
    font-size: var(--kw-text-sm);
    color: var(--kw-text-secondary);
    margin-top: 4px;
}

.dash-section {
    margin-bottom: 32px;
}

.dash-section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.dash-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dash-chart-container {
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: 10px;
    padding: 16px;
    height: 320px;
    position: relative;
}

.dash-chart-container--wide {
    height: 280px;
}

.dash-sessions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-session-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: 8px;
    font-size: var(--kw-text-sm);
}

.dash-mode-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
    flex-shrink: 0;
}

.dash-mode--practice {
    background: rgba(37,99,235,0.15);
    color: var(--kw-brand);
}

.dash-mode--exam {
    background: rgba(245,158,11,0.15);
    color: var(--kw-warning);
}

.dash-session-date {
    color: var(--kw-text-secondary);
}

.dash-session-score {
    font-weight: 600;
    margin-left: auto;
}

.dash-session-result {
    font-weight: 600;
    flex-shrink: 0;
}

.dash-result--pass {
    color: var(--kw-success);
}

.dash-result--fail {
    color: var(--kw-danger);
}

.dash-empty {
    text-align: center;
    padding: 48px 16px;
}

.dash-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.dash-empty-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.dash-empty-text {
    color: var(--kw-text-secondary);
    margin-bottom: 20px;
}

.dash-empty-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

@media (max-width: 767px) {
    .dash-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-charts-row {
        grid-template-columns: 1fr;
    }

    .dash-session-row {
        flex-wrap: wrap;
    }

    .dash-session-score {
        margin-left: 0;
    }
}
/* ===== Query Stats (Admin) ===== */
.query-stats-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.query-stats-section {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 20px;
    box-shadow: var(--kw-shadow-sm);
}

.query-stats-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
/* ===== Query Stats (Admin) ===== */
.query-stats-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.query-stats-section {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 18px;
    box-shadow: var(--kw-shadow-sm);
}

.query-stats-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.query-stats-section-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--kw-text);
    margin: 0;
}

.query-stats-section-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--kw-radius-pill);
    background: var(--kw-surface-2);
    color: var(--kw-text-secondary);
}

.query-stats-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    align-items: start;
}

.query-chart-card {
    background: var(--kw-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    padding: 12px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.query-chart-wrapper {
    position: relative;
    width: 100%;
    height: 240px;
}

.query-table-card {
    background: var(--kw-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    overflow-x: auto;
}

.query-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

    .query-table th {
        background: var(--kw-surface-2);
        padding: 8px 10px;
        text-align: left;
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--kw-text-secondary);
        border-bottom: 1px solid var(--kw-border);
        white-space: nowrap;
    }

    .query-table td {
        padding: 5px 8px;
        border-bottom: 1px solid var(--kw-border);
        vertical-align: middle;
        color: var(--kw-text);
    }

    .query-table tr:last-child td {
        border-bottom: none;
    }

    .query-table tr:hover td {
        background: var(--kw-surface-1);
    }

.query-rank {
    font-weight: 700;
    color: var(--kw-text-muted);
    width: 22px;
    text-align: center;
    font-size: 12px;
}

.query-metric {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
    font-size: 12px;
}

.query-code-cell {
    min-width: 240px;
    max-width: 480px;
}

.query-code-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.query-code-preview {
    flex: 1;
    min-width: 0;
    background: var(--kw-surface-2);
    border: 1px solid var(--kw-border);
    border-radius: 5px;
    padding: 4px 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    line-height: 1.35;
    color: var(--kw-text);
    word-break: break-all;
    max-height: 38px;
    overflow: hidden;
    white-space: pre-wrap;
    transition: max-height 0.2s ease, border-color 0.15s ease;
}

    .query-code-preview:hover {
        max-height: 200px;
        overflow-y: auto;
        border-color: var(--kw-border-strong);
    }

.query-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 4px;
    border: 1px solid var(--kw-border);
    background: var(--kw-bg);
    color: var(--kw-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

    .query-btn-icon:hover {
        background: var(--kw-surface-2);
        color: var(--kw-text);
        border-color: var(--kw-border-strong);
    }

    .query-btn-icon.copied {
        color: var(--kw-success);
        border-color: var(--kw-success);
        background: var(--kw-success-light);
    }

.query-pct-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.query-pct-bar-bg {
    width: 40px;
    height: 5px;
    background: var(--kw-surface-2);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.query-pct-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--kw-brand);
}

.query-empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--kw-text-secondary);
    font-size: 13px;
}

.query-instructions-card {
    background: var(--kw-warning-light);
    border: 1px solid var(--kw-warning);
    border-radius: var(--kw-radius-lg);
    padding: 20px;
    color: var(--kw-text);
    margin-bottom: 24px;
}

    .query-instructions-card pre {
        background: var(--kw-bg);
        padding: 12px;
        border-radius: 6px;
        border: 1px solid var(--kw-border);
        font-size: 12px;
        overflow-x: auto;
        margin: 12px 0;
    }

@media (max-width: 1024px) {
    .query-stats-grid {
        grid-template-columns: 1fr;
    }

    .query-chart-card {
        min-height: 260px;
    }
}

/* ===== Practice Batch Transition & Summary ===== */

.practice-countdown-card {
    background: var(--kw-surface-1);
    border: 2px solid var(--kw-brand);
    border-radius: var(--kw-radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.countdown-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--kw-text-primary);
}

.countdown-subtitle {
    font-size: 14px;
    color: var(--kw-text-secondary);
    margin-bottom: 14px;
}

.countdown-bar-container {
    width: 100%;
    height: 8px;
    background: var(--kw-surface-2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.countdown-bar-fill {
    height: 100%;
    background: var(--kw-brand);
    width: 100%;
    transition: width 0.1s linear;
    border-radius: 4px;
}

.countdown-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

/* Ad Slot */
.ad-slot-container {
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-lg);
    padding: 16px;
    margin-bottom: 24px;
}

.ad-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ad-slot-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--kw-text-muted);
    background: var(--kw-surface-2);
    padding: 2px 8px;
    border-radius: var(--kw-radius-sm);
}

.ad-slot-box {
    width: 100%;
    min-height: 160px;
    background: var(--kw-surface-2);
    border: 1px dashed var(--kw-border-strong);
    border-radius: var(--kw-radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--kw-text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.ad-slot-icon {
    font-size: 28px;
    color: var(--kw-text-muted);
    opacity: 0.7;
}

/* Detailed results list in practice summary */
.batch-answer-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.batch-answer-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--kw-surface-1);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius-md);
    font-size: 14px;
    line-height: 1.5;
}

.batch-answer--correct {
    border-left: 4px solid var(--kw-success);
}

.batch-answer--wrong {
    border-left: 4px solid var(--kw-danger);
}

.batch-answer-icon {
    flex-shrink: 0;
    font-size: 16px;
    font-weight: 700;
}

.batch-answer--correct .batch-answer-icon {
    color: var(--kw-success);
}

.batch-answer--wrong .batch-answer-icon {
    color: var(--kw-danger);
}

.batch-answer-text {
    flex: 1;
    color: var(--kw-text-primary);
}
