:root {
    /* Dark theme (default) */
    color-scheme: dark;
    --bg: #1e293b;
    --surface: #334155;
    --text: #e2e8f0;
    --text-muted: #a8b4c5;
    --border: #475569;
    --primary: #a5b4fc;
    --primary-hover: #c7d2fe;
    --primary-solid: #4f46e5;
    --primary-solid-hover: #4338ca;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-solid: #b91c1c;
    --danger-solid-hover: #991b1b;
    --success: #34d399;
    --warning: #fbbf24;
    --warning-solid: #b45309;
    --warning-solid-hover: #92400e;
    --phase-active-solid: #c2410c;
    --phase-active-solid-hover: #9a3412;
    --rating-idle: #94a3b8;
    --rating-active: #fbbf24;
    --code-comment: #a8b4c5;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.3), 0 4px 10px rgba(0,0,0,0.15);
    --max-width: 960px;
    /* Hardcoded accent overrides for dark mode */
    --accent-bg: #312e81;
    --accent-bg-soft: #1e1b4b;
    --timer-bg: #0f172a;
    --success-soft: #064e3b;
    --error-soft: #7f1d1d;
    --warning-soft: #422006;
    --hover-row: rgba(255,255,255,0.05);
    --error-text: #fca5a5;
    --success-text: #6ee7b7;
    --warning-text: #fde68a;
    --error-border: #7f1d1d;
    --success-border: #065f46;
    --warning-border: #a16207;
}

html.light {
    /* Light theme */
    color-scheme: light;
    --bg: #eef2f6;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #5b677a;
    --border: #cbd5e1;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-solid: #4f46e5;
    --primary-solid-hover: #4338ca;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-solid: #b91c1c;
    --danger-solid-hover: #991b1b;
    --success: #10b981;
    --warning: #f59e0b;
    --warning-solid: #b45309;
    --warning-solid-hover: #92400e;
    --phase-active-solid: #c2410c;
    --phase-active-solid-hover: #9a3412;
    --rating-idle: #5b677a;
    --rating-active: #92400e;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --accent-bg: #eef2ff;
    --accent-bg-soft: #eef2ff;
    --timer-bg: #f1f5f9;
    --success-soft: #dcfce7;
    --error-soft: #fef2f2;
    --warning-soft: #fffbeb;
    --hover-row: rgba(0,0,0,0.03);
    --error-text: #991b1b;
    --success-text: #166534;
    --warning-text: #92400e;
    --error-border: #fecaca;
    --success-border: #bbf7d0;
    --warning-border: #fcd34d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    scrollbar-gutter: stable;
}

/* Prevent visited links from going invisible (dark purple on dark bg) */
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
a:visited { color: var(--primary); }
a:visited:hover { color: var(--primary-hover); }
/* Buttons keep their own colors even when visited */
.btn:visited, .btn-primary:visited { color: #fff; }
.btn-secondary:visited, .btn-outline:visited { color: var(--text); }
/* Course title links stay as heading color */
.course-card .course-name a,
.course-card .course-name a:visited { color: var(--text); }

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo { font-size: 1.4rem; }
.brand-text { letter-spacing: -0.02em; }
.brand-tagline {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-links { display: flex; flex: 0 0 auto; gap: 20px; align-items: center; }
.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: color 0.15s;
}
.nav-user-name {
    display: inline-block;
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
.nav-link:hover { color: var(--text); }
.nav-link.logout { color: var(--error-text); }

.nav-dropdown {
    position: relative;
}
.nav-dropdown-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.nav-logout-form {
    margin: 0;
}
.nav-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    z-index: 200;
    overflow: hidden;
}
.nav-dropdown-menu.open {
    display: block;
}
.nav-dropdown-item {
    display: block;
    padding: 10px 16px;
    font-size: 0.88rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: background 0.1s;
}
.nav-dropdown-item:hover {
    background: var(--bg);
}
.nav-dropdown-item.disabled {
    color: var(--text-muted);
    cursor: default;
}
.nav-dropdown-item.disabled:hover {
    background: none;
}

.nav-home {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

@media (max-width: 900px) {
    .brand-tagline,
    .nav-user-name { display: none; }
    .navbar { padding: 0 12px; gap: 12px; }
    .nav-links { gap: 12px; }
}

@media (max-width: 420px) {
    .brand-text { display: none; }
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 28px 20px 60px;
}

.site-footer {
    text-align: center;
    padding: 18px 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}
.site-footer a:hover {
    color: var(--text);
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card h2 {
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 600;
}

.hint-inline {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.06s, box-shadow 0.15s, background 0.15s;
    text-decoration: none;
    color: #fff;
    background: var(--primary-solid);
}
.btn:not(:disabled):hover { background: var(--primary-solid-hover); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary { background: var(--primary-solid); }
.btn-primary:not(:disabled):hover { background: var(--primary-solid-hover); }

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

.btn-danger { background: var(--danger-solid); }
.btn-danger:not(:disabled):hover { background: var(--danger-solid-hover); }

.btn-warning { background: var(--warning-solid); color: #fff; }
.btn-warning:not(:disabled):hover { background: var(--warning-solid-hover); }

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:not(:disabled):hover, .btn-outline.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--accent-bg);
}

.phase-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 48px;
}
.phase-header h2 {
    margin: 0;
    line-height: 48px;
}
.phase-header-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 16px;
}

.session-timer {
    display: flex;
    align-items: center;
    gap: 8px;
}
.timer-value-large {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--primary);
}

