/* ═══════════════════════════════════════════════════════════════
   Class Roster — full-screen page: classes on the side, one class in the middle
   (invite card + student table). Built by js/tools/ClassRosterManager.js.
   Colours come from the active theme tokens (css/modern-themes.css, --mt-*),
   so the roster follows every theme; the values after the comma are the
   fallback for a page without a theme.
   ═══════════════════════════════════════════════════════════════ */

.cr-container {
    --cr-bg: var(--mt-bg, #f4f6f9);
    --cr-surface: var(--mt-surface, #ffffff);
    --cr-raised: var(--mt-surface-2, #f2f4f8);
    --cr-text: var(--mt-text, #111827);
    --cr-muted: var(--mt-text-muted, #5b6472);
    --cr-border: var(--mt-line, rgba(17, 24, 39, 0.1));
    --cr-border-strong: var(--mt-line-strong, rgba(17, 24, 39, 0.18));
    --cr-accent: var(--mt-accent, #2563eb);
    --cr-accent-hover: var(--mt-accent-hover, #1d4ed8);
    --cr-accent-text: var(--mt-accent-ink, #ffffff);
    --cr-accent-soft: color-mix(in srgb, var(--cr-accent) 11%, transparent);
    --cr-hover: color-mix(in srgb, var(--cr-text) 5%, transparent);
    --cr-danger: #dc2626;
    --cr-success: #059669;
    --cr-warn: #b45309;
    --cr-radius: 14px;
    --cr-tap: 42px;
    --cr-ease: cubic-bezier(0.22, 1, 0.36, 1);

    position: fixed;
    inset: 0;
    z-index: 2147483642;
    display: flex;
    flex-direction: column;
    background: var(--cr-bg);
    color: var(--cr-text);
    font-family: var(--mt-font, 'Outfit', 'Inter', 'Cairo', system-ui, sans-serif);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.28s var(--cr-ease), visibility 0s linear 0.28s;
}

.cr-container.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: opacity 0.2s ease, transform 0.28s var(--cr-ease);
}

.cr-container *,
.cr-container *::before,
.cr-container *::after { box-sizing: border-box; }

.cr-container [hidden] { display: none !important; }

/* the old dimmed backdrop is not used by the full page */
.cr-overlay { display: none; }

.cr-container button { font-family: inherit; }
.cr-container :focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }

/* ── Top bar ── */
.cr-top {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--cr-surface);
    border-bottom: 1px solid var(--cr-border);
}

.cr-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--cr-tap);
    padding: 0 14px;
    border: 1px solid var(--cr-border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--cr-text);
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.cr-back:hover { background: var(--cr-hover); }
.cr-container[dir="rtl"] .cr-back i { transform: scaleX(-1); }

.cr-top-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.cr-top-icon {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--cr-accent-soft);
    color: var(--cr-accent);
    font-size: 1rem;
}
.cr-header-title { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; color: var(--cr-text); }
.cr-header-subtitle { font-size: 0.82rem; color: var(--cr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cr-top-status {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--cr-raised);
    color: var(--cr-muted);
    font-size: 0.8rem; font-weight: 600;
}
.cr-top-status.is-on { color: var(--cr-success); background: color-mix(in srgb, var(--cr-success) 10%, transparent); }

/* ── Body: side list + main ── */
.cr-body { flex: 1 1 auto; min-height: 0; display: flex; }

.cr-side {
    flex: 0 0 280px;
    display: flex; flex-direction: column; gap: 10px;
    padding: 18px 14px;
    background: var(--cr-surface);
    border-inline-end: 1px solid var(--cr-border);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.cr-side-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 6px;
    font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--cr-muted);
}
.cr-side-count { background: var(--cr-raised); border-radius: 999px; padding: 1px 8px; letter-spacing: 0; }
.cr-side-count:empty { display: none; }

.cr-class-add-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--cr-tap);
    border: 1px dashed var(--cr-border-strong);
    border-radius: 12px;
    background: transparent;
    color: var(--cr-accent);
    font-size: 0.92rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.cr-class-add-btn:hover { background: var(--cr-accent-soft); border-color: var(--cr-accent); }

.cr-new-class { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--cr-border); border-radius: 12px; background: var(--cr-raised); }
.cr-new-class-actions { display: flex; justify-content: flex-end; gap: 8px; }

.cr-class-list { display: flex; flex-direction: column; gap: 4px; }
.cr-class-list-empty { padding: 18px 8px; text-align: center; color: var(--cr-muted); font-size: 0.86rem; }

.cr-class-item {
    display: flex; align-items: center; gap: 11px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--cr-text);
    text-align: start;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.cr-class-item:hover { background: var(--cr-hover); }
.cr-class-item.active { background: var(--cr-accent-soft); border-color: color-mix(in srgb, var(--cr-accent) 30%, transparent); }
.cr-class-item-icon, .cr-class-badge {
    flex: 0 0 auto;
    display: grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--cr-class-color, var(--cr-accent)) 16%, transparent);
    color: var(--cr-class-color, var(--cr-accent));
    font-weight: 700; font-size: 0.98rem;
}
.cr-class-item.archived .cr-class-item-icon { background: var(--cr-raised); color: var(--cr-muted); font-size: 0.82rem; }
.cr-class-item-text { display: flex; flex-direction: column; min-width: 0; }
.cr-class-item-name { font-weight: 600; font-size: 0.94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-class-count { font-size: 0.78rem; color: var(--cr-muted); }

.cr-archive-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--cr-border); }
.cr-archive-header {
    display: flex; align-items: center; gap: 8px;
    width: 100%; min-height: 38px; padding: 0 10px;
    border: none; border-radius: 10px; background: transparent;
    color: var(--cr-muted); font-size: 0.84rem; font-weight: 600; cursor: pointer;
}
.cr-archive-header:hover { background: var(--cr-hover); }
.cr-archive-header .arrow { margin-inline-start: auto; font-size: 0.7rem; transition: transform 0.2s ease; }
.cr-archive-header.is-open .arrow { transform: rotate(180deg); }
.cr-archive-content { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

/* ── Main ── */
.cr-main {
    flex: 1 1 auto; min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px clamp(16px, 3vw, 36px) 40px;
    display: flex; flex-direction: column; gap: 18px;
}
.cr-main > * { width: 100%; max-width: 1180px; margin-inline: auto; flex: 0 0 auto; }

.cr-class-head { display: flex; align-items: center; gap: 14px; }
.cr-class-badge { width: 52px; height: 52px; border-radius: 14px; font-size: 1.35rem; }
.cr-class-titles { flex: 1 1 auto; min-width: 0; }
.cr-student-title { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--cr-text); line-height: 1.2; overflow-wrap: anywhere; }
.cr-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cr-class-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.cr-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--cr-raised);
    color: var(--cr-muted);
    font-size: 0.8rem; font-weight: 600;
    vertical-align: middle;
}
.cr-chip i { font-size: 0.72rem; }
.cr-chip--ok { color: var(--cr-success); background: color-mix(in srgb, var(--cr-success) 10%, transparent); }
.cr-chip--muted { font-size: 0.74rem; }

