:root {
  --bg: #14171a;
  --panel: #1e2328;
  --line: #2e353d;
  --text: #e7eaed;
  --muted: #8a949e;
  --lcd: #b7d77a;
  --lcd-bg: #1d2614;
  --tx: #e5483b;
  --rx: #f0a428;
  --ok: #4cc26b;
  --req: #6b7785;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; user-select: none; }
.hidden { display: none !important; }
button, select, input { font: inherit; color: inherit; }

.screen { min-height: 100%; max-width: 520px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* Connexion */
#login { justify-content: center; }
.brand { text-align: center; }
.brand h1 { margin: 8px 0 4px; font-size: 1.6rem; letter-spacing: .02em; }
.brand p { margin: 0; color: var(--muted); }
form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
form label small { color: var(--muted); opacity: .8; }
input:not([type=checkbox]):not([type=range]), select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--text); width: 100%;
}
#loginForm { display: flex; flex-direction: column; gap: 14px; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; cursor: pointer; }
button.primary { background: var(--ok); border-color: var(--ok); color: #08170c; font-weight: 700; }
button.danger { border-color: var(--tx); color: var(--tx); }
.error { color: var(--tx); min-height: 1.2em; margin: 0; }

/* Barre du haut */
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar select { flex: 1; font-weight: 600; }
.icon-btn { padding: 10px 12px; font-size: 1.2rem; line-height: 1; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--req); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--tx); animation: blink 1s infinite; }
.latency { color: var(--muted); font-size: .8rem; min-width: 3.5em; text-align: right; }
@keyframes blink { 50% { opacity: .3; } }

/* Afficheur type radio */
.lcd { background: var(--lcd-bg); border: 2px solid #33402a; border-radius: 12px; padding: 12px 14px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--lcd); box-shadow: inset 0 0 18px rgba(0,0,0,.5); }
.lcd-row { display: flex; justify-content: space-between; font-size: .9rem; opacity: .85; }
.lcd-status { font-size: 1.5rem; font-weight: 700; margin: 6px 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 6px; background: rgba(0,0,0,.35); border-radius: 3px; overflow: hidden; }
#meterBar { height: 100%; width: 0; background: var(--lcd); transition: width 60ms linear; }
body[data-mode=tx] .lcd { color: #ffb3ab; }
body[data-mode=tx] #meterBar { background: var(--tx); }
body[data-mode=rx] .lcd { color: #ffd38a; }
body[data-mode=rx] #meterBar { background: var(--rx); }

/* Bouton PTT */
.ptt {
  align-self: center; width: min(72vw, 300px); aspect-ratio: 1; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at 35% 30%, #3a434d, #1c2126 70%);
  border: 6px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.5);
  touch-action: none; transition: transform 80ms, border-color 120ms, background 120ms;
}
.ptt:active { transform: scale(.97); }
#pttLabel { font-size: 2.6rem; font-weight: 800; letter-spacing: .06em; }
#pttSub { font-size: .85rem; color: var(--muted); }
.ptt.idle { border-color: var(--ok); }
.ptt.req { border-color: var(--req); }
.ptt.tx { border-color: var(--tx); background: radial-gradient(circle at 35% 30%, #ff6f61, #a3241a 70%); box-shadow: 0 0 40px rgba(229,72,59,.55); }
.ptt.tx #pttSub { color: #ffe1dd; }
.ptt.rx { border-color: var(--rx); box-shadow: 0 0 30px rgba(240,164,40,.35); }
.ptt.offline { opacity: .55; border-color: var(--tx); }

/* Utilisateurs */
.users h2 { font-size: .95rem; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.users ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.users li { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .9rem; }
.users li.talking { border-color: var(--rx); color: var(--rx); }

/* Réglages */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(94vw, 460px); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.settings-form { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.settings-form h2 { margin: 0; }
.settings-form label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.settings-form input[type=checkbox] { width: 20px; height: 20px; flex: none; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
legend { color: var(--muted); font-size: .9rem; padding: 0 4px; }
.key-list { margin: 0 0 10px; padding-left: 18px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hint { color: var(--rx); margin: 8px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; background: #000c; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; transition: .2s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
