/* ==================== Edu Console UI ==================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Noto+Serif+SC:wght@500;700&display=swap');

:root {
    --bg-base: #f4ead8;
    --bg-surface: #fffaf0;
    --bg-surface-hover: #f7efdf;
    --bg-element: #efe0c3;
    --text-primary: #2c2418;
    --text-secondary: #6f604a;
    --text-muted: #95846a;
    --accent-primary: #2f5e4e;
    --accent-primary-hover: #244c3f;
    --accent-bg: #2f5e4e;
    --accent-fg: #fffaf0;
    --success: #2f7d5a;
    --danger: #b84f3f;
    --warning: #c9872d;
    --border-color: rgba(85, 61, 32, 0.18);
    --border-hover: rgba(85, 61, 32, 0.32);
    --focus-ring: rgba(47, 94, 78, 0.24);
    --touch-target: 44px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 2px 8px rgba(72, 48, 22, 0.08);
    --shadow-md: 0 18px 45px rgba(72, 48, 22, 0.12);
    --quiz-width: 1080px;
    --transition: 0.18s ease;
    --drawer-duration: 260ms;
    --drawer-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--bg-base);
}

body {
    font-family: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(circle at top, rgba(255, 247, 226, 0.92) 0, rgba(244, 234, 216, 0.8) 28%, rgba(236, 220, 190, 0.94) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 15%, rgba(47, 94, 78, 0.08) 0, transparent 32%),
        radial-gradient(circle at 85% 10%, rgba(201, 135, 45, 0.1) 0, transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 35%);
    z-index: -1;
}

a {
    color: inherit;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    transform: translateY(-140%);
    padding: 10px 14px;
    border: 1px solid var(--border-hover);
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: transform var(--transition);
}

.skip-link:focus-visible {
    transform: translateY(0);
    outline: 2px solid transparent;
    box-shadow: 0 0 0 4px var(--focus-ring), var(--shadow-md);
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 24px 40px;
}

header {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
    margin-bottom: 32px;
    padding: 18px 20px;
    background: rgba(255, 250, 240, 0.72);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, var(--accent-bg), var(--warning));
}

header h1,
.login-header h1,
.card h2,
.modal-header h3,
.result-card h2 {
    font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
    letter-spacing: 0.01em;
}

header h1 {
    font-size: clamp(1.25rem, 1rem + 1vw, 1.9rem);
    line-height: 1.25;
}

.brand-block {
    position: relative;
    z-index: 1;
}

.brand-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-bottom: 8px;
    padding: 0 9px;
    border: 1px solid rgba(47, 94, 78, 0.22);
    border-radius: 999px;
    background: rgba(47, 94, 78, 0.08);
    color: var(--accent-primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px;
    border-radius: 16px;
    background: rgba(255, 250, 240, 0.78);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}

.nav-btn.active {
    color: var(--accent-fg);
    background: var(--accent-bg);
    border-color: var(--accent-bg);
    box-shadow: 0 10px 24px rgba(47, 94, 78, 0.22);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.card {
    position: relative;
    background: rgba(255, 250, 240, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, rgba(47, 94, 78, 0.42), rgba(201, 135, 45, 0.28), transparent 82%);
}

.card h2 {
    font-size: clamp(1.1rem, 0.95rem + 0.65vw, 1.45rem);
    font-weight: 700;
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.answer-input {
    width: 100%;
    min-height: var(--touch-target);
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.answer-input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group textarea:focus,
.answer-input:focus {
    outline: 2px solid transparent;
    border-color: rgba(47, 94, 78, 0.5);
    box-shadow: 0 0 0 4px var(--focus-ring);
    background: rgba(255, 255, 255, 0.9);
}

.fill-blank-inputs {
    display: grid;
    gap: 14px;
}

.fill-blank-field {
    display: grid;
    gap: 6px;
}

.fill-blank-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
}

.form-group textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.7;
}

.editor-input {
    width: 100%;
    min-height: var(--touch-target);
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.editor-input::placeholder {
    color: var(--text-muted);
}

.editor-input:focus {
    outline: 2px solid transparent;
    border-color: rgba(47, 94, 78, 0.5);
    box-shadow: 0 0 0 4px var(--focus-ring);
    background: rgba(255, 255, 255, 0.9);
}

textarea.editor-input {
    resize: vertical;
    line-height: 1.7;
}

.btn,
.btn-toggle,
.btn-clear,
.modal-close {
    -webkit-tap-highlight-color: transparent;
}

.btn,
.nav-btn,
.sheet-item {
    touch-action: manipulation;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--touch-target);
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), color var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: var(--accent-bg);
    color: var(--accent-fg);
    box-shadow: 0 12px 24px rgba(47, 94, 78, 0.18);
}

.btn.primary:hover {
    background: var(--accent-primary-hover);
}

.btn.secondary {
    background: rgba(255, 250, 240, 0.82);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-hover);
}

.btn.success {
    background: var(--success);
    color: #fff;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn.full-width {
    width: 100%;
}

.btn.small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.btn:focus-visible,
.nav-btn:focus-visible,
.sheet-item:focus-visible,
.btn-toggle:focus-visible,
.btn-clear:focus-visible,
.modal-close:focus-visible,
.option-item:focus-within,
.form-group input:focus-visible,
.form-group textarea:focus-visible,
.answer-input:focus-visible {
    outline: 2px solid transparent;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.upload-area {
    position: relative;
    display: grid;
    gap: 12px;
    align-items: center;
    min-height: 180px;
    padding: 28px;
    border: 1px dashed rgba(85, 61, 32, 0.32);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 250, 240, 0.95), rgba(239, 224, 195, 0.66));
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition);
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 16px;
    border: 1px solid rgba(85, 61, 32, 0.08);
    border-radius: 14px;
    background: repeating-linear-gradient(0deg, transparent 0 23px, rgba(85, 61, 32, 0.045) 24px);
    pointer-events: none;
}

.upload-content,
.upload-progress,
.upload-success {
    position: relative;
    z-index: 1;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-bg);
    background: linear-gradient(180deg, rgba(255, 250, 240, 1), rgba(223, 234, 223, 0.82));
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.upload-content {
    text-align: center;
}

.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 64px;
    margin-bottom: 10px;
    padding: 0 14px;
    border-radius: 18px;
    background: rgba(47, 94, 78, 0.1);
    color: var(--accent-primary);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.upload-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-hint {
    margin-top: 4px;
    color: var(--text-muted) !important;
    font-size: 12px !important;
}

.upload-success {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--success);
    font-size: 14px;
    font-weight: 600;
}

.btn-clear {
    border: none;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fade 0.18s ease;
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}

.form-group .checkbox-label {
    display: flex;
    margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
    flex: 0 0 auto;
    accent-color: var(--accent-bg);
    width: 18px;
    height: 18px;
}

.form-group .checkbox-label input[type="checkbox"] {
    width: auto;
    padding: 0;
}

.exams-list,
.users-list,
.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.exam-item,
.user-item,
.option-item,
.question-preview,
.result-stats .stat-item,
.practice-option,
.answer-feedback,
.modal-content,
.card,
.login-card {
    border-radius: 18px;
}

.exam-item,
.user-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.82);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.exam-item::before {
    content: '';
    position: absolute;
    inset: 14px auto 14px 0;
    width: 4px;
    border-radius: 0 999px 999px 0;
    background: var(--accent-bg);
    opacity: 0.72;
}

.exam-item:hover,
.user-item:hover,
.question-preview:hover {
    border-color: var(--border-hover);
}

.exam-info h3,
.user-item-name {
    font-size: 15px;
    font-weight: 700;
}

.exam-info,
.user-item-info,
.exam-actions,
.user-item-actions {
    position: relative;
    z-index: 1;
}

.exam-meta {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.exam-actions,
.user-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.empty-message {
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* Quiz UI */
.quiz-layout {
    --answer-sheet-width: 280px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--answer-sheet-width);
    gap: 20px;
    max-width: var(--quiz-width);
    margin: 0 auto;
    align-items: start;
    transition: grid-template-columns var(--drawer-duration) var(--drawer-ease);
}

