/* ── Reset & Variables ──────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a0a0a;
    --bg-panel: #111;
    --bg-hover: #1a1a1a;
    --bg-active: #222;
    --border: #222;
    --text: #888;
    --text-bright: #ccc;
    --text-dim: #555;
    --accent: #444;
    --accent-hover: #555;
    --success: #3a3;
    --error: #a33;
    --warn: #a83;
    --score-high: #4a4;
    --score-mid: #aa4;
    --score-low: #a44;
}

body {
    font-family: monospace;
    font-size: 12px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    overflow: hidden;
    height: 100vh;
}

/* ── Toolbar ───────────────────────────────────────────────────────── */
#toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    height: 28px;
    flex-shrink: 0;
}

#toolbar-left, #toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-ice-pill {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 1px 6px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 16px;
    transition: color .15s, border-color .15s;
}
.btn-ice-pill:hover { color: var(--text); border-color: var(--text-muted); }
.btn-ice-pill.active { color: #79b8d1; border-color: #79b8d1; }

#app-title { color: var(--text-bright); font-weight: bold; }
#toolbar-sep { color: var(--text-dim); }
#view-title { color: var(--text); }
#user-info { color: var(--text-dim); font-size: 11px; }

/* ? shortcut help button */
#btn-shortcut-help {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 50%;
    width: 16px; height: 16px;
    font-size: 10px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
#btn-shortcut-help:hover { color: var(--text-bright); border-color: var(--text); }

/* Shortcut help popup */
.shortcuts-popup {
    position: fixed;
    top: 28px; left: 0;
    z-index: 300;
    pointer-events: none;
    padding: 4px 0 0 8px;
}
.shortcuts-popup.hidden { display: none; }
.shortcuts-popup-inner {
    pointer-events: all;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 3px;
    min-width: 280px;
    max-width: 360px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,.55);
}
.shortcuts-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: bold;
    color: var(--text-bright);
}
.shortcuts-popup-header button {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.shortcuts-popup-header button:hover { color: var(--text-bright); }
.shortcuts-popup-body { padding: 6px 8px; font-size: 11px; }
.shortcut-section { margin-bottom: 8px; }
.shortcut-section:last-child { margin-bottom: 0; }
.shortcut-section-title {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .07em;
    font-size: 9px;
    margin-bottom: 3px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border);
}
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 0;
    gap: 8px;
}
.shortcut-key {
    color: var(--text-bright);
    font-family: monospace;
    background: var(--bg);
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.shortcut-desc { color: var(--text); }

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.on { background: var(--success); }
.status-dot.off { background: var(--error); }

/* ── App container ─────────────────────────────────────────────────── */
#app {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: calc(100vh - 28px);
}

body { display: flex; flex-direction: column; }

.view { display: none; height: 100%; overflow: hidden; }
.view.active { display: flex; flex-direction: column; }

/* ── Common components ─────────────────────────────────────────────── */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 8px;
    overflow: auto;
}

.panel-row {
    display: flex;
    gap: 8px;
    height: 100%;
    padding: 8px;
}

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

.toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text-bright); }
.btn:active { background: var(--bg-active); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-sm { padding: 2px 6px; font-size: 11px; }
.btn-danger { border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: #1a0a0a; }

.input {
    padding: 3px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-bright);
    font-family: inherit;
    font-size: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.input:disabled { opacity: .5; }

.section-label {
    color: var(--text-dim);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    padding: 2px 0;
}

.mono { font-family: monospace; }

.list-container { min-height: 40px; }
.scrollable { overflow-y: auto; }

.placeholder {
    color: var(--text-dim);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.hidden { display: none !important; }

/* ── Lobby ─────────────────────────────────────────────────────────── */
#lobby-panel {
    margin: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#username-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
#username-bar label { color: var(--text-dim); white-space: nowrap; }
#input-username { width: 200px; }

.nat-badge {
    font-size: 10px;
    padding: 1px 6px;
    border: 1px solid currentColor;
    white-space: nowrap;
    cursor: default;
    font-family: monospace;
}
.nat-unknown  { color: var(--text-dim); }
.nat-cone     { color: var(--score-high); }
.nat-symmetric{ color: var(--score-mid); }
.nat-blocked  { color: var(--score-low); }

#session-list { flex: 1; max-height: 200px; overflow-y: auto; }

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--border);
    margin-bottom: 2px;
    cursor: pointer;
}
.session-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.session-item .session-title { color: var(--text-bright); }
.session-item .session-meta { color: var(--text-dim); font-size: 11px; }

.section-label-meta { color: var(--text-dim); font-size: 10px; margin-left: 4px; text-transform: none; letter-spacing: 0; }

#saved-session-list { max-height: 200px; overflow-y: auto; }

.saved-session-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    margin-bottom: 2px;
}
.saved-session-item:hover { background: var(--bg-hover); }
.saved-session-main { display: flex; align-items: baseline; gap: 8px; }
.saved-session-title { color: var(--text-bright); }
.saved-session-meta { color: var(--text-dim); font-size: 11px; }
.saved-session-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.saved-session-date { color: var(--text-dim); font-size: 10px; flex: 1; }

