/* =========================================================
   LUNA – Kommandozentrale
   Reines CSS. Laptop zuerst, Handy unter 900 px (Container-Query auf #app).
   ========================================================= */

/* ---------- Schriften (lokal) ---------- */
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  --bg: #05070d;
  --bg-2: #080c16;
  --panel: rgba(10, 16, 28, 0.78);
  --panel-solid: #0a101c;
  --line: rgba(79, 227, 255, 0.16);
  --line-strong: rgba(79, 227, 255, 0.38);

  --text: #e8eef9;
  --text-2: #a9b6cc;     /* 9,6:1 auf --bg */
  --text-3: #7f8ca6;     /* 5,8:1 auf --bg */

  --cyan: #4fe3ff;
  --cyan-dim: rgba(79, 227, 255, 0.12);
  --violet: #b49bff;
  --violet-deep: #5b3df5;
  --violet-dim: rgba(180, 155, 255, 0.14);
  --green: #5dfdb0;
  --green-dim: rgba(93, 253, 176, 0.12);
  --amber: #ffc857;
  --amber-dim: rgba(255, 200, 87, 0.12);
  --red: #ff6b7a;
  --red-dim: rgba(255, 107, 122, 0.13);

  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r: 10px;
  --r-sm: 6px;
  --gap: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 45% at 50% 22%, rgba(91, 61, 245, 0.10), transparent 70%),
    linear-gradient(rgba(79, 227, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 227, 255, 0.035) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, video, canvas, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); }
a:hover { color: #9cf0ff; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.mono, time { font-family: var(--mono); }

/* ---------- Wortmarke ---------- */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.42em;
  color: var(--text);
}
.wordmark__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 10px var(--violet), 0 0 2px #fff inset;
  animation: breathe 3.2s ease-in-out infinite;
}

/* =========================================================
   LOGIN
   ========================================================= */
.login {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: inherit;
  background-color: var(--bg);
}
.login__box {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 36px 28px 28px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  backdrop-filter: blur(10px);
}
.login__box .orb { margin-bottom: 8px; }
.login__sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.field { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
}
.input,
#password {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: rgba(5, 7, 13, 0.8);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.2em;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
#password::placeholder { color: var(--text-3); letter-spacing: 0.1em; }
#password:focus-visible {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(79, 227, 255, 0.18);
}
.login__error {
  width: 100%;
  font-size: 13px;
  color: var(--red);
}
.login__error:empty { display: none; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: transparent;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: background .2s, border-color .2s, color .2s;
}
.btn:hover { background: var(--cyan-dim); border-color: var(--cyan); }
.btn--primary {
  width: 100%;
  border-color: var(--violet);
  background: linear-gradient(180deg, rgba(91, 61, 245, 0.55), rgba(91, 61, 245, 0.35));
  color: #fff;
}
.btn--primary:hover { background: rgba(91, 61, 245, 0.7); border-color: var(--violet); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  transition: color .2s, border-color .2s, background .2s;
}
.icon-btn:hover { color: var(--cyan); border-color: var(--line-strong); background: var(--cyan-dim); }
.icon-btn svg { width: 16px; height: 16px; }

