/* ================================================================
   style.css — Potok — "Studio" theme
   Contract: /DESIGN.md (Runway cinematic dark + ElevenLabs ink/stone).
   Rules: zero shadows, hairline borders, one functional signal
   colour (on-air red), mint only for voice activity, no webfonts,
   no backdrop-filter, no data: URIs (CSP default-src 'self').
   ================================================================ */

:root {
    color-scheme: dark;

    /* Canvas & surfaces — warm stone near-black */
    --bg-900: #080706;
    --bg-800: #0c0a09;
    --bg-700: #141210;
    --bg-600: #1c1917;
    --bg-500: #231f1c;
    --bg-400: #292524;
    --bg-300: #35302c;
    --bg-200: #44403c;

    /* Text */
    --text-100: #fafaf9;
    --text-200: #f5f5f4;
    --text-300: #e7e5e4;
    --text-400: #a8a29e;
    --text-500: #9a938c;
    --text-muted: #8a837c;

    /* Ink CTA (inverted pill, ElevenLabs primary on dark) */
    --accent: #fafaf9;
    --accent-ink: #0c0a09;
    --accent-hover: #e7e5e4;
    --accent-light: #e7e5e4;

    /* Functional signals */
    --signal: #d6361f;          /* on-air fill, white text 4.77:1 */
    --signal-hover: #c02f1a;
    --signal-dot: #ff5a3c;      /* dots / outlines only */
    --signal-soft: rgba(255, 90, 60, 0.12);
    --voice: #a7e5d3;           /* voice activity (mint) */
    --voice-soft: rgba(167, 229, 211, 0.14);

    /* Status (kept for JS/markup compatibility) */
    --success: #a7e5d3;
    --success-light: #c3efe2;
    --danger: #d6361f;
    --danger-hover: #c02f1a;
    --warning: #f4c5a8;

    /* Lines & geometry */
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --focus: rgba(250, 250, 249, 0.55);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 999px;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --transition: 0.16s ease;

    --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

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

html { font-size: 16px; }

body {
    font-family: var(--font-sans);
    background: var(--bg-800);
    color: var(--text-300);
    min-height: 100vh;
    line-height: 1.45;
    letter-spacing: -0.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
.logo, .room-icon { text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

::selection { background: rgba(250, 250, 249, 0.2); }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-300); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--bg-200); }

/* ================================================================
   UTILITY / BRAND
   ================================================================ */
.hidden { display: none !important; }

.eyebrow,
.sidebar-settings-title {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    line-height: 1.3;
}

.brand-mark {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--text-100);
}

.brand-word {
    font-size: 19px;
    font-weight: 500;
    letter-spacing: -0.04em;
    color: var(--text-100);
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Buttons — pills ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.btn:active { opacity: 0.86; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: transparent;
    color: var(--text-200);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.22); }

.btn-danger {
    background: var(--signal);
    color: #fff;
}
.btn-danger:hover { background: var(--signal-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-400);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-100); }

.btn-sm { min-height: 32px; padding: 0 14px; font-size: 13px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { min-height: 48px; padding: 0 26px; font-size: 15px; }

/* ================================================================
   LOGIN / JOIN
   ================================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        radial-gradient(640px 420px at 18% 8%, rgba(167, 229, 211, 0.07), transparent 70%),
        radial-gradient(560px 380px at 86% 14%, rgba(200, 184, 224, 0.07), transparent 70%),
        radial-gradient(700px 460px at 60% 108%, rgba(244, 197, 168, 0.06), transparent 70%),
        var(--bg-800);
}

.login-card {
    background: var(--bg-700);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: left;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    display: block;
    width: 40px;
    height: 40px;
    margin-bottom: 28px;
    color: var(--text-100);
}
.login-logo .logo-icon svg { width: 100%; height: 100%; display: block; }

.login-logo .eyebrow { margin-bottom: 14px; }

.login-logo h1 {
    font-size: 40px;
    font-weight: 400;
    line-height: 1;
    color: var(--text-100);
    letter-spacing: -0.045em;
}

.login-logo p {
    font-size: 15px;
    color: var(--text-400);
    margin-top: 12px;
}

.login-lang {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
}

.login-error {
    background: var(--signal-soft);
    border: 1px solid rgba(255, 90, 60, 0.35);
    border-radius: var(--radius-md);
    color: #ffb3a3;
    font-size: 13px;
    padding: 10px 14px;
    margin-bottom: 16px;
    display: none;
}
.login-error:not(:empty) { display: block; }

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 10px;
}

/* ── Code digit inputs ─────────────────────────────────────────── */
.code-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.code-inputs input {
    width: 100%;
    height: 68px;
    background: var(--bg-800);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-100);
    font-family: var(--font-sans);
    font-size: 30px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    text-align: center;
    transition: border-color var(--transition), background-color var(--transition);
    outline: none;
    caret-color: var(--text-100);
}
.code-inputs input::placeholder { color: var(--bg-200); }