/* ── Buttons and inputs ── */
.cr-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--cr-tap);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.92rem; font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.cr-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.cr-btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.85rem; }
.cr-btn-icon { padding: 0; width: var(--cr-tap); }
.cr-btn-sm.cr-btn-icon { width: 36px; }
.cr-btn-primary { background: var(--cr-accent); color: var(--cr-accent-text); }
.cr-btn-primary:hover:not(:disabled) { background: var(--cr-accent-hover); }
.cr-btn-ghost { background: var(--cr-surface); color: var(--cr-text); border-color: var(--cr-border-strong); }
.cr-btn-ghost:hover:not(:disabled), .cr-btn-ghost.is-on { background: var(--cr-hover); }
.cr-btn-danger { background: var(--cr-danger); color: #fff; }
.cr-btn-danger:hover { filter: brightness(0.93); }

.cr-input {
    width: 100%;
    min-height: var(--cr-tap);
    padding: 0 12px;
    border: 1px solid var(--cr-border-strong);
    border-radius: 10px;
    background: var(--cr-surface);
    color: var(--cr-text);
    font: inherit; font-size: 0.94rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cr-input::placeholder { color: color-mix(in srgb, var(--cr-muted) 75%, transparent); }
.cr-input:focus { border-color: var(--cr-accent); box-shadow: 0 0 0 3px var(--cr-accent-soft); }

/* ── Invite card ── */
.cr-invite, .cr-students {
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
}
.cr-invite-head {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border: none; background: transparent; color: var(--cr-text);
    text-align: start; cursor: pointer;
}
.cr-invite-icon { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--cr-accent-soft); color: var(--cr-accent); }
.cr-invite-titles { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.cr-invite-titles b { font-size: 1rem; font-weight: 700; }
.cr-invite-titles small { font-size: 0.82rem; color: var(--cr-muted); }
.cr-invite-head .arrow { color: var(--cr-muted); font-size: 0.8rem; transition: transform 0.2s ease; }
.cr-invite.is-open .cr-invite-head .arrow { transform: rotate(180deg); }

.cr-ways { display: none; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding: 0 18px 18px; }
.cr-invite.is-open .cr-ways { display: grid; }

.cr-way {
    position: relative;
    display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
    padding: 16px;
    border: 1px solid var(--cr-border);
    border-radius: 12px;
    background: var(--cr-bg);
    min-width: 0;
}
.cr-way--best { border-color: color-mix(in srgb, var(--cr-accent) 45%, transparent); background: var(--cr-accent-soft); }
.cr-way--wide { grid-column: 1 / -1; }
.cr-way-tag {
    position: absolute; top: 14px; inset-inline-end: 14px;
    padding: 2px 9px; border-radius: 999px;
    background: var(--cr-accent); color: var(--cr-accent-text);
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em;
}
.cr-way-title { display: flex; align-items: center; gap: 9px; font-size: 0.98rem; color: var(--cr-text); padding-inline-end: 96px; }
.cr-way:not(.cr-way--best) .cr-way-title { padding-inline-end: 0; }
.cr-way-title i { color: var(--cr-accent); }
.cr-way p { margin: 0; font-size: 0.86rem; color: var(--cr-muted); flex: 1 1 auto; }
.cr-link-row { display: flex; gap: 8px; width: 100%; }
.cr-link-input { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.86rem; min-width: 0; }
.cr-way-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; width: 100%; }
.cr-way p.cr-way-warn { flex: 0 0 auto; display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; font-size: 0.8rem; line-height: 1.4; color: #92400e; background: #fef3c7; border: 1px solid #fcd34d; }
.cr-way-warn i { margin-top: 2px; color: #d97706; }
.cr-way-warn b { color: inherit; }
.cr-way-note { font-size: 0.82rem; color: var(--cr-muted); flex: 1 1 220px; }
.cr-way-note.is-ok { color: var(--cr-success); font-weight: 600; }
.cr-way-btns { display: flex; gap: 8px; }
.cr-code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 1.5rem; font-weight: 700; letter-spacing: 0.14em;
    color: var(--cr-text);
    user-select: all;
}

/* ── Students ── */
.cr-students { display: flex; flex-direction: column; }
.cr-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; flex-wrap: wrap; }
.cr-section-title { font-size: 1rem; font-weight: 700; margin-inline-end: auto; }
.cr-search { position: relative; flex: 0 1 300px; min-width: 180px; display: block; }
.cr-search i { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--cr-muted); font-size: 0.82rem; pointer-events: none; }
.cr-search input {
    width: 100%; min-height: var(--cr-tap);
    padding: 0 12px; padding-inline-start: 36px;
    border: 1px solid var(--cr-border-strong); border-radius: 10px;
    background: var(--cr-surface); color: var(--cr-text);
    font: inherit; font-size: 0.92rem; outline: none;
}
.cr-search input:focus { border-color: var(--cr-accent); box-shadow: 0 0 0 3px var(--cr-accent-soft); }

