:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #1d2433;
    --muted: #667085;
    --line: #d9e0ea;
    --primary: #146c63;
    --primary-dark: #0d4f49;
    --accent: #b26a00;
    --danger: #b42318;
    --ok: #087443;
    --shadow: 0 10px 30px rgba(18, 35, 61, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: 2rem;
    line-height: 1.15;
}

h2 {
    font-size: 1.15rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--text);
    font-weight: 800;
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav form {
    margin: 0;
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    cursor: pointer;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 56px;
}

.app-footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 22px;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
}

.auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 430px;
    gap: 42px;
    align-items: start;
    min-height: calc(100vh - 150px);
    padding-top: 56px;
}

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 22% 18%, rgba(203, 169, 104, 0.16), transparent 34%),
        radial-gradient(circle at 82% 72%, rgba(17, 94, 89, 0.16), transparent 32%),
        linear-gradient(135deg, #061521 0%, #0a1d2a 48%, #07101a 100%);
    color: #f6f0e6;
}

.login-page .topbar {
    background: rgba(5, 18, 29, 0.78);
    border-bottom-color: rgba(203, 169, 104, 0.22);
}

.login-page .brand {
    color: #d9bd80;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-page .shell {
    width: min(1180px, calc(100% - 32px));
}

.login-page .app-footer {
    color: rgba(215, 223, 223, 0.66);
}

.login-page .auth-grid {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
    gap: 56px;
    align-items: center;
    min-height: calc(100vh - 150px);
    padding-top: 24px;
}

.auth-copy {
    max-width: 700px;
}

.auth-logo {
    display: block;
    width: min(430px, 100%);
    margin: 0 0 30px;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

.auth-copy h1 {
    max-width: 760px;
    margin-bottom: 18px;
    color: #e3c58a;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.1rem, 5vw, 4.4rem);
    font-weight: 500;
    line-height: 1.02;
}

.auth-copy h1 span {
    color: #8aa4aa;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.7em;
}

.login-page .lead {
    max-width: 720px;
    color: #d7dfdf;
    font-size: 1.08rem;
    line-height: 1.75;
}

.auth-panel {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(203, 169, 104, 0.42);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.auth-panel h2 {
    color: #13202b;
}

.auth-panel button {
    background: #b88943;
    color: #07101a;
}

.auth-panel button:hover {
    background: #d0aa69;
}

@media (max-width: 1100px) {
    .login-page .shell {
        width: min(100% - 28px, 620px);
        padding-top: 20px;
    }

    .login-page .auth-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 22px;
        align-items: stretch;
        min-height: 0;
        padding-top: 0;
    }

    .auth-panel {
        order: 1;
        width: 100%;
        max-width: 100%;
    }

    .auth-copy {
        order: 2;
        max-width: 100%;
    }

    .auth-logo {
        width: min(220px, 60vw);
        margin: 0 auto 18px;
    }

    .auth-copy h1 {
        font-size: clamp(1.45rem, 8vw, 2.15rem);
        line-height: 1.08;
        text-align: center;
    }

    .login-page .lead {
        font-size: 0.95rem;
        line-height: 1.55;
    }
}

.lead {
    max-width: 650px;
    color: var(--muted);
    font-size: 1.08rem;
}

.panel,
.question-card,
article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 24px;
}

.narrow {
    max-width: 560px;
}

.tabs {
    display: grid;
    gap: 24px;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    min-height: 150px;
    line-height: 1.5;
    resize: vertical;
}

textarea::placeholder {
    color: #98a2b3;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
}

.button.secondary {
    background: #eef2f7;
    color: var(--text);
}

.button.secondary:hover {
    background: #e2e8f0;
}

.danger-button {
    background: var(--danger);
}

.danger-button:hover {
    background: #8f1d14;
}

.danger-button.subtle {
    min-height: 34px;
    padding: 6px 10px;
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #ffccc7;
    font-size: 0.88rem;
}

.danger-button.subtle:hover {
    background: #ffe4e0;
}

