:root {
    --bg: #f6f7fb;
    --fg: #172033;
    --muted: #667085;
    --accent: #2457d6;
    --accent-hover: #1f49b8;
    --danger: #c4322b;
    --success: #12805c;
    --warning: #b7791f;
    --card: #ffffff;
    --surface-muted: #f8fafc;
    --border: #dfe4ec;
    --ring: rgba(36, 87, 214, 0.16);
    --radius: 8px;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    background: #eef2ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    min-height: 58px;
    padding: 10px 24px;
}

.topbar .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--fg);
    text-decoration: none;
    font-size: 16px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--fg);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

.brand-mark-lg {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 14px;
}

.topbar .nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar .user {
    color: var(--muted);
    font-size: 14px;
}

.topbar .logout {
    color: var(--muted);
}

.main {
    padding: 20px 20px;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
}

.page-wide {
    max-width: 1600px;
    margin: 0 auto;
}

h1 {
    margin: 0 0 16px 0;
    font-size: 24px;
    font-weight: 600;
}

h2 {
    font-size: 18px;
    margin: 24px 0 12px 0;
    font-weight: 600;
}

.card > h2:first-child {
    margin-top: 0;
}

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

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

.card-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.card-heading h2 {
    margin: 0;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.45;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: #ffffff;
    color: var(--fg);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #f9fafb;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

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

.btn-success:hover {
    background: #15803d;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='search'],
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ----- Auth ----- */
.auth-page {
    display: flex;
    justify-content: center;
    padding: 60px 20px;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    margin: 0 0 20px 0;
    font-size: 22px;
}

.auth-brand {
    margin-bottom: 22px;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}

.auth-divider span {
    padding: 0 12px;
}

.auth-btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* ----- Common UI ----- */
.hidden {
    display: none !important;
}

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

.page-header h1 {
    margin: 0;
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
}

.back-link {
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
}

.back-link:hover {
    color: var(--fg);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form input[type='text'] {
    flex: 1;
}

.inline-form input[name='code'] {
    flex: 0 1 220px;
    text-transform: uppercase;
}

.entry-page {
    min-height: calc(100vh - 114px);
    display: grid;
    place-items: center;
    padding: 24px 0;
}

.status-page {
    min-height: calc(100vh - 114px);
    display: grid;
    place-items: center;
    padding: 24px 0;
}

.status-panel {
    width: min(100%, 520px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.status-code {
    display: inline-block;
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.entry-panel {
    width: min(100%, 500px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.entry-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    font-weight: 700;
}

.entry-panel h1 {
    margin-bottom: 8px;
    font-size: 28px;
}

.entry-panel .muted {
    margin-top: 0;
    margin-bottom: 22px;
}

.join-code-form label {
    margin-bottom: 8px;
}

.join-code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.join-code-row input {
    text-transform: uppercase;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0;
}

.join-code-row .btn {
    min-width: 112px;
    min-height: 40px;
}

.create-exam-card {
    padding: 18px;
}

.create-exam-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) minmax(210px, 260px) auto;
    gap: 12px;
    align-items: end;
}

.form-field {
    min-width: 0;
}

.form-field label {
    margin-bottom: 6px;
}

.form-field-code input {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f9fafb;
    color: var(--text);
    cursor: pointer;
}

.form-check input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

.form-check span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.form-check strong {
    font-size: 14px;
    line-height: 1.2;
}

.form-check small {
    color: var(--muted);
    line-height: 1.3;
}

.form-actions {
    display: flex;
}

.form-actions .btn {
    min-height: 40px;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .join-code-row {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 820px) {
    .create-exam-form {
        grid-template-columns: 1fr;
    }

    .form-actions .btn {
        width: 100%;
    }
}

.actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions-row form {
    margin: 0;
}

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

.summary-tile {
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.summary-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.summary-tile strong {
    display: block;
    font-size: 24px;
    line-height: 1.1;
}

.summary-tile .summary-value-sm {
    font-size: 18px;
    line-height: 1.25;
}

.summary-tile small {
    display: block;
    margin-top: 6px;
}

.summary-danger {
    color: var(--danger);
}

.participant-page {
    max-width: calc(100vw - 24px);
}

.participant-top-strip {
    position: relative;
    display: grid;
    grid-template-columns: 34px minmax(220px, 0.75fr) minmax(520px, 1.7fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    margin-bottom: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.participant-back-link {
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
}

.participant-title h1 {
    margin: 0;
    overflow: hidden;
    font-size: 20px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant-title {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 10px;
}

.participant-title .page-subtitle {
    margin: 0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant-compact-metrics {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
}

.participant-metric {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 12px;
    border-right: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
}

.participant-metric span,
.participant-metric small {
    color: var(--muted);
}

.participant-metric strong {
    font-size: 15px;
    line-height: 1;
}

.participant-connection-details {
    position: relative;
    min-width: 0;
    margin-left: 10px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
}

.participant-connection-details .connection-log-summary {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 13px;
}

.participant-connection-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: min(860px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 180px));
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.participant-top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.copy-feedback {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    margin-left: 8px;
    font-size: 13px;
}

.copy-feedback-error {
    color: var(--danger);
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .participant-top-strip {
        grid-template-columns: 34px 1fr auto;
    }

    .participant-compact-metrics {
        grid-column: 1 / -1;
        flex-wrap: wrap;
        gap: 6px;
    }

    .participant-metric {
        border-right: 0;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--surface-muted);
    }

    .participant-connection-details {
        margin-left: 0;
    }
}

@media (max-width: 560px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .copy-feedback {
        display: flex;
        margin: 8px 0 0;
    }

    .participant-top-strip {
        grid-template-columns: 34px 1fr;
    }

    .participant-top-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

.inline-action-form {
    display: inline;
}

.rename-form {
    margin-top: 12px;
}

.section-actions {
    margin-top: 14px;
}

.error-details {
    margin-top: 8px;
}

.error-details pre {
    max-width: 100%;
    overflow: auto;
    background: #111827;
    color: #f9fafb;
    border-radius: 6px;
    padding: 10px 12px;
    white-space: pre-wrap;
}

.code-pill {
    background: #eef2ff;
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.05em;
}

.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 12px;
    margin: 0;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
}

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-draft {
    background: #f3f4f6;
    color: #4b5563;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-finished {
    background: #fee2e2;
    color: #991b1b;
}

/* ----- Tables ----- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--card);
}

.table-shell {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: #f9fafb;
    color: var(--muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #fafafa;
}

.table-actions {
    white-space: nowrap;
}

.exam-list-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(150px, auto) minmax(150px, auto);
    gap: 12px;
    align-items: end;
    margin: 16px 0 12px;
}

.exam-search,
.exam-filter {
    min-width: 0;
}

.exam-filter label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
}

.exam-list-summary {
    grid-column: 1 / -1;
    margin: -2px 0 0;
    font-size: 13px;
}

@media (max-width: 760px) {
    .exam-list-toolbar {
        grid-template-columns: 1fr;
    }
}

.connection-log-shell {
    box-shadow: none;
}

.connection-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.connection-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
}

.connection-state .conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.connection-state-online {
    background: #dcfce7;
    color: var(--success);
}

.connection-state-offline {
    background: #f3f4f6;
    color: var(--muted);
}

.connection-log-table code {
    white-space: nowrap;
}

.user-agent-cell {
    max-width: 420px;
    word-break: break-word;
}

/* ----- Exam (participant) page ----- */
.exam-page {
    max-width: 720px;
    margin: 0 auto;
}

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

.exam-header h1 {
    margin: 0;
    font-size: 20px;
}

.conn-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 14px;
    background: #f3f4f6;
    color: var(--muted);
}

.conn-status .conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.conn-status.conn-connected {
    background: #dcfce7;
    color: var(--success);
}

.conn-status.conn-warn {
    background: #fef3c7;
    color: var(--warning);
}

.conn-status.conn-disconnected {
    background: #fee2e2;
    color: var(--danger);
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#preview {
    margin-top: 12px;
    width: 100%;
    max-height: 300px;
    background: #000;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.exam-geekclass-btn {
    margin-top: 14px;
}

.exam-auth-divider {
    margin: 18px 0 16px;
}

/* ----- Live monitoring ----- */
.live-page {
    max-width: none;
    margin: 0;
}

.live-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.live-header h1 {
    margin: 0;
    font-size: 18px;
    min-width: 200px;
}

.live-code {
    font-size: 13px;
}

.live-stats {
    margin-left: auto;
    display: flex;
    gap: 10px 16px;
    flex-wrap: wrap;
    font-size: 14px;
}

.live-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
    margin: -4px 0 14px;
    flex-wrap: wrap;
}

.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f9fafb;
}

.segmented button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 7px 12px;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.segmented button:hover {
    color: var(--text);
    background: #eef2ff;
}

.segmented button.active {
    color: #fff;
    background: var(--accent);
}

.live-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: min(100%, 260px);
}

.live-search input {
    min-width: 220px;
    height: 38px;
}

.live-filter-summary {
    margin: 0 0 0 auto;
    font-size: 13px;
}

@media (max-width: 640px) {
    .live-toolbar,
    .live-search,
    .live-search input {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .live-stats,
    .live-filter-summary {
        margin-left: 0;
    }
}

.live-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 16px;
    align-items: start;
}

/* 3-колоночная сетка для активного экзамена: экраны | журнал | список */
.live-body-3col {
    grid-template-columns: 1fr 260px 280px;
}

@media (max-width: 1280px) {
    .live-body-3col {
        grid-template-columns: 1fr 240px;
    }
    .live-body-3col .live-roster {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1000px) {
    .live-body,
    .live-body-3col {
        grid-template-columns: 1fr;
    }
}

.live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.live-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.screen-card {
    position: relative;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition:
        border-color 0.2s,
        transform 0.1s;
    aspect-ratio: 16 / 10;
    display: flex;
    flex-direction: column;
}

.screen-card.filtered-hidden {
    display: none;
}

.screen-card:hover {
    border-color: var(--accent);
}

.screen-card.stale {
    border-color: var(--danger);
    animation: pulse-red 1.5s infinite;
}

.screen-card.disconnected .screen-img img,
.screen-card.stale .screen-img img {
    filter: saturate(0.55) brightness(0.7);
}

.screen-status {
    position: absolute;
    inset: auto 10px 10px 10px;
    z-index: 3;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(127, 29, 29, 0.88);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
}

@keyframes pulse-red {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
    }
}

.screen-name {
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
}

.screen-name .screen-since {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    white-space: nowrap;
}

.screen-img {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
}

.screen-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.screen-placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
}

.screen-card.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    border-radius: 0;
    aspect-ratio: auto;
    border: none;
}

.screen-card.fullscreen .screen-img img {
    object-fit: contain;
}

.live-log {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    position: sticky;
    top: 16px;
}

.live-log h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.live-log ul {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
}

.live-log li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.live-log li:last-child {
    border-bottom: none;
}

.live-log .log-empty {
    color: var(--muted);
    border-bottom: none;
}

.live-log .log-time {
    color: var(--muted);
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 500;
    margin-right: 8px;
    background: var(--surface-muted);
    padding: 1px 5px;
    border-radius: 3px;
}

.live-log .log-warn {
    color: var(--warning);
}

.live-log .log-error {
    color: var(--danger);
}

/* ----- Player ----- */
.player-card {
    padding: 0;
    overflow: hidden;
}

.participant-page .player-card {
    width: calc(100vw - 24px);
    margin-left: 50%;
    margin-bottom: 0;
    transform: translateX(-50%);
    border-radius: 8px;
}

.player-note {
    margin: 0;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.player-wrap {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
}

.participant-page .player-wrap {
    min-height: calc(100vh - 198px);
}

.player-wrap video,
.player-wrap img {
    width: 100%;
    max-height: 70vh;
    display: block;
    object-fit: contain;
}

.participant-page .player-wrap video,
.participant-page .player-wrap img {
    max-height: calc(100vh - 198px);
}

@media (max-width: 760px) {
    .participant-page,
    .participant-page .player-card {
        width: auto;
        max-width: 100%;
        margin-left: 0;
        transform: none;
    }

    .participant-page .player-wrap {
        min-height: 260px;
    }
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.speed-buttons {
    display: flex;
    gap: 4px;
}

.speed-buttons .btn {
    padding: 4px 8px;
    font-size: 12px;
}

.speed-buttons .btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.player-time {
    margin-left: auto;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--muted);
}

.timeline-wrap {
    position: relative;
    padding: 0 14px 14px;
}

.timeline {
    width: 100%;
    height: 40px;
    cursor: pointer;
    display: block;
}

.timeline rect.tl-gap {
    cursor: pointer;
    transition: opacity 0.15s;
}

.timeline rect.tl-gap:hover {
    opacity: 0.85;
}

.timeline .tl-connection-marker {
    cursor: pointer;
    vector-effect: non-scaling-stroke;
}

.timeline .tl-connection-marker:hover {
    stroke-width: 5;
}

.timeline-tooltip {
    position: absolute;
    bottom: 48px;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.timeline-tooltip strong {
    color: #fca5a5;
}

/* ----- Player exam time overlay & gap indicator ----- */
.player-wrap {
    position: relative;
}

.player-wrap-gap {
    background: #000;
}

.player-wrap-gap::before {
    content: 'Нет связи';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    z-index: 1;
}

.player-exam-time {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 6px 16px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 4;
}

.gap-indicator {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 600;
}

.player-actions {
    padding: 0 16px 14px;
    display: flex;
    gap: 8px;
}

/* ----- Live inline (merged exam+live page) ----- */
.live-inline-card {
    padding: 14px 16px;
}

.live-inline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    min-height: 36px;
}

.live-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.live-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.live-inline-header h2 {
    margin: 0;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.live-inline-header h2 .text-danger {
    color: var(--danger);
    animation: pulse-dot 1.5s ease-in-out infinite;
    font-size: 12px;
}

@keyframes pulse-dot {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.live-inline-header .live-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    margin-left: 0;
}

.live-inline-header .live-stats .text-success {
    color: var(--success);
}

.live-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.live-search-box i {
    position: absolute;
    left: 10px;
    color: var(--muted);
    font-size: 12px;
    pointer-events: none;
}

.live-search-box input[type='search'] {
    padding-left: 30px;
    width: 180px;
    min-height: 32px;
    height: 32px;
    font-size: 13px;
}

/* ----- Compact exam page ----- */
.exam-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.exam-topbar .back-link {
    font-size: 16px;
    color: var(--muted);
    padding: 4px 6px;
}

.exam-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.exam-title-group h1 {
    margin: 0;
    font-size: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exam-rename-form {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.exam-rename-form input[type='text'] {
    min-height: 34px;
    font-size: 16px;
    font-weight: 600;
}

.exam-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon {
    padding: 6px 10px;
    min-width: 34px;
    min-height: 32px;
    text-align: center;
    line-height: 1;
}

.btn-icon i {
    font-size: 13px;
}

/* Инфополоса */
.exam-infobar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.exam-infobar-invite {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.invite-input {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    min-height: 32px;
    height: 32px;
    font-size: 13px;
    padding: 4px 10px;
}

.exam-infobar-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
    flex-wrap: wrap;
}

.exam-infobar-stats i {
    margin-right: 2px;
}

.exam-params-details {
    font-size: 13px;
    margin-left: auto;
}

.exam-params-details summary {
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
}

.exam-params-details summary:hover {
    background: var(--surface-muted);
}

.exam-params-details[open] {
    flex: 1 0 100%;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.exam-params-kv {
    margin-top: 8px;
    font-size: 13px;
}

/* Participants table compact */
.participants-table .participant-name-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.participant-meta {
    font-size: 12px;
}

.participants-table td {
    padding: 8px 10px;
}

.cell-num {
    font-variant-numeric: tabular-nums;
}

.participants-table .table-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    white-space: nowrap;
}

.inline-action-form {
    display: inline-block;
    margin: 0;
}

/* Live log header */
.live-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.live-log-header h3 {
    margin: 0;
}

/* ----- Connection log as collapsible details ----- */
.connection-log-details {
    padding: 12px 16px;
}

.connection-log-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    list-style: none;
    user-select: none;
}

.connection-log-summary::-webkit-details-marker {
    display: none;
}

.connection-log-details[open] .connection-log-summary {
    margin-bottom: 12px;
}

.connection-log-details .table-shell {
    margin-top: 8px;
}

.participant-connection-details {
    padding: 0;
}

.participant-connection-details[open] .connection-log-summary {
    margin-bottom: 0;
}

.participant-connection-details .table-shell {
    margin-top: 0;
}

.user-role {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #eef2ff;
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    vertical-align: middle;
}

.participants-table .participant-name-cell > span:first-child {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.screen-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* ----- Toast notifications ----- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #1f2937;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateX(20px);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    pointer-events: auto;
    max-width: 320px;
}

.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

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

.toast-warn {
    background: var(--warning);
}

.toast-info {
    background: var(--accent);
}

/* ----- Live roster (compact participant list) ----- */
.live-roster {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.live-roster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.live-roster-header h3 {
    margin: 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.roster-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.roster-empty {
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
}

.roster-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.roster-item.roster-online {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.roster-item.roster-stale {
    background: #fef3c7;
    border-color: #fde68a;
    animation: pulse-amber 1.5s ease-in-out infinite;
}

@keyframes pulse-amber {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
    }
}

.roster-link {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: var(--fg);
}

.roster-link:hover {
    text-decoration: none;
    color: var(--accent);
}

.roster-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.roster-item.roster-online .roster-status-dot {
    background: var(--success);
}

.roster-item.roster-stale .roster-status-dot {
    background: var(--warning);
}

.roster-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.roster-frames {
    font-size: 12px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.roster-frames i {
    font-size: 10px;
    margin-right: 2px;
}

.roster-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.roster-rec i {
    font-size: 14px;
}

.roster-absence {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.text-success {
    color: var(--success);
}
.text-danger {
    color: var(--danger);
}
.text-warning {
    color: var(--warning);
}