.cr-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.4fr) auto;
    gap: 10px; align-items: end;
    padding: 14px 18px;
    background: var(--cr-raised);
    border-block: 1px solid var(--cr-border);
}
.cr-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cr-field > span { font-size: 0.78rem; font-weight: 600; color: var(--cr-muted); }
.cr-field em { font-style: normal; font-weight: 500; opacity: 0.8; }
.cr-field em::before { content: '· '; }

.cr-bulk-section { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--cr-border); }
.cr-bulk-head { display: flex; flex-direction: column; gap: 2px; }
.cr-bulk-head b { font-size: 0.95rem; }
.cr-bulk-head span { font-size: 0.84rem; color: var(--cr-muted); }
.cr-bulk-textarea {
    width: 100%; min-height: 150px; resize: vertical;
    padding: 12px;
    border: 1px solid var(--cr-border-strong); border-radius: 10px;
    background: var(--cr-surface); color: var(--cr-text);
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.86rem; line-height: 1.6;
    outline: none; tab-size: 4;
}
.cr-bulk-textarea:focus { border-color: var(--cr-accent); box-shadow: 0 0 0 3px var(--cr-accent-soft); }
.cr-bulk-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cr-bulk-preview { margin-inline-end: auto; font-size: 0.86rem; color: var(--cr-muted); }
.cr-bulk-preview b { color: var(--cr-success); }
.cr-file-btn { cursor: pointer; }

