/* Kontrafunk Corporate Design: Dunkelblau #2B394B, Orange #F59C00, Hellgrau #E6E6E6, Schrift Oxygen. */

@font-face {
  font-family: "Oxygen";
  src: url("../assets/fonts/Oxygen-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Oxygen";
  src: url("../assets/fonts/Oxygen-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --brand-blue: #2b394b;
  --brand-orange: #f59c00;
  --bg: #eeeeee;
  --card: #ffffff;
  --text: #2b394b;
  --muted: #5f6d80;
  --line: #d9dde2;
  --accent: #f59c00;
  --accent-text: #2b394b;
  --rec: #e30613;
  --ok: #6f8a0e;
  --warn: #b86e00;
  --error: #c4050f;
  --meter-bg: #e3e5e8;
  --meter-ok: #97b514;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2734;
    --card: #2b394b;
    --text: #ffffff;
    --muted: #b4bfcd;
    --line: #3e4e64;
    --meter-bg: #1d2734;
    --ok: #a9c82a;
    --warn: #f5b13d;
    --error: #ff6b63;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Oxygen", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.brandbar {
  background: var(--brand-blue);
  color: #ffffff;
  border-bottom: 4px solid var(--brand-orange);
}
.brandbar .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 16px;
}
.brandbar .logo { height: 38px; width: auto; display: block; }

.brandfoot { text-align: center; padding: 8px 16px 40px; }
.brandfoot img { width: min(300px, 100%); height: auto; opacity: .9; }
.brandbar .role { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: #ffffff; opacity: .85; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

main.wide { max-width: 1180px; }

/* Produzent: links Aufnahme + Teilnehmer, rechts Aufnahmeliste, Gast-Link, eigene Geräte. */
.studio { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
@media (min-width: 960px) {
  .studio { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
}
.rec-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rec-row #rec-btn { width: auto; flex: 1 1 260px; }
.rec-row .rec-time { margin: 0; font-size: 20px; }
.rec-row .mic-btn { width: auto; flex: 0 0 auto; }
#muted-banner, #hold-banner { margin: 12px 0 0; }

/* Hinweis für Gäste während der Warteschleife */
@keyframes cf-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }
.card.hold-notice { border-color: var(--brand-orange); border-width: 2px; text-align: center; }
.card.hold-notice strong { display: block; font-size: 18px; animation: cf-breathe 3s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .card.hold-notice strong { animation: none; } }

/* Einspieler */
.holdrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.holdrow .holdinfo { flex: 1; min-width: 120px; }
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.dropzone.over, .dropzone:hover { border-color: var(--brand-orange); color: var(--text); }
ul.clips { list-style: none; padding: 0; margin: 10px 0; }
ul.clips li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
ul.clips li:first-child { border-top: 0; }
ul.clips .clip-main { flex: 1; min-width: 0; }
ul.clips .clip-name { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
canvas.wave {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 4px;
  cursor: pointer;
  border-radius: 4px;
  background: var(--meter-bg);
  --wave-played: var(--brand-orange);
  --wave-rest: var(--muted);
  --wave-cursor: var(--text);
}
ul.clips .clip-progress { height: 3px; background: var(--meter-bg); border-radius: 2px; margin-top: 4px; overflow: hidden; }
ul.clips .clip-progress .bar { height: 100%; width: 0; background: var(--brand-orange); }
ul.clips li.playing .play { background: var(--brand-orange); border-color: var(--brand-orange); color: var(--brand-blue); }
ul.clips .tag { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* Stummgeschaltet: ruhiges, gut sichtbares Pulsieren. */
@keyframes cf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 6, 19, .55); }
  50% { box-shadow: 0 0 0 7px rgba(227, 6, 19, 0); }
}
.pulse {
  background: var(--rec) !important;
  border-color: var(--rec) !important;
  color: #ffffff !important;
  animation: cf-pulse 1.8s ease-in-out infinite;
}
/* Gast stummgeschaltet: Fensterrand pulsiert rot. */
@keyframes cf-edge {
  0%, 100% { box-shadow: inset 0 0 0 4px rgba(227, 6, 19, .9); }
  50% { box-shadow: inset 0 0 0 4px rgba(227, 6, 19, .3), inset 0 0 36px rgba(227, 6, 19, .35); }
}
body.is-muted::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  animation: cf-edge 1.8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  body.is-muted::after { animation: none; box-shadow: inset 0 0 0 4px var(--rec); }
}
/* stumm / Warteschleife: siehe unten (überschreibt "verbunden") */
li.peer.held .meter { opacity: .3; }
.held-tag:not(:empty) { font-size: 12px; font-weight: 700; color: var(--brand-blue); background: var(--brand-orange); border-radius: 10px; padding: 1px 8px; margin-left: 8px; }
.hold-section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.hold-section .holdrow { margin-bottom: 8px; }
.vol-label { min-width: 84px; }
.muted-banner { font-weight: 700; color: var(--rec); margin: 0 0 12px; }

/* Löschen: 1 Sekunde gedrückt halten. */
.hold {
  position: relative;
  overflow: hidden;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}
.hold::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--rec);
  transform: scaleX(0);
  transform-origin: left;
  opacity: .85;
}
.hold.holding::before { transform: scaleX(1); transition: transform 1s linear; }
.hold span { position: relative; }
.hold.holding { color: #ffffff; }

details.take { border-top: 1px solid var(--line); padding: 10px 0; }
details.take:first-child { border-top: 0; }
details.take summary { list-style: none; display: flex; align-items: center; gap: 10px; }
details.take summary::-webkit-details-marker { display: none; }
details.take summary::before { content: "▸"; color: var(--muted); width: 12px; }
details.take[open] summary::before { content: "▾"; }
details.take summary .title { flex: 1; }
details.take[open] summary { margin-bottom: 8px; }

.devsel { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin-top: 10px; font-size: 14px; }
.devsel select { padding: 6px 8px; font-size: 14px; }

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}


