:root {
    --bg: #15171c;
    --bg-soft: #1c1f26;
    --bg-lift: #242832;
    --line: #2e3340;
    --text: #e6e9ef;
    --text-dim: #939bab;
    --accent: #5b8cff;
    --speak: #3fd68a;
    --danger: #e0555f;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

svg { fill: currentColor; width: 20px; height: 20px; display: block; }

.screen { height: 100%; }
[hidden] { display: none !important; }

/* ---------- Connexion ---------- */

#login {
    display: grid;
    place-items: center;
    background: radial-gradient(1200px 600px at 50% -10%, #232838 0%, var(--bg) 60%);
    padding: 24px;
}

.login-card {
    width: min(380px, 100%);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 36px 32px 28px;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-mark {
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, var(--accent), #7b5bff);
    color: #fff;
}
.login-mark svg { width: 30px; height: 30px; }

.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.login-sub { margin: 0 0 26px; color: var(--text-dim); font-size: 14px; }
.gbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    width: 100%;
    height: 46px;
    border-radius: 999px;
    background: #fff;
    color: #1f232b;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}
.gbtn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.gbtn:active { transform: none; }
.glogo { width: 19px; height: 19px; }
.login-foot { margin: 26px 0 0; color: #5d6474; font-size: 12px; letter-spacing: .04em; }

.error {
    margin: 18px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(224, 85, 95, .12);
    border: 1px solid rgba(224, 85, 95, .35);
    color: #ff9aa1;
    font-size: 13px;
    text-align: left;
}

.error .detail {
    display: block;
    margin-top: 8px;
    color: #c98d92;
    font-size: 12px;
    line-height: 1.45;
}

/* ---------- Salon ---------- */

#room { display: flex; flex-direction: column; }

#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
    flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); }

.dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #6b7280;
    transition: background .25s;
}
.dot.online { background: var(--speak); box-shadow: 0 0 0 3px rgba(63, 214, 138, .16); }
.dot.offline { background: var(--danger); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.count {
    font-size: 12px;
    color: var(--text-dim);
    background: var(--bg-lift);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 10px;
}

.icon-btn {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border: 0; border-radius: 9px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-lift); color: var(--text); }
.icon-btn.ghost { background: rgba(0, 0, 0, .5); color: #fff; }

#stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
}

#screen-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: #000;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
#screen-video { width: 100%; height: 100%; object-fit: contain; display: block; }
#screen-label {
    position: absolute; left: 12px; top: 12px;
    background: rgba(0, 0, 0, .6);
    padding: 5px 11px; border-radius: 999px;
    font-size: 12px; color: #fff;
    backdrop-filter: blur(6px);
}
#btn-fullscreen { position: absolute; right: 12px; top: 12px; }

#peers {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 22px;
    flex-wrap: wrap;
}

#stage:not(:has(#screen-wrap:not([hidden]))) #peers {
    flex: 1 1 auto;
    align-items: center;
}

.peer { width: 150px; text-align: center; }

.avatar-wrap {
    position: relative;
    width: 96px; height: 96px;
    margin: 0 auto 12px;
}

.ring {
    position: absolute; inset: -6px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: border-color .12s ease, transform .12s ease;
}
.peer.speaking .ring {
    border-color: var(--speak);
    transform: scale(1.04);
    box-shadow: 0 0 22px rgba(63, 214, 138, .32);
}
.peer.muted .ring { border-color: transparent; }

.avatar {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-lift);
    display: block;
    transition: filter .2s, opacity .2s;
}
.peer.muted .avatar { filter: grayscale(.7); opacity: .6; }

.muted-badge, .share-badge {
    position: absolute;
    bottom: 0;
    display: none;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 3px solid var(--bg);
    color: #fff;
}
.muted-badge { right: -2px; background: var(--danger); }
.share-badge { left: -2px; background: var(--accent); }
.muted-badge svg, .share-badge svg { width: 15px; height: 15px; }
.peer.muted .muted-badge { display: grid; }
.peer.sharing .share-badge { display: grid; }

.peer-name {
    font-size: 14px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.peer-status { font-size: 12px; color: var(--text-dim); min-height: 18px; }
.peer.you .peer-name::after { content: " (toi)"; color: var(--text-dim); font-weight: 400; }

/* ---------- Barre d'actions ---------- */

#bar {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 14px;
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
    padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.pill {
    display: inline-flex; align-items: center; gap: 9px;
    height: 44px; padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-lift);
    color: var(--text);
    font: inherit; font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.pill:hover { background: #2c313d; }
.pill .off { display: none; }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.off { background: rgba(224, 85, 95, .16); border-color: rgba(224, 85, 95, .5); color: #ff9aa1; }
.pill.off .on { display: none; }
.pill.off .off { display: block; }
.pill.danger:hover { background: rgba(224, 85, 95, .18); border-color: rgba(224, 85, 95, .5); color: #ff9aa1; }
.pill:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Réglages ---------- */

#settings {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .55);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 20;
}

.panel {
    width: min(420px, 100%);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow);
    max-height: 100%;
    overflow: auto;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 600; }

.field { display: block; margin-bottom: 22px; }
.field > span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

select, input[type="range"] { width: 100%; }

select {
    height: 38px;
    padding: 0 10px;
    background: var(--bg-lift);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: inherit; font-size: 14px;
}

input[type="range"] {
    -webkit-appearance: none; appearance: none;
    height: 4px; border-radius: 2px;
    background: var(--line);
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--accent); cursor: pointer;
    border: 0;
}
input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: 0;
}

.meter {
    position: relative;
    height: 8px;
    margin-top: 12px;
    border-radius: 4px;
    background: var(--bg-lift);
    overflow: hidden;
}
.meter-fill {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--speak), #9ae66a);
    transition: width .06s linear;
}
.meter-mark {
    position: absolute; top: -3px; bottom: -3px;
    width: 2px;
    background: var(--text);
    opacity: .8;
}

.hint { margin: 10px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.45; }

kbd {
    background: var(--bg-lift);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
    font: inherit; font-size: 11px;
}

/* ---------- Toast ---------- */

#toast {
    position: fixed;
    left: 50%; bottom: 84px;
    transform: translateX(-50%);
    background: var(--bg-lift);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 13px;
    box-shadow: var(--shadow);
    z-index: 30;
}

@media (max-width: 560px) {
    #stage { padding: 12px; gap: 12px; }
    #peers { gap: 12px; }
    .peer { width: 104px; }
    .avatar-wrap { width: 72px; height: 72px; }
    .pill .label { display: none; }
    .pill { padding: 0 16px; }
}