/* Kleine Aktionsknöpfe (Meldungen, Agenten) */
.mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: rgba(79, 227, 255, 0.04);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s;
}
.mini:hover { background: var(--cyan-dim); border-color: var(--cyan); color: var(--text); }
.mini:disabled, .mini[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.mini--go { border-color: rgba(93, 253, 176, 0.55); color: var(--green); background: var(--green-dim); }
.mini--go:hover { background: rgba(93, 253, 176, 0.2); border-color: var(--green); color: #b8ffde; }
.mini--always { border-color: rgba(180, 155, 255, 0.55); color: var(--violet); background: var(--violet-dim); }
.mini--always:hover { background: rgba(180, 155, 255, 0.24); border-color: var(--violet); color: #ddd2ff; }
.mini--no { border-color: rgba(255, 107, 122, 0.45); color: var(--red); background: transparent; }
.mini--no:hover { background: var(--red-dim); border-color: var(--red); color: #ffb3bb; }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(5, 7, 13, 0.6);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  transition: color .2s, border-color .2s, background .2s;
}
.chip::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}
.chip:hover { color: var(--text); border-color: var(--cyan); background: var(--cyan-dim); }
.chip[aria-pressed="true"], .chip.active { color: var(--text); border-color: var(--violet); background: var(--violet-dim); }
.chip[aria-pressed="true"]::before, .chip.active::before { background: var(--violet); box-shadow: 0 0 6px var(--violet); }

.highlight { color: var(--cyan); font-family: var(--mono); font-weight: 500; }
.hint { font-size: 12px; color: var(--text-3); }
.empty {
  padding: 18px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* Fortschrittsbalken */
.bar {
  position: relative;
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(79, 227, 255, 0.12);
  overflow: hidden;
}
.bar__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(79, 227, 255, 0.7);
  transition: width .6s var(--ease), background .3s;
}
.bar__fill.warn { background: var(--amber); box-shadow: 0 0 8px rgba(255, 200, 87, 0.6); }
.bar__fill.full { background: var(--red); box-shadow: 0 0 8px rgba(255, 107, 122, 0.6); }

/* LEDs */
.led {
  flex: none;
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-3);
}
.led--aktiv    { background: var(--green); box-shadow: 0 0 8px var(--green); }
.led--laeuft   { background: var(--cyan);  box-shadow: 0 0 10px var(--cyan); animation: led-pulse 1.1s ease-in-out infinite; }
.led--pausiert { background: var(--amber); box-shadow: 0 0 6px rgba(255, 200, 87, 0.6); }
.led--fehler   { background: var(--red);   box-shadow: 0 0 10px var(--red); animation: led-blink 1.4s steps(2, end) infinite; }
.led--erledigt { background: transparent; border: 1.5px solid var(--green); }

/* =========================================================
   APP-RAHMEN
   ========================================================= */
#app {
  container: app / inline-size;
  min-height: 100dvh;
}
.app__inner {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 640px;
  padding: 14px 18px 0;
  gap: 14px;
}

/* ---------- Kopfleiste ---------- */
.top {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  backdrop-filter: blur(8px);
}
.top__brand { display: flex; align-items: center; gap: 22px; min-width: 0; }
.sys {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green);
  white-space: nowrap;
}
.sys::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: led-pulse 2.4s ease-in-out infinite;
}
.sys.warn, .sys[data-state="warn"] { color: var(--amber); }
.sys.error, .sys[data-state="error"], .sys[data-state="offline"] { color: var(--red); }

.clock {
  font-family: var(--mono);
  font-weight: 300;
  font-size: 34px;
  letter-spacing: 0.08em;
  color: var(--text);
  text-shadow: 0 0 18px rgba(79, 227, 255, 0.35);
  font-variant-numeric: tabular-nums;
}
.top__stats {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 26px;
}
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat__value {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat--cost { width: 150px; }
.stat--cost .bar { margin-top: 3px; }

/* ---------- Haupt-Raster ---------- */
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr) minmax(270px, 330px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "alerts core  agents"
    "alerts brain agents";
  gap: var(--gap);
}
#panel-alerts { grid-area: alerts; }
.core         { grid-area: core; }
.tabs         { grid-area: tabs; display: none; }
#brain        { grid-area: brain; }
#panel-agents { grid-area: agents; }

/* ---------- Panels mit HUD-Ecken ---------- */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  backdrop-filter: blur(8px);
}
.panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(var(--cyan), var(--cyan)) top left / 14px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) top left / 1px 14px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) top right / 14px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) top right / 1px 14px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom left / 14px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom left / 1px 14px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom right / 14px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom right / 1px 14px no-repeat;
  opacity: .55;
}
.panel__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.panel__title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
}
.panel__count {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  color: var(--text-2);
}
.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 227, 255, 0.25) transparent;
}

/* =========================================================
   MELDUNGEN
   ========================================================= */
.focus {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 14px 14px 0;
}
.focus__item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(79, 227, 255, 0.035);
  font-size: 14px;
  color: var(--text);
}
.focus__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

.alerts { display: grid; gap: 10px; align-content: start; }

.alert {
  --kind: var(--cyan);
  --kind-dim: var(--cyan-dim);
  position: relative;
  display: grid;
  gap: 6px;
  padding: 12px 14px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(8, 12, 22, 0.85);
  transition: border-color .3s, box-shadow .3s;
}
.alert::after {               /* kleiner Eckwinkel in Art-Farbe */
  content: "";
  position: absolute;
  top: -1px; right: -1px;
  width: 12px; height: 12px;
  border-top: 1px solid var(--kind);
  border-right: 1px solid var(--kind);
  border-top-right-radius: var(--r-sm);
  pointer-events: none;
}
.alert--freigabe   { --kind: var(--cyan);   --kind-dim: var(--cyan-dim); }
.alert--erinnerung { --kind: var(--amber);  --kind-dim: var(--amber-dim); }
.alert--agent      { --kind: var(--green);  --kind-dim: var(--green-dim); }
.alert--info       { --kind: var(--text-2); --kind-dim: rgba(169, 182, 204, 0.1); }
.alert--bestellung { --kind: var(--violet); --kind-dim: var(--violet-dim); }

