/* Genlok — palette A (régie) */
:root {
  --bg: #0E1013; --side: #12151A; --panel: #171A1F; --panel-2: #1D2127; --line: #2A2F37; --line-soft: #22262D;
  --text: #E8EAED; --text-2: #B4BBC5; --muted: #8A93A0;
  --cyan: #3FB6E8; --blue: #2F5FD0; --sel: #1B2638;
  --air: #D42C30; --air-dot: #E5383B; --ok: #2BB673; --warn: #F2A93B;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
a { color: var(--cyan); } a:hover { color: #7CCDF0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Mise en page */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 232px; max-width: 100%; padding: 24px 16px; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px; }
.side .logo { height: 30px; align-self: flex-start; margin-left: 8px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav .label { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--sel); color: var(--cyan); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 0 12px; }
.content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.main { padding: 4px 36px 40px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 820px) { .side { border-right: none; border-bottom: 1px solid var(--line); } .main { padding: 4px 16px 32px; } .topbar { padding: 12px 16px 8px; } }

/* Barre du haut : connexion et compte, détachés du contenu, en haut à droite */
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 18px 36px 10px; position: relative; z-index: 20; }
.topbar .conn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 12px; min-height: 36px; border-radius: 999px; border: 1px solid var(--line-soft); }
.topbar .conn.warn { color: var(--warn); border-color: #5C4618; }
.um-wrap { position: relative; }
.user-btn { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; max-width: 320px; }
.user-btn:hover { border-color: var(--muted); }
.user-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.user-btn[aria-expanded="true"] { border-color: var(--cyan); }
.user-btn .who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-btn .who-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .who-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .chev { color: var(--muted); font-size: 12px; }
.ua { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.ua.big { width: 46px; height: 46px; font-size: 16px; }
.user-menu { position: absolute; right: 0; top: calc(100% + 8px); width: min(340px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.45); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.um-id { display: flex; gap: 12px; align-items: center; }
.um-id > div { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.um-id strong { font-size: 15px; }
.um-id .tag { margin-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--cyan); }
.um-section { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.um-section h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.um-section p { margin: 0; font-size: 13.5px; color: var(--text-2); }
.um-server { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.um-link { font-size: 13.5px; color: var(--cyan); text-decoration: none; align-self: flex-start; }
.um-link:hover { text-decoration: underline; }
.um-logout { margin-top: 2px; }
@media (max-width: 560px) { .user-btn .who-text span { display: none; } }

.head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.head .kicker { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.chip strong { color: var(--text); font-weight: 600; }
.chip.air { background: #2A1416; border-color: #5A2226; color: var(--text); font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.card .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(var(--min, 280px), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > .grow { flex: 3 1 420px; } .row > .side-col { flex: 2 1 300px; }

/* Badges d'état */
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 4px 8px; border-radius: 5px; line-height: 1.2; }
.b-air { background: var(--air); color: #fff; } .b-pvw, .b-ok { background: var(--ok); color: var(--bg); }
.b-warn { background: var(--warn); color: var(--bg); } .b-off { background: var(--line); color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.d-ok { background: var(--ok); } .d-warn { background: var(--warn); } .d-air { background: var(--air-dot); } .d-off { background: #4A515C; }

/* Formulaires */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { border-color: #3A404A; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #3A6BDB; }
.btn.danger { background: transparent; border-color: #5A2226; color: #F08A8C; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg, .chip svg { width: 18px; height: 18px; flex: none; }
.btn.small svg { width: 16px; height: 16px; }
label.field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 600; }
.input, select.input, textarea.input { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 400; width: 100%; }
textarea.input { padding: 10px 12px; min-height: 80px; }
.input:focus { border-color: var(--cyan); outline: none; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.switch { flex: none; width: 48px; height: 28px; border-radius: 14px; border: none; background: #3A404A; position: relative; padding: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--blue); } .switch[aria-checked="true"]::after { left: 23px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.setting .txt { display: flex; flex-direction: column; gap: 2px; } .setting .txt span:last-child { font-size: 13px; color: var(--muted); }
.note { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin: 0; }
.note svg { width: 14px; height: 14px; flex: none; }
.note.warn { color: var(--warn); }
.error { color: #F08A8C; font-size: 14px; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 14px; text-align: left; vertical-align: middle; }
thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
tbody tr { border-top: 1px solid var(--line-soft); }
tbody tr.sel { background: var(--sel); }
tbody th { font-weight: 600; }
.sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

/* Vidéo simulée */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0B0D11; }
.video canvas { width: 100%; height: 100%; display: block; }
.video .tag { position: absolute; top: 10px; left: 10px; }

/* Lieux */
.lieu-card { border-radius: 16px; background: var(--panel); border: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.lieu-card.air { border: 2px solid var(--air); }
dl.stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
dl.stats dt { font-size: 12px; color: var(--muted); } dl.stats dd { margin: 4px 0 0; font-family: var(--mono); font-size: 14px; }

/* Commutation */
.bus { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.src { flex: 1 1 200px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.src.pvw { border: 2px solid var(--ok); } .src.pgm { border: 2px solid var(--air); }
.src .name { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; font-weight: 600; }
.take { flex: 1 1 180px; min-height: 140px; border-radius: 16px; border: none; background: var(--air); color: #fff; font: 800 26px var(--sans); letter-spacing: .1em; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.take small { font-size: 12px; font-weight: 500; letter-spacing: .02em; opacity: .85; }
.take:disabled { background: #4A2224; cursor: not-allowed; }
.monitor { border-radius: 16px; padding: 14px; background: var(--panel); display: flex; flex-direction: column; gap: 12px; }
.monitor.pvw { border: 2px solid var(--ok); } .monitor.pgm { border: 2px solid var(--air); }

/* Journal */
ol.journal { margin: 0; padding: 0; list-style: none; }
ol.journal li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
ol.journal li span:first-child { font-family: var(--mono); color: var(--muted); flex: none; }

/* Intercom */
.ptt { width: 220px; height: 160px; border-radius: 20px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font: 700 14px var(--sans); letter-spacing: .08em; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); user-select: none; }
.ptt.on { border: 2px solid var(--cyan); background: #1B2F4A; color: var(--cyan); }
.member { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.member.talk { border: 2px solid var(--cyan); }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: #B4BBC5; color: var(--bg); }
.chan { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 56px; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; width: 100%; }
.chan.on { border-color: var(--cyan); background: var(--sel); }

/* Onglets */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { border-color: var(--cyan); background: var(--sel); color: var(--cyan); }

/* Pages d'accueil */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth .brand { flex: 1 1 420px; padding: 64px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; background: var(--side); border-right: 1px solid var(--line); }
.auth .brand h1 { margin: 0; font-size: 40px; line-height: 1.15; letter-spacing: -.02em; }
.auth .brand p { margin: 0; font-size: 17px; color: var(--text-2); max-width: 460px; }
.auth .form { flex: 999 1 560px; min-width: 0; padding: 64px 24px; display: flex; align-items: center; justify-content: center; }
.auth form { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 22px; }
.role { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; text-align: left; width: 100%; }
.role.on { border: 2px solid var(--cyan); background: #16243F; }
.role .t { display: flex; flex-direction: column; gap: 3px; } .role .t span:last-child { font-size: 13px; color: var(--muted); font-weight: 400; }
.radio { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #4A515C; }
.role.on .radio { border-color: var(--cyan); background: radial-gradient(var(--cyan) 0 4px, transparent 5px); }

/* Fenêtres modales */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { display: flex; flex-direction: column; gap: 16px; }
dialog h2 { margin: 0; font-size: 20px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.secret { font-family: var(--mono); font-size: 20px; padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); text-align: center; user-select: all; }

/* Bandeau de connexion et notifications */
.toast { position: fixed; right: 16px; bottom: 16px; max-width: 420px; padding: 12px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 14px; z-index: 50; }
.toast.err { border-color: #5A2226; }
.offline { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: #2A2213; border: 1px solid #5C4618; font-size: 14px; }

/* Lecteur salle */
.player { position: fixed; inset: 0; background: #000; overflow: hidden; cursor: none; }
.player canvas, .player .wall { position: absolute; inset: 0; width: 100%; height: 100%; }
.player .wall { object-fit: cover; }
.player .wall-default { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; background: linear-gradient(135deg, #0F1218 0%, #141C2B 55%, #182540 100%); }
.player .wall-default img { height: 12vh; opacity: .9; }
.player .nosource { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vh; background: #0B0D10; }
.player .nosource strong { font-size: 8vh; font-weight: 800; letter-spacing: .18em; }
.player .nosource span { font-size: 2.8vh; color: var(--muted); }
.player .status { position: absolute; right: 1.2vw; bottom: 1.2vh; display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; background: rgba(14,16,19,.35); font-size: max(10px, 1vh); color: rgba(232,234,237,.7); opacity: 0; transition: opacity .6s; pointer-events: none; }
.player .status.show { opacity: .8; }
.player .status .dot { width: 6px; height: 6px; }
.player .exit { position: absolute; top: 12px; right: 12px; opacity: 0; transition: opacity .2s; cursor: pointer; }
.player:hover .exit { opacity: 1; cursor: default; }
.player:hover { cursor: default; }

/* Transitions de commutation */
.xf { position: absolute; inset: 0; }
.xf > canvas, .xf > img, .xf > video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
@keyframes gk-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes gk-fade-out { from { opacity: 1; } to { opacity: 0; } }
.card.trans { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; font-weight: 600; padding: 8px 16px; background: transparent; color: var(--text-2); border: 0; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--sel); color: var(--text); }
.seg button:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.bus .cut { align-self: stretch; }
@media (prefers-reduced-motion: reduce) { .xf { animation-duration: 1ms !important; } }

/* Profil (ouvre les paramètres) et version */
.version-update { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.lang-pick .input { min-height: 36px; padding: 4px 10px; font-size: 13px; width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Fenêtre de mise à jour : étapes numérotées et barre de progression */
dialog.update-progress { display: flex; flex-direction: column; gap: 16px; }
dialog.update-progress:not([open]) { display: none; }
.update-progress .steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.update-progress .step { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.update-progress .step .mark { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.update-progress .step.now { color: var(--text); font-weight: 600; }
.update-progress .step.now .mark { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 0 4px rgba(63,182,232,.15); animation: gk-pulse 1.4s ease-in-out infinite; }
.update-progress .step.done { color: var(--text-2); }
.update-progress .step.done .mark { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.update-progress .bar { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.update-progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--blue)); transition: width .3s; }
.update-progress .actions { display: flex; justify-content: flex-end; gap: 10px; }
.ok-text { color: var(--ok); }
@keyframes gk-pulse { 50% { box-shadow: 0 0 0 7px rgba(63,182,232,.05); } }
@media (prefers-reduced-motion: reduce) { .update-progress .step.now .mark { animation: none; } .update-progress .bar i { transition: none; } }

/* Serveur injoignable */
.unreachable { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.unreachable .card { width: min(560px, 100%); gap: 18px; padding: 28px; }
.ur-head { display: flex; gap: 14px; align-items: flex-start; }
.ur-head h1 { margin: 0 0 6px; font-size: 24px; }
.ur-head p { margin: 0; }
.ur-icon { width: 42px; height: 42px; border-radius: 12px; background: #2A2213; color: var(--warn); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ur-icon svg { width: 22px; height: 22px; }
.ur-server { display: flex; gap: 10px; flex-wrap: wrap; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); overflow-wrap: anywhere; }
.ur-change { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.ur-change .btn { align-self: flex-start; }
.ur-tips { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
