/* Podcast-Studio — Aufnahme-Editor (Doppelender), Referenz-Look
   Selbst-enthaltend: System-Fonts, Inline-SVG, keine externen Assets. */

:root {
  --bg:        #070a0d;
  --shell:     #0e1319;
  --panel:     #121821;
  --panel-2:   #17202a;
  --raise:     #1f2a35;
  --rail:      #0f151c;
  --stage:     #0a0f14;
  --line:      #232e3a;
  --line-soft: #1a232d;

  --ink:       #eef3f8;
  --ink-dim:   #aeb9c6;
  --muted:     #75828f;
  --faint:     #4b5662;

  --amber:     #f2b02c;   /* Spur „Du" */
  --amber-ink: #1a1204;
  --teal:      #35d6c4;   /* Spur „Gegenüber" */
  --green:     #34d17a;   /* Export / ok */
  --rec:       #ff4038;
  --rec-glow:  rgba(255,64,56,0.5);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  --dl-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"/><path d="M7 11l5 5 5-5"/><path d="M4 20h16"/></svg>');
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(820px 460px at 4% -6%, rgba(53,214,196,0.14), transparent 58%),
    radial-gradient(760px 520px at 106% 108%, rgba(53,214,196,0.10), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.5vh, 26px);
  min-height: 100%;
}

#app {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
[hidden] { display: none !important; }

/* ---------- Login ---------- */
#login {
  align-self: center;
  width: 100%; max-width: 460px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0) 120px), var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(22px, 4vw, 32px);
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 30px 70px -40px rgba(0,0,0,0.9);
}
.brand-lg { display: flex; align-items: center; gap: 13px; margin-bottom: 4px; }
.brand-lg .mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); }
.brand-lg .mark svg { width: 21px; height: 21px; }
.brand-lg .word { display: flex; flex-direction: column; line-height: 1.05; font-weight: 680; font-size: 20px; letter-spacing: -0.02em; }
.brand-lg .sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 3px; font-weight: 500; }
.login-intro { margin: 0 0 4px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.login-intro b { color: var(--ink-dim); font-weight: 600; }
.field-label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
#password { width: 100%; font-family: var(--mono); font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 15px; transition: border-color .15s, box-shadow .15s; }
#password::placeholder { color: var(--faint); }
#password:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(242,176,44,0.16); }
#create { appearance: none; cursor: pointer; font: inherit; font-weight: 640; font-size: 15px; color: var(--amber-ink);
  background: linear-gradient(180deg, #ffc247, var(--amber)); border: none; border-radius: 10px; padding: 14px 18px;
  box-shadow: 0 8px 20px -8px rgba(242,176,44,0.6), inset 0 1px 0 rgba(255,255,255,0.35); transition: transform .08s, filter .15s; }
#create:hover { filter: brightness(1.05); }
#create:active { transform: translateY(1px); }
#create:focus-visible { outline: 2px solid #ffd77a; outline-offset: 2px; }

/* ---------- Editor-Shell ---------- */
#studio {
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 214px 1fr 268px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar topbar topbar"
    "rail   stage  invite"
    "transport transport transport";
  height: min(74vh, 720px);
  min-height: 480px;
  box-shadow: 0 40px 90px -50px rgba(0,0,0,0.9);
}