.alert__head { display: flex; align-items: center; gap: 8px; }
.alert__kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 7px;
  border-radius: 4px;
  background: var(--kind-dim);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--kind);
}
.alert__kind::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.alert__time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}
.alert__title { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--text); }
.alert__text { font-size: 13px; color: var(--text-2); }
.alert__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.alert--new { animation: alert-flash 1.8s var(--ease) 1; }

/* =========================================================
   MITTE: LUNA
   ========================================================= */
.core {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 4px 0 2px;
  min-width: 0;
}

/* ---------- Kugel / Gesicht ---------- */
.orb {
  --size: clamp(170px, 24vh, 250px);
  --level: 0;
  --glow: var(--violet);
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.orb:focus-visible { outline-offset: 6px; border-radius: 50%; }
.orb--mini { --size: 132px; cursor: default; }

.ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transition: opacity .4s, filter .4s;
}
.ring--ticks {
  inset: 0;
  background: repeating-conic-gradient(from 0deg, rgba(79, 227, 255, 0.55) 0deg 0.6deg, transparent 0.6deg 6deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  animation: spin 120s linear infinite;
}
.ring--dash {
  inset: 11px;
  border: 1px dashed rgba(79, 227, 255, 0.4);
  animation: spin-rev 60s linear infinite;
}
.ring--scan {
  inset: 18px;
  background: conic-gradient(from 0deg, transparent 0 72%, rgba(180, 155, 255, 0) 72%, rgba(180, 155, 255, 0.85) 99%, #fff 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  animation: spin 6s linear infinite;
}

.face {
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  overflow: hidden;
  background: #0a0614;
  box-shadow:
    0 0 0 1px rgba(180, 155, 255, 0.55),
    0 0 26px 2px rgba(91, 61, 245, 0.35);
  animation: breathe-glow 5s ease-in-out infinite;
  transition: box-shadow .25s, filter .4s, opacity .4s;
}
.face img,
.face__vid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 32%;
}
.face img { transform: scale(1.32); transform-origin: 50% 38%; }
.face__vid { opacity: 0; transition: opacity .35s var(--ease); }
.face__vid.on { opacity: 1; }

/* Zustand: hört zu */
.orb[data-state="listening"] .ring--ticks { background: repeating-conic-gradient(from 0deg, rgba(79, 227, 255, 0.95) 0deg 0.6deg, transparent 0.6deg 6deg); animation-duration: 20s; }
.orb[data-state="listening"] .ring--dash { border-color: rgba(79, 227, 255, 0.75); animation-duration: 14s; }
.orb[data-state="listening"] .ring--scan {
  background: conic-gradient(from 0deg, transparent 0 60%, rgba(79, 227, 255, 0) 60%, rgba(79, 227, 255, 0.95) 99%, #fff 100%);
  animation-duration: 1.8s;
}
.orb[data-state="listening"] .face {
  animation: none;
  box-shadow: 0 0 0 1.5px var(--cyan), 0 0 30px 4px rgba(79, 227, 255, 0.35);
}

/* Zustand: spricht – Leuchten folgt --level (0…1) */
.orb[data-state="speaking"] .face {
  animation: none;
  box-shadow:
    0 0 0 calc(1.5px + 2px * var(--level)) var(--violet),
    0 0 calc(22px + 70px * var(--level)) calc(2px + 16px * var(--level)) rgba(91, 61, 245, calc(0.35 + 0.5 * var(--level))),
    0 0 calc(8px + 30px * var(--level)) rgba(180, 155, 255, calc(0.25 + 0.55 * var(--level)));
  transition: box-shadow 80ms linear;
}
.orb[data-state="speaking"] .ring--dash {
  inset: calc(11px - 5px * var(--level));
  border-color: rgba(180, 155, 255, calc(0.35 + 0.6 * var(--level)));
  transition: inset 80ms linear, border-color 80ms linear;
}
.orb[data-state="speaking"] .ring--scan { animation-duration: 3s; }

/* Zustand: verbindet */
.orb[data-state="connecting"] .face { animation: none; filter: saturate(.3) brightness(.65); box-shadow: 0 0 0 1px rgba(79, 227, 255, 0.4); }
.orb[data-state="connecting"] .ring--ticks { opacity: .35; }
.orb[data-state="connecting"] .ring--dash { animation-duration: 3s; border-color: rgba(79, 227, 255, 0.7); }
.orb[data-state="connecting"] .ring--scan {
  background: conic-gradient(from 0deg, transparent 0 50%, rgba(79, 227, 255, 0) 50%, rgba(79, 227, 255, 0.9) 100%);
  animation-duration: 1s;
}

/* Luna denkt im Hintergrund */
.orb--thinking::before,
.orb--thinking::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  pointer-events: none;
}
.orb--thinking::before {     /* kreisender Punkt */
  background: radial-gradient(circle at 50% 0%, var(--amber) 0 3px, transparent 4px);
  filter: drop-shadow(0 0 4px var(--amber));
  animation: spin 2.4s linear infinite;
}
.orb--thinking::after {      /* zweiter, gegenläufiger Bogen */
  inset: 18px;
  border: 1.5px solid transparent;
  border-bottom-color: rgba(255, 200, 87, 0.75);
  animation: spin-rev 3.2s linear infinite;
}

/* ---------- Status & Chips ---------- */
.status {
  max-width: 46ch;
  min-height: 1.45em;
  text-align: center;
  font-size: 15px;
  color: var(--text-2);
}
.status::before {
  content: "› ";
  font-family: var(--mono);
  color: var(--violet);
}
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* =========================================================
   GEHIRN
   ========================================================= */
#brain {
  container: brain / inline-size;
  overflow: hidden;
  transition: border-color .4s;
}
.brain__now {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-2);
}
.brain__body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, 1fr);
}
.brain__graph {
  position: relative;
  min-height: 200px;
  border-right: 1px solid var(--line);
}
#brain-canvas,
.brain__demo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.brain__demo text { font-family: var(--mono); }

