/* MEINCODE Zentrale — Leitstand. Konsolen-Optik: dunkle Housing, Monospace-Labels,
   glühende Status-Lampen als Signatur. Hell/Dunkel ueber prefers-color-scheme + data-theme. */

:root {
  --bg: #0a1017;
  --panel: #0e1823;
  --panel-2: #142230;
  --raise: #17293a;
  --line: #21323f;
  --line-soft: #182634;
  --text: #e8eef4;
  --muted: #8598aa;
  --faint: #566878;
  --accent: #46a4ff;
  --accent-ink: #051320;
  --work: #ffb43d;   /* Lampe: arbeitet */
  --ready: #33d6a6;  /* Lampe: bereit/fertig */
  --err: #ff6060;
  --r: 12px;
  --r-sm: 8px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", "Segoe UI Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar: 52px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #e9edf2; --panel: #ffffff; --panel-2: #f3f6f9; --raise: #eef2f6;
    --line: #d3dbe4; --line-soft: #e3e9ef; --text: #15212d; --muted: #5a6b7b; --faint: #8496a6;
    --accent: #0a6ee0; --accent-ink: #ffffff; --work: #c47d00; --ready: #12a37a; --err: #d64545;
  }
}
:root[data-theme="light"] {
  --bg: #e9edf2; --panel: #ffffff; --panel-2: #f3f6f9; --raise: #eef2f6;
  --line: #d3dbe4; --line-soft: #e3e9ef; --text: #15212d; --muted: #5a6b7b; --faint: #8496a6;
  --accent: #0a6ee0; --accent-ink: #ffffff; --work: #c47d00; --ready: #12a37a; --err: #d64545;
}
:root[data-theme="dark"] {
  --bg: #0a1017; --panel: #0e1823; --panel-2: #142230; --raise: #17293a;
  --line: #21323f; --line-soft: #182634; --text: #e8eef4; --muted: #8598aa; --faint: #566878;
  --accent: #46a4ff; --accent-ink: #051320; --work: #ffb43d; --ready: #33d6a6; --err: #ff6060;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--sans);
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.view { min-height: 100dvh; display: flex; flex-direction: column; }
button { font-family: inherit; }

/* ---------- Status-Lampe (Signatur) ---------- */
.lamp {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  background: var(--faint);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
  transition: background .25s, box-shadow .25s;
}
.lamp-idle { background: var(--faint); }
.lamp-work {
  background: var(--work);
  box-shadow: 0 0 0 1px rgba(255,180,61,.35), 0 0 10px 1px rgba(255,180,61,.55);
  animation: breathe 1.8s ease-in-out infinite;
}
.lamp-done {
  background: var(--ready);
  box-shadow: 0 0 0 1px rgba(51,214,166,.4), 0 0 10px 1px rgba(51,214,166,.5);
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,180,61,.30), 0 0 6px 1px rgba(255,180,61,.35); }
  50%      { box-shadow: 0 0 0 1px rgba(255,180,61,.45), 0 0 13px 3px rgba(255,180,61,.65); }
}

