:root {
  --bg: #0f1115; --panel: #171a21; --line: #262b36; --text: #eef0f4; --muted: #8b93a5;
  --accent: #f97316; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --ch: #2563eb;
  --radius: 18px; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 50% 0, #1b1f29, var(--bg) 60%); color: var(--text); }
body { display: grid; place-items: start center; padding: 16px; min-height: 100dvh; }
.unit { width: 100%; max-width: 420px; position: relative; }
.screen { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }
h1 { font-size: 24px; margin: 4px 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
code { background: var(--panel); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
input[type=range] { padding: 0; accent-color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.primary { background: var(--accent); color: #111; font-weight: 650; border-radius: 12px; padding: 12px 18px; }
.primary.big { padding: 16px; font-size: 17px; }
.ghost { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-top: 12px; }
.brand img { width: 32px; height: 32px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.seg button.on { background: #262c38; color: var(--text); }

.bar { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.bar .spacer { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 4px #ef444422; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px #22c55e22; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.icon { width: 36px; height: 36px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 20px; line-height: 1; }

.display { background: linear-gradient(160deg, color-mix(in srgb, var(--ch) 28%, var(--panel)), var(--panel)); border: 1px solid color-mix(in srgb, var(--ch) 45%, var(--line)); border-radius: var(--radius); padding: 18px; min-height: 150px; display: flex; flex-direction: column; gap: 6px; transition: background .3s; }
.display .label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.display .channel { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.talkers { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.talker { background: #ffffff14; border-radius: 99px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px; }
.talker::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: blink .8s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.call { background: #2a1c0f; border: 1px solid #7c3f12; border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; animation: in .25s; }
.call.done { background: var(--panel); border-color: var(--line); opacity: .8; }
.call.emergency { background: #3a1010; border-color: var(--bad); }
.call .txt { flex: 1; font-size: 14px; } .call b { display: block; font-size: 15px; }
.call button { background: var(--accent); color: #111; font-weight: 700; border-radius: 10px; padding: 10px 12px; white-space: nowrap; }
@keyframes in { from { transform: translateY(-6px); opacity: 0; } }

.meter { height: 6px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: var(--ok); transition: width .08s; }

.ptt { position: relative; height: 170px; border-radius: 28px; background: linear-gradient(180deg, #232836, #1a1e28); border: 1px solid var(--line); display: grid; place-items: center; user-select: none; -webkit-user-select: none; touch-action: none; }
.ptt-label { font-size: 18px; font-weight: 700; text-align: center; color: var(--text); }
.ptt-label small { font-weight: 500; color: var(--muted); font-size: 13px; }
.ptt.active { background: linear-gradient(180deg, #7c2d12, #431407); border-color: var(--accent); }
.ptt.active .ptt-ring { position: absolute; inset: -4px; border-radius: 30px; border: 2px solid var(--accent); animation: ring 1s infinite; }
@keyframes ring { from { opacity: 1; } to { opacity: 0; transform: scale(1.04); } }

.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.switch input { display: none; }
.switch span { width: 46px; height: 28px; background: var(--line); border-radius: 99px; position: relative; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 21px; }
.sos { background: #3a1010; border: 1px solid #7f1d1d; color: #fecaca; font-weight: 700; padding: 12px 16px; border-radius: 12px; }
.sos small { display: block; font-weight: 500; font-size: 11px; color: #fca5a5; }
.sos.holding { background: var(--bad); color: #fff; }

.bellbtn { margin: 24px auto; width: 230px; height: 230px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fb923c, #c2410c); box-shadow: 0 14px 0 #7c2d12, 0 20px 40px #0008; font-size: 28px; font-weight: 800; color: #fff; transition: transform .08s, box-shadow .08s; }
.bellbtn:active { transform: translateY(10px); box-shadow: 0 4px 0 #7c2d12, 0 8px 20px #0008; }
.led { display: flex; gap: 10px; align-items: center; justify-content: center; }
.led span { width: 16px; height: 16px; border-radius: 50%; background: #333; }
.led.sending span { background: var(--warn); animation: blink .3s infinite; }
.led.open span { background: var(--accent); animation: blink 1s infinite; }
.led.acked span { background: var(--ok); }
.led.error span { background: var(--bad); }

.pulse { width: 70px; height: 70px; border-radius: 50%; background: var(--accent); margin: 40px auto 10px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #f9731688; } 100% { box-shadow: 0 0 0 30px #f9731600; } }
#s-pending { text-align: center; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); width: min(400px, 92vw); padding: 20px; }
dialog::backdrop { background: #000a; }
dialog form { display: flex; flex-direction: column; gap: 14px; }

.overlay { position: fixed; inset: 0; background: #7f1d1d; display: grid; place-items: center; text-align: center; padding: 24px; z-index: 10; animation: flash 1s infinite; }
.overlay h1 { font-size: 48px; }
@keyframes flash { 50% { background: #b91c1c; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #262c38; border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; max-width: 90vw; z-index: 20; box-shadow: 0 10px 30px #0008; }

/* v0.3: Kopplungscode, Identifizieren, Direktruf-Auswahl */
.paircode { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.paircode b { font-size: 44px; letter-spacing: .25em; font-variant-numeric: tabular-nums; color: var(--accent); }
.identify { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; text-align: center; padding: 24px; background: var(--accent); color: #111; animation: idflash .4s infinite alternate; }
.identify b { font-size: 64px; }
@keyframes idflash { to { background: #fff7ed; } }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick:empty { display: none; }
.pick::before { content: attr(data-title); width: 100%; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.pick button { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: #20242e; font-weight: 600; display: inline-flex; gap: 8px; align-items: center; }
.pick button.on { border-color: var(--accent); background: #3b2414; }
.pick .sw { width: 10px; height: 10px; border-radius: 3px; }
.talker .reply { margin-left: 4px; background: var(--accent); color: #111; border-radius: 99px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
#s-pending { text-align: center; }

/* v0.4: Touch – keine Textauswahl, kein Kopiermenü, kein Doppeltipp-Zoom auf Bedienelementen */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
input, select, textarea { -webkit-user-select: text; user-select: text; }
button, .seg, .call, .talker, .ptt, .sos, .bellbtn { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ptt, .sos, .bellbtn { touch-action: none; }
.ptt *, .sos *, .bellbtn * { pointer-events: none; }
.sos { position: relative; overflow: hidden; min-height: 52px; }
.sos .sos-fill { position: absolute; inset: 0; width: 0; background: var(--bad); }
.sos.holding .sos-fill { width: 100%; transition: width 2s linear; }
.sos .sos-label { position: relative; }
.sos.holding { background: #3a1010; color: #fff; }
/* Schwarzbild: Funk läuft weiter, Display spart Strom */

/* v0.5: Schnelldurchsagen */
.ghost.wide { width: 100%; padding: 14px; font-weight: 650; color: var(--text); }
#quick-list button { border-left: 4px solid var(--qc, var(--accent)); }

/* v0.6: Filial-Code und Sensor-Simulator */
.site-form { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; }
.site-form input { font: inherit; font-size: 20px; letter-spacing: .15em; text-transform: uppercase; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid #fff3; background: #0003; color: inherit; }
.bellbtn.small { width: 180px; height: 180px; font-size: 20px; }
.sens-slider { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.sens-slider input { width: 100%; }
#sens-value.alarm { color: #ef4444; }
.pick .qhead { width: 100%; margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* v0.7: Hardware-Tasten, Filialruf, Kundendurchsage */
.keys { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.keyrow { display: flex; align-items: center; gap: 10px; }
.keyrow span { flex: 1; } .keyrow small { color: var(--muted); }
.keyrow b { font-family: ui-monospace, monospace; font-size: 13px; color: var(--accent); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keyrow button.learning { border-color: var(--accent); color: var(--accent); animation: blink 1s infinite; }
.keylog { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); background: #0006; border-radius: 8px; padding: 8px; min-height: 2.5em; word-break: break-all; }
.xbar { display: flex; align-items: center; gap: 10px; background: #2e1065; border: 1px solid #7c3aed; border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.xbar span { flex: 1; }
.xbar button { border: 1px solid #a78bfa; border-radius: 8px; padding: 6px 10px; background: none; color: inherit; }
.xin { position: fixed; inset: 0; z-index: 35; background: #1e1b4b; display: grid; place-items: center; text-align: center; padding: 24px; }
.xin h1 { font-size: 32px; margin: 6px 0; }
.xin .row { gap: 12px; margin-top: 18px; }
#btn-public.on { background: #b45309; border-color: #f59e0b; }
#btn-link.on { background: #6d28d9; border-color: #a78bfa; }
.pick button.sub { font-weight: 500; font-size: 13px; padding: 8px 12px; opacity: .9; }

/* Android-App: Browser-Teile ausblenden */
.app-only { display: none; }
.in-app .app-only { display: revert; }
.in-app .web-only { display: none !important; }
.in-app #btn-audio { display: none; }
#m-quit.danger { color: var(--bad); border-color: var(--bad); font-weight: 700; }