.brain__feed {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 227, 255, 0.25) transparent;
}

/* Aktiv: Rahmen leuchtet leicht, Titel-Punkt pulsiert */
.brain--active { border-color: rgba(180, 155, 255, 0.35); }
.brain--active .panel__title::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 10px;
  vertical-align: 1px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 8px var(--violet);
  animation: led-pulse 1s ease-in-out infinite;
}

/* Vollbild */
.brain--expanded {
  position: fixed !important;
  inset: 16px;
  z-index: 60;
  background: rgba(5, 7, 13, 0.97) !important;
  box-shadow: 0 0 0 100vmax rgba(2, 3, 7, 0.7);
}
.brain--expanded .brain__body { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); }
.brain--expanded .thought { font-size: 14px; }

/* ---------- Gedanken ---------- */
.thought {
  --t: var(--text-2);
  display: grid;
  grid-template-columns: 16px 64px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  padding: 4px 4px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.4;
  animation: thought-in .35s var(--ease) 1;
}
.thought__icon {
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  color: var(--t);
}
.thought__time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.thought__text { color: var(--text); overflow-wrap: anywhere; }

.thought--start      { --t: var(--violet); }
.thought--start .thought__text { font-weight: 600; }
.thought--denken     { --t: var(--violet); }
.thought--denken .thought__text { color: var(--text-2); }
.thought--werkzeug   { --t: var(--cyan); }
.thought--delegieren { --t: var(--cyan); }
.thought--ergebnis   { --t: var(--green); }
.thought--pruefen    { --t: var(--amber); }
.thought--agent      { --t: var(--green); }
.thought--antwort    { --t: var(--violet); background: var(--violet-dim); }
.thought--fehler     { --t: var(--red); background: var(--red-dim); }
.thought--fehler .thought__text { color: #ffc2c8; }
.thought--fabio      { --t: var(--cyan); }
.thought--fabio .thought__text { color: var(--cyan); }
.thought--luna       { --t: var(--violet); }
.thought--luna .thought__text { color: #d9ceff; }

/* =========================================================
   AGENTEN
   ========================================================= */
.agents { display: grid; gap: 10px; align-content: start; }

.agent {
  display: grid;
  gap: 9px;
  padding: 13px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(8, 12, 22, 0.85);
}
.agent--vorgeschlagen {
  border-style: dashed;
  border-color: rgba(180, 155, 255, 0.45);
  background: rgba(180, 155, 255, 0.04);
}
.agent__head { display: flex; align-items: center; gap: 10px; }
.agent__name { font-size: 15px; font-weight: 600; line-height: 1.25; min-width: 0; }
.agent__status {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
.agent__meta {
  display: grid;
  gap: 3px;
  font-size: 12px;
}
.agent__meta dt, .agent__meta .row > :first-child { color: var(--text-3); }
.agent__meta dd, .agent__meta .row > :last-child { font-family: var(--mono); color: var(--text-2); text-align: right; }
.agent__last {
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(79, 227, 255, 0.04);
  font-size: 13px;
  color: var(--text-2);
}
.agent__budget { display: grid; gap: 5px; font-size: 12px; color: var(--text-3); }
.agent__budget .row > :last-child { font-family: var(--mono); color: var(--text-2); }
.agent__actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* =========================================================
   TABS (nur Handy)
   ========================================================= */
.tabs {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
}
.tab[aria-selected="true"], .tab.active {
  border-color: var(--line-strong);
  background: var(--cyan-dim);
  color: var(--cyan);
}
#tab-badge {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--violet-deep);
  font-size: 11px;
  letter-spacing: 0;
  color: #fff;
}
#tab-badge:empty { display: none; }

/* =========================================================
   DOCK
   ========================================================= */
.dock {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px 12px;
}
.dock__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(8, 12, 22, 0.7);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  transition: color .2s, border-color .2s, background .2s;
}
.dock__btn svg { width: 16px; height: 16px; flex: none; }
.dock__btn:hover { color: var(--cyan); border-color: var(--line-strong); background: var(--cyan-dim); }
.dock__btn--quiet:hover { color: var(--red); border-color: rgba(255, 107, 122, 0.5); background: var(--red-dim); }
.dock__sep { width: 1px; margin: 6px 6px; background: var(--line); }

/* =========================================================
   DRAWER (<dialog>)
   ========================================================= */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(440px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--text);
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in .3s var(--ease) 1; }
.drawer::backdrop { background: rgba(2, 3, 7, 0.6); backdrop-filter: blur(3px); }
.drawer__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
#drawer-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
}
#drawer-close { margin-left: auto; }
.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.drawer__body .row {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(8, 12, 22, 0.85);
  align-items: center;
}