.phase-btn.active {
    border-color: var(--phase-active-solid);
    color: #fff;
    background: var(--phase-active-solid);
    box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.24);
}
.phase-btn.active:not(:disabled):hover {
    border-color: var(--phase-active-solid-hover);
    color: #fff;
    background: var(--phase-active-solid-hover);
}

.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.88rem;
}
.form-group input,
.form-group textarea,
textarea,
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-inline { display: flex; gap: 10px; flex-wrap: wrap; }
.form-inline input { flex: 1; min-width: 200px; }

.login-container {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header { margin-bottom: 28px; }
.logo-large { font-size: 3rem; display: block; margin-bottom: 12px; }
.login-header h1 { margin: 0; font-size: 1.5rem; }
.subtitle { color: var(--text-muted); margin-top: 6px; }

.login-form { text-align: left; }
.login-footer { margin-top: 20px; font-size: 0.85rem; color: var(--text-muted); }

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 10px;
}
.dash-header h1 { margin: 0; font-size: 1.6rem; }
.dashboard-state {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.connection-status {
    max-width: 360px;
    color: var(--error-text);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
}
.connection-status:not([hidden]) {
    align-items: center;
    background: var(--error-soft);
    border: 1px solid var(--error-border);
    border-radius: 999px;
    display: inline-flex;
    gap: 6px;
    padding: 5px 10px;
}
.connection-status:not([hidden])::before {
    content: "⚠";
}
.connection-status.recovered:not([hidden]) {
    background: var(--success-soft);
    border-color: var(--success-border);
    color: var(--success-text);
}
.connection-status.recovered:not([hidden])::before {
    content: "✓";
}

.phase-badge {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--border);
    color: var(--text-muted);
}
.phase-setup { background: #e0e7ff; color: #3730a3; box-shadow: 0 0 16px rgba(79, 70, 229, 0.25); }
.phase-discussion { background: var(--success-soft); color: var(--success-text); box-shadow: 0 0 16px rgba(16, 185, 129, 0.25); }
.phase-competition { background: #fef3c7; color: #92400e; box-shadow: 0 0 16px rgba(245, 158, 11, 0.25); }
.phase-ended { background: var(--timer-bg); color: var(--text-muted); }

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.team-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-family: inherit;
}
.team-card:hover {
    border-color: var(--team-color);
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}
.team-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.roster-member .team-dot {
    width: 4px;
    height: 14px;
    border-radius: 2px;
}
.team-name { font-weight: 600; font-size: 0.95rem; }
.team-name-large { font-size: 1.2rem; font-weight: 700; }

.team-banner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius);
    border-left: 4px solid var(--team-color);
}

.roster-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@media (max-width: 800px) {
    .roster-grid { grid-template-columns: repeat(2, 1fr); }
}