.quiz-layout.sheet-collapsed {
    --answer-sheet-width: 64px;
}

.quiz-main {
    min-width: 0;
}

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

.quiz-header h2 {
    border: none;
    margin: 0;
    padding: 0;
}

.quiz-progress {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
}

.quiz-progress,
.sheet-item,
.stat-value {
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    height: 8px;
    margin-bottom: 22px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(85, 61, 32, 0.12);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-bg), #3f7a66);
    transition: width 0.25s ease;
}

.question-type {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    margin-bottom: 14px;
    padding: 0 10px;
    border: 1px solid rgba(85, 61, 32, 0.18);
    border-radius: 999px;
    background: rgba(47, 94, 78, 0.08);
    color: var(--accent-primary);
    font-size: 12px;
    font-weight: 700;
}

.question-text {
    margin-bottom: 20px;
    font-size: clamp(1rem, 0.95rem + 0.4vw, 1.18rem);
    font-weight: 700;
    line-height: 1.75;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.9);
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.option-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.option-item.selected {
    border-color: var(--accent-bg);
    background: rgba(223, 234, 223, 0.72);
}

.option-item.correct {
    border-color: var(--success);
    background: rgba(223, 245, 232, 0.82);
}

.option-item.wrong {
    border-color: var(--danger);
    background: rgba(250, 230, 226, 0.88);
}