/* =========================================================
   MITTLERE BREITE (900–1180 px)
   ========================================================= */
@container app (max-width: 1180px) {
  .grid { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) minmax(240px, 280px); }
  .top__brand { gap: 14px; }
  .sys { display: none; }
  .clock { font-size: 28px; }
}

/* Gehirn schmal: Protokoll unter die Netzgrafik */
@container brain (max-width: 560px) {
  .brain__body { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 1fr) minmax(120px, auto); }
  .brain__graph { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* =========================================================
   HANDY (< 900 px)
   ========================================================= */
@container app (max-width: 899px) {
  .app__inner { height: auto; min-height: 100dvh; padding: 10px 12px 0; gap: 12px; }

  .top {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand clock" "stats stats";
    row-gap: 8px;
    padding: 10px 14px;
  }
  .top__brand { grid-area: brand; }
  .clock { grid-area: clock; font-size: 22px; }
  .top__stats { grid-area: stats; justify-content: space-between; gap: 14px; padding-top: 8px; border-top: 1px solid var(--line); }
  .stat--cost { flex: 1; width: auto; max-width: 200px; }
  .top__brand { gap: 12px; }
  .sys { display: inline-flex; font-size: 0; gap: 0; }   /* nur die Status-LED, Text bleibt für Screenreader */

  .grid {
    flex: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "core" "tabs" "alerts" "agents" "brain";
    gap: 12px;
  }
  .tabs { display: flex; position: sticky; top: 8px; z-index: 10; }
  .tab-hidden { display: none !important; }

  .orb { --size: 210px; }
  .panel__body { overflow: visible; }

  #brain { min-height: 0; }
  .brain__body { grid-template-columns: 1fr; grid-template-rows: 220px auto; }
  .brain__graph { border-right: 0; border-bottom: 1px solid var(--line); }
  .brain__feed { max-height: 240px; }
  .brain--expanded { inset: 0; border-radius: 0; }
  .brain--expanded .brain__body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 40%); }
  .brain--expanded .brain__feed { max-height: none; }

  .dock {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 0 -12px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(5, 7, 13, 0.94);
    backdrop-filter: blur(10px);
    justify-content: space-between;
  }
  .dock__btn {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-height: 52px;
    padding: 4px 2px;
    border-color: transparent;
    background: transparent;
    font-size: 10px;
    letter-spacing: 0.02em;
  }
  .dock__sep { display: none; }
}