/* ── Library Manager ───────────────────────────────────────────────── */
.lib-file-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 11px;
}
.lib-file-item:hover { background: var(--bg-hover); }
.lib-file-item.active { background: var(--bg-active); color: var(--text-bright); }
.lib-file-item .has-meta { color: var(--success); }
.lib-file-item .no-meta { color: var(--text-dim); }

.editor-form { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: flex; align-items: center; gap: 8px; }
.form-row label { width: 50px; color: var(--text-dim); flex-shrink: 0; }
.form-row .input { flex: 1; }

/* ── Host Layout ───────────────────────────────────────────────────── */
.host-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.host-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 4px;
}

.host-sidebar, .viewer-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── Video ─────────────────────────────────────────────────────────── */
.video-container {
    position: relative;
    background: #000;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    overflow: hidden;
}

.video-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    top: 4px;
    left: 6px;
    color: #fff;
    font-size: 11px;
    text-shadow: 0 0 4px #000, 0 0 2px #000;
    pointer-events: none;
    opacity: .8;
}

/* ── Playback Controls ─────────────────────────────────────────────── */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
}

.seek {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    outline: none;
    cursor: pointer;
}
.seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: var(--text);
    cursor: pointer;
}

#time-display { font-size: 10px; color: var(--text-dim); min-width: 80px; text-align: center; }

#mic-volume {
    display: none;
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    outline: none;
    cursor: pointer;
    accent-color: var(--score-ok, #4caf50);
}
#mic-volume.visible { display: block; }
#mic-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: var(--score-ok, #4caf50);
    cursor: pointer;
}

/* ── Score Strip ───────────────────────────────────────────────────── */
.score-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    margin-top: 2px;
}

.score-input { width: 56px; text-align: center; }

/* Brief flash when score set via keyboard */
@keyframes score-flash-kf {
    0%   { box-shadow: 0 0 0 2px var(--score-high); }
    100% { box-shadow: none; }
}
.score-flash { animation: score-flash-kf 0.35s ease-out; }

.score-presets {
    display: flex;
    gap: 2px;
}
.score-presets .btn { padding: 1px 4px; font-size: 10px; min-width: 22px; text-align: center; }

/* ── Sidebar Tabs ──────────────────────────────────────────────────── */
.sidebar-tabs {
    display: flex;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.stab {
    padding: 4px 10px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    border-bottom: 2px solid transparent;
}
.stab:hover { color: var(--text); }
.stab.active { color: var(--text-bright); border-bottom-color: var(--text-bright); }

.stab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}
.stab-content.active { display: flex; }

