:root {
  --bg: #12142B; --card: #191C3A; --card2: #1F2347; --line: rgba(242,246,250,.08);
  --cyan: #5AC8E3; --cyan-dim: rgba(90,200,227,.16); --text: #F2F6FA; --muted: #7C8AA3;
  --purple: #A78BFA; --green: #4ADE80; --amber: #FBBF24; --gold: #F5C451; --red: #F87171;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --nav-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif; font-size: 15px; line-height: 1.45; }
body { overscroll-behavior-y: none; }
a { color: var(--cyan); text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .01em; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Space Mono", Menlo, monospace; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Login */
.login-body { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 340px; text-align: center; }
.login h1 { font-size: 26px; margin-top: 14px; }
.login .sub { color: var(--muted); margin: 4px 0 26px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login input, .login button { border-radius: 12px; padding: 14px 16px; font-size: 16px; border: 1px solid var(--line); }
.login input { background: var(--card); color: var(--text); }
.login button { background: var(--cyan); color: #08121a; font-weight: 700; border: none; }
.login .msg { color: var(--red); margin: 4px 0 0; font-size: 14px; }
.logo-mark { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(145deg, var(--cyan-dim), transparent);
  border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center;
  font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 24px; color: var(--cyan); }
.logo-mark.big { width: 72px; height: 72px; font-size: 44px; border-radius: 20px; }

/* ---------- App-Rahmen */
#app { min-height: 100%; padding-bottom: calc(var(--nav-h) + var(--sab)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--sat)) 16px 10px; background: rgba(18,20,43,.85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .sub { font-size: 12px; color: var(--muted); }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-size: 16px; }
.iconbtn:active { background: var(--card2); }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(74,222,128,.15); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(74,222,128,.18);} 50% { box-shadow: 0 0 0 7px rgba(74,222,128,.04);} }

.view { display: none; padding: 14px 14px 24px; }
.view.active { display: block; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab); background: rgba(18,20,43,.92); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
nav.tabs button { background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; cursor: pointer; }
nav.tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs button.active { color: var(--cyan); }

/* ---------- Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.big-num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.big-num small { font-size: 13px; color: var(--muted); font-weight: 400; }
.bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--cyan); border-radius: 4px; transition: width .6s ease; }
.bar > i.warn { background: var(--amber); } .bar > i.hot { background: var(--red); }
.barchart { display: flex; align-items: flex-end; gap: 8px; height: 110px; margin-top: 10px; }
.barchart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.barchart .b { width: 70%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--cyan), rgba(90,200,227,.3)); min-height: 3px; }
.barchart .b.empty { background: rgba(255,255,255,.07); }
.barchart .d { font-size: 11px; color: var(--muted); margin-top: 6px; }
.row { display: flex; align-items: center; gap: 12px; }
.row + .row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--green); border-color: rgba(74,222,128,.3); } .pill.still { color: var(--muted); }
.pill.ueberfaellig { color: var(--amber); border-color: rgba(251,191,36,.35); } .pill.fehlt { color: var(--red); border-color: rgba(248,113,113,.35); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; }
.section-head h2 { font-size: 15px; } .section-head span { font-size: 12px; color: var(--muted); }

/* ---------- Organigramm */
.org { position: relative; padding: 6px 0 10px; }
.org svg.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.org .node { position: relative; z-index: 2; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0 auto; width: max-content; }
.avatar { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px;
  background: var(--card); border: 2px solid var(--cyan); color: var(--cyan); box-shadow: 0 0 24px rgba(90,200,227,.25); }
.avatar.fabian { background: linear-gradient(145deg, #2a2f5e, #12142B); border-color: var(--text); color: var(--text); box-shadow: 0 0 30px rgba(242,246,250,.15); font-family: Georgia, serif; font-style: italic; font-size: 26px; }
.person .n { font-weight: 700; font-size: 14px; } .person .r { font-size: 11.5px; color: var(--muted); margin-top: -4px; }
.chief { margin-top: 44px; cursor: pointer; }
.chief .avatar { width: 62px; height: 62px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 52px; }
.team { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 12px 10px; border-top: 2px solid var(--c); }
.team h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--c); display: flex; justify-content: space-between; align-items: center; }
.team h3 small { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 11px; }
.members { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.member { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid transparent; cursor: pointer; text-align: left; width: 100%; }
.member:active { background: var(--card2); }
.member .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; box-shadow: 0 0 8px var(--c); }
.member .dot.still { opacity: .45; box-shadow: none; } .member .dot.ueberfaellig { background: var(--amber); box-shadow: 0 0 8px var(--amber); } .member .dot.fehlt { background: var(--red); }
.member .mn { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brain { margin: 56px auto 0; width: max-content; text-align: center; cursor: pointer; }
.brain .core { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; font-size: 34px;
  background: radial-gradient(circle at 50% 40%, rgba(245,196,81,.55), rgba(245,196,81,.08) 70%); border: 2px solid var(--gold); box-shadow: 0 0 40px rgba(245,196,81,.35), inset 0 0 30px rgba(245,196,81,.25); animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1);} 50% { transform: scale(1.05); box-shadow: 0 0 60px rgba(245,196,81,.5), inset 0 0 36px rgba(245,196,81,.3);} }
.brain .n { font-weight: 700; margin-top: 8px; color: var(--gold); } .brain .r { font-size: 11.5px; color: var(--muted); }
.wire { fill: none; stroke-width: 1.4; stroke-dasharray: 4 7; opacity: .55; animation: flow 1.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -22; } }
.spark { filter: drop-shadow(0 0 4px currentColor); }

