@layer legacy, modern;

@layer legacy {
:root {
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #17202a;
}

.document-list {
    overflow-x: auto;
    border: 1px solid #d8dee6;
    border-radius: 10px;
    background: #fff;
}

.document-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 13px;
}

.document-table th,
.document-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #e7ebf0;
    text-align: left;
    vertical-align: middle;
}

.document-table th {
    background: #f8fafc;
    color: #475467;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.document-table tbody tr:last-child td {
    border-bottom: 0;
}

.document-table tbody tr:hover {
    background: #f8fbff;
}

.document-table td:first-child {
    max-width: 360px;
}

.document-table td strong,
.document-table td small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-table td small {
    margin-top: 2px;
    color: #667085;
    font-size: 11px;
}

.document-sort {
    width: 100%;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

.document-sort:hover:not(:disabled) {
    background: transparent;
    color: #1d4ed8;
}

.document-action-column {
    width: 58px;
    text-align: center !important;
}

.document-delete {
    display: inline-grid;
    place-items: center;
    width: 100%;
    height: 30px;
    padding: 0;
    border: 1px solid #f1b7b3;
    border-radius: 6px;
    color: #b42318;
    background: #fff;
}

.document-delete:hover:not(:disabled) {
    border-color: #d92d20;
    color: #fff;
    background: #d92d20;
}

.document-delete svg {
    width: 16px;
    height: 16px;
}

body.has-modal {
    overflow: hidden;
}

.app-modal-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgb(15 23 42 / 58%);
    backdrop-filter: blur(3px);
}

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

.app-modal {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    width: min(100%, 480px);
    padding: 24px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 70px rgb(15 23 42 / 28%);
    animation: modal-enter 140ms ease-out;
}

.app-modal-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #1d4ed8;
    background: #dbeafe;
    font-size: 20px;
    font-weight: 800;
}

.app-modal-icon.is-danger {
    color: #b42318;
    background: #fee4e2;
}

.app-modal-copy h2 {
    margin: 1px 0 7px;
    color: #101828;
    font-size: 19px;
}

.app-modal-copy p {
    margin: 0;
    color: #475467;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.app-modal-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.app-modal-actions button {
    min-width: 92px;
}

@keyframes modal-enter {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .app-modal { animation: none; }
}
}