.phase-settings {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.phase-settings-secondary {
    border-top: none;
    margin-top: 6px;
    padding-top: 0;
}

.lock-toggle {
    /* dead code — kept for reference, no template uses this */
    display: none;
}
.team-count-control {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
}
.team-count-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 32px;
}
.team-count-value {
    font-weight: 700;
    font-size: 1rem;
    min-width: 28px;
    text-align: center;
    line-height: 32px;
}
.team-count-value.editing {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    height: 30px;
}
.team-count-value.editing .btn {
    border-radius: 0;
    border: none;
    padding: 0 10px;
    font-size: 0.9rem;
    line-height: 30px;
    background: var(--bg);
    color: var(--text);
}
.team-count-value.editing .btn:hover {
    background: var(--border);
}
.team-count-value.editing #editing-count {
    min-width: 28px;
    padding: 0 4px;
    line-height: 30px;
    background: var(--surface);
    text-align: center;
}

.roster-team {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    background: var(--bg);
}
.roster-team h3 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.roster-member {
    padding: 6px 10px;
    background: var(--surface);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.roster-member .you { font-weight: 700; color: var(--primary); }

.loading { color: var(--text-muted); text-align: center; padding: 20px; }

.presenting-banner {
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
}
.presenting-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.presenting-name { font-size: 1.3rem; font-weight: 700; }
.team-name-marked::before,
.presenting-name.has-team-color::before {
    background: var(--team-color, var(--border));
    border-radius: 50%;
    content: "";
    display: inline-block;
    height: 0.65em;
    margin-right: 0.4em;
    vertical-align: 0.05em;
    width: 0.65em;
}

.team-card:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}
.team-capacity { color: var(--text-muted); font-size: 0.78rem; }

.phase-buttons, .team-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.add-student-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}
.add-student-form input { flex: 1; min-width: 140px; }