/* Top-Bar */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar .mark { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); }
.topbar .mark svg { width: 17px; height: 17px; }
.proj { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.proj-name { font-size: 14px; font-weight: 620; letter-spacing: -0.01em; }
.proj-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-top: 2px; }
.topbar-spacer { flex: 1; }
.session-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  background: var(--bg); border: 1px solid var(--line); border-radius: 100px; padding: 6px 12px;
}
.session-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.session-pill[data-live="1"] { color: var(--ink); }
.session-pill[data-live="1"] .dot { background: var(--green); box-shadow: 0 0 7px -1px var(--green); }
.btn-ghost {
  appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 560;
  color: var(--ink-dim); background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: #34404d; color: var(--ink); }
/* Export = Downloads-Trigger; leer → disabled Look */
.btn-export {
  display: inline-flex; align-items: center; gap: 8px;
  appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 620;
  color: #06301b; background: linear-gradient(180deg, #4be08a, var(--green)); border: none; border-radius: 9px; padding: 9px 15px;
  box-shadow: 0 6px 16px -8px rgba(52,209,122,0.6); transition: filter .15s, opacity .15s;
}
.btn-export svg { width: 15px; height: 15px; }
.btn-export:hover { filter: brightness(1.05); }
.btn-export[aria-disabled="true"] { background: var(--raise); color: var(--faint); box-shadow: none; cursor: default; }

/* Linke Spur-Leiste */
.rail {
  grid-area: rail;
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.rail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.add-track {
  appearance: none; font: inherit; font-size: 11px; color: var(--faint);
  background: transparent; border: 1px dashed var(--line); border-radius: 7px; padding: 4px 8px;
  cursor: not-allowed;
}
.rail-track {
  padding: 12px 13px; border-bottom: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 9px;
}
.rt-head { display: flex; align-items: center; gap: 9px; }
.rt-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.rail-track[data-who="local"]  .rt-dot { background: var(--amber); }
.rail-track[data-who="remote"] .rt-dot { background: var(--teal); }
.rt-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; }
.rt-state { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  display: inline-flex; align-items: center; gap: 4px; }
.rt-state::before { content:""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.rail-track[data-who="local"]  .rt-state[data-live="1"]::before { background: var(--amber); box-shadow: 0 0 6px -1px var(--amber); }
.rail-track[data-who="remote"] .rt-state[data-live="1"]::before { background: var(--teal); box-shadow: 0 0 6px -1px var(--teal); }
.rt-state[data-live="1"] { color: var(--ink-dim); }
.rt-controls { display: flex; align-items: center; gap: 8px; }
.rt-mute {
  appearance: none; cursor: pointer; font: inherit; font-size: 10px; font-weight: 600;
  width: 26px; height: 24px; flex: none;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.rt-mute:hover { color: var(--ink); border-color: #34404d; }
.rt-mute[data-on="1"] { color: var(--rec); border-color: rgba(255,64,56,0.5); background: rgba(255,64,56,0.08); }
/* Range-Slider (Anzeige/Lautstärke) */
.rt-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 3px;
  background: var(--raise); outline: none; cursor: pointer; }
.rt-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--ink); border: 2px solid var(--rail); box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.rt-slider::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--ink); border: 2px solid var(--rail); }

/* Zentrale Timeline */
.stage { grid-area: stage; background: var(--stage); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.ruler {
  height: 30px; flex: none; position: relative;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: flex-end;
  background:
    repeating-linear-gradient(90deg, transparent 0 63px, rgba(255,255,255,0.05) 63px 64px);
  padding: 0 0 5px 0;
}
.ruler span {
  position: absolute; bottom: 5px; font-family: var(--mono); font-size: 9px; color: var(--faint);
  transform: translateX(6px);
}
.lanes { flex: 1; position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: repeating-linear-gradient(90deg, transparent 0 63px, rgba(255,255,255,0.03) 63px 64px); }
.lane-row {
  flex: none; height: 92px; position: relative; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; padding: 6px 0;
}
.lane-tag {
  position: absolute; top: 8px; left: 10px; z-index: 2;
  font-size: 10.5px; font-weight: 600; color: #0a0f14;
  padding: 3px 9px; border-radius: 6px;
}
.lane-row[data-who="local"]  .lane-tag { background: var(--amber); }
.lane-row[data-who="remote"] .lane-tag { background: var(--teal); }
.lane-row canvas { display: block; width: 100%; height: 100%; }
/* Schreibkopf (Playhead) am rechten Rand des Live-Fensters */
.playhead { position: absolute; top: 0; bottom: 0; right: 16%; width: 1.5px; background: rgba(255,255,255,0.55); z-index: 3; pointer-events: none; }
.playhead::before { content:""; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top-color: rgba(255,255,255,0.8); border-bottom: 0; }

/* Rechtes Panel */
.invite { grid-area: invite; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto; }
.invite-inner { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.card-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--teal);
}
.card-head svg { width: 15px; height: 15px; }
.invite-hint { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
#guest-link { margin: 0; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 9px; padding: 9px 9px 9px 11px; min-height: 44px; }
#guest-link:empty { display: none; }
#guest-link a { flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#guest-link a:hover { color: var(--teal); }
.copy-btn { flex: none; cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; color: var(--ink);
  background: var(--raise); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; display: inline-flex; align-items: center; gap: 5px; transition: border-color .15s, color .15s; }
.copy-btn:hover { border-color: var(--teal); color: var(--teal); }
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

.people { display: flex; flex-direction: column; gap: 8px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line-soft); }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #0a0f14; }
.person-name { font-size: 12.5px; font-weight: 560; flex: 1; }
.person-state { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em; color: var(--faint); display: inline-flex; align-items: center; gap: 5px; }
.person-state::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.person-state[data-on="1"] { color: var(--green); }
.person-state[data-on="1"]::before { background: var(--green); box-shadow: 0 0 6px -1px var(--green); }

.results-head { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green); }
#downloads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
#downloads:empty { display: none; }
#downloads:empty + .results-empty { display: block; }
.results-empty { display: none; font-size: 11.5px; color: var(--faint); }
#downloads li { display: flex; }
#downloads a { flex: 1; display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 12px; color: var(--ink);
  text-decoration: none; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; transition: border-color .15s, background .15s; }
