:root {
  --brand: #9e0000;
  --brand-2: #c41616;
  --accent: #9e0000;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #646b78;
  --line: #e2e5ea;
  --ok: #18a058;
  --warn: #e0a100;
  --live: #e53935;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 16px rgba(0, 0, 0, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #181b21;
    --text: #e9ebef;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --accent: #ff7b7b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 8px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.error { color: var(--live); }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 9px; }
.btn.big { padding: 14px 22px; font-size: 17px; font-weight: 600; }

/* belépés */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 24px; max-width: 380px; width: 100%; text-align: center; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; }
.login-card p { color: var(--muted); }

/* keret */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button {
  position: relative; display: flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted);
  padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--accent); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.badge { background: var(--live); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }
.me { margin-left: auto; position: relative; display: flex; align-items: center; gap: 8px; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.conn.ok { background: var(--ok); }
.conn.bad { background: var(--live); }
.me-btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 18px; padding: 5px 12px; font: inherit; cursor: pointer; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: 40px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text); padding: 9px 10px; border-radius: 8px; font: inherit; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.menu-foot { color: var(--muted); font-size: 12px; padding: 6px 10px 2px; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 16px; background: color-mix(in srgb, var(--warn) 18%, var(--panel)); }
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; }

/* rádió */
.radio { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.radio-channels, .ptt-card, .history, .people, .call-log { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.channel-list, .history-list, .people-list, .log-list { list-style: none; margin: 0; padding: 0; }
.channel {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 2px solid transparent; cursor: pointer;
}
.channel + .channel { margin-top: 4px; }
.channel:hover { background: var(--bg); }
.channel.tx { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, transparent); }
.channel .ch-main { flex: 1; min-width: 0; }
.channel .ch-name { font-weight: 600; }
.channel .ch-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel .ch-sub.live { color: var(--live); font-weight: 600; }
.listen { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; width: 40px; height: 36px; cursor: pointer; font-size: 17px; opacity: .45; }
.listen.on { opacity: 1; border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--panel)); }
.ch-state { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.ch-state.connected { background: var(--ok); }
.ch-state.connecting { background: var(--warn); }
.ch-state.live { background: var(--live); animation: pulse 1s infinite; }

.radio-main { display: grid; gap: 16px; }
.ptt-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 16px; }
.tx-label { font-size: 16px; }
.busy { color: var(--live); font-weight: 600; margin-left: 6px; }
.ptt {
  position: relative; width: 210px; height: 210px; border-radius: 50%; border: 0; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle at 35% 30%, #d02a2a, var(--brand) 60%, #6a0000); color: #fff; font-weight: 800; font-size: 19px; letter-spacing: .05em;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--brand) 40%, transparent), inset 0 -6px 16px rgba(0, 0, 0, .25);
  transition: transform .08s ease;
}
.ptt:active, .ptt.on { transform: scale(.96); }
.ptt.on { background: radial-gradient(circle at 35% 30%, #ff5252, #e10000 60%, #8a0000); }
.ptt.busy-other { background: radial-gradient(circle at 35% 30%, #777, #555 60%, #333); }
.ptt.wait { opacity: .8; }
.ptt-ring { position: absolute; inset: -10px; border-radius: 50%; border: 4px solid transparent; pointer-events: none; }
.ptt.on .ptt-ring { border-color: #ff5252; animation: ring 1.1s infinite; }
.ptt-text { pointer-events: none; }
.ptt-hint { color: var(--muted); font-size: 13px; text-align: center; }
@keyframes ring { from { transform: scale(1); opacity: 1; } to { transform: scale(1.18); opacity: 0; } }
@keyframes pulse { 50% { opacity: .35; } }

.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-list { max-height: 46vh; overflow: auto; }
.clip { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.clip:last-child { border-bottom: 0; }
.clip .play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; cursor: pointer; flex: none; }
.clip .play.playing { background: var(--ok); }
.clip .who { font-weight: 600; }
.clip .meta { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); padding: 12px 4px; }

/* hívások */
.calls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.people-head input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.group-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding: 10px; border-radius: 10px; background: var(--bg); }
.people-list { margin-top: 10px; max-height: 62vh; overflow: auto; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person input { width: 18px; height: 18px; accent-color: var(--brand); }
.avatar { position: relative; width: 38px; height: 38px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 18%, var(--panel)); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--panel); background: #9aa1ad; }
.avatar .dot.online { background: var(--ok); }
.avatar .dot.incall { background: var(--live); }
.person .p-main { flex: 1; min-width: 0; }
.person .p-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .p-sub { color: var(--muted); font-size: 12.5px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 17px; }
.icon-btn:hover { border-color: var(--ok); }
.log-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.log-item .l-main { flex: 1; min-width: 0; }
.log-item .l-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-item .l-meta { color: var(--muted); font-size: 12.5px; }
.log-item.missed .l-name, .log-item.missed .l-meta b { color: var(--live); }

/* hívás képernyő */
.call {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #0b0d10; color: #fff;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}
.call-top { text-align: center; padding: 8px; }
.call-title { font-size: 22px; font-weight: 700; }
.call-status { color: #b9bec8; }
.call-stage { flex: 1; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-content: center; min-height: 0; overflow: auto; }
.tile { position: relative; background: #1b1f26; border-radius: 16px; overflow: hidden; aspect-ratio: 4/3; max-height: calc(100dvh - 200px); display: grid; place-items: center; border: 3px solid transparent; }
.tile.speaking { border-color: var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.screen { aspect-ratio: 16/9; background: #000; }
.tile.screen video { object-fit: contain; }
.tile .t-avatar { width: 96px; height: 96px; border-radius: 50%; background: #2c323c; display: grid; place-items: center; font-size: 36px; font-weight: 700; }
.tile .t-name { position: absolute; left: 10px; bottom: 8px; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 8px; font-size: 13px; }
.call-stage.sharing { grid-template-columns: 1fr; }
.fs-btn { position: absolute; right: 10px; bottom: 8px; width: 42px; height: 42px; border-radius: 10px; border: 0; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; cursor: pointer; }
.fs-btn svg { width: 26px; height: 26px; fill: currentColor; }
.call-stage:fullscreen { background: #000; padding: 0; grid-template-columns: 1fr; align-content: stretch; }
.call-stage:fullscreen .tile { aspect-ratio: auto; height: 100vh; border-radius: 0; border: 0; }
.call-actions { display: flex; justify-content: center; gap: 16px; padding: 14px 0 4px; }
.round { width: 60px; height: 60px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: #2a2f37; color: #fff; transition: background .15s, color .15s; }
.round svg { width: 28px; height: 28px; fill: currentColor; }
/* kapcsolók: kikapcsolva szürke és áthúzott ikon, bekapcsolva fehér és világos */
.round.toggle { background: #23272e; color: #6f7682; }
.round.toggle.on { background: #fff; color: #111; box-shadow: 0 0 0 3px rgba(255, 255, 255, .18); }
.round.accept { background: var(--ok); color: #fff; }
.round.decline { background: var(--live); color: #fff; }
.out-menu { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 55; background: #1b1f26; color: #fff; border-radius: 14px; padding: 6px; min-width: 260px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.out-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #9aa1ad; padding: 6px 10px; }
.out-menu button { display: block; width: 100%; text-align: left; padding: 11px 12px; background: none; border: 0; color: #fff; font: inherit; border-radius: 9px; cursor: pointer; }
.out-menu button:hover { background: #262b33; }
.out-menu button.active { background: #1f4d34; }

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }

@media (max-width: 820px) {
  .radio, .calls { grid-template-columns: 1fr; }
  .radio-main { order: -1; }
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .tabs button { padding: 8px 10px; }
  .me-btn { max-width: 30vw; padding: 5px 10px; }
  .brand span { display: none; }
  .tabs { margin-left: 0; }
  .tabs .ico { font-size: 17px; }
  .ptt { width: 190px; height: 190px; }
  .desktop-only { display: none; }
  .call-stage { grid-template-columns: 1fr; }
  .tile { aspect-ratio: auto; min-height: 30vh; }
  .tile.screen { min-height: 0; aspect-ratio: 16/9; }
  .call-actions { gap: 12px; }
  .round { width: 56px; height: 56px; }
}
@media (hover: none) { .ptt-hint .desk { display: none; } }