h1 { font-size: 24px; margin: 0; }
a.back { color: var(--muted); font-size: 14px; text-decoration: none; }
a.back:hover { color: var(--text); }
h2 { font-size: 17px; margin: 0 0 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin: 0 0 14px; }
label > input, label > select { margin-top: 6px; }

input[type=text], select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

button {
  font: inherit;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

a.button {
  display: block;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid var(--line);
}

button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }

button.primary, a.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.big { width: 100%; padding: 14px; font-size: 18px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.msg { margin: 12px 0 0; }
.msg.error { color: var(--error); }
.msg.warn { color: var(--warn); }

.meter {
  height: 10px;
  border-radius: 5px;
  background: var(--meter-bg);
  overflow: hidden;
  margin: -6px 0 16px;
}
.meter .bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--meter-ok) 0 70%, var(--brand-orange) 70% 90%, var(--rec) 90%);
  background-size: 100vw 100%;
  transition: width 60ms linear;
}
.meter.clip { outline: 2px solid var(--error); }

.devices > button { margin-bottom: 14px; }
.audio-setup .start button { margin-bottom: 14px; }

/* Gast: großer, gut treffbarer Stumm-Knopf (v. a. auf dem Handy) */
#mute { width: 100%; padding: 14px; font-size: 18px; font-weight: 600; }
.ios-hint { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--bg); font-size: 14px; }

.question .label { font-weight: 600; margin-bottom: 6px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; min-width: 72px; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--accent); color: var(--accent-text); }

.linkbox { margin-bottom: 16px; }
.linkbox .label { font-weight: 600; margin-bottom: 6px; }
.linkbox .share { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.linkbox .share .button, .linkbox .share button { font-size: 0.9em; padding: 6px 12px; }

.status { font-weight: 600; }
.status.ok::before, .status.wait::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--ok);
}
.status.wait::before { background: var(--warn); }

ul.peers { list-style: none; padding: 0; margin: 0; }
ul.peers li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
ul.peers li:first-child { border-top: 0; }
.tag { color: var(--muted); font-size: 14px; }

/* Teilnehmer-Zeile: neutral beim Verbinden, dezent grün wenn verbunden, orange bei Störung. */
ul.peers li.peer {
  display: block;
  padding: 12px 12px 12px 14px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 4px 0 0 var(--line);
  transition: background-color .4s ease, box-shadow .4s ease, border-color .4s ease;
}
ul.peers li.peer:first-child { border-top: 1px solid var(--line); }
ul.peers li.peer.connected {
  background: color-mix(in srgb, var(--meter-ok) 9%, transparent);
  border-color: color-mix(in srgb, var(--meter-ok) 35%, var(--line));
  box-shadow: inset 4px 0 0 var(--meter-ok);
}
ul.peers li.peer.reconnecting {
  background: color-mix(in srgb, var(--brand-orange) 9%, transparent);
  box-shadow: inset 4px 0 0 var(--brand-orange);
}
ul.peers li.peer .peer-head .name::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--line);
  vertical-align: 1px;
}
ul.peers li.peer.connected .peer-head .name::before { background: var(--meter-ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--meter-ok) 25%, transparent); }
ul.peers li.peer.reconnecting .peer-head .name::before { background: var(--brand-orange); }
.peer-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.peer-head .name { font-weight: 600; flex: 1; }
.peer-head .line { font-size: 13px; padding: 1px 8px; border-radius: 10px; border: 1px solid currentColor; }
.peer-head .line.good { color: var(--ok); }
.peer-head .line.fair { color: var(--warn); }
.peer-head .line.poor { color: var(--rec); }
li.peer .meter { margin: 0 0 8px; opacity: .45; }
li.peer.connected .meter { opacity: 1; }
li.peer.connected .peer-head .tag { color: var(--ok); }
.volume { display: flex; align-items: center; gap: 12px; }
.volume input[type=range] { flex: 1; accent-color: var(--accent); }
.volume .percent { min-width: 48px; text-align: right; }
#unlock { margin-bottom: 12px; }

