/* =========================================================
   BeeWorking — design system
   ========================================================= */
:root {
    --bg: #141317;
    --surface: #1d1c21;
    --surface-2: #26242b;
    --surface-3: #312e37;
    --border: #36333d;
    --border-strong: #4a4652;
    --text: #f3f1f6;
    --text-muted: #a9a4b3;
    --text-subtle: #7a7584;
    --accent: #f5b03c;
    --accent-hover: #ffc25c;
    --accent-soft: rgba(245, 176, 60, 0.14);
    --accent-text: #221705;
    --success: #3ecf8e;
    --warning: #f5a623;
    --danger: #ef5350;
    --danger-soft: rgba(239, 83, 80, 0.16);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --panel-width: 340px;
    --font: 'Inter Variable', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}
.icon-sm { width: 16px; height: 16px; }

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

/* --- Éléments de formulaire --- */
.input, .select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-subtle); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select {
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23a9a4b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    text-overflow: ellipsis;
}
.select option { background: var(--surface-2); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.field-label {
    display: block;
    margin: 18px 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-weight: 600;
    transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-lg { width: 100%; padding: 13px 16px; font-size: 15px; margin-top: 24px; }

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* --- Avatars pixel art : tête découpée dans la feuille LimeZu --- */
.sprite-avatar {
    --size: 32px;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    flex: 0 0 auto;
    background-color: var(--surface-3);
    background-repeat: no-repeat;
    /* 1 px de la feuille = size/16 ; aperçu de face en colonne 3, ligne 0 */
    background-size: calc(var(--size) * 56) auto;
    background-position: calc(var(--size) * -3) calc(var(--size) * -0.4);
    image-rendering: pixelated;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.status-dot.available { background: var(--success); }
.status-dot.busy { background: var(--warning); }
.status-dot.dnd { background: var(--danger); }

/* =========================================================
   Écran d'accueil
   ========================================================= */
#login-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    background:
        radial-gradient(1200px 600px at 20% 10%, rgba(245, 176, 60, 0.12), transparent 60%),
        linear-gradient(rgba(20, 19, 23, 0.88), rgba(20, 19, 23, 0.96)),
        url('../assets/office_map.png') center / cover;
}

.login-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: min(920px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin: auto;
}

.login-stage {
    padding: 28px;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stage-preview {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    overflow: hidden;
    background: repeating-conic-gradient(#2b2830 0 25%, #2f2c35 0 50%) 0 0 / 32px 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}
#prejoin-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    display: none;
    background: #000;
}
.stage-preview.has-video #prejoin-video { display: block; }
.stage-preview.has-video #prejoin-avatar { display: none; }
#prejoin-avatar {
    width: 96px;
    height: 192px;
    margin-bottom: 40px;
    image-rendering: pixelated;
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.4));
}

.stage-controls {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}
.round-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    transition: background .15s;
}
.round-btn:hover { background: rgba(255, 255, 255, 0.22); }
.round-btn .icon-off, .ctrl-btn .icon-off { display: none; }
.round-btn.off, .ctrl-btn.off { background: var(--danger); color: white; }
.round-btn.off:hover, .ctrl-btn.off:hover { background: #f26b68; }
.round-btn.off .icon-on, .ctrl-btn.off .icon-on { display: none; }
.round-btn.off .icon-off, .ctrl-btn.off .icon-off { display: block; }

.device-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
}
.device-row .select { padding-top: 8px; padding-bottom: 8px; }

.mic-meter {
    height: 4px;
    margin: -2px 0 4px 26px;
    border-radius: 2px;
    background: var(--surface-3);
    overflow: hidden;
}
.modal .mic-meter { margin-left: 0; margin-top: 8px; }
.mic-meter span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--success);
    border-radius: 2px;
    transition: width .08s linear;
}
.stage-hint { margin: 6px 0 0; font-size: 12px; color: var(--text-subtle); }

.login-form { padding: 32px 32px 24px; display: flex; flex-direction: column; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-logo { width: 52px; height: 52px; border-radius: 12px; image-rendering: pixelated; }
.wordmark { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.wordmark span, .brand-name span { color: var(--accent); }
.login-form h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { margin: 6px 0 0; color: var(--text-muted); }

.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    max-height: 172px;
    overflow-y: auto;
    padding: 2px;
    margin: 0 -2px;
}
.skin-opt {
    height: 56px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    transition: border-color .15s, background .15s;
}
.skin-opt:hover { border-color: var(--border-strong); }
.skin-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.skin-preview {
    width: 32px;
    height: 64px;
    margin-bottom: -10px;
    background-repeat: no-repeat;
    background-size: 1792px auto;      /* feuille 896 px affichée en x2 */
    background-position: -96px 0;      /* aperçu de face (ligne 0, colonne 3) */
    image-rendering: pixelated;
}
.login-foot { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--text-subtle); }