.table-toolbar {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.table-toolbar input {
    max-width: 240px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}
.filter-dropdown {
    position: relative;
}
.filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.filter-btn:hover {
    border-color: var(--primary);
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}
.week-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}
.week-selector select {
    padding: 6px 32px 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.week-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

.filter-picker {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 160px;
}

.sortable {
    cursor: pointer;
    user-select: none;
}
.sortable:hover {
    color: var(--primary);
}
.sort-arrow {
    font-size: 0.7rem;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
    min-height: 36px;
}
.card-header-row h2 {
    margin: 0;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.pag-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-right: 10px;
}

.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tr:hover { background: var(--bg); }

.team-tag {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    display: inline-flex;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}
.team-tag::before {
    background: var(--team-color, var(--text-muted));
    border-radius: 50%;
    content: "";
    flex: 0 0 auto;
    height: 8px;
    width: 8px;
}
.team-tag.clickable {
    cursor: pointer;
    transition: opacity 0.1s;
}
.team-tag.clickable:hover {
    opacity: 0.8;
}
.unassigned-tag {
    --team-color: var(--text-muted);
    background: var(--surface);
    color: var(--text-muted);
}

.team-picker {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 140px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 300;
}
.team-picker-item {
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.1s;
}
.team-picker-item:hover {
    background: var(--bg);
}

.flash-messages { margin-bottom: 18px; }
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash-error { background: var(--error-soft); color: var(--error-text); border: 1px solid var(--error-border); }
.flash-success { background: var(--success-soft); color: var(--success-text); border: 1px solid var(--success-border); }

@media (max-width: 640px) {
    .dash-header h1 { font-size: 1.25rem; }
    .team-grid { grid-template-columns: 1fr 1fr; }
    .roster-grid { grid-template-columns: 1fr; }
    .card { padding: 18px; }
}

/* ===== LANDING PAGE ===== */
.intro-card {
    padding: 32px;
}
.intro-content {
    display: flex;
    align-items: center;
    gap: 28px;
}
.intro-content .logo-huge {
    font-size: 3.5rem;
    flex-shrink: 0;
}
.intro-text h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
}
.intro-text p {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}
.intro-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
@media (max-width: 600px) {
    .intro-content {
        flex-direction: column;
        text-align: center;
    }
    .intro-links {
        justify-content: center;
    }
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.course-card {
    display: block;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 18px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
.course-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.course-card-unavailable:hover {
    border-color: var(--border);
    box-shadow: none;
    transform: none;
}
.course-card .course-name {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.course-card .course-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.course-card .course-instructor {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.course-availability {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.course-card .course-stats {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-solid);
    color: #fff;
}
.badge-muted {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.instructor-entry { display: none; }

.course-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.course-actions .btn {
    flex: 1;
    min-width: 120px;
}

.competition-control {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.form-row .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}
.form-row select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text);
}

.timer-display {
    background: var(--timer-bg);
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.timer-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.timer-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'SF Mono', monospace;
    color: var(--text);
}

.timer-box {
    background: var(--timer-bg);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.timer-box .timer-display {
    background: transparent;
    padding: 4px 0;
}
.timer-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.timer-controls .btn {
    min-width: 100px;
}

.comp-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.comp-actions .btn {
    flex: 1;
    min-width: 140px;
}

.active-info {
    background: var(--bg);
    border-radius: 8px;
    padding: 14px;
    border: 1px solid var(--border);
}
.info-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.95rem;
}
.info-row:last-child {
    margin-bottom: 0;
}
.info-label {
    color: var(--text-muted);
    min-width: 80px;
}
.info-value {
    font-weight: 600;
}

.question-display {
    background: var(--accent-bg);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 4px;
}
.offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    margin-right: 4px;
}
.small { font-size: 0.8rem; }

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    grid-column: 1 / -1;
}

.course-name-sm {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 4px 0 0;
}

.top-nav {
    margin-bottom: 14px;
}

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

.course-card-large {
    background: var(--bg);
}

.course-card-large .course-stats {
    font-weight: 500;
}

/* Demo page */
.demo-steps {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 12px;
}
.demo-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.demo-step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-solid);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.demo-step-body h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}
.demo-step-body p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Discussion question cards */
.disc-questions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.disc-question-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.disc-question-card.is-hidden {
    opacity: 0.6;
}
.hidden-question-badge {
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.disc-question-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    background: var(--bg);
    transition: background 0.1s;
}
.disc-question-header:hover {
    background: var(--accent-bg);
}
.disc-question-header:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
}
.disc-question-num {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
    min-width: 24px;
}
.disc-question-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.92rem;
}
.disc-question-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.disc-question-body {
    display: none;
    padding: 16px 18px;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    line-height: 1.7;
}
.disc-question-card.expanded .disc-question-body {
    display: block;
}
.disc-question-body .markdown-content p {
    margin: 0 0 10px;
}
.disc-question-body .markdown-content pre {
    background: var(--timer-bg);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    font-size: 0.82rem;
}
.disc-question-body .markdown-content code {
    background: var(--timer-bg);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.85rem;
}
.disc-question-body .markdown-content pre code {
    background: none;
    padding: 0;
}