.cr-select-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 18px;
    background: var(--cr-accent-soft);
    border-bottom: 1px solid var(--cr-border);
    position: sticky; top: 0; z-index: 2;
}
.cr-select-count { font-weight: 600; font-size: 0.9rem; margin-inline-end: auto; }

.cr-table-wrap { overflow-x: auto; }
.cr-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.cr-table th {
    padding: 10px 10px;
    text-align: start;
    font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--cr-muted);
    border-bottom: 1px solid var(--cr-border);
    white-space: nowrap;
}
.cr-table td { padding: 4px 10px; border-bottom: 1px solid var(--cr-border); vertical-align: middle; height: 52px; }
.cr-table tbody tr:last-child td { border-bottom: none; }
.cr-table tbody tr:hover { background: var(--cr-hover); }
.cr-table tbody tr.is-selected { background: var(--cr-accent-soft); }
.cr-table th:first-child, .cr-table td:first-child { padding-inline-start: 18px; }
.cr-table th:last-child, .cr-table td:last-child { padding-inline-end: 14px; }
.cr-col-check { width: 40px; }
.cr-col-check input { width: 18px; height: 18px; accent-color: var(--cr-accent); cursor: pointer; vertical-align: middle; }
.cr-col-num { width: 36px; color: var(--cr-muted); font-variant-numeric: tabular-nums; }
.cr-col-act { text-align: end; }

.cr-cell--name { display: flex; align-items: center; gap: 10px; min-width: 200px; height: 52px; }
.cr-table td.cr-cell--name { border-bottom: 1px solid var(--cr-border); }
.cr-table tbody tr:last-child td.cr-cell--name { border-bottom: none; }
.cr-student-avatar {
    flex: 0 0 auto;
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 0.85rem;
}
.cr-cell-btn {
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 100%; min-height: 34px;
    padding: 4px 8px; margin-inline-start: -8px;
    border: 1px solid transparent; border-radius: 8px;
    background: transparent; color: var(--cr-text);
    font-size: inherit; text-align: start;
    cursor: text;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.cr-cell-btn:hover { background: var(--cr-surface); border-color: var(--cr-border-strong); }
.cr-cell-btn.is-empty { color: var(--cr-muted); font-size: 0.84rem; opacity: 0.55; }
.cr-cell-btn.is-empty i { font-size: 0.68rem; }
.cr-table tr:hover .cr-cell-btn.is-empty { opacity: 1; }
.cr-cell--name .cr-cell-btn { font-weight: 600; margin-inline-start: -4px; }
.cr-cell--pin .cr-cell-btn { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.86rem; letter-spacing: 0.04em; }
.cr-cell-input { min-height: 36px; padding: 0 8px; margin-inline-start: -8px; font-size: 0.92rem; min-width: 120px; }
.cr-cell--name .cr-cell-input { margin-inline-start: -4px; }

.cr-status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; font-weight: 600; color: var(--cr-muted); white-space: nowrap; }
.cr-status--ok { color: var(--cr-success); }
.cr-status--warn { color: var(--cr-warn); cursor: help; }