.option-item input {
    flex: 0 0 auto;
    accent-color: var(--accent-bg);
}

.option-item label {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.55;
}

.quiz-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
}

.answer-sheet-sidebar {
    position: sticky;
    top: 20px;
    width: 100%;
    min-width: 0;
}

.answer-sheet-card {
    padding: 22px;
    transition: padding var(--drawer-duration) var(--drawer-ease), box-shadow var(--transition), background var(--transition);
}

.answer-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    transition: margin-bottom var(--drawer-duration) var(--drawer-ease);
}

.answer-sheet-header h3 {
    max-width: 92px;
    min-width: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    transition: max-width var(--drawer-duration) var(--drawer-ease), opacity 140ms ease, transform var(--drawer-duration) var(--drawer-ease);
}

.answer-sheet-body {
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    transform: translateX(0);
    transition: grid-template-rows var(--drawer-duration) var(--drawer-ease), opacity 160ms ease, transform var(--drawer-duration) var(--drawer-ease);
}

.answer-sheet-body-inner {
    min-height: 0;
    overflow: hidden;
}

.btn-toggle {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    inline-size: 44px;
    block-size: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid rgba(85, 61, 32, 0.14);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 250, 240, 0.96), rgba(246, 240, 227, 0.84));
    color: var(--accent-primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 0 0 1px rgba(255, 255, 255, 0.32),
        0 4px 10px rgba(72, 48, 22, 0.06);
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), color var(--transition), transform var(--transition);
}

.btn-toggle:hover {
    border-color: rgba(47, 94, 78, 0.28);
    color: var(--accent-primary-hover);
    background: linear-gradient(180deg, rgba(255, 250, 240, 1), rgba(239, 231, 214, 0.92));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.96),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4),
        0 6px 14px rgba(72, 48, 22, 0.08);
    transform: translateY(-1px);
}

.btn-toggle:focus-visible {
    outline: 2px solid transparent;
    box-shadow:
        0 0 0 4px rgba(47, 94, 78, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.96),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4),
        0 6px 14px rgba(72, 48, 22, 0.08);
}

.answer-sheet-stats {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.answer-sheet-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.sheet-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    min-height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 250, 240, 0.85);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: transform var(--transition), border-color var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
}