/* ── Sidebar split layout ──────────────────────────────────────────── */
.sidebar-top {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.sidebar-resize-handle {
    flex-shrink: 0;
    height: 5px;
    background: var(--border);
    cursor: ns-resize;
    transition: background 0.15s;
    user-select: none;
    touch-action: none;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle:active { background: var(--accent); }

.sidebar-bottom {
    flex-shrink: 0;
    height: 44%;
    min-height: 80px;
    display: flex;
    flex-direction: column;
}

/* ── Chat ──────────────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    padding: 4px;
    overflow-y: auto;
    font-size: 11px;
}

.chat-msg {
    margin-bottom: 2px;
    word-break: break-word;
    cursor: pointer;
    border-radius: 2px;
}
.chat-msg:hover { background: var(--bg-hover); }
.chat-msg .chat-user { color: var(--text-bright); }
.chat-msg .chat-time { color: var(--text-dim); font-size: 10px; margin-right: 4px; }
.chat-msg.system { color: var(--text-dim); font-style: italic; }

.chat-input-row {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-top: 1px solid var(--border);
}
.btn-say { color: var(--text-dim); white-space: nowrap; }
.btn-say.say-on   { color: #79b8d1; border-color: #79b8d1; }
.btn-say.say-mute { color: #a33;    border-color: #a3333355; }

/* ── Math autocomplete dropdown ────────────────────────────────────── */
@keyframes suggest-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.math-suggest {
    position: fixed;
    z-index: 400;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 18px rgba(0,0,0,.65);
    font-size: 11px;
    font-family: monospace;
    max-height: 220px;
    overflow-y: auto;
    min-width: 220px;
    animation: suggest-fade-in .1s ease;
}
.math-suggest.hidden { display: none; }
.math-suggest-item {
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text);
    white-space: nowrap;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.math-suggest-item:hover,
.math-suggest-item.selected { background: var(--bg-active); color: var(--text-bright); }
/* Signature: bold matched prefix; rest is normal text */
.msi-sig { color: var(--text-bright); flex-shrink: 0; }
.msi-sig b { color: #79b8d1; font-weight: bold; }
/* Hint: dim, right-aligned, truncated */
.msi-hint {
    color: var(--text-dim);
    font-size: 9.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

/* ── User List ─────────────────────────────────────────────────────── */
.rename-bar {
    display: flex;
    gap: 4px;
    padding: 6px 6px 4px;
    border-bottom: 1px solid var(--border);
}
.user-item {
    padding: 6px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}
.user-item .user-main {
    display: flex;
    align-items: center;
    gap: 5px;
}
.user-item .user-name { color: var(--text-bright); flex: 1; }
.user-item.host .user-name { color: var(--warn); }
.user-item.self { opacity: 0.8; }
.badge {
    font-size: 9px;
    padding: 0 4px;
    border: 1px solid currentColor;
    border-radius: 2px;
    flex-shrink: 0;
}
.badge-host { color: var(--warn); }
.badge-self { color: var(--accent); }
.badge-auth { color: var(--score-high); }
.badge-anon { color: var(--text-dim); }
.conn-state { font-size: 9px; color: var(--text-dim); margin-left: auto; }
.conn-state.conn-ok  { color: var(--score-high); }
.conn-state.conn-bad { color: var(--score-low); }
.conn-state.conn-mid { color: var(--score-mid); }

/* ── Score List ────────────────────────────────────────────────────── */
.score-item {
    display: flex;
    align-items: center;
    padding: 3px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    gap: 8px;
}
.score-item .score-idx { color: var(--text-dim); width: 24px; text-align: right; }
.score-item .score-title { flex: 1; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-item .score-val { font-weight: bold; width: 36px; text-align: center; }
.score-val { font-weight: bold; }
.score-val.high { color: var(--score-high); }
.score-val.mid { color: var(--score-mid); }
.score-val.low { color: var(--score-low); }
.score-val.na { color: var(--text-dim); }
.score-item .score-comment { color: var(--text-dim); font-size: 10px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-item.current { background: var(--bg-active); }
.score-item.playing { border-left: 2px solid var(--warn); }

/* ── Playlist Items ────────────────────────────────────────────────── */
.playlist-item {
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    cursor: pointer;
}
.playlist-item:hover { background: var(--bg-hover); }
.playlist-item.playing { background: var(--bg-active); border-left: 2px solid var(--warn); }
.playlist-item .pl-main {
    display: flex;
    align-items: center;
    gap: 6px;
}
.playlist-item .pl-idx { color: var(--text-dim); width: 24px; text-align: right; flex-shrink: 0; }
.playlist-item .pl-title { flex: 1; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-item .pl-author { color: var(--text-dim); font-size: 10px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.playlist-item .pl-tags { color: var(--text-dim); font-size: 9px; }
.playlist-item .pl-comment {
    color: var(--text-dim);
    font-size: 10px;
    padding-left: 30px;
    margin-top: 2px;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Info Area ─────────────────────────────────────────────────────── */
.info-area {
    padding: 8px;
    font-size: 11px;
}
.info-card {
    border: 1px solid var(--border);
    padding: 8px;
    margin-bottom: 10px;
}
.info-title { color: var(--text-bright); font-size: 13px; font-weight: bold; margin-bottom: 3px; }
.info-author { color: var(--text-dim); margin-bottom: 4px; }
.info-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.info-tags .tag { border: 1px solid var(--border); padding: 0 4px; font-size: 9px; color: var(--text-dim); }
.info-comment { color: var(--text-dim); font-style: italic; font-size: 10px; margin-top: 4px; }
.info-score-section { margin-top: 4px; }
.score-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.score-label { color: var(--text-dim); }
.score-badge {
    font-size: 18px;
    font-weight: bold;
    padding: 2px 8px;
    border: 1px solid currentColor;
}
.score-badge.high { color: var(--score-high); }
.score-badge.mid { color: var(--score-mid); }
.score-badge.low { color: var(--score-low); }
.score-badge.na { color: var(--text-dim); }
.score-comment-text { color: var(--text-dim); font-style: italic; margin-top: 4px; }

/* ── Stats ─────────────────────────────────────────────────────────── */
.stats-area {
    padding: 8px;
    font-size: 11px;
}
.stats-area .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid var(--border);
}
.stat-label { color: var(--text-dim); }
.stat-value { color: var(--text-bright); }

.score-histogram {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 60px;
    margin-top: 8px;
    padding: 0 2px;
}
.histo-bar {
    flex: 1;
    background: var(--accent);
    min-width: 8px;
    position: relative;
}
.histo-bar .histo-label {
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--text-dim);
}

/* ── Viewer Layout ─────────────────────────────────────────────────── */
.viewer-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.viewer-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Session Bar ───────────────────────────────────────────────────── */
.session-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    min-width: 300px;
    max-width: 500px;
    max-height: 80vh;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-bright);
}
.modal-close {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
}
.modal-body { padding: 8px; overflow-y: auto; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
}

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-bright);
    padding: 6px 16px;
    font-size: 11px;
    z-index: 200;
    pointer-events: none;
    transition: opacity .2s;
}
.toast.hidden { opacity: 0; }

/* ── Connection Error Banner ───────────────────────────────────────── */
.rtc-error {
    background: #200;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 8px 12px;
    margin: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .host-sidebar, .viewer-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); }
    .host-layout, .viewer-layout { flex-direction: column; }
    .host-sidebar, .viewer-sidebar { height: 40%; }
}

/* ── Stream Inspector ───────────────────────────────────────────────── */
.inspector {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 500;
    background: rgba(0,0,0,.88);
    border: 1px solid #333;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    min-width: 210px;
    box-shadow: 0 4px 16px rgba(0,0,0,.7);
    color: var(--text);
    backdrop-filter: blur(4px);
}
.inspector.hidden { display: none; }
.insp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-bottom: 1px solid #2a2a2a;
    cursor: default;
}
.insp-title {
    color: var(--text-bright);
    font-weight: bold;
    font-size: 11px;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.insp-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    padding: 0 2px;
    line-height: 1;
}
.insp-close:hover { color: var(--text-bright); }
.insp-table {
    width: 100%;
    border-collapse: collapse;
    padding: 4px 0;
}
.insp-table tr:hover { background: rgba(255,255,255,.03); }
.insp-lbl {
    color: var(--text-dim);
    padding: 2px 8px;
    white-space: nowrap;
    width: 72px;
}
.insp-val {
    color: var(--text);
    padding: 2px 8px;
    font-weight: bold;
}
.insp-val.insp-ok  { color: var(--score-high); }
.insp-val.insp-warn { color: var(--score-mid); }
.insp-val.insp-bad  { color: var(--score-low); }