.cr-student-remove {
    width: 36px; height: 36px;
    border: none; border-radius: 9px; background: transparent;
    color: var(--cr-muted); cursor: pointer; opacity: 0.55;
    transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.cr-table tr:hover .cr-student-remove, .cr-student-remove:focus-visible { opacity: 1; }
.cr-student-remove:hover { background: color-mix(in srgb, var(--cr-danger) 12%, transparent); color: var(--cr-danger); }
.cr-col-act { width: 88px; white-space: nowrap; }
.cr-student-pw {
    width: 36px; height: 36px;
    border: none; border-radius: 9px; background: transparent;
    color: var(--cr-muted); cursor: pointer; opacity: 0.55;
    transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.cr-table tr:hover .cr-student-pw, .cr-student-pw:focus-visible { opacity: 1; }
.cr-student-pw:hover { background: var(--cr-accent-soft); color: var(--cr-accent); }

/* password badge beside the join status */
.cr-pw { display: inline-flex; align-items: center; gap: 5px; margin-inline-start: 8px; padding: 2px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; color: var(--cr-accent); background: var(--cr-accent-soft); white-space: nowrap; }
.cr-pw--locked { color: var(--cr-danger); background: color-mix(in srgb, var(--cr-danger) 12%, transparent); }

/* who can join with email */
.cr-who { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cr-who-opt { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border: 1px solid var(--cr-border); border-radius: 12px; background: var(--cr-surface); cursor: pointer; font-size: 0.84rem; line-height: 1.3; }
.cr-who-opt input { margin-top: 2px; accent-color: var(--cr-accent); flex: 0 0 auto; }
.cr-who-opt span { display: flex; flex-direction: column; gap: 2px; }
.cr-who-opt b { color: var(--cr-text); font-weight: 700; }
.cr-who-opt small { color: var(--cr-muted); font-size: 0.76rem; }
.cr-who-opt:has(input:checked) { border-color: var(--cr-accent); box-shadow: 0 0 0 1px var(--cr-accent) inset; }
@media (max-width: 560px) { .cr-who { grid-template-columns: 1fr; } }

/* set a new password pop-up */
.cr-pw-card { align-items: stretch; text-align: start; }
.cr-pw-card .cr-pop-title { text-align: center; }
.cr-pw-card .cr-pw-help { text-align: center; }
.cr-pw-card .cr-pw-help b { word-break: break-all; color: #111827; }
.cr-pw-step { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.cr-pw-step[hidden] { display: none; }
.cr-pw-input { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 1.2rem; text-align: center; letter-spacing: 0.06em; color: #111827; background: #fff; }
.cr-pw-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.cr-pw-show { text-align: center; padding: 12px; border-radius: 14px; background: #f5f4ff; letter-spacing: 0.08em; word-break: break-all; }

.cr-privacy { margin: 0; padding: 12px 18px; border-top: 1px solid var(--cr-border); font-size: 0.82rem; color: var(--cr-muted); }
.cr-privacy i { margin-inline-end: 6px; color: var(--cr-success); }
.cr-main:not(.cr-has-students) .cr-privacy,
.cr-main:not(.cr-has-students) .cr-table thead,
.cr-main:not(.cr-has-students) .cr-search { display: none; }

/* ── Empty states ── */
.cr-empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 20px; color: var(--cr-muted); }
.cr-empty-state--page { margin-block: auto; }
.cr-empty-state--compact { padding: 32px 20px; }
.cr-empty-icon { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 18px; background: var(--cr-accent-soft); color: var(--cr-accent); font-size: 1.4rem; }
.cr-empty-title { font-size: 1.15rem; font-weight: 700; color: var(--cr-text); }
.cr-empty-state p { margin: 0; max-width: 420px; font-size: 0.92rem; }

/* ── Pop-up menu ── */
.cr-ctx-menu {
    position: absolute; z-index: 20;
    min-width: 200px; padding: 6px;
    background: var(--cr-surface);
    border: 1px solid var(--cr-border-strong); border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}
.cr-ctx-menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: 40px; padding: 0 12px;
    border: none; border-radius: 8px; background: transparent;
    color: var(--cr-text); font-size: 0.9rem; text-align: start; cursor: pointer;
}
.cr-ctx-menu button:hover { background: var(--cr-hover); }
.cr-ctx-menu button i { width: 16px; color: var(--cr-muted); }
.cr-ctx-menu button.is-danger, .cr-ctx-menu button.is-danger i { color: var(--cr-danger); }

/* ── QR pop-up ── */
.cr-pop { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(10, 14, 24, 0.55); }
.cr-pop-card {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    width: min(420px, 100%); padding: 28px 24px;
    background: #fff; color: #111827;
    border-radius: 20px; text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.cr-pop-close { position: absolute; top: 12px; inset-inline-end: 12px; width: 38px; height: 38px; border: none; border-radius: 50%; background: #f1f5f9; color: #334155; cursor: pointer; }
.cr-pop-title { font-size: 1.15rem; font-weight: 700; padding-inline: 34px; }
.cr-qr { padding: 10px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; word-break: break-all; }
.cr-qr img, .cr-qr canvas { display: block; max-width: 100%; height: auto; }
.cr-pop-code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.16em; }
.cr-pop-card p { margin: 0; font-size: 0.88rem; color: #475569; }

/* ── Tablet ── */
@media (max-width: 1100px) {
    .cr-ways { grid-template-columns: 1fr 1fr; }
    .cr-way--best { grid-column: 1 / -1; }
    .cr-add-row { grid-template-columns: 1fr 1fr; }
    .cr-field--name { grid-column: 1 / -1; }
    .cr-add-row .cr-btn { grid-column: 1 / -1; }
}

/* ── Phone: classes become a strip on top, table rows become cards ── */
@media (max-width: 760px) {
    .cr-top { padding: 10px 12px; gap: 10px; }
    .cr-back span, .cr-header-subtitle, .cr-top-status span { display: none; }
    .cr-top-status { padding: 9px; }
    .cr-body { flex-direction: column; }
    .cr-side {
        flex: 0 0 auto;
        flex-direction: row; align-items: center; gap: 8px;
        padding: 10px 12px;
        border-inline-end: none; border-bottom: 1px solid var(--cr-border);
        overflow-x: auto; overflow-y: hidden;
    }
    .cr-side-head { display: none; }
    .cr-class-add-btn { flex: 0 0 auto; padding: 0 14px; }
    .cr-new-class { flex: 0 0 260px; }
    .cr-class-list, .cr-archive-content { flex-direction: row; }
    .cr-archive-group { display: flex; gap: 4px; margin: 0; padding: 0; border: none; }
    .cr-class-item { flex: 0 0 auto; width: auto; max-width: 220px; }
    .cr-class-count { display: none; }
    .cr-main { padding: 16px 12px 32px; gap: 14px; }
    .cr-class-head { flex-wrap: wrap; }
    .cr-student-title { font-size: 1.25rem; }
    .cr-class-badge { width: 44px; height: 44px; }
    .cr-class-actions .cr-btn span { display: none; }
    .cr-class-actions .cr-btn { width: 36px; padding: 0; }
    .cr-ways { grid-template-columns: 1fr; padding: 0 12px 12px; }
    .cr-link-row { flex-direction: column; }
    .cr-toolbar, .cr-add-row, .cr-bulk-section, .cr-select-bar, .cr-privacy { padding-inline: 12px; }
    .cr-search { flex: 1 1 100%; order: 3; }
    .cr-add-row { grid-template-columns: 1fr; }

    .cr-table thead { display: none; }
    .cr-table, .cr-table tbody { display: block; }
    .cr-table tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 2px 10px; align-items: center;
        padding: 10px 12px;
        border-bottom: 1px solid var(--cr-border);
    }
    .cr-table td, .cr-table td.cr-cell--name { height: auto; padding: 0; border: none; }
    .cr-table td:first-child { padding: 0; }
    .cr-col-num { display: none; }
    .cr-col-check { grid-row: 1; grid-column: 1; width: auto; }
    .cr-cell--name { grid-row: 1; grid-column: 2; min-width: 0; }
    .cr-col-act { grid-row: 1; grid-column: 3; width: auto; }
    .cr-table td[data-label] { grid-column: 2 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; }
    .cr-table td[data-label]::before { content: attr(data-label); flex: 0 0 72px; font-size: 0.74rem; font-weight: 600; color: var(--cr-muted); }
    .cr-student-remove { opacity: 1; }
    .cr-cell-btn.is-empty { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .cr-container, .cr-container * { transition: none !important; }
}