/* ---------- Chat */
.roles .avatar.s { width: 44px; height: 44px; font-size: 14px; box-shadow: none; border-width: 1.5px; }
.thread { display: flex; flex-direction: column; min-height: calc(100vh - 140px - var(--nav-h)); }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--cyan); color: #08121a; border-bottom-right-radius: 5px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; white-space: normal; }
.msg.ai p { margin: 0 0 8px; } .msg.ai p:last-child { margin: 0; }
.msg.ai h1, .msg.ai h2, .msg.ai h3 { font-size: 14.5px; margin: 8px 0 4px; color: var(--cyan); }
.msg.ai ul, .msg.ai ol { margin: 4px 0 8px; padding-left: 20px; } .msg.ai li { margin: 2px 0; }
.msg.ai code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.msg.ai pre { background: #0d0f22; padding: 10px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; }
.msg.ai pre code { background: none; padding: 0; }
.msg.ai table { border-collapse: collapse; font-size: 13px; display: block; overflow-x: auto; }
.msg.ai td, .msg.ai th { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.msg.user .meta { color: rgba(8,18,26,.6); }
.msg.tool { align-self: flex-start; background: none; border: none; color: var(--muted); font-size: 12px; padding: 0 6px; }
.typing { display: inline-flex; gap: 4px; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25;} 40% { opacity: 1;} }
.composer { position: sticky; bottom: calc(var(--nav-h) + var(--sab)); display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 8px; background: linear-gradient(180deg, transparent, var(--bg) 30%); }
.composer textarea { flex: 1; resize: none; max-height: 140px; min-height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 11px 14px; font: inherit; font-size: 15px; }
.composer button { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--cyan); color: #08121a; font-size: 18px; font-weight: 700; cursor: pointer; flex-shrink: 0; }
.composer button:disabled { opacity: .4; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { background: none; border: none; padding: 5px 10px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--cyan-dim); color: var(--cyan); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

/* ---------- Gedächtnis */
.brain-hero { position: relative; height: 150px; border-radius: 16px; overflow: hidden; background: radial-gradient(ellipse at 50% 60%, #1b1f45, #0d0f22); border: 1px solid var(--line); }
.brain-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.brain-hero .stats { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; gap: 16px; }
.brain-hero .stats b { display: block; font-size: 20px; } .brain-hero .stats span { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.search { display: flex; gap: 8px; margin-top: 12px; }
.search input { flex: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 12px 14px; font-size: 15px; }
.hit { padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.hit .name { font-weight: 600; font-size: 14px; } .hit .path { font-size: 11px; color: var(--muted); }
.hit .snip { font-size: 12.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit .snip mark { background: rgba(90,200,227,.25); color: var(--cyan); border-radius: 3px; padding: 0 2px; }

/* ---------- Sheet */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 86vh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 14px 18px calc(24px + var(--sab)); border-top: 1px solid var(--line); animation: up .25s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--muted); margin: 0 auto 14px; opacity: .5; }
.sheet h2 { font-size: 18px; } .sheet .kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sheet .kv span:first-child { color: var(--muted); } .sheet pre { background: #0d0f22; border-radius: 10px; padding: 10px; font-size: 11.5px; overflow-x: auto; color: var(--muted); }
.sheet .note { font-size: 14px; line-height: 1.5; } .sheet .note h1, .sheet .note h2, .sheet .note h3 { color: var(--cyan); font-size: 15px; margin: 12px 0 4px; }
.sheet .note pre { color: var(--text); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--cyan); color: #08121a; border-color: transparent; }
.btn.full { width: 100%; margin-top: 12px; }
