/* RAMPENSAU Intercom – dunkles Regie-Design (Tokens nach ma3patch/DESIGN.md) */
:root {
  --bg: #101114; --surface: #17181c; --control: #1e2025; --hover: #26282e;
  --border: #34363d; --border-strong: #4a4d55;
  --text: #f2f2f0; --text-2: #b7b8bd; --muted: #8f9198;
  --brand: #f07d00; --brand-hover: #ff8c12; --brand-ink: #1a0f00;
  --ok: #3ecf6e; --warn: #f5b041; --err: #ff716a;
  --talk: #e5322d; --talk-glow: rgba(229, 50, 45, .35);
  --r-sm: 4px; --r: 6px; --r-lg: 12px;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 "IBM Plex Sans", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.25rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
p { margin: .5rem 0 0; color: var(--text-2); }
a { color: var(--brand); }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: .8125rem; color: var(--muted); }
.muted { color: var(--muted); }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 8px 20px; border-bottom: 1px solid var(--border);
  background: rgba(16, 17, 20, .94); backdrop-filter: blur(8px);
}
.topbar .title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.topbar .title small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.sep { width: 1px; height: 20px; background: var(--border); }

/* Status-Pille */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--control);
  color: var(--text-2); font-size: .8125rem; white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill[data-state="connected"]::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill[data-state="connecting"]::before { background: var(--warn); animation: blink 1s infinite; }
.pill[data-state="media-failed"]::before, .pill[data-state="offline"]::before { background: var(--err); }
@keyframes blink { 50% { opacity: .3; } }

/* Grundelemente */
main { width: min(100% - 32px, 1200px); margin: 0 auto; padding: 24px 0 48px; }
main.narrow { max-width: 440px; }
.card { padding: 20px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
label { display: block; margin: 14px 0 6px; color: var(--text-2); font-size: .8125rem; font-weight: 600; }
label:first-child { margin-top: 0; }
input, select {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--control); color: var(--text); font: inherit;
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus { outline: none; border-color: var(--brand); }
input[type="color"] { width: 38px; padding: 3px; }
input[type="range"] { min-height: 0; padding: 0; border: 0; background: none; accent-color: var(--brand); }
input[type="checkbox"] { width: 16px; min-height: 16px; accent-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--control); color: var(--text);
  font: inherit; font-weight: 600; font-size: .875rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:focus-visible, button:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: .8125rem; }
.btn.big { min-height: 52px; padding: 12px 24px; font-size: 1rem; }
.notice { margin-top: 12px; font-size: .875rem; color: var(--text-2); }
.notice[data-level="error"] { color: var(--err); }
.notice[data-level="warn"] { color: var(--warn); }
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 50; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--control); color: var(--text); font-size: .875rem; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast[data-level="error"] { border-color: var(--err); }
.toast[data-level="warn"] { border-color: var(--warn); }

/* Pegel */
.meter { position: relative; height: 6px; border-radius: 3px; background: var(--control); overflow: hidden; }
.meter span { position: absolute; inset: 0 auto 0 0; width: calc(var(--level, 0) * 100%); background: var(--muted); transition: width 80ms linear; }
.meter[data-signal="true"] span { background: var(--ok); }