/* ---------- Login ---------- */
#view-login { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 40px 30px 34px; width: 100%; max-width: 380px; text-align: center;
}
.login-lamp { display: inline-block; width: 14px; height: 14px; margin-bottom: 18px; }
.login-title { font: 700 1.4rem/1 var(--mono); letter-spacing: .12em; margin: 0; }
.login-title span { color: var(--accent); margin-left: .1em; }
.login-lead { color: var(--muted); margin: 10px 0 22px; }
#login-slot { min-height: 48px; display: flex; justify-content: center; align-items: center; }
.dev-login {
  background: var(--accent); color: var(--accent-ink); border: 0; cursor: pointer;
  padding: 12px 22px; border-radius: var(--r-sm); font: 700 .95rem var(--sans);
}
.login-hint { color: var(--faint); font-size: .8rem; margin-top: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar); flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-lamp { width: 9px; height: 9px; }
.brand-word { font: 700 .82rem var(--mono); letter-spacing: .22em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.global-status {
  font: 600 .68rem var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 20px;
}
.global-status.busy { color: var(--work); border-color: rgba(255,180,61,.4); }
.icon-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  width: 34px; height: 34px; border-radius: var(--r-sm); cursor: pointer; font-size: 1rem;
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { background: var(--line); }

/* ---------- Konsole: zwei Spalten ---------- */
.console { flex: 1; display: flex; min-height: 0; }
.board {
  width: 304px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line); min-height: 0;
}
.board-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; font: 600 .68rem var(--mono); letter-spacing: .2em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-soft);
}
.board-count { color: var(--work); }
.station-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.station {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 11px 12px; color: var(--text);
}
.station:hover { background: var(--panel-2); }
.station.active { background: var(--panel-2); border-color: var(--line); }
.station.active::before {
  content: ""; position: absolute; left: 0; width: 3px; height: 26px; border-radius: 2px;
  background: var(--accent); margin-left: -12px;
}
.station { position: relative; }
.station-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.station-name { font: 600 .92rem var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-sub {
  font: .74rem/1.2 var(--mono); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.station.working .station-sub { color: var(--work); }
.station-meta { font: .66rem var(--mono); color: var(--faint); flex-shrink: 0; }

/* ---------- Buehne ---------- */
.stage { flex: 1; display: flex; min-height: 0; min-width: 0; background: var(--bg); }
.stage-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--faint);
}
.stage-empty .lamp { width: 16px; height: 16px; }

.conv { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.conv-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.conv-title { font: 600 .98rem var(--sans); }
.conv-sub {
  margin-left: auto; font: .68rem var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.conv-sub.working { color: var(--work); }

.messages { flex: 1; overflow-y: auto; padding: 20px 18px 10px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 76%; padding: 11px 14px; border-radius: 13px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.wb { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.wb.err { border-color: rgba(255,96,96,.5); }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: .8rem; padding: 2px; }
.msg .meta { display: block; font: .64rem var(--mono); opacity: .6; margin-top: 5px; }
.typing {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px;
  color: var(--work); font: .8rem var(--mono); padding: 4px 2px;
}

/* Download- + Upload-Chips */
.dl-wrap, .up-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dl-link {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-width: 100%;
  overflow-wrap: anywhere; text-decoration: none; font: 600 .82rem var(--mono);
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--r-sm); padding: 7px 11px;
}
.dl-link:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.up-chip { font: .72rem var(--mono); background: rgba(127,127,127,.16); border-radius: 6px; padding: 3px 8px; overflow-wrap: anywhere; }

/* ---------- Composer ---------- */
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 7px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 6px 4px 12px; font: .78rem var(--mono); max-width: 100%;
}
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.attach-x { background: var(--line); color: var(--text); border: 0; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 1; flex-shrink: 0; }
.attach-x:hover { background: var(--err); color: #fff; }
.composer { display: flex; gap: 9px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.attach-btn { font-size: 1.4rem; font-weight: 300; }
#input {
  flex: 1; resize: none; max-height: 160px; font: inherit;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 13px;
}
#input:focus { outline: none; border-color: var(--accent); }
.send-btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--r-sm); width: 46px; font-size: 1.2rem; cursor: pointer; flex-shrink: 0; }
.send-btn:disabled { opacity: .45; cursor: default; }

.drop-hint {
  position: absolute; inset: 10px; z-index: 4; pointer-events: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 2px dashed var(--accent); border-radius: var(--r); color: var(--accent);
  font: 600 .95rem var(--mono); letter-spacing: .05em;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--raise); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: var(--r-sm); font-size: .9rem; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

.only-narrow { display: none; }

/* ---------- Schmal (Handy): eine Spalte ---------- */
@media (max-width: 820px) {
  .board { width: 100%; border-right: 0; }
  .stage { display: none; }
  .console.in-conv .board { display: none; }
  .console.in-conv .stage { display: flex; }
  .only-narrow { display: grid; }
  .msg { max-width: 86%; }
}

/* ---------- Fokus + Reduced Motion ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .lamp-work { animation: none; }
  * { transition: none !important; }
}