.secondary-button {
    background: #eef2f7;
    color: var(--text);
    border: 1px solid var(--line);
}

.secondary-button:hover {
    background: #e2e8f0;
}

.table-button {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 0.88rem;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.table-actions form {
    margin: 0;
}

.password-reset-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.password-reset-form input {
    width: 126px;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 0.88rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.status-badge.active {
    background: #e7f7ed;
    color: #166534;
    border: 1px solid #bbebcb;
}

.status-badge.blocked {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #d8e0ea;
}

.admin-create-user {
    margin-bottom: 20px;
}

.admin-create-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.page-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.source-counts {
    margin: 8px 0 0;
    color: var(--muted);
}

.source-counts strong {
    color: var(--text);
    font-weight: 800;
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.metrics div {
    display: grid;
    gap: 4px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metrics span,
.muted {
    color: var(--muted);
}

.metrics strong {
    font-size: 1.7rem;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.two-col > div,
.two-col > article,
section > article {
    padding: 22px;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title-row h2,
.section-title-row form {
    margin: 0;
}

.profile-list {
    display: grid;
    gap: 14px;
}

.progression-panel {
    margin-top: 20px;
}

.trend-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.trend-card {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.trend-card span {
    color: var(--muted);
}

.trend-card b {
    width: fit-content;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e8f3f1;
    color: var(--primary-dark);
    font-size: 0.78rem;
}

.trend-card small {
    color: var(--muted);
    font-weight: 700;
}

.trend-progredindo {
    border-left: 4px solid var(--ok);
}

.trend-piorando {
    border-left: 4px solid var(--danger);
}

.trend-estavel,
.trend-aguardando {
    border-left: 4px solid var(--accent);
}

.progress-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(120px, 180px) 52px;
    gap: 12px;
    align-items: center;
}

.progress-row span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

meter {
    width: 100%;
    height: 12px;
}

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

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

th,
td {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.selected-row {
    background: #edf8f6;
}

.ai-log-runs,
.ai-log-detail {
    margin-bottom: 20px;
}

.ai-log-summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.ai-log-summary-grid div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.ai-log-summary-grid span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.ai-log-summary-grid strong {
    display: block;
    margin-top: 2px;
}

.ai-log-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #d8e0ea;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
}

.ai-log-status-complete,
.ai-log-status-validado,
.ai-log-status-ok {
    border-color: #bbebcb;
    background: #e7f7ed;
    color: #166534;
}

.ai-log-status-partial,
.ai-log-status-running,
.ai-log-status-iniciado {
    border-color: #b7d8d2;
    background: #edf8f6;
    color: #0f5f56;
}

.ai-log-status-failed,
.ai-log-status-erro,
.ai-log-status-rejeitado,
.ai-log-status-descartado {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.ai-log-payload summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 800;
}

.ai-log-payload pre {
    max-width: min(620px, 76vw);
    max-height: 280px;
    overflow: auto;
    margin: 8px 0 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
}

@media (max-width: 900px) {
    .ai-log-summary-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

.notice,
.warning {
    padding: 12px 14px;
    border-radius: 6px;
    background: #fff7e6;
    color: #7a4b00;
}

.warning {
    margin-bottom: 18px;
    border: 1px solid #ffd591;
}

.danger-panel {
    border-color: #ffccc7;
}

.check-line {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    color: var(--text);
    font-weight: 600;
}

.check-line input {
    width: 18px;
    min-height: 18px;
    margin-top: 3px;
}

.exam {
    display: grid;
    gap: 18px;
}

.question-card {
    padding: 22px;
}

.question-card h2 {
    white-space: pre-wrap;
    font-size: 1rem;
    font-weight: 650;
}

.choices {
    display: grid;
    gap: 10px;
}

.choice {
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-weight: 500;
}

.choice input {
    width: 18px;
    min-height: 18px;
    margin-top: 3px;
}

.choice span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.submit-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    padding: 14px 0;
    background: linear-gradient(180deg, rgba(245, 247, 251, 0), var(--bg) 35%);
}

.exam-timer {
    position: fixed;
    right: 18px;
    bottom: 76px;
    z-index: 30;
    display: grid;
    gap: 2px;
    min-width: 132px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.exam-timer span {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.exam-timer strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    font-size: 1.2rem;
}

.processing-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(29, 36, 51, 0.45);
    backdrop-filter: blur(3px);
}

.processing-overlay[hidden] {
    display: none;
}

.processing-box {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(420px, 100%);
    padding: 28px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
}

.processing-box h2,
.processing-box p {
    margin-bottom: 0;
}

.processing-box p {
    color: var(--muted);
}

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #d9e0ea;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.is-processing {
    cursor: wait;
}

.is-processing button {
    cursor: wait;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.text-block {
    white-space: pre-wrap;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.reflection-button {
    background: #b26a00;
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(178, 106, 0, 0.22);
}

.reflection-button:hover {
    background: #8d5300;
}

.success-toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 90;
    width: min(360px, calc(100% - 32px));
    padding: 14px 18px;
    background: #087443;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.24);
    color: #ffffff;
    font-weight: 800;
    text-align: center;
    animation: toast-in 0.22s ease-out;
}

.success-toast.is-hiding {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.success-toast.error-toast {
    background: #fff1f0;
    color: var(--danger);
    border-color: #ffccc7;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reflection-hint {
    margin-bottom: 0;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.student-reflection-admin {
    margin-bottom: 22px;
    border-left: 4px solid var(--primary);
}

.question-bank-filter {
    margin-bottom: 22px;
}

.question-bank-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.question-bank-bottom-actions {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

.question-bank-list {
    display: grid;
    gap: 18px;
}

.ai-simulado-panel {
    width: min(560px, 100%);
    margin: 18px auto 0;
    border-color: #b7d8d2;
}

.ai-simulado-panel h2 {
    margin-top: 0;
}

.ai-loading-box {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid #b7d8d2;
    border-radius: 8px;
    background: #edf8f6;
    color: #0f5f56;
}

.ai-loading-box p {
    grid-column: 2;
    margin: 0;
    color: #51716c;
    font-size: 0.92rem;
}

.ai-loading-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    animation: aiPulse 1s ease-in-out infinite;
}

@keyframes aiPulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.85);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.question-bank-card {
    padding: 22px;
}

.question-bank-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

.question-bank-head h2 {
    margin-bottom: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.question-bank-stem {
    color: #111827;
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.55;
    white-space: pre-wrap;
}

.question-bank-image,
.question-image,
.question-review-image {
    margin: 14px 0;
}

.question-bank-image img,
.question-image img,
.question-review-image img {
    display: block;
    max-width: min(720px, 100%);
    max-height: 520px;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.question-bank-alternatives {
    display: grid;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.question-bank-alternative {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.question-bank-alternative span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    background: #e8edf4;
    border-radius: 50%;
    font-weight: 850;
}

.question-bank-alternative p {
    margin: 0;
    white-space: pre-wrap;
}

.question-bank-alternative.is-correct {
    background: #eefbf3;
    border-color: #a8e0bd;
}

.question-bank-alternative.is-correct span {
    background: var(--ok);
    color: #ffffff;
}

.question-bank-answer {
    margin: 12px 0 0;
    color: var(--muted);
}

.question-edit-box {
    width: min(920px, 100%);
}

.admin-question-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.alternatives-edit-grid {
    grid-template-columns: 1fr;
    align-items: start;
}

.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.52);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-box {
    position: relative;
    width: min(620px, 100%);
    max-height: min(720px, calc(100vh - 36px));
    overflow: auto;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
}

.modal-box h2 {
    padding-right: 42px;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    min-height: 36px;
    padding: 0;
    background: #eef2f7;
    color: var(--text);
    font-size: 1.1rem;
}

.modal-close:hover {
    background: #e2e8f0;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.question-delete-button {
    margin-right: auto;
}

.review-item {
    margin-bottom: 10px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.review-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.review-answer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.review-answer-grid p {
    margin: 0;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.review-alternatives-block {
    margin-top: 14px;
}

.review-alternatives-block h3 {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.review-alternatives {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.review-alternative {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.review-alternative.is-correct {
    border-color: #a8e0bd;
    background: #eefbf3;
}

.review-alternative.is-selected:not(.is-correct) {
    border-color: #ffd0c9;
    background: #fff5f3;
}

.review-letter {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e8edf4;
    font-weight: 800;
}

.review-alternative.is-correct .review-letter {
    background: var(--ok);
    color: #ffffff;
}

.review-alternative.is-selected:not(.is-correct) .review-letter {
    background: var(--danger);
    color: #ffffff;
}

.ai-commentary-block {
    margin-top: 16px;
    padding: 14px;
    border: 1px solid #b7d8d2;
    border-radius: 8px;
    background: #f3fbf9;
}

.ai-commentary-block h3,
.ai-commentary-block h4 {
    margin: 0 0 8px;
}

.ai-commentary-block h4 {
    color: #0f5f56;
    font-size: 0.94rem;
}

.ai-commentary-correct p {
    margin-top: 0;
}

.ai-commentary-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ai-commentary-list li {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.ai-commentary-list p {
    margin: 0;
}

.ai-answer-source {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #b7d8d2;
}

.ai-answer-source a {
    font-weight: 800;
}

.ai-answer-source p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.ai-history-panel {
    margin-bottom: 20px;
}

.ai-history-panel ul {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ai-history-panel li {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.ai-history-panel li:last-child {
    border-bottom: 0;
}

.ai-history-panel span {
    color: var(--muted);
}

.ok {
    color: var(--ok);
}

.bad {
    color: var(--danger);
}

code {
    padding: 2px 5px;
    border-radius: 4px;
    background: #eef2f7;
}

@media (max-width: 780px) {
    .topbar,
    .page-head,
    .nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        padding: 14px 18px;
    }

    .login-page .topbar {
        position: static;
        min-height: 52px;
        padding: 12px 16px;
    }

    .login-page .shell {
        width: min(100% - 24px, 520px);
        padding: 18px 0 34px;
    }

    .auth-grid,
    .two-col,
    .metrics,
    .admin-question-grid,
    .admin-create-form {
        grid-template-columns: 1fr;
    }

    .auth-logo {
        width: min(190px, 58vw);
        margin: 0 auto 16px;
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
    }

    .auth-copy h1 {
        margin-bottom: 12px;
        font-size: 1.85rem;
        line-height: 1.08;
        text-align: center;
    }

    .auth-copy h1 span {
        display: block;
        margin: 4px 0;
        font-size: 0.55em;
    }

    .login-page .lead {
        margin-bottom: 0;
        font-size: 0.94rem;
        line-height: 1.52;
        text-align: left;
    }

    .auth-panel {
        padding: 18px;
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    }

    .question-bank-head {
        flex-direction: column;
    }

    .question-bank-head .button,
    .question-bank-actions .button,
    .question-bank-actions button,
    .question-bank-bottom-actions .button,
    .question-bank-bottom-actions button {
        width: 100%;
    }

    .result-actions,
    .modal-actions {
        justify-content: stretch;
    }

    .result-actions .button,
    .result-actions button,
    .modal-actions .button,
    .modal-actions button {
        width: 100%;
    }

    .success-toast {
        right: 16px;
        bottom: 16px;
    }

    .modal-box {
        padding: 20px;
    }

    .progress-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 430px) {
    .login-page .brand {
        font-size: 0.92rem;
    }

    .auth-logo {
        width: min(150px, 52vw);
        margin-bottom: 12px;
    }

    .auth-copy h1 {
        font-size: 1.45rem;
    }

    .login-page .lead {
        font-size: 0.9rem;
        line-height: 1.45;
    }

    .auth-panel {
        padding: 16px;
    }

    .auth-panel h2 {
        margin-bottom: 12px;
        font-size: 1.05rem;
    }
}