/* Modern application theme */
@layer modern {
:root {
    --ink: #182033;
    --muted: #667085;
    --line: rgba(148, 163, 184, .25);
    --surface: rgba(255, 255, 255, .88);
    --surface-solid: #fff;
    --primary: #635bff;
    --primary-dark: #4f46e5;
    --primary-soft: #eeedff;
    --cyan: #06b6d4;
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 5px 16px rgba(16, 24, 40, .05);
    --shadow-lg: 0 20px 50px rgba(30, 41, 59, .10), 0 2px 8px rgba(30, 41, 59, .04);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f7f8fc;
    color: var(--ink);
}

html {
    min-height: 100%;
    background:
        radial-gradient(circle at 8% 5%, rgba(99, 91, 255, .12), transparent 27rem),
        radial-gradient(circle at 92% 12%, rgba(6, 182, 212, .09), transparent 25rem),
        #f7f8fc;
}

body {
    min-height: 100vh;
    background: transparent;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    pointer-events: none;
    background-image: linear-gradient(rgba(99, 91, 255, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 91, 255, .025) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, black, transparent 75%);
}

::selection {
    color: #fff;
    background: var(--primary);
}

.shell {
    width: min(1180px, calc(100% - 40px));
    margin: 24px auto 64px;
    gap: 22px;
}

.menu {
    position: sticky;
    top: 16px;
    z-index: 20;
    align-items: center;
    width: max-content;
    max-width: 100%;
    margin: 0 auto 10px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 16px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 10px 35px rgba(31, 41, 55, .10);
    backdrop-filter: blur(18px) saturate(150%);
}

.menu::before {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin: 0 5px 0 1px;
    border-radius: 10px;
    content: "AV";
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    box-shadow: 0 7px 16px rgba(99, 91, 255, .28);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: -.02em;
}

.menu a {
    position: relative;
    padding: 9px 14px;
    border-radius: 10px;
    color: #667085;
    font-size: 14px;
    font-weight: 650;
    transition: color .18s ease, background .18s ease, transform .18s ease;
}

.menu a:hover {
    color: var(--ink);
    background: #f3f4f8;
    transform: translateY(-1px);
}

.menu a.is-active {
    color: var(--primary-dark);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px rgba(99, 91, 255, .08);
}

.menu.is-disabled .menu-links {
    opacity: .45;
}

.menu.is-disabled .menu-links a {
    pointer-events: none;
}

.menu.is-disabled .menu-toggle {
    cursor: not-allowed;
    opacity: .55;
}

.menu-hamburger .menu-toggle {
    display: none;
}

.menu-hamburger .menu-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel {
    position: relative;
    overflow: hidden;
    padding: clamp(22px, 3vw, 34px);
    border: 1px solid rgba(255, 255, 255, .92);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.panel::after {
    position: absolute;
    top: 0;
    left: 28px;
    right: 28px;
    height: 1px;
    content: "";
    background: linear-gradient(90deg, transparent, rgba(99, 91, 255, .25), transparent);
}

h1, h2, h3 {
    color: #172033;
    letter-spacing: -.035em;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1.08;
}

h2 {
    margin-bottom: 18px;
    font-size: clamp(20px, 2vw, 25px);
    line-height: 1.2;
}

h3 {
    font-size: 17px;
}

p {
    color: var(--muted);
}

.page-heading > div > p,
.chat-heading > div > p,
.panel > div:first-child > p {
    max-width: 650px;
    margin-bottom: 0;
    font-size: 16px;
}

label {
    gap: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: .005em;
}

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

.checkbox-control input {
    width: 18px;
    min-height: 18px;
}

input,
textarea,
select,
button {
    min-height: 46px;
    border-radius: 11px;
}

input,
textarea,
select {
    border: 1px solid #d8dce7;
    padding: 10px 13px;
    color: var(--ink);
    background: rgba(255, 255, 255, .92);
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, .025), 0 1px 2px rgba(16, 24, 40, .025);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:hover,
textarea:hover,
select:hover {
    border-color: #b7bfd0;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 91, 255, .13), 0 4px 14px rgba(99, 91, 255, .08);
}

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

input[type="file"] {
    padding: 6px;
}

input[type="file"]::file-selector-button {
    height: 32px;
    margin-right: 10px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

textarea {
    min-height: 104px;
    line-height: 1.5;
}

button {
    position: relative;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 7px 16px rgba(79, 70, 229, .20), inset 0 1px rgba(255, 255, 255, .22);
    font-size: 14px;
    font-weight: 750;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

button:hover:not(:disabled) {
    filter: brightness(1.04);
    transform: translateY(-2px);
    box-shadow: 0 11px 22px rgba(79, 70, 229, .26), inset 0 1px rgba(255, 255, 255, .22);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:focus-visible {
    outline: 3px solid rgba(99, 91, 255, .22);
    outline-offset: 3px;
}

button:disabled {
    color: rgba(255, 255, 255, .9);
    background: #a7a7c4;
    box-shadow: none;
}

.landing-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
    align-items: center;
    gap: clamp(24px, 5vw, 64px);
    min-height: min(680px, calc(100vh - 160px));
}

.landing-copy {
    display: grid;
    gap: 14px;
}

.landing-kicker {
    width: fit-content;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 13px;
    font-weight: 800;
}

.landing-copy h1 {
    margin: 0;
    font-size: clamp(42px, 7vw, 78px);
}

.landing-copy p:not(.landing-kicker) {
    max-width: 580px;
    margin: 0;
    color: #475467;
    font-size: clamp(17px, 2vw, 21px);
}

.login-choice-grid {
    display: grid;
    gap: 14px;
}

.login-choice-button {
    display: grid;
    gap: 6px;
    min-height: 118px;
    padding: 22px;
    border: 1px solid rgba(99, 91, 255, .22);
    border-radius: 8px;
    color: #fff;
    text-align: left;
}

.login-choice-button:disabled {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 7px 16px rgba(79, 70, 229, .20), inset 0 1px rgba(255, 255, 255, .22);
    cursor: default;
}

.login-choice-button span {
    font-size: 24px;
    font-weight: 850;
}

.login-choice-button small {
    color: rgba(255, 255, 255, .84);
    font-size: 14px;
    font-weight: 750;
}

.login-choice-button.teacher {
    background: linear-gradient(135deg, #0f766e, #06b6d4);
}

.login-choice-button.teacher:disabled {
    background: linear-gradient(135deg, #0f766e, #06b6d4);
}

button.secondary {
    color: #4f46e5;
    background: #f0efff;
    box-shadow: inset 0 0 0 1px rgba(99, 91, 255, .08);
}

button.secondary:hover:not(:disabled) {
    background: #e8e7ff;
    box-shadow: 0 7px 16px rgba(79, 70, 229, .10);
}

button.danger {
    color: #b42318;
    background: #fff0ef;
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .10);
}

button.danger:hover:not(:disabled) {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 8px 18px rgba(220, 38, 38, .22);
}

.stack {
    gap: 17px;
}

.stack > button {
    justify-self: start;
}

.page-heading,
.list-heading,
.faq-question,
.faq-actions {
    gap: 22px;
}

.status {
    min-height: 0;
    margin-top: 18px;
    color: #4338ca;
    font-size: 14px;
    font-weight: 650;
}

.status:empty {
    display: none;
}

.collection-notification {
    margin: 1rem 0;
    padding: 0.9rem 1rem;
    border: 1px solid #7bc8be;
    border-left-width: 0.45rem;
    border-radius: 0.65rem;
    background: #eaf8f6;
    color: #164e4a;
    box-shadow: 0 4px 14px rgba(22, 78, 74, 0.08);
    font-weight: 650;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.collection-notification[hidden] { display: none; }

.notification-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.advanced-hidden-controls {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #f1b7b3;
    border-radius: 8px;
    background: #fff8f7;
}

.advanced-hidden-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.advanced-hidden-heading h2,
.advanced-hidden-heading p {
    margin: 0;
}

.advanced-hidden-heading p {
    margin-top: 4px;
}

.advanced-hidden-controls textarea[readonly] {
    color: #667085;
    background: #f8fafc;
}

.status:not(:empty) {
    width: fit-content;
    padding: 8px 12px;
    border: 1px solid #dcd9ff;
    border-radius: 9px;
    background: #f4f3ff;
}

.status.is-error:not(:empty) {
    color: #b42318;
    border-color: #fecaca;
    background: #fff1f2;
}

.collection-control {
    min-width: 250px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(248, 250, 252, .75);
}

.collection-picker {
    gap: 7px;
}

.output {
    min-height: 74px;
    margin: 20px 0 0;
    padding: 16px 18px;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 14px;
    color: #d5f5ef;
    background: #151827;
    box-shadow: inset 0 1px 8px rgba(0, 0, 0, .25);
    font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.results,
.faq-list,
.document-list {
    gap: 14px;
}

.result,
.faq-entry,
.document-entry {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .76);
    box-shadow: var(--shadow-sm);
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.result:hover,
.faq-entry:hover,
.document-entry:hover {
    border-color: rgba(99, 91, 255, .25);
    box-shadow: 0 12px 28px rgba(30, 41, 59, .08);
    transform: translateY(-2px);
}

.result {
    padding: 18px;
}

.document-list,
.results {
    margin-top: 20px;
}

.document-entry {
    padding: 18px 20px;
}

.document-entry h3 {
    margin-bottom: 2px;
}

.document-entry p,
.meta {
    color: var(--muted);
    font-size: 13px;
}

.faq-entry {
    gap: 15px;
    padding: 20px;
}

.faq-question {
    align-items: end;
}

.faq-question > label {
    flex: 1;
}

.faq-question .meta {
    display: inline-flex;
    align-items: center;
    min-height: 29px;
    padding: 5px 10px;
    border: 1px solid #e4e7ec;
    border-radius: 999px;
    color: #667085;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 650;
}

.faq-question .generated-flag {
    color: #7c3aed;
    border-color: #ddd6fe;
    background: #f5f3ff;
}

.faq-question .question-origin-flag[data-origin="generated"] {
    color: #7c3aed;
    border-color: #ddd6fe;
    background: #f5f3ff;
}

.faq-question .question-origin-flag[data-origin="new"] {
    color: #166534;
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.faq-question .question-origin-flag[data-origin="edited"] {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: #eff6ff;
}

.faq-question .question-origin-flag[data-origin="retrieved"] {
    color: #0f766e;
    border-color: #99f6e4;
    background: #f0fdfa;
}

.faq-list-controls {
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8f9fc;
}

.faq-list-controls label {
    gap: 3px;
    font-size: 11px;
}

.faq-list-controls select,
.faq-list-controls button {
    min-height: 38px;
}

.chat-messages {
    height: min(600px, 62vh);
    min-height: 360px;
    gap: 20px;
    margin-top: 24px;
    padding: clamp(16px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 0, rgba(99, 91, 255, .055), transparent 22rem),
        rgba(247, 248, 252, .82);
    box-shadow: inset 0 1px 3px rgba(16, 24, 40, .025);
    scrollbar-color: #c7c4ff transparent;
}

.chat-welcome {
    padding: 22px 26px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .72);
    box-shadow: var(--shadow-sm);
}

.bot-avatar,
.user-avatar {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    box-shadow: 0 5px 12px rgba(16, 24, 40, .10);
}

.bot-avatar {
    background: linear-gradient(135deg, var(--primary), var(--cyan));
}

.user-avatar {
    color: #475467;
    background: linear-gradient(135deg, #fff, #e8ebf2);
}

.message {
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 5px 17px 17px 17px;
    box-shadow: var(--shadow-sm);
}

.message-row.user .message {
    border-color: transparent;
    border-radius: 17px 5px 17px 17px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 9px 20px rgba(79, 70, 229, .20);
}

.cache-badge {
    padding: 4px 8px;
    color: #4338ca;
    background: #eeedff;
}

.chat-grid {
    gap: 10px;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 8px 22px rgba(30, 41, 59, .06);
}

.chat-grid textarea {
    min-height: 48px;
    max-height: 160px;
}

.search-grid,
.export-grid {
    gap: 10px;
}

.compare-form {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.compare-form label {
    min-width: 0;
}

.compare-process-controls {
    display: grid;
    grid-template-columns: minmax(230px, 1fr) minmax(120px, .35fr) auto;
    align-items: end;
    gap: 12px;
}

.compare-model-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 12px;
}

.compare-model-group {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.compare-model-group[hidden] {
    display: none;
}

.compare-model-group legend {
    padding: 0 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

.compare-question {
    display: grid;
}

.compare-toggle {
    min-height: 46px;
    padding: 0 4px 7px;
}

#compareStatus:not(:empty) {
    width: 100%;
    box-sizing: border-box;
}

.compare-parallel { margin: 1rem 0; padding: 1rem; border: 1px solid #718096; border-radius: 8px; }
.compare-parallel-lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 1rem; margin-top: 1rem; }
.compare-model-lane { border-top: 3px solid #3182ce; padding: 0.75rem; background: rgba(128, 128, 128, 0.08); border-radius: 6px; min-width: 0; overflow-wrap: anywhere; }
.compare-model-lane h3 { margin: 0 0 0.5rem; }
.compare-model-lane[data-state="complete"] { border-color: #25834a; }
.compare-model-lane[data-state="stopped"] { border-color: #bc4141; }
.compare-parallel-join { text-align: center; margin-bottom: 0; }

.compare-progress {
    display: grid;
    gap: 10px;
}

.compare-progress-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.compare-progress-heading strong {
    color: #172033;
}

.compare-progress-heading span {
    color: #667085;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.compare-progress-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.compare-end-test {
    min-height: 34px;
    padding: 0 12px;
    color: #b42318;
    background: #fff0ef;
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .10);
}

.compare-end-test:hover:not(:disabled) {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 8px 18px rgba(220, 38, 38, .22);
}

.compare-progress-current {
    margin: 0;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
}

.compare-progress-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 4px 12px;
    margin: 0;
    color: #475467;
    font-size: 12px;
    font-weight: 600;
}

.compare-progress-facts dt {
    color: #667085;
}

.compare-progress-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.compare-progress-steps {
    display: grid;
    gap: 5px;
    margin: 0;
    padding-left: 22px;
    color: #667085;
    font-size: 12px;
    font-weight: 600;
}

.compare-progress-steps li.is-done {
    color: #0f766e;
}

.compare-progress-steps li.is-active {
    color: #4338ca;
    font-weight: 800;
}

.compare-progress-steps time {
    color: #667085;
    font-size: 11px;
    font-weight: 700;
}

.compare-progress.is-complete .compare-progress-current {
    color: #0f766e;
}

.compare-runs {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.compare-results-grid {
    display: grid;
    gap: 12px;
}

.compare-run-headings,
.compare-result-columns {
    display: grid;
    grid-template-columns: repeat(var(--compare-run-count), minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.compare-run-heading {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
    box-shadow: var(--shadow-sm);
}

.compare-run-heading h3,
.compare-run-heading p {
    margin: 0;
}

.compare-run-heading p {
    color: var(--muted);
    font-size: 12px;
}

.compare-result-section {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
    box-shadow: var(--shadow-sm);
}

.compare-result-section[open] > summary {
    margin-bottom: 10px;
}

.compare-result-summary {
    color: #344054;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
}

.compare-result-cell {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.compare-result-cell pre {
    min-height: 110px;
    max-height: 310px;
    margin: 0;
    overflow: auto;
    padding: 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #f8fafc;
    color: #172033;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.compare-raw-panel h2 {
    margin-bottom: 12px;
}

.compare-raw-json {
    display: grid;
    gap: 10px;
}

.json-panel {
    border: 1px solid #334155;
    border-radius: 8px;
    background: #111827;
    overflow: hidden;
}

.json-panel > summary {
    padding: 10px 12px;
    cursor: pointer;
    color: #e5e7eb;
    background: #1f2937;
    font-size: 13px;
    font-weight: 800;
}

.json-panel[open] > summary {
    border-bottom: 1px solid #334155;
}

.json-code {
    max-height: 520px;
    margin: 0;
    overflow: auto;
    padding: 16px;
    background: #111827;
    color: #d1d5db;
    white-space: pre;
    tab-size: 2;
    font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.json-key {
    color: #7dd3fc;
}

.json-string {
    color: #86efac;
}

.json-number {
    color: #fbbf24;
}

.json-boolean {
    color: #c4b5fd;
}

.json-null {
    color: #fca5a5;
}

.compare-detail-block {
    display: grid;
    gap: 12px;
}

.compare-detail-block + .compare-detail-block {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.compare-detail-block > summary {
    cursor: pointer;
    color: #172033;
    font-size: 18px;
    font-weight: 800;
}

.compare-detail-block[open] > summary {
    margin-bottom: 12px;
}

.compare-prompt-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
}

.compare-prompt-block {
    display: grid;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.compare-prompt-block > summary {
    cursor: pointer;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

.compare-prompt-grid textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 260px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.compare-sources {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.compare-source-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 2px;
}

.compare-source-toolbar strong {
    color: #344054;
    font-size: 13px;
}

.compare-source-actions {
    display: inline-flex;
    gap: 8px;
}

.compare-source-actions button {
    border: 1px solid #d0d5dd;
    border-radius: 7px;
    background: #ffffff;
    color: #344054;
    width: 30px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
}

.compare-source-actions button:hover:not(:disabled) {
    border-color: #98a2b3;
    background: #f9fafb;
}

.compare-source-actions button:disabled {
    color: #98a2b3;
    cursor: default;
    opacity: .7;
}

.compare-source-action-icon::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.compare-source-action-icon.is-expand::before {
    border-top: 8px solid currentColor;
}

.compare-source-action-icon.is-collapse::before {
    border-bottom: 8px solid currentColor;
}

.compare-source {
    padding: 9px 11px;
    border: 1px solid #e4e7ec;
    border-radius: 7px;
    background: #f8fafc;
    color: #475467;
    font-size: 13px;
}

.compare-source.is-selected {
    border-color: rgba(99, 91, 255, .28);
    background: #f5f7ff;
}

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

.compare-source summary::-webkit-details-marker {
    display: none;
}

.compare-source summary::marker {
    content: "";
}

.compare-source summary strong,
.compare-source summary span {
    min-width: 0;
}

.compare-source-summary-meta {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: #667085;
    white-space: nowrap;
}

.compare-source-toggle {
    display: inline-flex;
    align-items: center;
    color: #344054;
}

.compare-source-toggle::before {
    content: "";
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid currentColor;
    transition: transform .15s ease;
}

.compare-source[open] .compare-source-toggle::before {
    transform: rotate(90deg);
}

.compare-source-meta {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 5px 12px;
    margin: 10px 0;
}

.compare-source-meta dt {
    color: #667085;
    font-weight: 700;
}

.compare-source-meta dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.compare-source-text {
    max-height: 260px;
    margin: 0;
    white-space: pre-wrap;
}

@media (max-width: 760px) {
    .menu-hamburger {
        display: grid;
        grid-template-columns: auto 1fr;
        width: 100%;
        align-items: center;
        overflow: visible;
    }

    .menu-hamburger::before {
        position: static;
    }

    .menu-hamburger .menu-toggle {
        display: inline-flex;
        justify-self: end;
        align-items: center;
        gap: 8px;
        min-height: 38px;
        padding: 0 12px;
        border-radius: 10px;
    }

    .menu-hamburger .menu-toggle::before,
    .menu-hamburger .menu-toggle::after {
        content: "";
    }

    .menu-hamburger .menu-toggle::before {
        width: 16px;
        height: 12px;
        border-top: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        box-shadow: inset 0 5px 0 transparent, 0 5px 0 currentColor;
    }

    .menu-hamburger .menu-links {
        display: none;
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        gap: 6px;
        padding-top: 8px;
    }

    .menu-hamburger.is-open .menu-links {
        display: grid;
    }

    .menu-hamburger .menu-links a {
        display: block;
        width: 100%;
    }

    .compare-process-controls,
    .compare-model-groups,
    .compare-run-headings,
    .compare-result-columns {
        grid-template-columns: 1fr;
    }

    .compare-toggle {
        min-height: 0;
        padding: 0;
    }

    .compare-progress-heading,
    .compare-source-toolbar,
    .notification-editor-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .compare-progress-heading span,
    .compare-source-actions {
        align-self: start;
    }

    .compare-source summary {
        align-items: start;
        flex-direction: column;
    }

    .compare-source-summary-meta {
        justify-content: flex-start;
        white-space: normal;
    }

    .faq-list-controls,
    .category-combobox {
        grid-template-columns: 1fr;
    }

    .faq-list-controls {
        width: 100%;
    }

    .faq-question {
        align-items: stretch;
        flex-direction: column;
    }

    .faq-question .meta {
        width: fit-content;
        white-space: normal;
    }

    .faq-actions {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 430px) {
    .shell {
        width: min(100% - 16px, 1180px);
        margin-top: 8px;
        gap: 10px;
    }

    .panel {
        padding: 16px;
        border-radius: 14px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 20px;
    }

    .page-heading,
    .list-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .collection-control {
        width: 100%;
        min-width: 0;
    }

    .collection-picker {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .faq-entry {
        padding: 14px;
    }

    .faq-actions button,
    .compare-form > button,
    .notification-editor-footer button,
    .stack > button {
        width: 100%;
    }

    .compare-result-section,
    .compare-run-heading,
    .compare-source {
        padding: 10px;
    }

    .compare-result-cell pre,
    .compare-prompt-grid textarea,
    .compare-source-text {
        font-size: 12px;
    }

    .compare-prompt-grid textarea {
        min-height: 220px;
    }
}

@media (max-width: 380px) {
    .menu-hamburger .menu-toggle {
        padding: 0 10px;
    }

    input,
    textarea,
    select,
    button {
        min-height: 44px;
    }

    .faq-list-controls {
        padding: 6px;
    }

    #compareMeta,
    .compare-run-heading p,
    .compare-progress-facts,
    .compare-source-summary-meta {
        font-size: 11px;
    }
}

/* Shared mobile navigation for every screen. */
.menu-hamburger .menu-toggle {
    display: none;
}

.menu-hamburger .menu-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-toggle-icon {
    position: relative;
    display: block;
    width: 20px;
    height: 16px;
}

.menu-toggle-icon::before,
.menu-toggle-icon::after,
.menu-toggle-icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    content: "";
    transition: transform .18s ease, top .18s ease, opacity .18s ease;
}

.menu-toggle-icon::before {
    top: 1px;
}

.menu-toggle-icon span {
    top: 7px;
}

.menu-toggle-icon::after {
    top: 13px;
}

.menu-hamburger.is-open .menu-toggle-icon::before {
    top: 7px;
    transform: rotate(45deg);
}

.menu-hamburger.is-open .menu-toggle-icon span {
    opacity: 0;
}

.menu-hamburger.is-open .menu-toggle-icon::after {
    top: 7px;
    transform: rotate(-45deg);
}

@media (max-width: 760px) {
    .menu-hamburger {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr);
        align-items: center;
        justify-content: start;
        width: 100%;
        overflow: visible;
    }

    .menu-hamburger::before {
        position: static;
        grid-column: 1;
        margin: 0;
    }

    .menu-hamburger .menu-toggle {
        display: inline-grid;
        grid-column: 2;
        place-items: center;
        width: 40px;
        min-width: 40px;
        height: 40px;
        min-height: 40px;
        margin-left: 8px;
        padding: 0;
        border: 1px solid rgba(99, 91, 255, .16);
        border-radius: 10px;
        color: #344054;
        background: #fff;
        box-shadow: 0 5px 14px rgba(16, 24, 40, .08);
    }

    .menu-hamburger .menu-toggle::before,
    .menu-hamburger .menu-toggle::after {
        content: none;
    }

    .menu-hamburger .menu-toggle-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .menu-hamburger .menu-links {
        display: none;
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        gap: 6px;
        padding-top: 10px;
    }

    .menu-hamburger.is-open .menu-links {
        display: grid;
    }

    .menu-hamburger .menu-links a {
        display: block;
        width: 100%;
        padding: 11px 12px;
    }
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 24px, 1180px);
        margin-top: 12px;
        gap: 14px;
    }

    .menu {
        top: 8px;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        border-radius: 14px;
        scrollbar-width: none;
    }

    .menu::-webkit-scrollbar {
        display: none;
    }

    .menu::before {
        position: sticky;
        left: 0;
        flex: 0 0 34px;
    }

    .menu a {
        flex: 0 0 auto;
        padding: 9px 11px;
    }

    .panel {
        padding: 20px;
        border-radius: 18px;
    }

    .list-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .faq-list-controls {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .faq-list-controls button {
        grid-column: 1 / -1;
    }

    .stack > button,
    .document-toolbar button,
    .faq-actions button {
        width: 100%;
    }

    .faq-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .landing-panel {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .login-choice-button {
        min-height: 96px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
}

@layer legacy {
* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

.menu {
    display: flex;
    gap: 8px;
}

.menu a {
    padding: 10px 14px;
    border-radius: 6px;
    color: #0f5f59;
    text-decoration: none;
    font-weight: 700;
}

.menu a:hover,
.menu a.is-active {
    background: #dff2ef;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 32px auto;
    display: grid;
    gap: 18px;
}

.panel {
    background: #ffffff;
    border: 1px solid #d8dee6;
    border-radius: 8px;
    padding: 22px;
}

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

p {
    color: #566573;
}

.stack,
.chat-grid,
.search-grid,
.export-grid {
    display: grid;
    gap: 12px;
}

.chat-grid {
    grid-template-columns: 1fr;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e9ee;
}

.chat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.chat-composer textarea {
    width: 100%;
    min-height: 52px;
    resize: vertical;
}

.chat-advanced {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.5fr) minmax(120px, .5fr);
    align-items: end;
    gap: 12px;
    margin: 0;
    padding: 12px 14px 14px;
    border: 1px solid #d8dee6;
    border-radius: 10px;
}

.chat-advanced legend {
    padding: 0 6px;
    color: #344054;
    font-weight: 700;
}

.chat-advanced label {
    display: grid;
    gap: 6px;
    color: #475467;
    font-size: 13px;
    font-weight: 700;
}

.chat-advanced select,
.chat-advanced input {
    width: 100%;
}

.search-grid {
    grid-template-columns: minmax(320px, auto) 1fr 88px auto;
}

.export-grid {
    grid-template-columns: minmax(320px, auto) auto;
    justify-content: start;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

input,
textarea,
select,
button {
    min-height: 42px;
    border-radius: 6px;
    font: inherit;
}

input,
textarea,
select {
    border: 1px solid #b8c2cc;
    padding: 8px 10px;
    background: #ffffff;
}

textarea {
    min-height: 84px;
    resize: vertical;
}

button {
    border: 0;
    padding: 0 16px;
    background: #0f766e;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

button:disabled {
    background: #8aa5a1;
    cursor: progress;
}

button.secondary {
    color: #0f5f59;
    background: #dff2ef;
}

button.danger {
    background: #b42318;
}

.page-heading,
.list-heading,
.faq-question,
.faq-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.collection-control {
    min-width: 220px;
}

.collection-picker {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(170px, 1fr);
    gap: 8px;
    min-width: 320px;
}

.status {
    min-height: 22px;
    color: #0f5f59;
}

.status.is-error {
    color: #b42318;
}

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

.document-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.document-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid #d8dee6;
    border-radius: 8px;
    padding: 16px;
}

.document-entry h3,
.document-entry p {
    margin: 0;
}

.document-toolbar {
    display: flex;
    gap: 8px;
}

.document-entry p {
    margin-top: 6px;
}

.faq-entry {
    display: grid;
    gap: 12px;
    border: 1px solid #d8dee6;
    border-radius: 8px;
    padding: 16px;
}

.faq-entry h3 {
    margin: 0;
}

.faq-question .meta {
    margin: 0;
    white-space: nowrap;
}

.faq-question .generated-flag {
    color: #8a4b08;
    font-weight: 700;
}

.faq-actions {
    justify-content: flex-end;
}

.faq-list-controls {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.output {
    min-height: 64px;
    overflow: auto;
    padding: 12px;
    background: #101820;
    color: #d7f9ef;
    border-radius: 6px;
}

.results {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.chat-output {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.chat-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.chat-heading p {
    margin-bottom: 0;
}

.chat-messages {
    height: min(560px, 60vh);
    min-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 18px;
    padding: 20px;
    border: 1px solid #d8dee6;
    border-radius: 12px;
    background: #f8fafb;
}

.chat-welcome {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: auto;
    color: #344054;
}

.chat-welcome p {
    margin: 4px 0 0;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 82%;
}

.message-row.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message-row.assistant {
    align-self: flex-start;
}

.bot-avatar,
.user-avatar {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 800;
}

.bot-avatar {
    background: #0f766e;
    color: #fff;
}

.user-avatar {
    background: #d9e2ec;
    color: #344054;
}

.message {
    padding: 11px 14px;
    border-radius: 4px 14px 14px 14px;
    background: #fff;
    border: 1px solid #d8dee6;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-row.user .message {
    color: #fff;
    background: #0f766e;
    border-color: #0f766e;
    border-radius: 14px 4px 14px 14px;
}

.message.is-thinking {
    color: #667085;
    font-style: italic;
}

.cache-badge {
    display: block;
    width: max-content;
    margin-top: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    color: #0f5f59;
    background: #dff2ef;
    font-size: 11px;
    font-weight: 700;
}

.thumb-down {
    display: inline-flex;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0 !important;
    margin: 0 0 0 .4em;
    padding: 4px !important;
    vertical-align: -.12em;
    border: 1px solid #2563eb;
    border-radius: 4px;
    background: #fff !important;
    color: #2563eb;
    font-size: 1em;
    line-height: 1;
}

.thumb-down:hover:not(:disabled),
.thumb-down.is-selected {
    border-color: #1d4ed8;
    background: #eff6ff;
    color: #1d4ed8;
}

.thumb-down.is-selected {
    opacity: 1;
    border-width: 2px;
    border-color: #1d4ed8;
    background: #dbeafe !important;
    cursor: default;
}

.thumb-down img {
    display: block;
}

.chat-answer {
    border: 1px solid #b8d8d2;
    border-radius: 8px;
    padding: 14px;
    background: #eef8f6;
    white-space: pre-wrap;
}

.chat-answer.is-empty {
    color: #566573;
    background: #f8fafb;
    border-color: #d8dee6;
}

.result {
    border: 1px solid #d8dee6;
    border-radius: 8px;
    padding: 14px;
}

.meta {
    margin-bottom: 8px;
    color: #566573;
    font-size: 14px;
}

@media (max-width: 760px) {
    .chat-grid,
    .search-grid,
    .export-grid {
        grid-template-columns: 1fr;
    }

    .chat-advanced {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .faq-question,
    .document-entry {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-messages {
        height: 55vh;
        padding: 14px;
    }

    .message-row {
        max-width: 95%;
    }

    .compare-form,
    .compare-process-controls,
    .compare-model-groups,
    .compare-run-headings,
    .compare-result-columns,
    .compare-prompt-grid {
        grid-template-columns: 1fr;
    }

    .collection-control {
        min-width: 0;
    }

    .collection-picker {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .document-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}
}

/* Unlayered table rules take precedence over the retained legacy card layout. */
.document-list {
    display: block;
    overflow-x: auto;
    border: 1px solid #d8dee6;
    border-radius: 10px;
    background: #fff;
}

.document-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 13px;
}

.document-table th,
.document-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #e7ebf0;
    text-align: left;
    vertical-align: middle;
}

.document-table th { background: #f8fafc; color: #475467; font-size: 12px; white-space: nowrap; }
.document-table tbody tr:last-child td { border-bottom: 0; }
.document-table tbody tr:hover { background: #f8fbff; }
.document-table td:first-child { max-width: 360px; }
.document-table td strong,
.document-table td small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-table td small { margin-top: 2px; color: #667085; font-size: 11px; }

.document-sort {
    width: 100%;
    padding: 7px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    text-align: left;
}

.document-sort:hover:not(:disabled) { background: transparent; color: #1d4ed8; }
.document-action-column { width: 58px; text-align: center !important; }

.document-delete {
    display: inline-grid;
    place-items: center;
    width: 100%;
    height: 30px;
    padding: 0;
    border: 1px solid #f1b7b3;
    border-radius: 6px;
    color: #b42318;
    background: #fff;
}

.document-delete:hover:not(:disabled) { border-color: #d92d20; color: #fff; background: #d92d20; }
.document-delete svg { width: 16px; height: 16px; }

.category-combobox {
    display: grid;
    grid-template-columns: minmax(170px, .8fr) minmax(180px, 1.2fr);
    gap: 8px;
}

.document-toolbar {
    align-items: end;
}

.document-type-filter {
    display: grid;
    gap: 4px;
    color: #475467;
    font-size: 12px;
    font-weight: 700;
}

.document-type-filter select {
    min-width: 170px;
}

.faq-generation-progress {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
}

.faq-generation-progress[hidden] { display: none; }

.faq-generation-progress-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.faq-generation-progress progress { width: 100%; accent-color: #2563eb; }

.faq-generation-progress strong[data-health="possibly-stalled"],
.faq-generation-progress strong[data-health^="slow"] { color: #9a6700; }

.faq-generation-progress strong[data-health="failed"] { color: #b42318; }

.faq-generation-progress strong[data-health="completed"] { color: #166534; }

/* Compact FAQ editor for large collections. */
.faq-list {
    gap: 8px;
}

.faq-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 12px 14px;
    border-radius: 10px;
}

.faq-entry:hover {
    transform: none;
}

.faq-question {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(260px, 1.4fr) minmax(330px, 1fr) auto;
    align-items: end;
    gap: 10px;
}

.faq-question > label:first-child {
    display: contents;
}

.faq-question > label:first-child .faq-field-title {
    grid-column: 1;
    grid-row: 1;
}

.faq-question > label:first-child .faq-question-input {
    grid-column: 1;
    grid-row: 2;
}

.faq-category-field {
    display: contents;
}

.faq-category-field .faq-field-title {
    grid-column: 2;
    grid-row: 1;
}

.faq-category-field .category-combobox {
    grid-column: 2 / 4;
    grid-row: 2;
}

.faq-question .meta {
    grid-column: 3;
    grid-row: 1;
    align-self: end;
    min-height: 34px;
}

.faq-field-title {
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

.faq-category-field .category-combobox {
    grid-template-columns: minmax(145px, .9fr) minmax(145px, 1.1fr);
}

.faq-answer-field {
    grid-column: 1;
    min-width: 0;
}

.faq-answer-field textarea {
    min-height: 68px;
    resize: vertical;
}

.faq-question-input {
    min-height: 38px;
    resize: vertical;
}

.faq-actions {
    display: flex;
    grid-column: 2;
    align-items: end;
    align-self: end;
    gap: 6px;
    padding-bottom: 1px;
}

.faq-icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 7px;
    background: #fff;
}

.faq-icon-button svg {
    width: 17px;
    height: 17px;
}

.faq-save {
    border: 1px solid #9bc4ff;
    color: #1d4ed8;
}

.faq-save:hover:not(:disabled) {
    border-color: #2563eb;
    color: #fff;
    background: #2563eb;
}

.faq-delete {
    border: 1px solid #f1b7b3;
    color: #b42318;
}

.faq-delete:hover:not(:disabled) {
    border-color: #d92d20;
    color: #fff;
    background: #d92d20;
}

@media (max-width: 1050px) {
    .faq-question {
        grid-template-columns: minmax(240px, 1fr) minmax(300px, 1fr);
    }
    .faq-question .meta {
        grid-column: 2;
        grid-row: 1;
        width: max-content;
        justify-self: end;
    }
    .faq-question > label:first-child .faq-question-input {
        grid-column: 1;
        grid-row: 2;
    }
    .faq-category-field .faq-field-title {
        grid-column: 1;
        grid-row: 3;
    }
    .faq-category-field .category-combobox {
        grid-column: 1 / -1;
        grid-row: 4;
    }
}

@media (max-width: 720px) {
    .faq-question { grid-template-columns: 1fr; }
    .faq-question > label:first-child .faq-field-title { grid-column: 1; grid-row: 1; }
    .faq-question .meta { grid-column: 1; grid-row: 1; justify-self: end; }
    .faq-question > label:first-child .faq-question-input { grid-column: 1; grid-row: 2; }
    .faq-category-field .faq-field-title { grid-column: 1; grid-row: 3; }
    .faq-category-field .category-combobox { grid-column: 1; grid-row: 4; }
    .faq-category-field .category-combobox { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .category-combobox { grid-template-columns: 1fr; }
}

/* FAQ Editor and Compare phone refinements. Kept unlayered so they override older page rules above. */
@media (max-width: 760px) {
    .menu-hamburger {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        width: 100%;
        overflow: visible;
    }

    .menu-hamburger::before {
        position: static;
        flex: 0 0 auto;
    }

    .menu-hamburger .menu-toggle {
        display: inline-flex;
        justify-self: end;
        align-items: center;
        gap: 8px;
        min-height: 38px;
        padding: 0 12px;
        border-radius: 10px;
    }

    .menu-hamburger .menu-toggle::before {
        width: 16px;
        height: 12px;
        border-top: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        box-shadow: 0 5px 0 currentColor;
    }

    .menu-hamburger .menu-links {
        display: none;
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        gap: 6px;
        padding-top: 8px;
    }

    .menu-hamburger.is-open .menu-links {
        display: grid;
    }

    .menu-hamburger .menu-links a {
        display: block;
        width: 100%;
    }

    .compare-process-controls,
    .compare-model-groups,
    .compare-run-headings,
    .compare-result-columns,
    .compare-prompt-grid {
        grid-template-columns: 1fr;
    }

    .compare-toggle {
        min-height: 0;
        padding: 0;
    }

    .compare-progress-heading,
    .compare-source-toolbar,
    .notification-editor-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .compare-progress-heading span,
    .compare-source-actions {
        align-self: start;
    }

    .compare-source summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .compare-source-summary-meta {
        justify-content: flex-start;
        white-space: normal;
    }

    .faq-list-controls {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .faq-list-controls button {
        grid-column: auto;
        width: 100%;
    }

    .faq-question {
        grid-template-columns: 1fr;
    }

    .faq-question .meta {
        grid-column: 1;
        grid-row: auto;
        justify-self: start;
        width: fit-content;
        max-width: 100%;
        white-space: normal;
    }

    .faq-question > label:first-child .faq-field-title,
    .faq-question > label:first-child .faq-question-input,
    .faq-category-field .faq-field-title,
    .faq-category-field .category-combobox {
        grid-column: 1;
    }

    .faq-category-field .category-combobox,
    .category-combobox {
        grid-template-columns: 1fr;
    }

    .faq-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .faq-icon-button {
        width: 100%;
    }
}

@media (max-width: 430px) {
    .shell {
        width: min(100% - 16px, 1180px);
        margin-top: 8px;
        gap: 10px;
    }

    .panel {
        padding: 16px;
        border-radius: 14px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 20px;
    }

    .page-heading,
    .list-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .collection-control,
    .collection-picker {
        width: 100%;
        min-width: 0;
    }

    .collection-picker {
        grid-template-columns: 1fr;
    }

    .faq-entry,
    .compare-result-section,
    .compare-run-heading,
    .compare-source {
        padding: 10px;
    }

    .compare-form > button,
    .notification-editor-footer button,
    .stack > button {
        width: 100%;
    }

    .compare-result-cell pre,
    .compare-prompt-grid textarea,
    .compare-source-text {
        font-size: 12px;
    }

    .compare-prompt-grid textarea {
        min-height: 220px;
    }
}

@media (max-width: 380px) {
    .menu-hamburger .menu-toggle {
        padding: 0 10px;
    }

    input,
    textarea,
    select,
    button {
        min-height: 44px;
    }

    .faq-list-controls {
        padding: 6px;
    }

    #compareMeta,
    .compare-run-heading p,
    .compare-progress-facts,
    .compare-source-summary-meta {
        font-size: 11px;
    }
}
/* Teacher session controls */
.menu-links a[aria-disabled="true"] { opacity: .4; cursor: not-allowed; text-decoration: none; }
.menu-logout[hidden], #studentLogin[hidden], #teacherLogin[hidden], #teacherAccount[hidden], #teacherClassrooms[hidden] { display: none !important; }
.menu-logout { align-self: center; }
.menu.is-disabled .menu-toggle { cursor: pointer; opacity: 1; }
.teacher-login-dialog { width: min(440px, calc(100vw - 32px)); border: 0; border-radius: 18px; padding: 28px; color: #172b4d; }
.teacher-login-dialog::backdrop { background: rgb(15 23 42 / 55%); }
.teacher-login-dialog form { display: grid; gap: 16px; }
.teacher-login-dialog h2 { margin: 0; }
.teacher-login-dialog label { display: grid; gap: 6px; }
.teacher-login-dialog input, .teacher-login-dialog select { width: 100%; box-sizing: border-box; }
.teacher-login-actions { display: flex; justify-content: flex-end; gap: 12px; }
#teacherLoginMessage { margin: 0; min-height: 1.5em; }
.classroom-panel { display: grid; gap: 14px; }
.classroom-panel[hidden], .classroom-form[hidden] { display: none !important; }
.classroom-picker { display: flex; flex-wrap: wrap; gap: 12px; }
.classroom-picker select { flex: 1; min-width: 200px; }
.classroom-form, .classroom-form label { display: grid; gap: 10px; }
.classroom-form { gap: 16px; }
.classroom-form input[name="code"] { max-width: 160px; text-transform: uppercase; }
.classroom-description { white-space: pre-wrap; overflow-wrap: anywhere; }
.classroom-table-wrapper { overflow-x: auto; }
.classroom-students { border-collapse: collapse; width: 100%; text-align: left; }
.classroom-students th, .classroom-students td { padding: 10px 14px; border-bottom: 1px solid #ddd; }
.classroom-students td, #classroomRosterText { font-family: Consolas, monospace; user-select: text; }
.classroom-copy-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.classroom-form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
#classroomCopy[data-copied="true"] { color: #fff; background: #15803d; border-color: #15803d; box-shadow: 0 0 0 3px rgb(21 128 61 / 15%); }
#classroomCopyFeedback { color: #166534; font-weight: 600; font-size: 14px; }
