:root {
    --bg-primary: #131a2b;
    --bg-secondary: #1a2338;
    --bg-card: #202b45;
    --bg-card-hover: #283655;
    --border: #32435f;
    --border-focus: #fbbf24;
    --text-primary: #e8eaed;
    --text-secondary: #b6c2d9;
    --text-muted: #8e9ab4;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Force light text everywhere */
h1, h2, h3, h4, h5, h6, p, span, div, label, li, strong, td, th {
    color: inherit;
}

.text-light { color: #ffffff !important; }
.text-muted { color: var(--text-secondary) !important; font-size: 0.85rem; }

/* HEADER */
#sticky-context {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
}
body.has-presence-bar #sticky-context {
    top: 44px;
}
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 1;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.header-right .btn { flex-shrink: 0; }

.app-header .hamburger-btn { order: 0; }
#btn-users {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: auto !important;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge.connected,
.status-badge.configured {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.disconnected {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* MAIN */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* STEPS */
.step { margin-bottom: 2rem; }

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #1a1d27;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.step-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    color: #ffffff;
}

.step-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

#grading-locked-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* CARDS */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

/* FORMS */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    transition: border-color var(--transition);
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.15);
}

textarea {
    resize: vertical;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
}

.form-actions {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #1a1d27;
    font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #0f1117; }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-xs { padding: 0.25rem 0.6rem; font-size: 0.7rem; border-radius: 4px; }

.card-precalc {
    margin-top: 0.25rem;
}

.btn-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.btn-warning {
    background: var(--warning);
    color: #000;
    font-weight: 700;
}
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-danger {
    background: var(--error);
    color: white;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

/* TOGGLE */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

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

/* STUDENTS GRID */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

.student-card-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.student-checkbox-label {
    display: flex;
    align-items: center;
    padding: 0 0.5rem 0 0.25rem;
    cursor: pointer;
}

.student-check {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

button.student-card {
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    flex: 1;
}

.student-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-primary);
}

.student-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.student-card.graded {
    opacity: 0.55;
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.04);
}

.student-card.graded .student-avatar {
    background: var(--success);
    opacity: 0.7;
}

.student-card.graded .student-status {
    color: var(--success);
}

.graded-wrapper {
    order: 999;
}

.student-card.regraded {
    opacity: 1;
    border-color: rgba(167, 139, 250, 0.65);
    background: rgba(167, 139, 250, 0.10);
}

.student-card.regraded .student-avatar {
    background: #a78bfa;
    color: #241046;
    opacity: 1;
}

.student-card.regraded .student-name {
    color: #ddd0ff;
}

.status-tag-regraded {
    background: rgba(167, 139, 250, 0.18);
    color: #c4b5fd;
    border: 1px solid rgba(167, 139, 250, 0.55);
    font-weight: 700;
}

.student-card.late {
    opacity: 1;
    border-color: rgba(239, 68, 68, 0.72);
    border-width: 1px;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4), 0 12px 28px rgba(239, 68, 68, 0.18);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.07));
}

.student-card.late .student-avatar {
    background: #ef4444;
    color: #2b0b0b;
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.45);
}

.student-card.late .student-name {
    color: #ffd2d2;
    text-shadow: 0 0 7px rgba(239, 68, 68, 0.32);
}

.student-card.late .student-status {
    color: #ffb4b4;
    font-weight: 700;
}

.late-wrapper {
    order: 1000;
}

.student-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #1a1d27;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.student-info {
    flex: 1;
    min-width: 0;
}

.student-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
}

.student-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-tag-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-tag-graded {
    background: var(--success-bg);
    color: var(--success);
}

.status-tag-late {
    background: rgba(239, 68, 68, 0.28);
    color: #ff8080;
    border: 1px solid rgba(239, 68, 68, 0.68);
    font-weight: 800;
    text-shadow: 0 0 8px rgba(255, 77, 79, 0.35);
}

/* BATCH BAR */
.batch-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.batch-count {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.9rem;
}

/* BATCH RESULTS */
.batch-result-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: opacity 0.3s ease;
}

.batch-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.batch-skipped {
    opacity: 0.5;
    padding: 0.75rem 1rem;
}

.batch-error {
    border-color: rgba(239, 68, 68, 0.3);
    padding: 0.75rem 1rem;
}

/* GRADING LAYOUT */
.grading-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.student-info-card .student-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.student-info-card .student-avatar {
    width: 52px;
    height: 52px;
    font-size: 1.2rem;
}

.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: baseline;
}

.file-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-right: 0.25rem;
}