.code-inputs input:focus {
    border-color: var(--text-100);
    background: var(--bg-600);
}

.code-inputs input:not(:placeholder-shown) {
    border-color: rgba(255, 255, 255, 0.32);
}

.captcha-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.login-submit {
    width: 100%;
    min-height: 50px;
    font-size: 15px;
}

/* ================================================================
   APP SHELL (index / home)
   ================================================================ */
.app-shell {
    min-height: 100vh;
    background:
        radial-gradient(760px 420px at 50% -8%, rgba(200, 184, 224, 0.06), transparent 70%),
        var(--bg-800);
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
}

.app-topbar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.app-topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.username-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 3px 12px 3px 3px;
    font-size: 13px;
    color: var(--text-300);
    max-width: 200px;
}
.username-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.username-chip .avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--text-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-ink);
    flex-shrink: 0;
}

.app-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 20px;
}

.join-card {
    width: 100%;
    max-width: 520px;
}

.join-card .eyebrow { margin-bottom: 18px; }

.join-card h2 {
    font-size: 48px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.045em;
    color: var(--text-100);
    margin-bottom: 14px;
}

.join-card .subtitle {
    font-size: 16px;
    color: var(--text-400);
    margin-bottom: 36px;
    max-width: 40ch;
}

.join-card .room-input-wrap {
    position: relative;
    margin-bottom: 14px;
}

.join-card .room-input-wrap .room-prefix {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 15px;
    pointer-events: none;
}

.room-input {
    width: 100%;
    height: 54px;
    padding: 0 18px 0 38px;
    background: var(--bg-700);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-100);
    font-family: var(--font-mono);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition), background-color var(--transition);
}

.room-input::placeholder { color: var(--text-muted); }
.room-input:focus {
    border-color: var(--text-100);
    background: var(--bg-600);
}

.join-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.join-btn {
    min-height: 52px;
    font-size: 15px;
}

.join-hints {
    margin-top: 40px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.join-hints div { display: grid; gap: 4px; }
.join-hints strong { font-size: 14px; font-weight: 500; color: var(--text-200); }
.join-hints span { font-size: 13px; color: var(--text-500); }

.recent-rooms {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.recent-rooms-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 10px;
}

/* ================================================================
   ROOM PAGE
   ================================================================ */
.room-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-900);
}

/* Top bar */
.room-topbar {
    height: 56px;
    background: var(--bg-800);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px 0 20px;
    gap: 12px;
    flex-shrink: 0;
    z-index: 10;
}

.room-topbar .room-icon {
    display: flex;
    color: var(--text-100);
}
.room-topbar .room-icon svg { width: 24px; height: 24px; }

.room-topbar .room-name {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-300);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.room-topbar .room-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--radius-sm);
    background: var(--signal);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.room-topbar .room-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: on-air 1.6s ease-in-out infinite;
}

.room-topbar .room-badge.idle {
    background: transparent;
    color: var(--text-400);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}
.room-topbar .room-badge.idle::before {
    background: var(--text-muted);
    animation: none;
}

@keyframes on-air {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.room-topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Body */
.room-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* Sidebar */
.room-sidebar {
    width: 248px;
    background: var(--bg-800);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.sidebar-section {
    padding: 18px 12px 6px;
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0 8px;
}

.participant-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 12px 12px;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--radius-md);
    cursor: default;
    transition: background-color var(--transition);
}
.participant-item:hover { background: rgba(255, 255, 255, 0.04); }
.participant-item.self .participant-avatar { background: var(--text-100); color: var(--accent-ink); }

.participant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-400);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-200);
    flex-shrink: 0;
    position: relative;
}

.participant-avatar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: var(--voice);
    border: 2px solid var(--bg-800);
    border-radius: 50%;
}

.participant-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.participant-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.participant-sub {
    font-size: 11.5px;
    color: var(--text-500);
}

/* Settings panel at bottom of sidebar */
.sidebar-settings {
    padding: 16px 20px 18px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 12px;
}

.sidebar-settings-title { margin-bottom: 2px; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-300);
}
.setting-label .icon { width: 16px; height: 16px; color: var(--text-400); }