/* ── Host context menu ─────────────────────────────────────────── */
.ctx-menu {
    position: fixed;
    z-index: 3000;
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    min-width: 160px;
    padding: 3px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,.6);
    font-size: 12px;
    user-select: none;
}
.ctx-item {
    padding: 5px 16px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ctx-item:hover { background: var(--bg-hover); color: var(--text-bright); }
.ctx-item.active { color: var(--text-bright); }
.ctx-item.active::before {
    content: '>';
    font-size: 10px;
    color: var(--accent-hover);
    width: 8px;
    flex-shrink: 0;
}
.ctx-item:not(.active)::before { content: ''; width: 8px; flex-shrink: 0; }
.ctx-label {
    padding: 3px 16px 1px;
    color: var(--text-dim);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    cursor: default;
}
.ctx-sep {
    height: 1px;
    background: var(--border);
    margin: 3px 0;
}

/* ── Auto-mode button states ────────────────────────────────────── */
#btn-auto-mode[data-mode="continue"] { color: var(--text); }
#btn-auto-mode[data-mode="loop"]     { color: #7ec87e; border-color: #7ec87e55; }
#btn-auto-mode[data-mode="random"]   { color: #79b8d1; border-color: #79b8d155; }
#btn-auto-mode[data-mode="none"]     { color: var(--text-dim); opacity: 0.6; }
/* ── Viewer Stats & Info ─────────────────────────────────────────── */
.stats-combined-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px;
}