/* ---------- Crew-Panel ---------- */
.panel { width: min(100% - 24px, 1400px); margin: 0 auto; padding: 16px 0 120px; }
.start { display: grid; place-items: center; min-height: calc(100dvh - 56px); padding: 24px 16px; }
.start .card { width: min(100%, 440px); text-align: center; }
.start h1 { font-size: 1.5rem; }
.start .who { margin-top: 6px; font-size: 1.05rem; color: var(--text); }
.start .btn.big { width: 100%; margin-top: 20px; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.key {
  --ch: var(--brand);
  position: relative; display: flex; flex-direction: column; min-height: 210px; padding: 12px 12px 12px 16px;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden;
}
.key::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--ch); }
.key header { display: flex; align-items: baseline; gap: 8px; }
.key .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 1rem; letter-spacing: .02em; text-transform: uppercase; }
.key .hotkey { font-family: var(--mono); font-size: .75rem; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 5px; }
.key .speakers { min-height: 20px; margin-top: 4px; font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key .speakers b { color: var(--text); font-weight: 600; }
.key[data-active="true"] { border-color: var(--ch); }
.key[data-active="true"] .speakers { color: var(--text); }
.key[data-calling="true"] { animation: call .4s steps(1) 8; }
@keyframes call { 50% { background: var(--ch); } }
.talk {
  flex: 1; display: grid; place-items: center; min-height: 92px; margin-top: 10px;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--control);
  color: var(--text-2); font: 700 1rem/1 inherit; letter-spacing: .12em; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background-color 80ms ease, border-color 80ms ease;
}
.talk:hover { border-color: var(--text-2); }
.talk small { display: block; margin-top: 6px; font-size: .6875rem; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.talk[data-on="true"] { background: var(--talk); border-color: var(--talk); color: #fff; box-shadow: 0 0 24px var(--talk-glow); }
.talk[data-on="true"] small { color: rgba(255,255,255,.85); }
.talk:disabled { cursor: default; opacity: .4; }
.talk.listen-only { cursor: default; border-style: dashed; letter-spacing: .06em; font-size: .8125rem; }
.listen { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin-top: 10px; }
.listen button {
  min-width: 52px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--control); color: var(--ok); font: 600 .75rem/1 var(--mono); cursor: pointer;
}
.listen button[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.listen .meter { grid-column: 1 / -1; height: 4px; }
.key .actions { display: flex; gap: 6px; margin-top: 8px; }
.key .actions .btn { flex: 1; }
.dock {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 10px 20px; border-top: 1px solid var(--border); background: rgba(23, 24, 28, .97);
}
.dock .field { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: .8125rem; }
.dock select { width: 220px; min-height: 32px; padding: 4px 8px; }
.dock .meter { width: 90px; }
.dock input[type="range"] { width: 110px; }
.dock label { margin: 0; }
.dock .btn { margin-left: auto; }

/* ---------- Talent ---------- */
.talent { display: grid; place-items: center; min-height: calc(100dvh - 56px); padding: 24px 16px; }
.talent .card { width: min(100%, 420px); text-align: center; }
.talent .channels { display: grid; gap: 8px; margin-top: 18px; text-align: left; }
.talent .ch { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--control); }
.talent .ch i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--brand)); }
.talent .ch[data-active="true"] { border-color: var(--c, var(--brand)); }
.talent .ch span { flex: 1; font-weight: 600; }
.talent .ch small { color: var(--text-2); }
.talent input[type="range"] { width: 100%; margin-top: 16px; }

/* ---------- Admin ---------- */
.admin { width: min(100% - 32px, 1320px); }
.grid-2 { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list a { color: var(--text); font-weight: 600; text-decoration: none; }
.list a:hover { color: var(--brand); }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: 0 0 auto; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input[type="text"], .inline-form input:not([type]) { flex: 1; }
.matrix-wrap { overflow-x: auto; }
table.matrix { width: 100%; border-collapse: collapse; font-size: .875rem; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.matrix thead th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; vertical-align: bottom; }
.matrix thead th .swatch { display: inline-block; margin-right: 6px; vertical-align: -1px; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .member { display: flex; align-items: center; gap: 8px; min-width: 200px; }
.matrix .member small { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: 0 0 auto; }
.dot[data-online="true"] { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.tl { display: inline-flex; gap: 4px; }
.tl button {
  width: 30px; height: 26px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--control);
  color: var(--muted); font: 700 .75rem/1 var(--mono); cursor: pointer;
}
.tl button:hover { border-color: var(--border-strong); color: var(--text-2); }
.tl button[aria-pressed="true"][data-kind="talk"] { background: rgba(240, 125, 0, .18); border-color: var(--brand); color: var(--brand); }
.tl button[aria-pressed="true"][data-kind="listen"] { background: rgba(62, 207, 110, .14); border-color: var(--ok); color: var(--ok); }
.tl button:disabled { opacity: .25; cursor: not-allowed; }
.matrix td[data-talking="true"] .tl button[data-kind="talk"] { background: var(--talk); border-color: var(--talk); color: #fff; }
.tag { display: inline-block; padding: 1px 6px; border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text-2); font: .6875rem/1.5 var(--mono); text-transform: uppercase; }
.menu-actions { display: flex; gap: 4px; justify-content: flex-end; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .dock select { width: 160px; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 12px; gap: 10px; }
  .topbar .logo { width: 96px; }
  .keys { grid-template-columns: 1fr 1fr; gap: 8px; }
  .key { min-height: 180px; padding: 10px 10px 10px 13px; }
  .talk { min-height: 80px; }
  .dock { gap: 8px 12px; padding: 8px 12px; }
  .dock .field.optional { display: none; }
  .dock .btn { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