/* Team table with free-position draggable cards */
.team-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.team-info {
    flex: 1 1 auto;
    min-width: 160px;
    max-width: 35%;
}
.team-instructions {
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.team-table-wrapper {
    flex: 0 0 60%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.team-table-wrapper .team-table {
    width: 100%;
}

.team-table {
    position: relative;
    min-height: 280px;
    background: var(--timer-bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding-bottom: 24px;
}
@media (max-width: 700px) {
    .team-layout {
        flex-direction: column;
    }
    .team-info,
    .team-table-wrapper {
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        max-width: none;
    }
    .team-table-wrapper {
        align-items: stretch;
    }
    .team-table-wrapper > .btn {
        align-self: flex-end;
    }
}

.teammate-card {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    padding: 6px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s;
    z-index: 1;
    min-width: 70px;
}
.teammate-card:active {
    cursor: grabbing;
    z-index: 10;
}
.teammate-card.dragging {
    opacity: 0.4;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.card-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    position: relative;
    padding: 4px;
}

.card-name {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-id {
    font-size: 0.6rem;
    color: var(--text-muted);
    line-height: 1;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#card-you .card-circle {
    border-style: dashed;
}

.thumb-btn {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.1s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.thumb-btn:hover {
    transform: scale(1.3);
}
.thumb-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}
.thumb-btn.active-green {
    background: var(--success-soft);
    border-color: var(--success-text);
    box-shadow: 0 0 0 3px var(--success-text);
}
.thumb-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ===== DEMO MODE STYLES ===== */

/* Demo landing page */
.demo-hero {
    text-align: center;
    padding: 32px 24px;
}

.demo-hero h2 {
    margin-bottom: 8px;
}

.demo-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 1.05rem;
}

.demo-role-picker {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.demo-role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 240px;
    padding: 28px 20px;
    border-radius: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 2px solid;
}

.demo-role-instructor {
    background: var(--accent-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.demo-role-instructor:hover {
    background: var(--accent-bg-soft);
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.demo-role-student {
    background: var(--success-soft);
    border-color: var(--success-border);
    color: var(--success-text);
}

.demo-role-student:hover {
    background: var(--success-soft);
    border-color: #4ade80;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.15);
}

.demo-role-icon {
    font-size: 2.5rem;
}

button.demo-role-card {
    font: inherit;
    cursor: pointer;
}

.demo-role-label {
    font-size: 1.15rem;
    font-weight: 700;
}

.demo-role-desc {
    font-size: 0.85rem;
    opacity: 0.75;
    text-align: center;
}

.demo-actions {
    margin-top: 12px;
}

.demo-session-note {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.demo-unavailable {
    padding: 24px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* Demo Mode banner (shown on all pages when in demo) */
.demo-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 20px;
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    border-bottom: 2px solid #f59e0b;
    font-size: 0.9rem;
    color: #78350f;
}

.demo-banner-text {
    flex: 1;
}

.demo-banner-reset-form,
.demo-banner-exit-form {
    margin: 0;
}

.demo-banner-reset,
.demo-banner-exit {
    color: #78350f;
    text-decoration: none;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.15s;
    white-space: nowrap;
}

.demo-banner-reset,
.demo-banner-exit {
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.demo-banner-reset:hover,
.demo-banner-exit:hover {
    background: rgba(120, 53, 15, 0.12);
}

@media (max-width: 640px) {
    .demo-banner {
        flex-wrap: wrap;
        gap: 6px;
    }

    .demo-banner-text {
        flex-basis: 100%;
    }
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.theme-toggle:hover { background: var(--bg); }

/* ===== Poll / Stars ===== */
.poll-section { margin-top: 14px; }
.poll-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}
.poll-card p { margin: 0 0 8px; font-weight: 500; }
.star-row {
    display: flex;
    gap: 6px;
    font-size: 1.6rem;
}
.star {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--rating-idle);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    transition: color 0.15s, transform 0.15s;
}
.star:hover, .star.active { color: var(--rating-active); }
.star:hover { transform: scale(1.08); }
.star:disabled,
.star:disabled:hover {
    color: var(--rating-idle);
    transform: none;
    cursor: default;
}
.star:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 1px;
    border-radius: 4px;
}

/* ===== You Are Up ===== */
.you-are-up {
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #92400e;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 700;
    text-align: center;
    margin: 10px 0;
}

/* ===== History Panel ===== */
.history-panel {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
}
.history-panel h4 { margin: 0 0 10px; font-size: 1rem; }
.history-heading {
    align-items: baseline;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.history-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.history-item:last-child { border-bottom: none; }

/* ===== Poll Status ===== */
.poll-status {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.poll-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== Student Presentation Timer ===== */
.student-timer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--timer-bg, rgba(99, 102, 241, 0.08));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    margin: 10px 0;
}
.student-timer .timer-label {
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
    font-weight: 600;
}
.student-timer .timer-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--text, #e2e8f0);
}

/* ===== Instructor Poll Glide Button ===== */
.poll-btn {
    position: relative;
    overflow: hidden;
    z-index: 0;
}
.poll-btn .btn-glide {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.5));
    z-index: -1;
    transition: none;
}
.poll-btn.gliding {
    cursor: default;
    pointer-events: none;
}
.poll-btn.gliding .btn-label {
    color: var(--warning-text);
}

/* ===== Student Poll Pulse Badge ===== */
.poll-pulse {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #92400e;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    margin: 10px 0;
    animation: poll-pulse-anim 0.8s ease-in-out infinite alternate;
}
.poll-pulse .pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse-dot-anim 0.8s ease-in-out infinite alternate;
}
@keyframes poll-pulse-anim {
    from { transform: scale(1); }
    to   { transform: scale(1.03); }
}
@keyframes pulse-dot-anim {
    from { opacity: 0.4; transform: scale(0.8); }
    to   { opacity: 1;   transform: scale(1.2); }
}

/* Light theme overrides for poll pulse + student timer */
html.light .poll-pulse {
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #92400e;
}
html.light .student-timer {
    background: rgba(99, 102, 241, 0.06);
}

/* ===== Logo ===== */
.logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* ===== Discussion Sign-up ===== */
.presenting-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    margin-left: auto;
}
.disc-question-actions .presenting-badge {
    margin-left: 0;
}
.toggle-present-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 8px;
}
.toggle-present-btn.selected {
    background: var(--primary-solid);
    color: #fff;
    border-color: var(--primary-solid);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 76px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.2s ease-out, toast-out 0.3s ease-in 2.2s forwards;
    max-width: 360px;
    pointer-events: auto;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ===== Roster replacement preview ===== */
.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.72);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: fixed;
    z-index: 1200;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    padding: 24px;
    width: 100%;
}
.modal-card h2 { margin-top: 0; }
.modal-card ul { margin: 12px 0; padding-left: 22px; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}
.roster-replace-warning,
.capacity-danger,
.text-danger { color: var(--error-text); }
.text-warning { color: var(--warning-text); }
.roster-replace-warning { font-weight: 600; }
.capacity-summary,
.participation-count { margin: 12px 0 0; color: var(--text-muted); }
.capacity-summary.capacity-warning,
.capacity-summary.capacity-danger {
    border: 1px solid;
    border-radius: 8px;
    font-weight: 600;
    padding: 8px 10px;
}
.capacity-summary.capacity-warning {
    background: var(--warning-soft);
    border-color: var(--warning-border);
    color: var(--warning-text);
}
.capacity-summary.capacity-danger {
    background: var(--error-soft);
    border-color: var(--error-border);
    color: var(--error-text);
}
.capacity-summary.capacity-success { color: var(--success-text); }