#downloads a::before { content:""; width: 15px; height: 15px; flex: none; background: var(--green);
  -webkit-mask: var(--dl-icon) center / contain no-repeat; mask: var(--dl-icon) center / contain no-repeat; }
#downloads a:hover { border-color: var(--green); background: var(--raise); }

/* Transport-Leiste */
.transport {
  grid-area: transport;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px;
  padding: 11px 18px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.tp-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.timecode { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 25px; font-weight: 600; letter-spacing: 0.01em; color: var(--muted); transition: color .2s; }
.timecode.live { color: var(--rec); }
.tp-center { display: flex; align-items: center; justify-content: center; gap: 10px; }
#rec { appearance: none; cursor: pointer; font: inherit; font-weight: 640; font-size: 14px; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 100px; padding: 12px 24px;
  display: inline-flex; align-items: center; gap: 10px;
  transition: transform .08s, border-color .15s, background .15s, box-shadow .2s, color .15s; }
#rec::before { content:""; width: 12px; height: 12px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 9px -1px var(--rec-glow); flex: none; }
#rec:hover { border-color: #34404d; background: var(--raise); }
#rec:active { transform: translateY(1px); }
#rec:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
#rec.recording { color: #fff; background: linear-gradient(180deg, #3a1615, #2a100f); border-color: rgba(255,64,56,0.55);
  box-shadow: 0 0 0 1px rgba(255,64,56,0.25), 0 12px 30px -14px var(--rec-glow); }
#rec.recording::before { background: #fff; border-radius: 2px; box-shadow: 0 0 10px 1px var(--rec-glow); animation: rec-pulse 1.35s ease-in-out infinite; }
@keyframes rec-pulse { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:.45;transform:scale(0.8);} }
#rec:disabled { opacity: .55; cursor: progress; }
/* Monitor-Stummschalter im Transport (spiegelt Gegenüber-Mute) */
.tp-monitor { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.tp-icon-btn { appearance: none; cursor: pointer; width: 38px; height: 38px; display: grid; place-items: center;
  color: var(--ink-dim); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; transition: border-color .15s, color .15s; }
.tp-icon-btn:hover { border-color: #34404d; color: var(--ink); }
.tp-icon-btn svg { width: 18px; height: 18px; }
.tp-right { display: flex; align-items: center; justify-content: flex-end; }
#status { margin: 0; display: flex; align-items: center; gap: 9px; font-size: 12.5px; line-height: 1.35; color: var(--ink-dim); text-align: right; justify-content: flex-end; }
#status:empty { display: none; }
#status::before { content:""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(117,130,143,0.12); }
#status[data-tone="ok"] { color: var(--ink); }
#status[data-tone="ok"]::before { background: var(--green); box-shadow: 0 0 8px -1px var(--green); }
#status[data-tone="rec"]::before { background: var(--rec); box-shadow: 0 0 8px -1px var(--rec); animation: rec-pulse 1.35s ease-in-out infinite; }
#status[data-tone="warn"] { color: #f6d38a; }
#status[data-tone="warn"]::before { background: var(--amber); box-shadow: 0 0 8px -1px var(--amber); }
#status[data-tone="err"] { color: #ffb3ae; }
#status[data-tone="err"]::before { background: var(--rec); box-shadow: 0 0 8px -1px var(--rec); }

/* Gast: Einladung weg, ruhiger */
.guest-note { display: none; font-size: 12px; color: var(--muted); }
body[data-role="guest"] .studio-invite { display: none; }
body[data-role="guest"] .guest-note { display: block; }

/* ---------- Responsiv ---------- */
@media (max-width: 900px) {
  #studio {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "topbar" "stage" "rail" "invite" "transport";
    height: auto;
  }
  .rail { border-right: none; border-top: 1px solid var(--line); flex-direction: row; overflow-x: auto; }
  .rail-head { display: none; }
  .rail-track { border-bottom: none; border-right: 1px solid var(--line-soft); min-width: 190px; }
  .stage { min-height: 300px; }
  .invite { border-left: none; border-top: 1px solid var(--line); }
  .transport { grid-template-columns: 1fr; gap: 12px; }
  .tp-left, .tp-center, .tp-right { justify-content: space-between; }
  #rec { flex: 1; justify-content: center; }
  #status { justify-content: flex-start; text-align: left; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .btn-ghost { display: none; }
  .timecode { font-size: 21px; }
}
/* Fokus-Sichtbarkeit auf allen interaktiven Elementen (WCAG 2.4.7) */
.btn-ghost:focus-visible, .btn-export:focus-visible, .copy-btn:focus-visible,
.rt-mute:focus-visible, .tp-icon-btn:focus-visible, .add-track:focus-visible,
#guest-link a:focus-visible, #downloads a:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}
.rt-slider:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