.sheet-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.sheet-item.current {
    border-color: var(--accent-bg);
    color: var(--accent-bg);
    background: rgba(223, 234, 223, 0.72);
}

.sheet-item.answered {
    border-color: rgba(47, 94, 78, 0.26);
    color: var(--text-primary);
    background: rgba(223, 234, 223, 0.46);
}

.sheet-item.correct {
    border-color: var(--success);
    color: var(--success);
    background: rgba(223, 245, 232, 0.84);
}

.sheet-item.wrong {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(250, 230, 226, 0.9);
}

.answer-sheet-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    color: var(--text-muted);
    font-size: 12px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border: 1px solid;
    border-radius: 999px;
}

.legend-dot.current {
    border-color: var(--accent-bg);
}

.legend-dot.correct {
    border-color: var(--success);
}

.legend-dot.wrong {
    border-color: var(--danger);
}

.legend-dot.unanswered {
    border-color: var(--border-color);
}

/* Feedback & Results */
.answer-feedback {
    display: none;
    margin-top: 22px;
    padding: 18px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.92);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
}

.answer-feedback.correct {
    border-color: rgba(47, 125, 90, 0.4);
    background: rgba(223, 245, 232, 0.9);
    color: var(--success);
}

.answer-feedback.wrong {
    border-color: rgba(184, 79, 63, 0.4);
    background: rgba(250, 230, 226, 0.92);
    color: var(--danger);
}

.feedback-icon,
.feedback-text {
    font-weight: 700;
}

.correct-answer {
    margin-top: 10px;
    color: var(--text-primary);
}

.answer-analysis {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-left: 4px solid currentColor;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.45);
    color: var(--text-secondary);
    text-align: left;
    font-size: 13px;
}

.answer-analysis-title {
    color: var(--text-primary);
}

.answer-analysis-content {
    display: inline-block;
    margin-top: 4px;
    color: var(--text-secondary);
}

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

.result-card h2 {
    font-size: clamp(1.4rem, 1.2rem + 0.6vw, 1.9rem);
    margin-bottom: 28px;
    border: none;
    padding-bottom: 0;
}

.result-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
}

.result-stats .stat-item {
    min-width: 140px;
    padding: 22px 20px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.9);
    box-shadow: var(--shadow-sm);
}

.result-stats .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-stats .stat-label {
    display: block;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

#result-content {
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}

.analysis-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.analysis-summary > div {
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: rgba(239, 224, 195, 0.48);
}

.summary-label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.analysis-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.editor-actions {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 16px 0 0;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: rgba(255, 250, 240, 0.94);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.analysis-divider {
    margin: 16px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.question-preview {
    margin-bottom: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.88);
    box-shadow: var(--shadow-sm);
}

.question-preview .q-type {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    margin-right: 8px;
    margin-bottom: 8px;
    padding: 0 8px;
    border: 1px solid rgba(47, 94, 78, 0.18);
    border-radius: 999px;
    color: var(--accent-primary);
    font-size: 12px;
    font-weight: 700;
}

.question-preview .q-text {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.65;
}

.question-preview .q-answer {
    color: var(--success);
    font-size: 13px;
    font-weight: 600;
}

.question-preview .q-analysis {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

/* User & Admin */
.admin-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.user-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-item-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--accent-bg);
    color: var(--accent-fg);
    font-size: 12px;
    font-weight: 700;
}

.user-item-badge.normal {
    background: rgba(255, 250, 240, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(58, 42, 20, 0.55);
    backdrop-filter: blur(6px);
}

.modal-content {
    width: 100%;
    max-width: 440px;
    padding: 28px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.98);
    box-shadow: var(--shadow-md);
}

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

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-description {
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 14px;
}

.practice-settings-content {
    max-width: 500px;
}

.practice-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.practice-option {
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.86);
}

.practice-option input {
    margin-top: 4px;
}

.practice-option span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.practice-option strong {
    color: var(--text-primary);
    font-size: 14px;
}

