/* Luna-Look: hell, ruhig, Serifen-Überschriften, dunkler Avatar mit mintfarbenen Augen */
:root {
  --bg: #f3f4f9; --panel: #ffffff; --panel2: #eef0f8; --line: #dfe3ee; --text: #141a33; --muted: #667091;
  --accent: #3a3fa0; --accent2: #8fe0cb; --ink: #0f1524; --ok: #15803d; --warn: #b7791f; --crit: #c0392b;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* Kopfzeile */
header { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.brand { font-family: var(--serif); font-size: 19px; font-weight: 700; white-space: nowrap; }
.brand small { display: block; font-family: "Segoe UI", sans-serif; font-weight: 400; color: var(--muted); font-size: 11px; }
.prompt { flex: 1 1 320px; min-width: 0; display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px 6px 14px; box-shadow: 0 1px 2px rgba(20, 26, 51, .04); }
.prompt input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); font-size: 16px; min-width: 120px; }
.btn { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.rec { background: #fde8e6; border-color: var(--crit); animation: pulse 1s infinite; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
.badge.live { color: var(--ok); border-color: #b7e4c7; background: #effaf2; }
.badge.off { color: var(--warn); border-color: #f1d9a6; background: #fff7e5; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 20px 0; }
.chip { font-size: 13px; color: var(--muted); border: 1px dashed #c3c9de; border-radius: 999px; padding: 4px 12px; background: transparent; }
.chip:hover { color: var(--accent); border-color: var(--accent); }

/* Layout */
.wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; gap: 16px; padding: 14px 20px 28px; align-items: start; }
@media (max-width: 1350px) { .wrap { grid-template-columns: 280px minmax(0, 1fr); } .right { grid-column: 1 / -1; } }
@media (max-width: 900px) { .wrap { grid-template-columns: 1fr; } }
.left, .right { position: sticky; top: 74px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 88px); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(20, 26, 51, .04); }

/* Luna */
.luna { text-align: center; }
.avatar { width: 116px; height: 116px; margin: 4px auto 6px; position: relative; }
.avatar .ring { position: absolute; inset: 0; border-radius: 50%; border: 5px solid #e2e6f3; }
.avatar.busy .ring { border-color: var(--accent); border-top-color: var(--accent2); animation: spin 1.4s linear infinite; }
.avatar .face { position: absolute; inset: 10px; border-radius: 50%; background: var(--ink); display: flex; align-items: center; justify-content: center; gap: 14px; }
.avatar .eye { width: 11px; height: 26px; border-radius: 6px; background: var(--accent2); animation: blink 5s infinite; }
.avatar.talk .eye { animation: talk .35s infinite alternate; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes talk { to { transform: scaleY(.55); } }
@keyframes pulse { 50% { opacity: .45; } }
.luna h2 { font-family: var(--serif); margin: 2px 0 0; font-size: 22px; }
.luna .role { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.status { font-size: 13px; color: var(--accent); min-height: 20px; }

/* Team */
.team { display: flex; flex-direction: column; gap: 6px; }
.agent { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; border: 1px solid var(--line); border-left: 4px solid var(--c); background: var(--panel); transition: .2s; }
.agent .em { font-size: 18px; }
.agent .nm { font-weight: 600; font-size: 13px; line-height: 1.2; }
.agent .tx { color: var(--muted); font-size: 11.5px; max-width: 170px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agent .dot { width: 9px; height: 9px; border-radius: 50%; background: #cfd5e8; margin-left: auto; flex: none; }
.agent.busy { background: color-mix(in srgb, var(--c) 8%, white); box-shadow: 0 0 0 1px var(--c); }
.agent.busy .dot { background: var(--c); animation: pulse 1s infinite; }

/* Netz-Karte */
.ml h3, .box h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ml .big { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.ml .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 2px 0; }
.ml .row b { color: var(--text); font-weight: 600; }
.ml .note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ml.train .big { animation: pulse 1s infinite; }

/* Fazit */
.summary { background: linear-gradient(135deg, #eef0ff, #e8f7f2); border: 1px solid #cfd6f5; border-radius: 16px; padding: 14px 18px; margin-bottom: 14px; }
.summary h3 { margin: 0 0 4px; font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.summary #summaryText { font-family: var(--serif); font-size: 17.5px; line-height: 1.5; }
.runinfo { color: var(--muted); font-size: 13px; margin: 0 0 12px; min-height: 20px; }

/* Widgets */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.w { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; animation: pop .45s ease-out; min-width: 0; box-shadow: 0 1px 2px rgba(20, 26, 51, .04); }
.w.s { grid-column: span 2; } .w.m { grid-column: span 6; } .w.l { grid-column: span 12; }
@media (max-width: 1500px) { .w.s { grid-column: span 3; } }
@media (max-width: 900px) { .w.m { grid-column: span 12; } .w.s { grid-column: span 6; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.w h4 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.w .sub { font-size: 12px; color: #8b94b3; }
.w .by { font-size: 11px; color: var(--c, var(--muted)); margin-top: 6px; }
.kpi .val { font-family: var(--serif); font-size: 34px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.chartbox { position: relative; height: 240px; margin-top: 8px; }
.w.l .chartbox { height: 300px; }
.fcnote { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rel { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); margin-left: 6px; }
.rel.niedrig { color: var(--warn); border-color: #f1d9a6; background: #fff7e5; }
.rel.mittel { color: var(--ok); border-color: #b7e4c7; background: #effaf2; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
h2.sec { font-family: var(--serif); font-size: 18px; margin: 20px 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 70px 20px; border: 1px dashed #c3c9de; border-radius: 16px; font-family: var(--serif); font-size: 17px; }

/* Befunde */
.findings { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.f { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--sev, var(--accent)); border-radius: 14px; padding: 12px 14px; animation: pop .45s ease-out; }
.f.kritisch { --sev: var(--crit); } .f.warnung { --sev: var(--warn); } .f.info { --sev: var(--accent); }
.f h5 { margin: 0 0 4px; font-size: 15px; }
.f p { margin: 0 0 8px; color: #3a4466; font-size: 13.5px; }
.f .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.ver { margin-left: auto; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.ver.bestaetigt { color: var(--ok); border-color: #b7e4c7; background: #effaf2; }
.ver.korrigiert { color: var(--warn); border-color: #f1d9a6; background: #fff7e5; }
.ver.abgelehnt { color: var(--crit); border-color: #f0c2bd; background: #fdecea; }
.vercomment { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Rechte Spalte: Bus + Chat */
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-height: 0; box-shadow: 0 1px 2px rgba(20, 26, 51, .04); }
.box > h3 { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.feed { overflow: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.msg { font-size: 13px; animation: pop .3s ease-out; }
.msg .who { font-weight: 600; color: var(--c, var(--accent)); }
.msg .to { color: var(--muted); }
.msg.tool { color: var(--muted); font-size: 12px; font-family: Consolas, monospace; }
.msg.err { color: var(--crit); }
.bubble { padding: 8px 12px; border-radius: 14px; max-width: 92%; font-size: 14px; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff; }
.bubble.bot { align-self: flex-start; background: var(--panel2); }
.chatin { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chatin input { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text); outline: 0; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #fdecea; border: 1px solid var(--crit); color: #7f1d1d; padding: 10px 16px; border-radius: 12px; z-index: 50; }

/* Agenten-Fenster */
body.agentwin .wrap { grid-template-columns: 1fr; padding-top: 14px; }
.stream { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; font-family: var(--serif); font-size: 18px; line-height: 1.55; min-height: 220px; max-height: 42vh; overflow: auto; white-space: pre-wrap; }
.awhead { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); border-top: 5px solid var(--c); background: var(--panel); }
.awhead .big { font-size: 34px; }
.awhead h1 { margin: 0; font-family: var(--serif); font-size: 24px; }
.awhead .st, .awhead .role { font-size: 13px; color: var(--muted); }
.w.kpi { order: -1; }
.ver.nicht_pruefbar { color: var(--muted); }

/* Gespräch mit Luna: Klick aufs Gesicht */
.avatar { cursor: pointer; outline-offset: 4px; }
.avatar:focus-visible { outline: 2px solid var(--accent); border-radius: 50%; }
.avatar.listen .ring { border-color: var(--accent2); box-shadow: 0 0 0 6px rgba(143, 224, 203, .35); animation: pulse 1s infinite; }
.avatar.listen .eye { transform: scaleY(1.25); background: #c6fff0; }
.hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.agentfeed { max-height: 38vh; }

/* Umschalter eigene Sitzung / Bühne */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 7px 12px; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* Zuschauer-Ansicht: nur mitlesen, keine Steuerung */
.viewernote { display: none; margin-top: 8px; font-size: 12px; color: var(--muted); background: var(--panel2); border-radius: 10px; padding: 6px 10px; }
body.viewer .viewernote { display: block; }
body.viewer .prompt, body.viewer .chips, body.viewer .chatin { display: none !important; }