/* =========================================================
   Application
   ========================================================= */
#app {
    display: grid;
    grid-template-columns: 1fr 0;
    height: 100vh;
    height: 100dvh; /* mobile : tient compte de la barre d'adresse */
}
/* Le panneau (chat, participants) flotte par-dessus la carte au lieu de la rétrécir */

#game-container {
    position: relative;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    touch-action: none; /* le jeu gère lui-même le toucher (déplacement, zoom à deux doigts) */
    -webkit-user-select: none;
    user-select: none;
}
#game-container canvas { display: block; }

/* --- Pastille de marque --- */
.brand-chip {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: rgba(29, 28, 33, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}
.brand-chip img { width: 28px; height: 28px; border-radius: 8px; image-rendering: pixelated; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.online-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
}
.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(62, 207, 142, 0); }
    100% { box-shadow: 0 0 0 0 rgba(62, 207, 142, 0); }
}

/* --- Vignettes vidéo --- */
#video-bar {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    max-width: calc(100% - 520px);
    overflow-x: auto;
    z-index: 20;
    padding: 2px;
    scrollbar-width: thin;
}
.video-tile {
    position: relative;
    flex: 0 0 auto;
    width: 176px;
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
    transition: box-shadow .15s, opacity .2s, width .2s;
}
.video-tile.connecting { opacity: .55; }
.video-tile.speaking { box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--success); }
.video-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    background: #000;
}
.video-tile.has-video video { display: block; }
.video-tile.local video { transform: scaleX(-1); }
.video-tile.local.screen video { transform: none; object-fit: contain; }
.video-tile.expanded { width: 480px; }
.video-tile.expanded video { object-fit: contain; }
.video-tile .tile-avatar {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.video-tile .tile-avatar .sprite-avatar { --size: 64px; }
.video-tile.has-video .tile-avatar { display: none; }
.video-tile .tile-label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    max-width: calc(100% - 16px);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    white-space: nowrap;
}
.video-tile .tile-label span { overflow: hidden; text-overflow: ellipsis; }
.video-tile .tile-muted { width: 13px; height: 13px; color: var(--danger); display: none; }
.video-tile.muted .tile-muted { display: block; }

/* --- Bandeau de zone --- */
#zone-banner {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 19;
    padding: 6px 14px;
    background: rgba(29, 28, 33, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    box-shadow: var(--shadow-sm);
}
#video-bar:not(:empty) ~ #zone-banner { top: 166px; }

/* --- Toasts --- */
#toasts {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 300px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 13px;
    pointer-events: auto;
    animation: toast-in .2s ease-out;
}
.toast .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--text-muted); }
.toast.error .icon { color: var(--danger); }
.toast .sprite-avatar { --size: 22px; }
.toast.leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* --- Barre de contrôle --- */
#control-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    background: rgba(29, 28, 33, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.bar-sep { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }

.ctrl-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 11px;
    background: var(--surface-3);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.ctrl-btn:hover { background: #3d3943; }
.ctrl-btn.active { background: var(--accent); color: var(--accent-text); }
.ctrl-btn.active:hover { background: var(--accent-hover); }
.ctrl-btn.toggled { background: var(--accent-soft); color: var(--accent); }

/* Infobulles */
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 5px 8px;
    background: #0d0c0f;
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s, transform .12s;
    z-index: 60;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
}

