:root {
    --navy: #182433;
    --navy-light: #26374b;
    --background: #f4f6fa;
    --surface: #ffffff;
    --border: #dce3ec;
    --text: #243247;
    --muted: #64748b;
    --sidebar-width: 224px;
    --header-height: 88px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family: Arial, "Noto Sans TC",
                 "Microsoft JhengHei", sans-serif;
}

button, input, select, textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    padding: 10px 16px;
    transition: background .15s, border-color .15s;
}

button:hover:not(:disabled) {
    background: #edf2f7;
    border-color: #94a3b8;
}

button:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-height);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--navy);
    color: white;
    padding: 16px 32px;
}

.brand h1 {
    font-size: 25px;
    letter-spacing: 1.5px;
    margin: 0;
}

.brand p {
    margin: 6px 0 0;
    font-size: 13px;
    color: #cbd5e1;
}

.login-button {
    color: white;
    background: transparent;
    border-color: #64748b;
}

.app-layout {
    padding-top: var(--header-height);
}

.sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border);
    padding: 24px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-label {
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 22px 12px 10px;
}

.nav-label:first-child {
    margin-top: 0;
}

.nav-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 13px 14px;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
}

.nav-item.active {
    background: var(--navy);
    color: white;
}

.nav-item.active:hover {
    background: var(--navy-light);
}

.sidebar-footer {
    margin-top: auto;
    padding: 24px 12px 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.8;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px 40px 60px;
    max-width: 1500px;
}

.page-heading {
    margin-bottom: 26px;
}

.page-heading h2 {
    margin: 0 0 8px;
    font-size: 28px;
}

.page-heading p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

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

.grade-tabs button {
    min-width: 68px;
}

.grade-tabs button.active,
.subject-button.active {
    background: var(--navy);
    color: white;
    border-color: var(--navy);
}

.subjects {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.subject-button {
    padding: 20px 12px;
    font-size: 17px;
    font-weight: bold;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 18px;
}

.card h3 {
    margin-top: 0;
}

.card h4 {
    margin-bottom: 12px;
}

.filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.filters label,
#custom-subject-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

select,
input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px;
    color: var(--text);
    background: white;
}

textarea {
    resize: vertical;
    line-height: 1.6;
}

.toolbar,
.section-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.section-heading {
    justify-content: space-between;
    margin: 14px 0;
}

.section-heading h4 {
    margin: 0;
}

.toolbar button {
    padding: 7px 12px;
    font-size: 13px;
}

.cohorts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cohorts label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--navy);
}

.option {
    display: block;
    width: 100%;
    text-align: left;
    margin: 8px 0;
    padding: 14px;
    white-space: pre-wrap;
}

.option.selected {
    background: #e0e7ff;
    border-color: #6366f1;
}

.option.correct-option {
    background: #edf8f0;
    border-color: #16a34a;
    color: #166534;
    opacity: 1;
}

.option.wrong-option {
    background: #fff1f2;
    border-color: #dc2626;
    color: #991b1b;
    opacity: 1;
}

.result:not(:empty) {
    background: #f4f6fa;
    padding: 18px;
    margin: 16px 0;
    border-radius: 8px;
}

.correct-text {
    color: #15803d;
}

.wrong-text {
    color: #b91c1c;
}

.source,
.muted {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.preserve {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.7;
}

.secondary {
    font-size: 13px;
    color: var(--muted);
}

progress {
    width: 100%;
    height: 12px;
    accent-color: var(--navy);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

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

th {
    background: var(--background);
}

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

.choice-card,
.mode-card {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
}

.choice-card:has(input:checked),
.mode-card:has(input:checked) {
    background: #f0f4f9;
    border-color: #64748b;
}

.mode-card {
    align-items: flex-start;
    min-height: 100px;
}

.mode-card input {
    margin-top: 3px;
}

.mode-card p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
    margin: 8px 0 0;
}

.count-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.upload-zone {
    margin-top: 20px;
    padding: 32px 20px;
    text-align: center;
    border: 2px dashed #b5c2d1;
    border-radius: 12px;
    background: #f8fafc;
}

.upload-zone.dragging {
    border-color: var(--navy);
    background: #e8eef6;
}

.upload-symbol {
    font-size: 36px;
    color: var(--muted);
    margin-bottom: 10px;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.file-row button {
    flex-shrink: 0;
    font-size: 12px;
}

.primary-button {
    display: block;
    width: 100%;
    padding: 15px;
    background: var(--navy);
    color: white;
    font-weight: bold;
    margin-top: 20px;
}

.primary-button:hover:not(:disabled) {
    background: var(--navy-light);
}

#ai-summary {
    line-height: 1.9;
    font-size: 14px;
}

.current-course {
    color: var(--muted);
    font-size: 14px;
}

#message {
    color: #b91c1c;
}

#page-teachers .card,
#page-records .card {
    overflow-x: auto;
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 180px;
    }

    .main-content {
        padding: 24px;
    }

    .subjects {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters,
    .mode-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    :root {
        --header-height: 76px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .brand h1 {
        font-size: 20px;
    }

    .sidebar {
        position: sticky;
        top: var(--header-height);
        width: 100%;
        flex-direction: row;
        padding: 8px;
        gap: 4px;
        z-index: 90;
        overflow-x: auto;
        border-bottom: 1px solid var(--border);
    }

    .nav-label,
    .sidebar-footer {
        display: none;
    }

    .nav-item {
        width: auto;
        white-space: nowrap;
        margin: 0;
        padding: 10px;
        font-size: 12px;
    }

    .main-content {
        margin-left: 0;
        padding: 18px 12px;
    }

    .card {
        padding: 16px;
    }

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

    .page-heading h2 {
        font-size: 24px;
    }
}

/* V0.6.0.2 explanation and citation formatting */
.result .preserve { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.result h4 { margin: 1rem 0 .4rem; }

.analysis-content img{max-width:100%;height:auto;display:block;margin:12px 0}.analysis-content p{margin:0 0 .5em;overflow-wrap:anywhere}.analysis-content table{max-width:100%}.analysis-content{overflow-wrap:anywhere}