/* Noise badge */
.noise-badge {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.06em;
}
.noise-badge.active { background: var(--voice-soft); color: var(--voice); }
.noise-badge.pending { background: rgba(244, 197, 168, 0.14); color: var(--warning); }
.noise-badge.off { background: var(--bg-400); color: var(--text-500); }

/* Toggle switch */
.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-300);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-300);
    border-radius: 50%;
    left: 3px;
    top: 3px;
    transition: transform var(--transition), background-color var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--text-100); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: var(--accent-ink); }
.toggle input:focus-visible + .toggle-slider { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Video grid */
.video-grid {
    flex: 1;
    background: var(--bg-900);
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    grid-auto-rows: min-content;
    gap: 14px;
    overflow-y: auto;
    align-content: start;
    min-width: 0;
}

.start-panel {
    position: fixed;
    inset: 56px 0 0 248px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 7, 6, 0.88);
    z-index: 20;
}

.start-card {
    width: min(720px, 100%);
    max-height: 100%;
    overflow-y: auto;
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 36px;
    display: grid;
    gap: 24px;
}

.start-card h1 {
    color: var(--text-100);
    font-size: 40px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.045em;
    margin: 14px 0 12px;
}

.start-card p {
    color: var(--text-400);
    font-size: 15px;
    max-width: 52ch;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}

.settings-grid label,
.range-label {
    display: grid;
    gap: 8px;
    color: var(--text-500);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.settings-select,
.share-input {
    width: 100%;
    min-width: 0;
    height: 44px;
    background: var(--bg-700);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-200);
    font-family: inherit;
    font-size: 14px;
    letter-spacing: normal;
    text-transform: none;
    padding: 0 12px;
    outline: none;
    transition: border-color var(--transition);
}
.share-input { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-400); }

.settings-select:focus,
.share-input:focus {
    border-color: var(--text-100);
}

.start-stream-btn {
    min-height: 56px;
    font-size: 16px;
    background: var(--signal);
    color: #fff;
}
.start-stream-btn:hover { background: var(--signal-hover); }
.start-stream-btn::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

.share-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.video-wrapper {
    position: relative;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

/* Frame drawn above video/placeholder so the voice ring stays visible */
.video-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px var(--border);
    pointer-events: none;
    z-index: 2;
    transition: box-shadow var(--transition);
}

.video-wrapper.speaking::after {
    box-shadow: inset 0 0 0 2px var(--voice);
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

.video-wrapper.local-camera {
    max-width: 360px;
    justify-self: end;
}
.video-wrapper.local-camera video { object-fit: cover; }

.participant-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.62);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-200);
    z-index: 3;
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* No video placeholder */
.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(60% 70% at 50% 40%, rgba(255, 255, 255, 0.035), transparent 70%),
        var(--bg-800);
    gap: 14px;
}

.video-placeholder span {
    color: var(--text-400);
    font-size: 13.5px;
    text-align: center;
    padding: 0 16px;
}

.video-placeholder .avatar-large {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-100);
}
.video-placeholder .avatar-large svg { width: 22px; height: 22px; }

/* Controls bar */
.controls-bar {
    height: 88px;
    background: var(--bg-800);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 14px;
    padding: 14px 24px 0;
    flex-shrink: 0;
}

.controls-bar.post-start {
    flex-wrap: wrap;
}

.control-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.control-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--bg-600);
    color: var(--text-200);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
    position: relative;
}

.control-btn:hover { background: var(--bg-400); }
.control-btn:active { opacity: 0.85; }

.control-btn.active {
    background: var(--text-100);
    border-color: var(--text-100);
    color: var(--accent-ink);
}
.control-btn.active:hover { background: var(--accent-hover); }

.control-btn.muted {
    background: var(--signal-soft);
    border-color: rgba(255, 90, 60, 0.5);
    color: var(--signal-dot);
}
.control-btn.muted:hover { background: rgba(255, 90, 60, 0.2); }

.control-btn.leave {
    background: var(--signal);
    border-color: var(--signal);
    color: #fff;
    width: 46px;
    height: 46px;
}
.control-btn.leave:hover { background: var(--signal-hover); }

.control-btn .btn-icon {
    display: flex;
    line-height: 1;
    pointer-events: none;
}
.control-btn .btn-icon svg { width: 20px; height: 20px; }

.control-btn-label {
    position: absolute;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-500);
    white-space: nowrap;
    pointer-events: none;
}

/* Controls divider */
.controls-divider {
    width: 1px;
    height: 30px;
    margin-top: 8px;
    background: var(--border-strong);
}