.self-card-wrap, .emote-wrap { position: relative; }
.self-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border: none;
    border-radius: 11px;
    background: transparent;
    text-align: left;
    transition: background .15s;
}
.self-card:hover, .self-card[aria-expanded="true"] { background: var(--surface-3); }
.self-card .sprite-avatar { --size: 34px; }
.self-text { display: flex; flex-direction: column; min-width: 0; }
.self-name { font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.self-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.self-card .chevron { color: var(--text-subtle); }

/* --- Menus --- */
.menu {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    min-width: 220px;
    padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 40;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    text-align: left;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item .check { margin-left: auto; color: var(--accent); visibility: hidden; }
.menu-item[aria-checked="true"] .check { visibility: visible; }
.menu-hint { padding: 6px 10px 4px; font-size: 11px; color: var(--text-subtle); border-top: 1px solid var(--border); margin-top: 4px; }

.menu-row {
    left: 50%;
    transform: translateX(-50%);
    min-width: 0;
    display: flex;
    gap: 2px;
}
.emote-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 22px;
    transition: background .12s, transform .12s;
}
.emote-btn:hover { background: var(--surface-3); transform: translateY(-2px); }
.emote-btn kbd {
    position: absolute;
    right: 2px;
    bottom: 1px;
    padding: 0 3px;
    border: none;
    font-size: 9px;
}

/* =========================================================
   Panneau latéral
   ========================================================= */
#side-panel {
    position: fixed;
    top: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 40;
    width: var(--panel-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(29, 28, 33, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: panel-in .18s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translateX(12px); } }
body.panel-open #toasts { right: calc(var(--panel-width) + 28px); }
body:not(.panel-open) #side-panel { display: none; }

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.segmented {
    flex: 1;
    display: flex;
    padding: 3px;
    background: var(--surface-2);
    border-radius: 10px;
}
.seg-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    transition: background .15s, color .15s;
}
.seg-btn.active { background: #403c47; color: var(--text); box-shadow: var(--shadow-sm); }
.seg-btn:not(.active):hover { color: var(--text); }
.count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--surface);
    font-size: 11px;
    line-height: 18px;
    color: var(--text-muted);
}

.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* --- Chat --- */
.chat-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 14px 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: var(--text-subtle);
}
.chat-empty .icon { width: 32px; height: 32px; opacity: .6; }
.chat-empty p { margin: 0; }

.msg-group {
    display: grid;
    grid-template-columns: 36px 1fr;
    column-gap: 10px;
    padding: 6px 0;
}
.msg-group .sprite-avatar { --size: 36px; grid-row: span 2; }
.msg-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-author { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-group.mine .msg-author { color: var(--accent); }
.msg-time { font-size: 11px; color: var(--text-subtle); flex: 0 0 auto; }
.msg-body { grid-column: 2; display: flex; flex-direction: column; gap: 2px; }
.msg-text {
    color: #e3e0e8;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.msg-system {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    font-size: 12px;
    color: var(--text-subtle);
    text-align: center;
}
.msg-system::before, .msg-system::after { content: ''; flex: 1; height: 1px; background: var(--border); }

#typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.dots { display: inline-flex; gap: 3px; }
.dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 12px;
    padding: 4px 4px 4px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#chat-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 8px 0;
    outline: none;
}
#chat-input::placeholder { color: var(--text-subtle); }
.send-btn { background: var(--accent); color: var(--accent-text); width: 34px; height: 34px; }
.send-btn:hover { background: var(--accent-hover); color: var(--accent-text); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-subtle); cursor: default; }
.composer-hint { padding: 6px 14px 12px; font-size: 11px; color: var(--text-subtle); }
kbd {
    font-family: var(--font);
    font-size: 10px;
    padding: 1px 5px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--text-muted);
}

/* --- Participants --- */
.people-head {
    padding: 14px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-subtle);
}
#members-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    transition: background .12s;
}
.member:hover { background: var(--surface-2); }
.member .avatar-wrap { position: relative; display: flex; }
.member .avatar-wrap .sprite-avatar { --size: 36px; }
.member .avatar-wrap .status-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    box-shadow: 0 0 0 2px var(--surface);
}
.member:hover .avatar-wrap .status-dot { box-shadow: 0 0 0 2px var(--surface-2); }
.m-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-name .me { color: var(--text-subtle); font-weight: 400; }
.m-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.m-sub .icon { width: 13px; height: 13px; }
.m-sub .in-call { color: var(--success); }
.m-sub .mic-off { color: var(--danger); }
.m-actions { display: flex; gap: 2px; } /* toujours visibles : pas de survol sur téléphone */
.m-actions .icon-btn[data-tip]::after { bottom: auto; top: calc(100% + 6px); }

.panel-foot {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-subtle);
}

/* =========================================================
   Fenêtre de réglages
   ========================================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 9, 12, 0.6);
    backdrop-filter: blur(3px);
}
.modal-card {
    width: min(420px, 100%);
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 22px; }

/* =========================================================
   Petits écrans
   ========================================================= */