.practice-option small {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.modal-close {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 250, 240, 0.7);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.modal-close:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px 36px;
    border: 1px solid var(--border-color);
    background: rgba(255, 250, 240, 0.94);
    box-shadow: var(--shadow-md);
}

.login-header {
    margin-bottom: 28px;
    text-align: center;
}

.login-header h1 {
    font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-error {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(184, 79, 63, 0.4);
    border-radius: 14px;
    background: rgba(250, 230, 226, 0.9);
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

/* Toasts */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 1000;
    transform: translateX(-50%) translateY(18px);
    min-width: 220px;
    max-width: min(92vw, 460px);
    padding: 12px 18px;
    border-radius: 14px;
    background: var(--text-primary);
    color: var(--bg-surface);
    opacity: 0;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition), opacity var(--transition);
    font-size: 14px;
    font-weight: 700;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
    color: #fff;
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

.toast.warning {
    background: var(--warning);
    color: #2c2418;
}

footer {
    padding: 24px 12px 0;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.upload-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(47, 94, 78, 0.22);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.answer-sheet-sidebar.collapsed .answer-sheet-card {
    padding: 10px 8px;
}

.answer-sheet-sidebar.collapsed .answer-sheet-header {
    gap: 0;
    justify-content: center;
    margin-bottom: 0;
}

.answer-sheet-sidebar.collapsed .answer-sheet-header h3 {
    max-width: 0;
    opacity: 0;
    transform: translateX(8px);
}

.answer-sheet-sidebar.collapsed .answer-sheet-body {
    grid-template-rows: 0fr;
    opacity: 0;
    transform: translateX(12px);
}

.answer-sheet-sidebar.collapsed .btn-toggle {
    border-color: rgba(47, 94, 78, 0.24);
    color: var(--accent-primary-hover);
    background: linear-gradient(180deg, rgba(241, 247, 242, 0.98), rgba(225, 236, 227, 0.92));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.98),
        inset 0 0 0 1px rgba(255, 255, 255, 0.36),
        0 6px 14px rgba(47, 94, 78, 0.08);
}

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

@media (max-width: 920px) {
    header {
        grid-template-columns: 1fr;
    }

    .header-right {
        justify-content: flex-start;
    }

    .quiz-layout {
        grid-template-columns: 1fr;
    }

    .answer-sheet-sidebar,
    .answer-sheet-sidebar.collapsed {
        position: static;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px 14px 28px;
    }

    header {
        padding: 16px;
        margin-bottom: 22px;
    }

    nav {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        overflow-x: visible;
    }

    .nav-btn {
        width: 100%;
        min-height: 38px;
        padding: 0 10px;
        white-space: normal;
        line-height: 1.2;
    }

    #admin-nav-btn {
        grid-column: 1 / -1;
    }

    .card,
    .login-card,
    .modal-content {
        padding: 22px;
    }

    .quiz-actions,
    .modal-actions,
    .exam-actions,
    .user-item-actions {
        width: 100%;
    }

    .quiz-actions .btn,
    .modal-actions .btn,
    .exam-actions .btn,
    .user-item-actions .btn {
        flex: 1 1 180px;
    }

    .answer-sheet-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }

    .result-stats {
        gap: 12px;
    }
}

@media (max-width: 520px) {
    .login-card {
        padding: 20px;
    }

    .quiz-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .quiz-actions,
    .modal-actions {
        flex-direction: column;
    }

    .quiz-actions .btn,
    .modal-actions .btn,
    .result-actions .btn,
    .exam-actions .btn,
    .user-item-actions .btn {
        width: 100%;
        flex: 1 1 auto;
    }

    .answer-sheet-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }

    .exam-item,
    .user-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .answer-sheet-stats,
    .result-stats {
        flex-direction: column;
    }
}

@media (max-width: 420px) {
    .container {
        padding-inline: 10px;
    }

    .card,
    .login-card,
    .modal-content {
        border-radius: 18px;
    }

    .question-text {
        font-size: 1rem;
    }
}