.volume-range {
    width: 100%;
    accent-color: var(--text-100);
}

.geek-panel {
    position: fixed;
    right: 16px;
    top: 68px;
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100vh - 170px);
    overflow-y: auto;
    background: var(--bg-800);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    z-index: 50;
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-500);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.stats-header button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-400);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.stats-header button:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-100); }

.stats-content {
    padding: 6px 16px 10px;
    display: grid;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}

.stat-item:last-child { border-bottom: none; }

.stat-item span {
    color: var(--text-500);
}

.stat-item strong {
    color: var(--text-200);
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* ================================================================
   VIEWER (watch.html)
   ================================================================ */
.viewer-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-900);
}

.viewer-container > header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-800);
}

.viewer-container .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.viewer-container main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px;
}

.video-container {
    position: relative;
    width: min(100%, 1600px);
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 140px);
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px var(--border);
}

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

.video-container .stats-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: min(340px, calc(100% - 24px));
    max-height: calc(100% - 90px);
    overflow-y: auto;
    background: rgba(12, 10, 9, 0.94);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    z-index: 5;
}

.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.video-overlay > * { pointer-events: auto; }

.loading-spinner,
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--text-400);
    font-size: 14px;
    text-align: center;
}

.spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--bg-300);
    border-top-color: var(--text-100);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.central-play-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--text-100);
    color: var(--accent-ink);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--transition);
}
.central-play-btn:hover { background: var(--accent-hover); }
.central-play-btn .play-icon { font-size: 24px; margin-left: 4px; }

.video-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.video-container:hover .video-controls,
.video-container.show-controls .video-controls,
.video-controls:focus-within { opacity: 1; }

.stream-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-300);
}

.live-badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--radius-sm);
    background: var(--signal);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.controls-right {
    display: flex;
    gap: 8px;
}
.controls-right .control-btn { width: 40px; height: 40px; font-size: 16px; background: rgba(28, 25, 23, 0.9); }

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-400);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warning);
}
.connection-status.connected .status-dot { background: var(--voice); }
.connection-status.disconnected .status-dot,
.connection-status.failed .status-dot { background: var(--signal-dot); }

/* ================================================================
   TOAST
   ================================================================ */
.toast {
    position: fixed;
    bottom: 104px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--text-100);
    color: var(--accent-ink);
    padding: 11px 18px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    text-align: center;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ================================================================
   ALTCHA widget
   ================================================================ */
altcha-widget {
    --altcha-color-base: var(--bg-800);
    --altcha-color-border: var(--border-strong);
    --altcha-color-border-focus: var(--text-100);
    --altcha-color-input-bg: var(--bg-800);
    --altcha-color-text: var(--text-300);
    --altcha-color-text-secondary: var(--text-500);
    --altcha-color-footer-bg: var(--bg-700);
    --altcha-border-radius: 12px;
    width: 100%;
}

/* ================================================================
   RESPONSIVE / MOTION
   ================================================================ */
@media (max-width: 860px) {
    .join-hints { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 680px) {
    .app-topbar { padding: 0 16px; height: 58px; }
    .username-chip { display: none; }
    .app-main { padding: 36px 16px; align-items: flex-start; }
    .join-card h2 { font-size: 38px; }
    .join-actions { grid-template-columns: 1fr; }

    .room-sidebar { display: none; }
    .room-topbar {
        height: auto;
        min-height: 56px;
        flex-wrap: wrap;
        padding: 10px 12px;
        row-gap: 8px;
    }
    .room-topbar .topbar-right {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
        overflow-x: auto;
    }
    .video-grid { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
    .start-panel { position: fixed; inset: 0; padding: 12px; z-index: 30; align-items: flex-start; overflow-y: auto; }
    .start-card { padding: 22px 18px; gap: 20px; }
    .start-card h1 { font-size: 32px; }
    .settings-grid { grid-template-columns: 1fr; }
    .share-row { grid-template-columns: 1fr; }
    .controls-bar { gap: 10px; padding: 12px 12px 0; height: 84px; }
    .control-btn, .control-btn.leave { width: 44px; height: 44px; }
    .control-btn-label { top: 50px; }
    .controls-divider { display: none; }
    .login-card { padding: 30px 22px 26px; }
    .login-logo h1 { font-size: 34px; }
    .code-inputs input { height: 62px; }
    .geek-panel { top: 108px; right: 8px; left: 8px; width: auto; }
    .viewer-container > header { padding: 0 12px; }
    .viewer-container main { padding: 10px; }
    .video-controls { opacity: 1; }
    .toast { bottom: 96px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