.file-link {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

.file-link:hover {
    color: var(--accent-hover);
}

.file-links-disabled .file-link {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.file-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--accent);
}

.file-downloadable {
    cursor: pointer;
    transition: all var(--transition);
}

.file-downloadable:hover {
    background: rgba(251, 191, 36, 0.25);
    border-color: var(--accent);
}

.file-downloadable::before { content: ""; }

/* ALERTS */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin: 0.75rem 0;
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

/* Entrega fuera de plazo: aviso destacado para que no pase desapercibido.
   Solo aplica al #deadline-warning; los demas .alert-warning siguen en ambar. */
#deadline-warning.alert-warning {
    background: #b91c1c;
    border: 1px solid #fbbf24;
    color: #fde047;
    font-size: 1rem;
    font-weight: 600;
    padding: 1rem 1.15rem;
}

#deadline-warning.alert-warning strong {
    color: #fef08a;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

/* ANALYSIS */
.quality-badge {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.quality-alta { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.quality-media { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.quality-baja { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }

.confidence-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.rubric-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.rubric-item {
    display: block;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.rubric-item .criterion-name {
    display: block;
    width: 100%;
    margin-bottom: 0.45rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
}

.rubric-item .criterion-mark {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.mark-cumple {
    background: var(--success-bg);
    color: var(--success);
}

.mark-no-cumple {
    background: var(--error-bg);
    color: var(--error);
}

/* Rubric editable select */
.rubric-select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--bg-card);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='M3 5.2l4 4 4-4' fill='none' stroke='%23e8eaed' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.7rem center;
    background-size: 14px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem 0.4rem 2.05rem;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
}
.rubric-select::-ms-expand { display: none; }
.rubric-select option {
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-size: 0.85rem;
    line-height: 1.4;
    background: #1a2338;
    color: #e8eaed;
}

.rubric-select:focus {
    border-color: var(--accent);
    outline: none;
}

.rubric-item .criterion-reason,
.rubric-item .criterion-ai-note {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.35rem;
}
.rubric-item .criterion-reason {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.analyze-btn-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-evaluate {
    padding: 0.65rem 1.35rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-enable-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

.btn-enable-icon:hover {
    background: rgba(245, 158, 11, 0.35);
}

.rubric-all-cumple-wrap {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.rubric-all-cumple-wrap .btn {
    padding: 0.6rem 1.5rem;
    font-weight: 600;
}

@media (max-width: 600px) {
    .rubric-all-cumple-wrap {
        gap: 1.2rem;
        flex-direction: column;
        align-items: stretch;
        padding: 0 1rem;
    }
    .rubric-all-cumple-wrap .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
}

h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

.tag-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.tag-list li {
    padding: 0.25rem 0.65rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.feedback-editor {
    margin-bottom: 1rem;
}

.feedback-editor textarea {
    min-height: 160px;
}

.tokens-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

/* SUBMIT */
.submit-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* LOADING & EMPTY STATES */
.loading-state, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* TOASTS */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.toast {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    max-width: 380px;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow);
}

.toast.success { background: #065f46; color: #a7f3d0; border: 1px solid rgba(16,185,129,0.4); }
.toast.error { background: #7f1d1d; color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); }
.toast.info { background: #2d2510; color: #fcd34d; border: 1px solid rgba(251,191,36,0.4); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* HAMBURGER BUTTON */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.hamburger-btn:hover {
    background: var(--bg-card-hover);
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger-btn.open .hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.hamburger-btn.open .hamburger-line:nth-child(2) {
    opacity: 0;
}
.hamburger-btn.open .hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .students-grid { grid-template-columns: 1fr; }
    .main-content { padding: 1rem; }
    .app-header { padding: 0.5rem 1rem; flex-wrap: wrap; }
    .logo h1 { font-size: 1rem; }
    .step-header { flex-direction: column; align-items: flex-start; }
    .step-actions { width: 100%; }
    .card { padding: 1rem; }
    .rubric-item { flex-direction: column; align-items: stretch; }
    .submit-actions { flex-direction: column; }
    .submit-actions .btn { width: 100%; justify-content: center; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .batch-bar { flex-direction: column; align-items: flex-start; }

    .hamburger-btn {
        display: flex;
    }

    .header-right {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
        margin-top: 0.5rem;
    }

    .header-right.open {
        display: flex;
    }

    .header-right .btn {
        width: 100%;
        justify-content: center;
    }
}

/* AUTH PAGES */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.auth-card h2 {
    color: #ffffff;
    margin-bottom: 1.5rem;
}

.auth-card label {
    color: var(--text-secondary);
}

/* BREADCRUMB NAV */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.breadcrumb-nav a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.breadcrumb-nav a:hover { text-decoration: underline; }
.breadcrumb-nav .sep { color: var(--text-muted); }
.breadcrumb-nav .current { color: #ffffff; font-weight: 600; }

/* CONFIG CARDS */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

button.config-card,
.config-card {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: inherit;
    text-align: left;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--text-primary);
}

.config-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.config-card .card-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: #ffffff;
    flex: 1;
    min-width: 0;
}

.config-card .card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.card-pending.pending-zero {
    color: var(--text-muted);
}

.card-pending.pending-some {
    color: var(--warning);
    font-weight: 600;
}

.card-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-order-btns {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex-shrink: 0;
}

.card-order-btns .btn-order {
    width: 1.5rem;
    height: 1.2rem;
    padding: 0;
    font-size: 0.65rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.card-order-btns .btn-order:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}


.assignment-draggable {
    cursor: grab;
}

.assignment-draggable .card-drag-handle {
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    border: 1px dashed transparent;
    flex-shrink: 0;
}

.assignment-draggable .card-drag-handle:hover {
    color: var(--accent);
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.08);
}

.assignment-draggable.dragging {
    opacity: 0.65;
}

.assignment-draggable.drag-over {
    border-style: dashed;
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.card-edit-link {
    font-size: 1.1rem;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition), color var(--transition), transform 0.1s ease;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.config-card:hover .card-edit-link {
    opacity: 1;
}

.card-edit-link:hover {
    color: var(--accent);
    background: rgba(251, 191, 36, 0.15);
}

.card-edit-link:active {
    transform: scale(0.9);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.form-hint code {
    background: var(--bg-primary);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    color: var(--accent);
}

.config-card .card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

button.add-card,
.add-card {
    border: 2px dashed var(--border);
    background: transparent;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: 'DM Sans', -apple-system, sans-serif;
}
.add-card:hover { border-color: var(--accent); color: var(--accent); background: rgba(251,191,36,0.05); }

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 700px;
    min-height: 200px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.modal h3 {
    margin-bottom: 1rem;
    color: #ffffff;
}

.modal .form-actions {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.diagnostic-section {
    margin-top: 1rem;
}
.diagnostic-section h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.diagnostic-list {
    list-style: none;
    padding-left: 0;
    max-height: 200px;
    overflow-y: auto;
}
.diagnostic-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.diagnostic-list li:last-child {
    border-bottom: none;
}

/* ─── URL Reference (caso practico) ─── */

.url-reference {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.url-reference summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
}

.url-reference-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-top: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ─── Course Preview ─── */

.course-preview-iframe {
    width: 100%;
    height: 400px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
}

.form-link {
    display: inline-block;
    color: var(--accent);
    font-size: 0.82rem;
    word-break: break-all;
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
}

.form-link:hover {
    text-decoration: underline;
}

/* ─── Role permissions help ─── */

.role-permissions-help {
    margin: 0.75rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
}

.role-permissions-help summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 500;
}

.role-perms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.role-perm-card {
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}

.role-perm-card strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--accent);
    font-size: 0.95rem;
}

.role-perm-section {
    margin-bottom: 0.6rem;
}

.role-perm-section:last-child {
    margin-bottom: 0;
}

.role-perm-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.role-perm-section.role-perm-no .role-perm-label {
    color: var(--danger, #c53030);
}

.role-perm-card ul {
    margin: 0;
    padding-left: 1rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.role-perm-card li {
    margin-bottom: 0.2rem;
}

/* ─── Permissions config ─── */

.perm-role-section {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.perm-role-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: var(--accent);
}

.perm-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.perm-check {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.perm-check input {
    margin-top: 0.2rem;
}

/* ─── User Management ─── */

.users-list {
    margin-bottom: 1rem;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.user-row.user-disabled {
    opacity: 0.6;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-role {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: rgba(251, 191, 36, 0.15);
    border-radius: 3px;
    color: var(--accent);
}

.user-enabled {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-actions {
    display: flex;
    gap: 0.35rem;
}

/* ─── Color Picker ─── */

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-input {
    width: 40px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    cursor: pointer;
}

.color-presets {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-dot:hover {
    transform: scale(1.2);
    border-color: rgba(255,255,255,0.4);
}

/* ─── Grading Locked ─── */

.grading-locked {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.grading-locked .rubric-select,
.grading-locked textarea {
    background: var(--bg-secondary) !important;
    cursor: not-allowed;
}

/* ─── Dashboard ─── */

.dashboard-btn {
    position: relative;
}

.dashboard-icon {
    font-size: 0.7rem;
}

.dashboard-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.dash-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    text-align: center;
}

.dash-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.35rem;
}

.dash-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.dash-stat-critical {
    border-color: rgba(239, 68, 68, 0.4);
}
.dash-stat-critical .dash-stat-value { color: var(--error); }

.dash-stat-warning {
    border-color: rgba(245, 158, 11, 0.4);
}
.dash-stat-warning .dash-stat-value { color: var(--warning); }

.dash-stat-info {
    border-color: rgba(251, 191, 36, 0.4);
}
.dash-stat-info .dash-stat-value { color: var(--accent); }

.dash-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dash-alert-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border-left: 3px solid var(--border);
    align-items: flex-start;
}

.dash-alert-clickable {
    cursor: pointer;
    transition: background 0.15s ease;
}

.dash-alert-clickable:hover {
    background: var(--bg-card-hover);
}

.dash-link-inline {
    display: inline-block;
    margin-top: 0.25rem;
    font-weight: 600;
}

.dash-alert-critical {
    border-left-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.dash-alert-warning {
    border-left-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.dash-alert-info {
    border-left-color: var(--accent);
    background: rgba(251, 191, 36, 0.05);
}

.dash-alert-sev {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.dash-alert-critical .dash-alert-sev { color: var(--error); }
.dash-alert-warning .dash-alert-sev { color: var(--warning); }
.dash-alert-info .dash-alert-sev { color: var(--accent); }

.dash-alert-body {
    flex: 1;
    min-width: 0;
}

.dash-alert-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.dash-alert-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.dash-alert-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.dash-tag {
    font-size: 0.7rem;
    padding: 0.12rem 0.45rem;
    border-radius: 3px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    font-weight: 500;
}

.dash-tag-student {
    background: rgba(251, 191, 36, 0.12);
    color: var(--accent);
}

.dash-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

.dash-link {
    font-size: 0.78rem;
    color: var(--accent);
    text-decoration: none;
    margin-top: 0.3rem;
    display: inline-block;
}

.dash-link:hover {
    text-decoration: underline;
}

/* ─── Prompt Panel ─── */

.prompt-section {
    margin-bottom: 1.25rem;
}

.prompt-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    width: 100%;
    text-align: left;
    transition: background var(--transition);
}

.prompt-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.prompt-toggle-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.prompt-status {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
}

.prompt-status-custom {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent);
}

.prompt-panel {
    margin-top: 0.5rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.prompt-editor {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.prompt-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ─── Section Tabs (Tareas / Foros) ─── */
.section-tabs {
    display: flex;
    gap: 0;
    padding: 0 1.5rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.section-tab {
    padding: 0.65rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}
.section-tab:hover { color: var(--text-primary); }
.section-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ─── Forum section ─── */
.forum-post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}
.forum-post-card.is-teacher {
    border-left: 3px solid var(--success);
    background: rgba(16, 185, 129, 0.04);
}
.forum-post-card.is-student {
    border-left: none;
}
.card-stats-row {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    margin-top: 0.25rem;
    letter-spacing: 0.01em;
}
.card-pending.pending-zero {
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
}
.card-pending.pending-some {
    color: #e5913a;
    font-weight: 600;
}
.forum-post-card.is-student.reply-to-feedback {
    border: 2px solid #eab308;
    background: rgba(234,179,8,0.08);
}
.forum-post-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.forum-post-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}
.forum-post-avatar.teacher { background: var(--success); }
.forum-post-avatar.student { background: var(--accent); }
.forum-post-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.forum-post-author { font-weight: 600; font-size: 0.9rem; }
.forum-post-date { font-size: 0.75rem; color: var(--text-muted); }
.forum-post-content {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.forum-post-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
}
.forum-post-content a,
.forum-post-content a:visited,
.forum-post-content a:hover {
    color: #fcd34d !important;
    text-decoration: underline;
}
.alert a,
.alert-error a {
    color: #fcd34d !important;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.forum-reply-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-top: 1rem;
}
.forum-reply-box h4 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.forum-reply-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 800px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}
.forum-reply-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.forum-reply-actions .btn { min-width: auto; }
.forum-reply-actions .text-muted {
    width: 100%;
    margin-top: 0.25rem;
}
@media (max-width: 600px) {
    .forum-reply-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .forum-reply-actions .btn {
        width: 100%;
        text-align: center;
    }
    .forum-reply-box {
        padding: 0.75rem;
    }
}
.forum-post-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}
.forum-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}
.forum-badge-teacher {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}
.forum-badge-student {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent);
}
.forum-badge-replied {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}
.forum-badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}
.forum-status-bar {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.forum-status-bar strong { color: var(--text-primary); }

@media (max-width: 480px) {
    .breadcrumb-nav { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .section-tabs { padding: 0 0.75rem; }
    .section-tab { padding: 0.5rem 1rem; font-size: 0.8rem; }
}

/* AI CHAT */
.ai-chat-msg {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 92%;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-chat-msg.user {
    background: rgba(59,130,246,0.15);
    border: 1px solid rgba(59,130,246,0.25);
    align-self: flex-end;
    color: var(--text-primary);
}
.ai-chat-msg.assistant {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    align-self: flex-start;
    color: var(--text-primary);
}
.ai-chat-msg .chat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
    opacity: 0.6;
}
#ai-chat-input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.88rem;
}
#ai-chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* DEV CHAT PANEL */
.dev-chat-panel {
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: 70vh;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    z-index: 9999;
}
.dev-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--accent);
    font-size: 0.88rem;
    cursor: default;
}
.dev-chat-model {
    font-size: 0.7rem;
    opacity: 0.5;
    font-weight: 400;
}
.dev-chat-toggle {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}
.dev-chat-toggle input { width: 14px; height: 14px; accent-color: var(--accent); }
.dev-chat-btn-clear, .dev-chat-btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 0.2rem;
    line-height: 1;
}
.dev-chat-btn-clear:hover, .dev-chat-btn-close:hover { color: var(--text-primary); }
.dev-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 200px;
    max-height: 50vh;
}
.dev-msg {
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.55;
    max-width: 95%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.dev-msg.user {
    background: rgba(251, 191, 36, 0.12);
    color: var(--text-primary);
    align-self: flex-end;
    border: 1px solid rgba(251, 191, 36, 0.2);
}
.dev-msg.assistant {
    background: var(--bg-primary);
    color: var(--text-primary);
    align-self: flex-start;
    border: 1px solid var(--border);
}
.dev-msg pre {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    overflow-x: auto;
    font-size: 0.8rem;
    margin: 0.4rem 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.dev-msg code {
    background: rgba(251, 191, 36, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.82rem;
    font-family: 'JetBrains Mono', monospace;
}
.dev-msg pre code {
    background: none;
    padding: 0;
}
.dev-chat-input-area {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.dev-chat-input-area textarea {
    flex: 1;
    resize: none;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.85rem;
    min-height: 36px;
    max-height: 120px;
}
.dev-chat-input-area textarea:focus { outline: none; border-color: var(--accent); }
.dev-chat-typing {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}
.dev-chat-typing .dot-pulse { display: inline-flex; gap: 3px; }
.dev-chat-typing .dot-pulse span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent); opacity: 0.4;
    animation: dotPulse 1.2s infinite ease-in-out;
}
.dev-chat-typing .dot-pulse span:nth-child(2) { animation-delay: 0.2s; }
.dev-chat-typing .dot-pulse span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.1); } }

.dev-cursor-blink {
    color: var(--accent);
    font-weight: 700;
    animation: cursorBlink 0.8s infinite;
}
@keyframes cursorBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.dev-thinking-indicator {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
}
.dev-thinking-indicator::after {
    content: '...';
    animation: thinkingDots 1.5s infinite;
}
@keyframes thinkingDots {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

@media (max-width: 600px) {
    .dev-chat-panel { width: 100%; right: 0; max-height: 80vh; border-radius: var(--radius) var(--radius) 0 0; }
    .dev-tasks-panel { width: 100% !important; right: 0 !important; max-height: 80vh; border-radius: var(--radius) var(--radius) 0 0; }
}

/* Manual Grade Link */
.btn-link-subtle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.7;
    padding: 0.3rem;
}
.btn-link-subtle:hover {
    color: var(--text-secondary);
    opacity: 1;
}

/* Dev Tasks Panel */
.dev-tasks-panel {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 380px;
    max-height: 70vh;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}
.dev-tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    background: rgba(251, 191, 36, 0.08);
    border-radius: var(--radius) var(--radius) 0 0;
}
.dev-tasks-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    max-height: 45vh;
}
.dev-task-msg {
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
    max-width: 90%;
}
.dev-task-msg.user {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
    margin-left: auto;
}
.dev-task-msg.dev {
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
    margin-right: auto;
}
.dev-task-msg-header {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.dev-task-msg.user .dev-task-msg-header { color: var(--accent); }
.dev-task-msg.dev .dev-task-msg-header { color: #4ade80; }
.dev-task-msg-time {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: auto;
}
.dev-task-msg-text {
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}
.dev-tasks-input-area {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    align-items: flex-end;
}
.dev-tasks-input-area textarea {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    resize: none;
    font-family: inherit;
}
.dev-tasks-input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
}


/* ============================================================
   PRESENCE BAR - Real-time user activity
   ============================================================ */
#presence-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, rgba(15,20,35,0.95), rgba(25,32,50,0.95));
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 4px 1rem;
    display: flex;
    align-items: center;
    min-height: 36px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
#presence-bar.has-users { display: flex; }
#presence-users {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
#presence-users::-webkit-scrollbar { display: none; }

.presence-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 2px 10px 2px 4px;
    background: rgba(255,255,255,0.04);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.3s;
}
.presence-user:hover {
    background: rgba(255,255,255,0.08);
}

.presence-avatar {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    overflow: hidden;
}
.presence-avatar .walker {
    animation: walk-bounce 0.6s ease-in-out infinite;
    display: inline-block;
    font-size: 18px;
    line-height: 1;
}
@keyframes walk-bounce {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

.presence-flag {
    font-size: 14px;
    line-height: 1;
}

.presence-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.presence-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary, #e0e0e0);
}
.presence-activity {
    font-size: 0.65rem;
    color: var(--text-secondary, #999);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.presence-country {
    font-size: 0.62rem;
    color: var(--text-secondary, #888);
    opacity: 0.7;
}

.presence-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 6px #34d399;
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px #34d399; }
    50% { opacity: 0.5; box-shadow: 0 0 2px #34d399; }
}

/* Offset body to account for presence bar */
body.has-presence-bar {
    padding-top: 44px;
}

@media (max-width: 600px) {
    #presence-bar { padding: 3px 0.5rem; }
    .presence-user { padding: 2px 6px 2px 3px; gap: 0.3rem; }
    .presence-info { display: none; }
    .presence-avatar { width: 24px; height: 24px; }
    .presence-avatar .walker { font-size: 15px; }
}

.presence-context {
    font-size: 0.68rem;
    color: var(--accent, #f5a623);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.presence-activity {
    font-size: 0.7rem !important;
    color: #a5f3c4 !important;
    font-weight: 500 !important;
}
.presence-name {
    font-size: 0.75rem !important;
}
.presence-info {
    gap: 1px !important;
}
@media (max-width: 600px) {
    .presence-info { display: flex !important; flex-direction: column !important; }
    .presence-context { display: none; }
    .presence-activity { font-size: 0.6rem !important; }
}

.presence-location {
    font-size: 0.72rem;
    color: #fbbf24;
    font-weight: 600;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* Spinning refresh icon */
.spin-icon {
  display: inline-block;
  animation: spin-refresh 1s linear infinite;
}
@keyframes spin-refresh {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Group notes button on subject cards */
.card-notes-btn {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.2s, transform 0.15s;
  z-index: 2;
}

.card-notes-btn:hover {
  opacity: 0.8;
  transform: scale(1.15);
}

.subject-card {
  position: relative;
}

.forum-only-pending-toggle { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; user-select: none; }
.check-nike { appearance: none; -webkit-appearance: none; width: 15px; height: 15px; margin: 0; flex-shrink: 0; background: #fff; border: 1px solid #cbd5e1; border-radius: 3px; position: relative; cursor: pointer; }
.check-nike:checked::after { content: ''; position: absolute; left: 4px; top: 0; width: 4px; height: 9px; border: solid #16a34a; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.check-nike:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }

.criterion-copy-row {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    width: 100%;
    flex: 1 1 100%;
    min-width: 0;
}
.criterion-copy-text {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}
.criterion-copy-actions {
    display: inline-flex;
    align-items: flex-start;
    gap: 1.15rem;
    flex: 0 0 auto;
    margin-left: 0.45rem;
}
.copy-comment-btn {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    padding: 0;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.copy-comment-btn:hover,
.copy-comment-btn:focus-visible {
    color: var(--text-primary);
    border-color: var(--accent, #60a5fa);
    outline: none;
}
.copy-comment-btn.copied {
    color: var(--success, #86efac);
    border-color: var(--success, #86efac);
}

.ai-comment-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    margin-top: 3px;
    cursor: pointer;
}

.rubric-pick { position: relative; }
.rubric-pick-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.45rem 0.75rem;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    cursor: pointer;
}
.rubric-pick-arrow {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='M3 5.2l4 4 4-4' fill='none' stroke='%23e8eaed' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}
.rubric-pick-label { white-space: nowrap; }
.rubric-pick-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 50;
    min-width: 100%;
    width: max-content;
    max-width: 100%;
    box-sizing: border-box;
    background: #1a2338;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.3rem;
    box-shadow: 0 12px 28px rgba(0,0,0,0.4);
}
.rubric-pick-menu button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: transparent;
    color: #e8eaed;
    border: 0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    cursor: pointer;
}
.rubric-pick-menu button:hover { background: rgba(255,255,255,0.08); }
.rubric-pick .rubric-select {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.feedback-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    overflow: hidden;
}
.fmt-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.045);
}
.fmt-label {
    margin-right: 0.25rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.fmt-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}
.fmt-btn-mark { background: #fff3a0; color: #1a1d27; border-color: #e6d58a; }
.fmt-btn:disabled, .feedback-editor.is-locked .fmt-btn { opacity: 0.45; pointer-events: none; }
.feedback-view {
    min-height: clamp(240px, 46vh, 620px);
    padding: 0.75rem 0.85rem;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.feedback-view:focus { outline: none; border-color: var(--border-focus); }
.feedback-view:empty:before { content: attr(data-placeholder); color: var(--text-muted); }
.feedback-view strong { font-weight: 700; }
.feedback-view span.fmt-mark { background: #fff3a0; color: #1a1d27; }
.feedback-editor .fmt-source {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

.grading-layout { position: relative; }
.student-slide-ghost {
    position: absolute;
    z-index: 4;
    width: 100%;
    left: 0;
    margin: 0;
    pointer-events: none;
    transition: transform 190ms cubic-bezier(0.2, 0, 0, 1), opacity 190ms linear;
}
.student-slide-ghost.is-out {
    transform: translateX(26%);
    opacity: 0;
}
.student-info-card.student-enter {
    animation: studentIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes studentIn {
    from { transform: translateX(-18%); opacity: 0.15; }
    to { transform: none; opacity: 1; }
}
#grading-student-name.name-flash {
    border-radius: 4px;
    animation: nameFlash 680ms ease;
}
@keyframes nameFlash {
    0%, 40% { box-shadow: inset 0 -0.55em 0 #fff3a0; }
    100% { box-shadow: inset 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .student-slide-ghost { transition: none; }
    .student-info-card.student-enter,
    #grading-student-name.name-flash { animation: none; }
}
#view-grading { position: relative; }
#student-handoff {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    z-index: 400;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem 1.25rem 1.15rem;
    background: rgba(19, 26, 43, 0.96);
    color: #e8eaed;
    font-weight: 700;
    font-size: 1.15rem;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
#student-handoff .spinner {
    width: 58px;
    height: 58px;
    border-width: 4px;
}
#student-handoff p {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
}
#student-handoff .handoff-jump {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.6rem;
    max-width: 40rem;
    margin-top: 0.35rem;
}
#student-handoff .handoff-leave,
#student-handoff .handoff-enter {
    margin: 0;
    text-align: center;
    line-height: 1.35;
}
#student-handoff .handoff-leave {
    font-size: 1.05rem;
    color: #b6c2d9;
}
#student-handoff .handoff-enter {
    font-size: 1.15rem;
}
#student-handoff .handoff-enter strong {
    display: inline-block;
    margin-top: 0.2rem;
    font-size: 1.55rem;
    font-weight: 800;
    color: #fff;
}
#student-handoff .handoff-leave strong {
    display: inline-block;
    margin-top: 0.2rem;
    font-size: 1.2rem;
    font-weight: 750;
    color: #e8eaed;
}


.history-panel {
    margin-top: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    overflow: hidden;
}
.history-panel.is-grave { border-color: rgba(251, 191, 36, 0.45); }
.history-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.72rem 0.9rem;
    border: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.history-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.history-arrow {
    flex: none;
    width: 0.42rem;
    height: 0.42rem;
    margin-top: 0.05rem;
    border-right: 1.5px solid var(--text-secondary);
    border-bottom: 1.5px solid var(--text-secondary);
    transform: rotate(-45deg);
}
.history-panel.is-open .history-arrow {
    margin-top: -0.15rem;
    transform: rotate(45deg);
}
.history-title {
    font-size: 0.92rem;
    font-weight: 650;
    color: var(--text-primary);
}
.history-summary {
    margin-left: auto;
    max-width: 58%;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: right;
}
.history-panel.is-grave .history-summary { color: #fbbf24; }
.history-body {
    display: none;
    max-height: 28rem;
    overflow: auto;
    scrollbar-color: var(--border) transparent;
}
.history-panel.is-open .history-body { display: block; }
.history-repeat,
.history-series {
    margin: 0;
    padding: 0.7rem 0.95rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    line-height: 1.45;
}
.history-repeat { color: var(--text-primary); }
.history-repeat strong { font-weight: 650; color: #fbbf24; }
.history-series { color: var(--text-secondary); }
.history-row {
    padding: 0.8rem 0.95rem 0.9rem;
    border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: 0; }
.history-row-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.15rem 0.8rem;
}
.history-case {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 650;
    line-height: 1.3;
}
.history-when {
    flex: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}
.history-subject {
    margin: 0.12rem 0 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.35;
}
.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}
.history-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-primary);
    background: transparent;
    font-size: 0.72rem;
    line-height: 1.35;
}
.history-chip-warn { border-color: rgba(251, 191, 36, 0.7); }
.history-chip-bad { border-color: rgba(252, 165, 165, 0.75); }
.history-excerpt {
    margin: 0.5rem 0 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.history-excerpt.is-open {
    display: block;
    overflow: visible;
}
.history-more {
    margin-top: 0.15rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}
.history-more:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.history-issues {
    margin: 0.45rem 0 0;
    padding: 0;
    list-style: none;
}
.history-issues li {
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
}
.history-issues li.history-issue-bad { color: #fca5a5; }
.history-issues li.history-issue-warn { color: #fbbf24; }
@media (max-width: 720px) {
    .history-summary { max-width: 100%; margin-left: 1.1rem; text-align: left; }
    .history-toggle { flex-wrap: wrap; }
    .history-row-head { flex-direction: column; align-items: flex-start; }
    .history-case,
    .history-repeat,
    .history-excerpt { overflow-wrap: anywhere; }
}

.admin-note { margin: 0.35rem 0 0.15rem; }
.admin-note-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
    padding: 0.1rem 0.05rem;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
}
.admin-note:not(.has-note) .admin-note-toggle { cursor: default; }
.admin-note-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.admin-note-arrow {
    flex: none;
    width: 0.38rem;
    height: 0.38rem;
    border-right: 1.5px solid var(--text-secondary);
    border-bottom: 1.5px solid var(--text-secondary);
    transform: rotate(-45deg);
}
.admin-note.is-open .admin-note-arrow {
    margin-top: 0.12rem;
    transform: rotate(45deg);
}
.admin-note:not(.has-note) .admin-note-arrow { visibility: hidden; }
.admin-note-status { color: var(--text-secondary); }
.admin-note.has-note .admin-note-status { color: var(--text-primary); }
.admin-note-body {
    display: none;
    margin: 0.2rem 0 0.35rem 1rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.admin-note.is-open .admin-note-body { display: block; }
.teacher-note { margin: 0.9rem 0 0.2rem; }
.teacher-note-label {
    display: block;
    margin: 0 0 0.4rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.4;
}
.teacher-note textarea {
    width: 100%;
    min-height: 4.6rem;
    resize: vertical;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.65rem;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.45;
}
.teacher-note textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.teacher-note-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.45rem;
}
#teacher-note-save-status {
    color: var(--text-secondary);
    font-size: 0.75rem;
}
.history-teacher-note {
    margin: 0;
    padding: 0.7rem 0.95rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.history-teacher-note strong { font-weight: 650; color: var(--text-primary); }

.history-body {
    background: #151c2c;
    color: var(--text-primary);
    font-family: "Courier New", Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.45;
}
.history-body .history-repeat,
.history-body .history-series,
.history-body .history-case,
.history-body .history-when,
.history-body .history-subject,
.history-body .history-excerpt,
.history-body .history-issues li,
.history-body .history-teacher-note,
.history-body .history-chip,
.history-body .history-more {
    color: var(--text-primary);
    font-family: "Courier New", Courier, monospace;
}
.history-body .history-case { font-size: 1.05rem; }
.history-body .history-excerpt,
.history-body .history-repeat,
.history-body .history-series,
.history-body .history-teacher-note { font-size: 0.95rem; }
.history-body .history-when,
.history-body .history-subject,
.history-body .history-issues li,
.history-body .history-chip,
.history-body .history-more { font-size: 0.88rem; }
.history-body .history-repeat strong,
.history-body .history-teacher-note strong,
.history-body .history-issues li.history-issue-bad,
.history-body .history-issues li.history-issue-warn {
    color: var(--text-primary);
}
.history-body .history-more {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.no-draft-note {
    margin: 0.9rem 0 0.35rem;
    color: var(--text-primary);
    font-size: 0.98rem;
    line-height: 1.45;
}