#rec-btn.recording { background: var(--rec); border-color: var(--rec); color: #ffffff; }
.rec-time { font-weight: 600; color: var(--rec); margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.rec-status { font-weight: 600; margin: 0 0 12px; }
.rec-status.live { color: var(--rec); }
.take { margin-top: 18px; }
.take-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
ul.files { list-style: none; padding: 0; margin: 0; }
ul.files li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
ul.files li.complete .tag { color: var(--ok); }

/* Live-Mitschnitt: eigener, zurückgenommener Block */
ul.files li.live-divider {
  display: block;
  margin-top: 10px;
  padding: 8px 10px;
  border-top: 2px dashed var(--line);
  background: var(--bg);
  border-radius: 6px 6px 0 0;
}
ul.files li.live-divider strong { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
ul.files li.live-divider .tag { font-size: 12px; }
ul.files li.live-track { background: var(--bg); padding-left: 10px; padding-right: 10px; border-top-color: transparent; opacity: .85; }
ul.files li.live-track > span:first-child::before { content: "◉ "; color: var(--muted); }

/* Pufferbalken je Teilnehmer: hell = beim Produzenten, kräftig = auf dem Server. */
.buffer {
  grid-column: 1 / -1;
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: var(--meter-bg);
  overflow: hidden;
  margin-top: -4px;
}
.buffer .have, .buffer .up {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  transition: width .8s ease;
}
.buffer .have { background: var(--meter-ok); opacity: .35; }
.buffer .up { background: var(--meter-ok); }
ul.files .tag { font-variant-numeric: tabular-nums; }
label.format { margin: 18px 0 0; font-weight: 400; color: var(--muted); font-size: 14px; }
label.format select { max-width: 260px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.controls .group { min-width: 96px; }
.controls .expand { margin-left: auto; color: var(--muted); }
.more { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 2px; }
button.small { padding: 5px 10px; font-size: 13px; }
button.small.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

@media (max-width: 520px) {
  ul.files li { grid-template-columns: 1fr auto; }
  ul.files li .tag { grid-column: 1; }
}

ul.sessions { list-style: none; padding: 0; margin: 0; }
ul.sessions li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
ul.sessions li:first-child { border-top: 0; }
ul.sessions a { color: var(--text); font-weight: 700; }
ul.sessions li { flex-wrap: wrap; }
ul.sessions .actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
a.button.small { display: inline-block; padding: 5px 12px; font-size: 13px; }
select.small-select { width: auto; display: inline-block; padding: 5px 8px; font-size: 13px; }

details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 14px; }

/* Einklappbare Bereiche (Karten) */
details.section > summary { list-style: none; display: flex; align-items: center; gap: 8px; font-size: 17px; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
details.section:not([open]) > summary::after { transform: rotate(-90deg); }
details.section:not([open]) > summary { margin-bottom: 0; }

[hidden] { display: none !important; }

/* Stumm und Warteschleife haben Vorrang vor "verbunden" */
ul.peers li.peer.muted { box-shadow: inset 4px 0 0 var(--rec); }
ul.peers li.peer.held { box-shadow: inset 4px 0 0 var(--brand-orange); background: color-mix(in srgb, var(--brand-orange) 7%, transparent); }

/* Telefon-Gäste */
.phone-form .row { display: flex; flex-wrap: wrap; gap: 8px; }
.phone-form .row input { flex: 1 1 160px; min-width: 0; }
.phone-lines { list-style: none; padding: 0; margin: 12px 0 0; }
.phone-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 12px; border: 1px solid var(--line, #ccd); border-radius: 8px; margin-bottom: 8px; }
.phone-line .who { flex: 1 1 180px; }
.phone-line.connected { border-color: #2e9d57; box-shadow: inset 4px 0 0 #2e9d57; }
.phone-line.ringing .state, .phone-line.calling .state { animation: cf-breathe 1.2s ease-in-out infinite; }
.phone-line.ended { opacity: .6; }
.phone-line .vol { display: flex; align-items: center; gap: 6px; font-size: .9em; }