.stats-section, .info-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
}

.now-playing-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.info-section.placeholder {
    color: var(--text-dim);
    text-align: center;
    padding: 20px;
}

/* ── Democracy score badge ────────────────────────────────────────── */
#btn-democracy.active { color: #79b8d1; border-color: #79b8d1; }
/* ── Math expression highlighting in chat ───────────────────────── */
.math-num    { color: #7aab8a; }
.math-const  { color: #79b8d1; }
.math-expr   { color: #c9a85c; border-bottom: 1px dotted #c9a85c; }
.math-score  { color: #7ec87e; border-bottom: 1px dotted #5a9a5a; }
.math-remove { color: #c88080; border-bottom: 1px dotted #a55555; }
.math-result { color: var(--text-dim); font-size: 0.88em; }

/* ── IP address in user list ─────────────────────────────────────── */
.user-ip {
    color: var(--text-dim);
    font-size: 9px;
    margin-top: 1px;
    font-family: monospace;
}

/* ── User score panel (above chat input) ─────────────────────────── */
.user-score-panel {
    border-top: 1px solid var(--border);
    padding: 4px 6px;
    background: var(--bg-panel);
    font-size: 10px;
    flex-shrink: 0;
}
.user-score-panel.hidden { display: none; }
.usr-score-label {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 3px;
}
.usr-score-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 1px 0;
}
.usr-score-who { color: var(--text); }
.usr-score-ip  { color: var(--text-dim); margin-left: 4px; font-family: monospace; }
.usr-score-val { color: var(--text-bright); font-weight: bold; margin-left: auto; }

/* ── Lobby announcement banner ─────────────────────────────────────── */
.lobby-announcement {
    margin: 8px 8px 0;
    padding: 6px 10px;
    background: var(--bg-panel);
    border: 1px solid var(--warn);
    color: var(--warn);
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-word;
    flex-shrink: 0;
}

/* ── @video mention chip in chat ──────────────────────────────────── */
.at-video-chip {
    display: inline-block;
    padding: 0 5px;
    border: 1px solid var(--accent);
    border-radius: 2px;
    color: var(--text-bright);
    font-size: 10px;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    background: var(--bg-hover);
    cursor: default;
    user-select: none;
}
/* Host chat panel: chips look clickable (host can seek via click) */
.host-chat .at-video-chip {
    cursor: pointer;
    border-color: #79b8d1;
    color: #79b8d1;
}
.host-chat .at-video-chip:hover {
    background: rgba(121,184,209,0.12);
}
/* Keep the old class for future flexibility but unused now */
.at-video-chip.host-clickable {
    cursor: pointer;
    border-color: #79b8d1;
    color: #79b8d1;
}
.at-video-chip.host-clickable:hover {
    background: rgba(121,184,209,0.12);
}