/* Keep projected code comments readable on the bundled dark code theme. */
.hljs .hljs-comment,
.hljs .hljs-quote { color: var(--code-comment); }
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ===== Session Results (Top 3 Teams) ===== */
.session-results { text-align: center; }
.result-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-medal { font-size: 2.2rem; }
.result-team { font-size: 1.3rem; font-weight: 600; }

/* ===== Presentation timer reached zero ===== */
.timer-value.timer-expired {
    color: var(--danger);
    animation: timer-expired-pulse 1s ease-in-out infinite alternate;
}
.timer-box.timer-expired,
.student-timer.timer-expired {
    border-color: var(--danger);
    background: var(--error-soft);
}
@keyframes timer-expired-pulse {
    from { opacity: 0.55; }
    to   { opacity: 1; }
}

/* Time is up but a rating poll is still open: informational, not an alarm. */
.timer-value.timer-time-up {
    color: var(--warning-text);
}
.timer-box.timer-time-up,
.student-timer.timer-time-up {
    border-color: var(--warning-border);
    background: var(--warning-soft);
}
.timer-box.timer-time-up::after,
.student-timer.timer-time-up::after {
    content: "Time's up — rating open";
    flex-basis: 100%;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--warning-text);
}

/* ===== Rating window: final-seconds urgency (student) ===== */
.poll-pulse.urgent {
    background: linear-gradient(90deg, #fee2e2, #fecaca);
    color: #991b1b;
    animation-duration: 0.4s;
}
.poll-pulse.urgent .pulse-dot { background: var(--danger); }

/* Draw the eye to Submit when an unsaved rating is at risk. */
#btn-submit-rating.attention {
    animation: submit-attention 0.9s ease-in-out infinite alternate;
}
@keyframes submit-attention {
    from { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
    to   { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.30); }
}

/* ===== Instructor: outstanding raters during a poll ===== */
.poll-non-raters {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}
.poll-non-raters strong { color: var(--text); font-weight: 600; }

/* Respect reduced-motion preference: effectively disables all animations
   and transitions for users who request it. */
@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;
    }
}