/* =========================================================
   ANIMATIONEN
   ========================================================= */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
@keyframes breathe  { 50% { opacity: .45; } }
@keyframes breathe-glow {
  50% { box-shadow: 0 0 0 1px rgba(180, 155, 255, 0.7), 0 0 38px 6px rgba(91, 61, 245, 0.45); }
}
@keyframes led-pulse { 50% { opacity: .35; } }
@keyframes led-blink { 50% { opacity: .2; } }
@keyframes alert-flash {
  0%   { border-color: var(--kind); box-shadow: 0 0 0 1px var(--kind), 0 0 24px var(--kind-dim); background: rgba(20, 28, 46, 0.95); }
  100% { border-color: var(--line); box-shadow: none; }
}
@keyframes thought-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Ergänzungen für das JS ---------- */
.panel__count:empty { display: none; }
.sys.offline { color: var(--red); }
.report { margin-top: 6px; font-size: 13px; color: var(--text-2); white-space: pre-wrap; }

/* =========================================================
   HOLOGRAMM (ersetzt Ringe und rundes Foto)
   ========================================================= */
.orb {
  --size: clamp(260px, 44vh, 470px);
  position: relative;
  z-index: 5;
  animation: float 7s ease-in-out infinite;
}
.orb--mini { --size: 150px; }
.orb--thinking::before { content: none; }
.orb--thinking::after { top: auto; border: 0; }  /* bleibt Lichtkegel, Farbe kommt aus holo.js */

.face {
  inset: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none !important;
  animation: none !important;
  filter: none !important;
}
.face img, .face__vid, .face__vid.on { opacity: 0 !important; transform: none; }  /* nur Quelle fürs Punktraster */
.holo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 18px rgba(79, 190, 255, 0.35));
}
.orb[data-state="connecting"] .holo { opacity: .6; }

/* Lichtkegel des Projektors unter Luna */
.orb::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%;
  bottom: -6%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(79, 227, 255, 0.35), transparent);
  filter: blur(4px);
  animation: float-shadow 7s ease-in-out infinite;
  pointer-events: none;
}
.orb--mini::after { display: none; }

@keyframes float        { 50% { transform: translateY(-10px); } }
@keyframes float-shadow { 50% { transform: translateY(10px) scaleX(.85); opacity: .6; } }

@container app (max-width: 899px) {
  .orb { --size: min(78vw, 340px); }
}

/* ---------- Kostenübersicht (Drawer) ---------- */
button.stat { padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
button.stat:hover .stat__value { color: var(--cyan); }
.cost {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(8, 12, 22, 0.85);
}
.cost__name { font-weight: 600; text-transform: capitalize; }
.cost__eur { font-family: var(--mono); color: var(--text); }
.cost__meta { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.cost .bar { height: 5px; }
.drawer__body .cost .row { padding: 0; border: 0; background: none; }

/* ---------- Nachrichten-Laufband ---------- */
.ticker {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 0 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  overflow: hidden;
}
.ticker__label {
  flex: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
}
.ticker__window {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  -webkit-mask: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
          mask: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker__track {
  display: flex;
  width: max-content;
  animation: ticker var(--dur, 50s) linear infinite;
}
.ticker:hover .ticker__track, .ticker:focus-within .ticker__track { animation-play-state: paused; }
.ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 28px 0 0;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.ticker__item::after { content: "◆"; margin-left: 20px; font-size: 7px; color: var(--line-strong); }
.ticker__item:hover { color: var(--text); }
.ticker__topline { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.ticker__eil {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--red-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  animation: led-blink 1.4s steps(2, end) infinite;
}
.ticker__item--eil { color: #ffc2c8; }
@keyframes ticker { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker__window { overflow-x: auto; }
}
.ticker { padding-right: 0; }
.ticker__map {
  flex: none;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.ticker__map:hover { color: var(--cyan); background: var(--cyan-dim); }
.ticker__warn {
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.ticker__warn--rot    { background: var(--red-dim);   color: var(--red); }
.ticker__warn--orange { background: var(--amber-dim); color: var(--amber); }
.ticker__item--rot    { color: #ffc2c8; }
.ticker__item--orange { color: #ffe2a8; }