@media (max-width: 860px) {
    .login-card { grid-template-columns: 1fr; }
    .login-stage { border-right: none; border-bottom: 1px solid var(--border); }
    .stage-preview { aspect-ratio: 16 / 9; }
    #side-panel {
        inset: 0 0 0 auto;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(var(--panel-width), 100%);
        z-index: 50;
        border-radius: 0;
        border-width: 0 0 0 1px;
    }
    body.panel-open #toasts { right: 14px; }
    #video-bar { max-width: calc(100% - 28px); top: 64px; }
    .self-text, .self-card .chevron { display: none; }
    #toasts { width: auto; left: 14px; top: 64px; }
}
@media (max-width: 520px) {
    .online-pill { display: none; }
    .ctrl-btn { width: 38px; height: 38px; }
    #control-bar { gap: 3px; bottom: 10px; }
    .bar-sep { margin: 0 1px; }
}

/* --- Objets interactifs --- */
.interact-prompt {
    position: absolute;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 8px;
    background: rgba(29, 28, 33, 0.94);
    border: 1px solid var(--accent);
    border-radius: 999px;
    box-shadow: var(--shadow);
    font-weight: 500;
    animation: toast-in .15s ease-out;
}
.interact-prompt kbd {
    min-width: 24px;
    padding: 2px 6px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.note-text { margin: 14px 0 0; white-space: pre-wrap; color: var(--text-muted); line-height: 1.6; }

/* =========================================================
   Comptes : connexion, inscription, profil, administration
   ========================================================= */
.auth-view { display: flex; flex-direction: column; }
.form-error {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    border: 1px solid rgba(239, 83, 80, 0.4);
    color: #ffb4b2;
    font-size: 13px;
}
.field-hint { font-size: 11px; font-weight: 400; color: var(--text-subtle); text-transform: none; letter-spacing: 0; margin-left: 6px; }
.auth-switch { margin: 14px 0 0; text-align: center; color: var(--text-muted); font-size: 13px; }
.link-btn {
    padding: 0;
    border: none;
    background: none;
    color: var(--accent);
    font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }
.login-sub strong { color: var(--text); font-weight: 600; }

.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-item.danger { color: #ff8a87; }
.menu-item .icon-sm { color: var(--text-muted); }
.menu-item.danger .icon-sm { color: inherit; }

.btn-secondary { background: var(--surface-3); color: var(--text); }
.btn-secondary:hover { background: #3d3943; }
.btn-danger { background: var(--danger); color: white; }

.modal-wide { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.modal-section.first { margin-top: 14px; padding-top: 0; border-top: none; }
.modal-section h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > .input, .form-row > .select { flex: 1 1 160px; width: auto; }
.form-row > .btn { flex: 0 0 auto; }
#profile-skins { max-height: 200px; }

.invite-result {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    background: var(--accent-soft);
    border: 1px solid rgba(245, 176, 60, 0.4);
    border-radius: var(--radius);
}
.invite-result .input { flex: 1 1 260px; width: auto; font-family: monospace; font-size: 12px; }
.invite-result .field-hint { flex-basis: 100%; margin: 0; }

.admin-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}
.admin-list li:hover { background: var(--surface-2); }
.admin-list .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list .sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list .select { width: auto; padding: 6px 30px 6px 10px; font-size: 12px; }
.admin-list .empty { color: var(--text-subtle); font-size: 13px; padding: 4px 8px; }
.role-badge {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
}

/* --- Invités --- */
.btn-block { width: 100%; padding: 12px 16px; }
.or-sep {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 14px;
    color: var(--text-subtle);
    font-size: 12px;
}
.or-sep::before, .or-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.guest-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* --- Téléphones : barre de contrôle compacte --- */
@media (max-width: 520px) {
    .bar-sep { display: none; }
    #control-bar { padding: 4px; gap: 4px; max-width: calc(100% - 16px); }
    .self-card { padding: 2px; }
    .self-card .sprite-avatar { --size: 32px; }
    .video-tile { width: 112px; }
    .video-tile .tile-avatar .sprite-avatar { --size: 44px; }
    #zone-banner { top: 64px; }
    #video-bar:not(:empty) ~ #zone-banner { top: 160px; }
    .interact-prompt { bottom: 70px; max-width: calc(100% - 24px); }
    [data-tip]::after { display: none; } /* pas d'infobulle au toucher */
    .brand-chip { top: 10px; left: 10px; }
    #toasts { top: 56px; left: 10px; right: 10px; }
    .menu { left: 0; }
    .menu-row { left: auto; right: -60px; transform: none; }
}

/* --- Canaux du chat --- */
.channel-bar {
    display: flex;
    gap: 4px;
    padding: 10px 12px 0;
}
.channel-btn {
    position: relative;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    transition: background .15s, color .15s, border-color .15s;
}
.channel-btn:hover { color: var(--text); }
.channel-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.dot-badge {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 4px;
    border-radius: 50%;
    background: var(--danger);
    vertical-align: middle;
}
.chat-log[hidden], .dm-list[hidden], #dm-thread[hidden] { display: none !important; }
#dm-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#dm-guest-note { flex: 1; }

/* Liste des conversations privées */
.dm-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.dm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 10px;
    background: transparent;
    text-align: left;
}
.dm-item:hover { background: var(--surface-2); }
.dm-item .sprite-avatar { --size: 36px; }
.dm-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dm-item .title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dm-item .preview { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-item .unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: white; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.dm-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.dm-header .sprite-avatar { --size: 28px; }
.dm-name { font-weight: 600; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }

/* Suppression d'un message */
.msg-text { position: relative; padding-right: 26px; }
.msg-delete {
    position: absolute;
    top: -2px;
    right: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-subtle);
    display: none;
    align-items: center;
    justify-content: center;
}
.msg-text:hover .msg-delete { display: inline-flex; }
.msg-delete:hover { background: var(--danger-soft); color: var(--danger); }
.msg-delete .icon { width: 13px; height: 13px; }
.msg-nearby-tag { font-size: 10px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* --- Annonce vocale --- */
.broadcast-banner {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 21;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: toast-in .2s ease-out;
}
.broadcast-banner .link-btn { color: var(--accent-text); text-decoration: underline; }
#video-bar:not(:empty) ~ .broadcast-banner { top: 166px; }
.ctrl-btn.live { background: var(--danger); color: white; animation: live 1.6s infinite; }
@keyframes live { 50% { box-shadow: 0 0 0 4px rgba(239, 83, 80, 0.3); } }
.video-tile.broadcaster { box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--accent); }

/* Repère de couleur par canal (même code que les bulles au-dessus des personnages) */
.channel-btn::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    vertical-align: 1px;
    background: #f3f1f6;
}
.channel-btn[data-channel="nearby"]::before { background: #3ecf8e; }
.channel-btn[data-channel="dm"]::before { background: #f472b6; }
.channel-btn.active[data-channel="nearby"] { background: rgba(62, 207, 142, 0.14); border-color: #3ecf8e; color: #3ecf8e; }
.channel-btn.active[data-channel="dm"] { background: rgba(244, 114, 182, 0.14); border-color: #f472b6; color: #f472b6; }
#chat-nearby .msg-group.mine .msg-author { color: #3ecf8e; }
#dm-messages .msg-group.mine .msg-author { color: #f472b6; }

/* Actions d'un participant : discrètes, accentuées au survol */
.m-actions .icon-btn { color: var(--text-subtle); }
.member:hover .m-actions .icon-btn { color: var(--text-muted); }
.m-actions .icon-btn:hover { color: var(--text); }
.m-actions .icon-btn.dm-btn { color: #f472b6; }
@media (hover: none) {
    .m-actions .icon-btn { width: 36px; height: 36px; color: var(--text-muted); }
}

/* =========================================================
   Réunions avancées : verrou, frapper, amphithéâtre, grand écran
   ========================================================= */
.btn-sm { padding: 6px 12px; font-size: 13px; gap: 6px; }
#zone-banner:not([hidden]) { display: flex; align-items: center; gap: 8px; }
#zone-banner.on-stage { background: var(--accent); color: var(--accent-text); }
.zone-lock {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: -3px -8px -3px 0;
    border: none;
    border-radius: 50%;
    background: rgba(245, 176, 60, 0.18);
    color: var(--accent);
    pointer-events: auto;
    cursor: pointer;
    transition: background .15s;
}
.zone-lock:hover { background: rgba(245, 176, 60, 0.32); }
.zone-lock.locked { background: var(--danger); color: white; }
.zone-lock[data-tip]::after { top: calc(100% + 8px); bottom: auto; }

.knock-prompt { border-color: var(--danger); padding: 6px 6px 6px 14px; }
.knock-prompt > .icon { color: var(--danger); }
.knock-prompt .icon-btn { width: 28px; height: 28px; }

.knock-card { align-items: center; }
.knock-body { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.knock-actions { display: flex; gap: 6px; }

.presentation {
    position: absolute;
    top: 56px;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    width: min(1200px, calc(100% - 48px));
    z-index: 18;
    display: flex;
    flex-direction: column;
    background: #0d0c10;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: toast-in .2s ease-out;
}
#video-bar:not(:empty) ~ .presentation { top: 200px; }
.presentation[hidden] { display: none; }
.presentation-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
}
.presentation-head > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presentation-head .icon-btn[data-tip]::after { top: calc(100% + 8px); bottom: auto; }
.presentation video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.presentation:fullscreen { border: none; border-radius: 0; }
.video-tile.screen:not(.local) { cursor: zoom-in; box-shadow: var(--shadow-sm), inset 0 0 0 2px #7aa2ff; }

@media (max-width: 760px) {
    .presentation { top: 110px; bottom: 76px; width: calc(100% - 20px); }
    #video-bar:not(:empty) ~ .presentation { top: 200px; }
    .knock-prompt { bottom: 70px; max-width: calc(100% - 24px); }
    .knock-prompt #knock-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* =========================================================
   Vie du bureau : poste attitré
   ========================================================= */
.desk-card { bottom: 132px; padding: 6px 6px 6px 14px; }
.desk-card > .icon { color: var(--accent); }
.desk-card #desk-action[hidden] { display: none; }
.desk-card:has(#desk-action[hidden]) { padding-right: 14px; }
.menu-kbd { margin-left: auto; font-size: 11px; padding: 1px 6px; }
@media (max-width: 760px) {
    .desk-card { bottom: 118px; max-width: calc(100% - 24px); }
    .desk-card #desk-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* =========================================================
   Réglages : interrupteurs d'ambiance
   ========================================================= */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row strong { display: block; font-size: 14px; font-weight: 600; }
.toggle-row small { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.switch {
    appearance: none;
    flex: none;
    position: relative;
    width: 38px;
    height: 22px;
    margin: 0;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background .15s;
}
.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform .15s, background .15s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--accent-text); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =========================================================
   Navigation : recherche (Ctrl+K), plan de l'étage
   ========================================================= */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 4px;
    padding: 5px 6px 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.search-trigger:hover { background: #3d3943; color: var(--text); }
.search-trigger kbd { font-size: 10px; padding: 1px 5px; }
.search-modal { align-items: flex-start; padding-top: 12vh; }
.search-card {
    width: min(620px, 100%);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.search-field { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-field .icon { color: var(--text-muted); }
.search-field input { flex: 1; border: none; outline: none; background: transparent; color: var(--text); font-size: 16px; }
.search-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.search-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-subtle); }
.search-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.search-item.active { background: var(--surface-3); }
.search-icon { width: 28px; height: 28px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface-2); color: var(--text-muted); }
.search-icon .sprite-avatar { --size: 24px; }
.search-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-text span { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-text small { font-size: 12px; color: var(--text-muted); }
.search-empty { padding: 18px; text-align: center; color: var(--text-muted); }
.search-foot { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.search-foot kbd { font-size: 10px; padding: 1px 5px; }

.plan-view {
    position: absolute;
    inset: 0;
    z-index: 17;
    display: flex;
    flex-direction: column;
    background: #d9f2d6;
    animation: toast-in .18s ease-out;
}
.plan-view[hidden] { display: none; }
.plan-head {
    position: absolute;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 14px;
    background: rgba(29, 28, 33, 0.92);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.plan-head small { color: var(--text-muted); font-weight: 400; }
#plan-canvas { flex: 1; width: 100%; height: 100%; display: block; cursor: crosshair; }

@media (max-width: 760px) {
    .search-trigger span, .search-trigger kbd { display: none; }
    .search-trigger { padding: 6px; margin-left: 0; }
    .plan-head small { display: none; }
    .plan-head { top: 64px; }
}

/* Aperçu d'un message reçu, chat fermé (clic : ouvre la conversation) */
.toast.peek { width: 100%; text-align: left; color: var(--text); cursor: pointer; align-items: center; border-left: 3px solid #f3f1f6; }
.toast.peek:hover { background: var(--surface-3); }
.toast.peek-nearby { border-left-color: #3ecf8e; }
.toast.peek-dm { border-left-color: #f472b6; }
.toast.peek .sprite-avatar { --size: 28px; flex: none; }
.peek-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.peek-body strong { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.peek-body span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Panneau ouvert (grand écran) : les éléments centrés se décalent pour rester visibles */
@media (min-width: 861px) {
    body.panel-open #control-bar,
    body.panel-open .interact-prompt,
    body.panel-open #zone-banner,
    body.panel-open #video-bar,
    body.panel-open .broadcast-banner,
    body.panel-open .presentation,
    body.panel-open .plan-head {
        left: calc(50% - (var(--panel-width) + 28px) / 2);
    }
    body.panel-open #video-bar { max-width: calc(100% - var(--panel-width) - 340px); }
    body.panel-open .presentation { width: min(1200px, calc(100% - var(--panel-width) - 76px)); }
}

/* =========================================================
   Créateur d'avatar
   ========================================================= */
.skin-custom { position: relative; border-style: dashed; }
.skin-custom > .icon { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; color: var(--accent); }
.skin-custom.empty { align-items: center; }
.skin-custom.empty .skin-preview { display: none; }
.skin-custom.empty > .icon { position: static; width: 20px; height: 20px; }
#avatar-modal { z-index: 110; } /* aussi par-dessus l'écran d'accueil */
.avatar-card { width: min(720px, 100%); }
.avatar-body { display: grid; grid-template-columns: 180px 1fr; gap: 18px; margin-top: 16px; }
.avatar-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 14px 10px;
    border-radius: var(--radius);
    background: radial-gradient(circle at 50% 70%, #3a3542 0, var(--surface-2) 70%);
    border: 1px solid var(--border);
}
#avatar-preview { width: 128px; height: 256px; image-rendering: pixelated; }
.avatar-options { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.avatar-tabs { flex: none; }
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 6px;
    max-height: 236px;
    overflow-y: auto;
    padding: 2px;
}
.avatar-colors { max-height: 120px; }
.avatar-opt {
    height: 64px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.avatar-opt:hover { border-color: var(--border-strong); }
.avatar-opt.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.avatar-thumb { width: 48px; height: 96px; margin-top: -8px; image-rendering: pixelated; background-repeat: no-repeat; flex: none; }
.avatar-none { align-items: center; font-size: 12px; color: var(--text-muted); }
/* Cadrage des aperçus selon l'onglet */
.avatar-grid[data-cat="outfit"] .avatar-opt { align-items: flex-end; }
.avatar-grid[data-cat="outfit"] .avatar-thumb { margin: 0 0 -2px; }
.avatar-grid[data-cat="body"] .avatar-opt { align-items: center; }
.avatar-grid[data-cat="body"] .avatar-thumb { width: 32px; height: 64px; margin: 0; }
@media (max-width: 640px) {
    .avatar-body { grid-template-columns: 1fr; }
    .avatar-stage { flex-direction: row; justify-content: center; }
    #avatar-preview { width: 64px; height: 128px; }
}

/* =========================================================
   Téléphone : joystick au doigt, vidéos repliables, zones sûres
   ========================================================= */
/* Joystick : apparaît sous le pouce quand on glisse sur la carte */
.touch-stick {
    position: absolute;
    z-index: 15;
    width: 88px;
    height: 88px;
    margin: -44px 0 0 -44px;
    border-radius: 50%;
    background: rgba(29, 28, 33, 0.35);
    border: 2px solid rgba(243, 241, 246, 0.45);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}
.touch-stick[hidden] { display: none; }
.touch-stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;
    background: rgba(243, 241, 246, 0.85);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.touch-stick.running { border-color: var(--accent); }
.touch-stick.running .touch-stick-knob { background: var(--accent); }

/* Pastille pour replier les vidéos (petits écrans seulement) */
.video-fold { display: none; }
@media (max-width: 760px) {
    .video-fold:not([hidden]) {
        position: absolute;
        top: 14px;
        right: 12px;
        z-index: 21;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        height: 40px;
        padding: 0 12px;
        border-radius: 999px;
        border: 1px solid var(--border);
        background: rgba(29, 28, 33, 0.92);
        backdrop-filter: blur(10px);
        color: var(--text);
        font-family: inherit;
        font-size: 13px;
        font-weight: 600;
        box-shadow: var(--shadow-sm);
        cursor: pointer;
    }
    .video-fold .video-fold-chevron { transition: transform .2s; color: var(--text-muted); }
    .videos-folded .video-fold .video-fold-chevron { transform: rotate(180deg); }
    .video-fold.speaking { border-color: var(--success); box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.35); }
    body.videos-folded #video-bar { display: none; }
    body.videos-folded #video-bar:not(:empty) ~ #zone-banner { top: 64px; }
    body.videos-folded #video-bar:not(:empty) ~ .broadcast-banner { top: 64px; }
    body.videos-folded #video-bar:not(:empty) ~ .presentation { top: 110px; }
    /* Vignettes : défilement horizontal au doigt, sans barre */
    #video-bar { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    #video-bar::-webkit-scrollbar { display: none; }
}

/* Toucher : boutons plus francs, pas de zoom au double toucher ni de surlignage gris */
body.touch button, body.touch .ctrl-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body.touch #interact-prompt kbd { display: none; } /* pas de touche X sur un téléphone */
html, body { overscroll-behavior: none; } /* pas de « tirer pour rafraîchir » en jouant */

/* Écrans à encoche / barre de geste : rien sous les bords arrondis */
@supports (padding: env(safe-area-inset-bottom)) {
    #control-bar { bottom: calc(16px + env(safe-area-inset-bottom)); }
    .brand-chip { top: calc(14px + env(safe-area-inset-top)); left: calc(14px + env(safe-area-inset-left)); }
    @media (max-width: 860px) {
        .brand-chip { top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); }
        #video-bar { top: calc(64px + env(safe-area-inset-top)); }
    }
    @media (max-width: 520px) {
        #control-bar { bottom: calc(10px + env(safe-area-inset-bottom)); }
    }
}

/* =========================================================
   Mondes : accueil, création, réglages
   ========================================================= */
/* Accueil des mondes : pas d'aperçu micro/caméra, une seule colonne plus large */
.login-card.wide { grid-template-columns: 1fr; width: min(760px, 100%); }
.login-card.wide .login-stage { display: none; }
.lobby-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lobby-head .btn { flex: none; }
.lobby-title { margin: 22px 0 8px; font-size: 15px; font-weight: 700; }
.world-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.world-card {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 8px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}
.world-card:hover { border-color: var(--accent); background: var(--surface-3); }
.world-thumb { width: 72px; height: 50px; object-fit: cover; border-radius: 8px; image-rendering: pixelated; background: var(--surface-3); }
.world-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.world-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-meta { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 200px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.tag-online { background: rgba(62, 207, 142, 0.16); color: var(--success); }
.tag-owner { background: rgba(245, 176, 60, 0.16); color: var(--accent); }
.tag-temp { background: rgba(122, 162, 255, 0.16); color: #7aa2ff; }
.world-empty { margin: 4px 0; font-size: 13px; color: var(--text-muted); }
.lobby-link { margin-top: 6px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .btn { flex: none; }
.field-help { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }
.segmented-block { flex: none; }
.world-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; color: var(--text-muted); font-size: 13px; }
.world-line strong { color: var(--text); }

/* Choix de la carte */
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.map-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    text-align: left;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: border-color .15s;
}
.map-card:hover { border-color: var(--border-strong, #4a4753); }
.map-card.active { border-color: var(--accent); }
.map-card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; image-rendering: pixelated; background: var(--surface-3); }
.map-card strong { margin-top: 4px; font-size: 14px; }
.map-size { font-size: 12px; color: var(--accent); font-weight: 600; }
.map-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* Réglages du monde */
.world-modal { max-height: calc(100vh - 32px); overflow-y: auto; }
.world-section { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--border); }
.world-members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.world-member { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.world-member .m-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-member .m-role { font-size: 12px; color: var(--text-muted); }
.danger-zone { display: flex; justify-content: flex-end; padding-top: 14px; }
@media (max-width: 520px) {
    .world-card { grid-template-columns: 56px minmax(0, 1fr); }
    .world-thumb { width: 56px; height: 40px; }
    .world-tags { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}

/* Retour à l'accueil (choisir un autre monde), en tête de la pastille du monde */
.brand-chip { padding-left: 4px; }
.home-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 30px;
    padding: 0 10px 0 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.home-btn:hover { background: #3d3943; border-color: var(--accent); }
@media (max-width: 520px) {
    .home-btn { padding: 0 6px; }
    .home-btn span { display: none; }
}

/* Mes mondes : renommer, supprimer depuis l'accueil (boutons dans la carte, à droite) */
.world-row {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    transition: border-color .15s, background .15s;
}
.world-row:hover { border-color: var(--accent); background: var(--surface-3); }
.world-row .world-card { flex: 1; min-width: 0; border: none; background: transparent; }
.world-row .world-card:hover { background: transparent; }
.world-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    align-self: stretch;
    padding: 0 8px;
    border-left: 1px solid var(--border);
}
.world-actions .icon-btn { width: 32px; height: 32px; }
.world-actions .icon-btn.danger:hover { color: var(--danger); background: rgba(240, 82, 82, 0.12); }
/* Souris : boutons discrets jusqu'au survol ; écran tactile : toujours visibles */
@media (hover: hover) {
    .world-actions .icon-btn { opacity: .55; }
    .world-row:hover .world-actions .icon-btn, .world-actions .icon-btn:focus-visible { opacity: 1; }
}

/* Personnes connectées dans un monde (accueil) */
.tag-presence { display: inline-flex; align-items: center; gap: 4px; }
.tag-presence .icon { width: 12px; height: 12px; }
.tag-presence.live { background: rgba(62, 207, 142, 0.16); color: var(--success); }
