/* Lock viewport to prevent overall app from scrolling */
html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(5, 7, 12, 0.6);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

/* Dedicated Isolated Chat Scroll Container */
#chat-feed {
  scrollbar-width: thin;
  scrollbar-color: #334155 rgba(5, 7, 12, 0.5);
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

#chat-feed::-webkit-scrollbar {
  width: 6px;
}

#chat-feed::-webkit-scrollbar-track {
  background: rgba(5, 7, 12, 0.5);
  border-radius: 4px;
}

#chat-feed::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#chat-feed::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

/* Glassmorphism subtle effects */
.glass-panel {
  background: rgba(18, 26, 43, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(30, 41, 59, 0.8);
}

/* Terminal-Tastenleiste (Handy) */
.term-key {
  min-width: 2rem;
  min-height: 1.9rem;
  padding: 0 .6rem;
  border-radius: .375rem;
  border: 1px solid #1e293b;
  background: #121a2b;
  color: #cbd5e1;
  touch-action: manipulation;
  cursor: pointer;
}
.term-key:hover { color: #38bdf8; border-color: rgba(56, 189, 248, .5); }
.term-key:active { transform: scale(.95); background: rgba(56, 189, 248, .15); }

/* ------------------------------------------------------------------------
   Agenten-Pulse & KG-Fenster (Phase 10.1)
   Status-Farben: ok #34d399 · idle #38bdf8 · warn #fbbf24 · error #fb7185 · unknown #64748b
   Status erscheint nie nur als Farbe — immer mit Icon + Text.
   ------------------------------------------------------------------------ */
[data-status="ok"]      { --st: #34d399; --st-bg: rgba(52, 211, 153, .12); }
[data-status="idle"]    { --st: #38bdf8; --st-bg: rgba(56, 189, 248, .10); }
[data-status="warn"]    { --st: #fbbf24; --st-bg: rgba(251, 191, 36, .12); }
[data-status="error"]   { --st: #fb7185; --st-bg: rgba(251, 113, 133, .14); }
[data-status="unknown"] { --st: #64748b; --st-bg: rgba(100, 116, 139, .12); }

.pulse-card {
  position: relative;
  background:
    radial-gradient(120% 80% at 100% 0%, var(--st-bg), transparent 60%),
    linear-gradient(180deg, rgba(18, 26, 43, .85), rgba(9, 13, 22, .9));
  border: 1px solid color-mix(in srgb, var(--st) 35%, #1e293b);
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset, 0 0 24px -12px var(--st);
  transition: border-color .4s, box-shadow .4s;
}
.pulse-card-icon { color: var(--st); filter: drop-shadow(0 0 4px var(--st)); animation: pulse-beat 1.6s ease-in-out infinite; }
.pulse-card[data-status="error"] .pulse-card-icon { animation-duration: .7s; }

.pulse-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .05rem .45rem; border-radius: 999px;
  font: 600 9.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #e2e8f0; background: var(--st-bg);
  border: 1px solid color-mix(in srgb, var(--st) 45%, transparent);
  white-space: nowrap;
}
.pulse-pill i { color: var(--st); font-size: 9px; }

.pulse-ecg { width: 100%; height: 22px; display: block; overflow: visible; }
.pulse-ecg path {
  fill: none; stroke: var(--st, #38bdf8); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 90 230; filter: drop-shadow(0 0 3px var(--st));
  animation: pulse-ecg 2.4s linear infinite;
}
.pulse-card[data-status="error"] .pulse-ecg path { animation-duration: 1.1s; }
.pulse-card[data-status="idle"] .pulse-ecg path,
.pulse-card[data-status="unknown"] .pulse-ecg path { animation-duration: 4s; opacity: .7; }
@keyframes pulse-ecg { from { stroke-dashoffset: 320; } to { stroke-dashoffset: 0; } }
@keyframes pulse-beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } }

.pulse-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--st); box-shadow: 0 0 6px var(--st); flex-shrink: 0; }
[data-status="ok"] > .pulse-dot, .pulse-dot[data-status="ok"] { animation: pulse-glow 2s ease-in-out infinite; }
.pulse-dot[data-status="error"], [data-status="error"] > .pulse-dot { animation: pulse-glow .8s ease-in-out infinite; }
@keyframes pulse-glow { 50% { box-shadow: 0 0 0 3px transparent, 0 0 12px var(--st); opacity: .65; } }

.pulse-row {
  display: flex; align-items: center; gap: .45rem; padding: .3rem .4rem; border-radius: .4rem;
  background: rgba(5, 7, 12, .6); border: 1px solid #1e293b; cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
}
.pulse-row:hover { border-color: color-mix(in srgb, var(--st) 55%, #1e293b); background: var(--st-bg); }
.pulse-row:active { transform: scale(.99); }
.pulse-row .glyph { font-size: 13px; width: 16px; text-align: center; }
.pulse-branch { margin-left: .75rem; padding-left: .55rem; border-left: 1px dashed #334155; display: grid; gap: .25rem; }
.pulse-sub { display: flex; flex-wrap: wrap; gap: .25rem; margin: .1rem 0 0 1.5rem; }
.pulse-sub button {
  display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .4rem; border-radius: 999px;
  font-size: 9.5px; color: #cbd5e1; background: var(--st-bg); border: 1px solid color-mix(in srgb, var(--st) 35%, transparent); cursor: pointer;
}
.pulse-engine {
  padding: .4rem .45rem; border-radius: .5rem; cursor: pointer;
  background: linear-gradient(160deg, var(--st-bg), rgba(5, 7, 12, .7) 55%);
  border: 1px solid color-mix(in srgb, var(--st) 30%, #1e293b);
  transition: border-color .2s, transform .15s;
}
.pulse-engine:hover { border-color: var(--st); }
.pulse-engine .big { font: 700 15px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #f1f5f9; letter-spacing: -.02em; }
.pulse-meter { height: 3px; border-radius: 3px; background: #1e293b; overflow: hidden; }
.pulse-meter > span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #38bdf8, #a78bfa); }
.pulse-meter.hot > span { background: linear-gradient(90deg, #fbbf24, #fb7185); }
.pulse-spark { width: 100%; height: 22px; display: block; }
.pulse-spark .line { fill: none; stroke: #a78bfa; stroke-width: 1.5; }
.pulse-spark .area { fill: url(#spark-grad); opacity: .5; }
.pulse-spark rect.hit { fill: transparent; }
.pulse-spark rect.hit:hover { fill: rgba(167, 139, 250, .15); }

/* KG-Fenster */
.kg-shell { background: radial-gradient(1200px 600px at 20% -10%, rgba(56,189,248,.07), transparent 60%), #0d131f; }
.kg-stage {
  background:
    radial-gradient(circle at 1px 1px, rgba(148,163,184,.10) 1px, transparent 0) 0 0 / 22px 22px,
    radial-gradient(900px 500px at 50% 40%, rgba(56,189,248,.05), transparent 70%),
    #05070c;
}
.kg-lens-switch { display: inline-flex; padding: 2px; border-radius: .5rem; background: #05070c; border: 1px solid #1e293b; }
.kg-lens-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: .4rem; font-size: 11px; font-weight: 600; color: #94a3b8; cursor: pointer; transition: all .2s; }
.kg-lens-btn:hover { color: #fff; }
.kg-lens-btn.is-active { background: linear-gradient(135deg, rgba(56,189,248,.25), rgba(167,139,250,.2)); color: #fff; box-shadow: 0 0 12px -4px #38bdf8; }
.kg-chip { padding: .1rem .6rem; border-radius: 999px; font-size: 11px; font-weight: 500; color: #94a3b8; background: #121a2b; border: 1px solid rgba(30,41,59,.6); cursor: pointer; transition: all .15s; }
.kg-chip:hover { color: #fff; }
.kg-chip.is-active { background: #38bdf8; color: #000; border-color: #38bdf8; }
.kg-chip.is-focus { background: rgba(167,139,250,.15); color: #ddd6fe; border-color: rgba(167,139,250,.5); display: inline-flex; align-items: center; gap: .35rem; }
.kg-zoom-btn { width: 28px; height: 28px; border-radius: .4rem; background: rgba(13,19,31,.85); border: 1px solid #1e293b; color: #94a3b8; font-size: 11px; cursor: pointer; }
.kg-zoom-btn:hover { color: #38bdf8; border-color: rgba(56,189,248,.5); }
.kg-tooltip {
  position: absolute; pointer-events: none; z-index: 10; max-width: 260px;
  padding: .45rem .6rem; border-radius: .5rem; font-size: 11px; color: #e2e8f0;
  background: rgba(9, 13, 22, .95); border: 1px solid color-mix(in srgb, var(--st, #38bdf8) 50%, #1e293b);
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 16px -8px var(--st, #38bdf8);
}
.kg-legend {
  position: absolute; left: .5rem; bottom: .5rem; display: flex; flex-wrap: wrap; gap: .35rem .6rem; max-width: calc(100% - 1rem);
  padding: .35rem .55rem; border-radius: .5rem; font-size: 10px; color: #94a3b8;
  background: rgba(9, 13, 22, .8); border: 1px solid #1e293b; backdrop-filter: blur(6px);
}
.kg-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.kg-legend .ln { width: 18px; height: 0; border-top: 2px solid var(--st); }
.kg-legend .ln.dash { border-top-style: dashed; }
.kg-legend .ln.dot { border-top: 2px dotted #475569; }
.kg-drawer { animation: kg-drawer-in .25s ease-out; }
@keyframes kg-drawer-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.kg-section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin-bottom: .35rem; }
.kg-rel { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem .45rem; border-radius: .35rem; background: #05070c; border: 1px solid rgba(30,41,59,.7); cursor: pointer; font-size: 10.5px; }
.kg-rel:hover { border-color: rgba(56,189,248,.45); }
.kg-kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .75rem; font-size: 10.5px; }
.kg-kv dt { color: #64748b; }
.kg-kv dd { color: #e2e8f0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.kg-action { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .55rem; border-radius: .4rem; font-size: 11px; color: #e2e8f0; background: #05070c; border: 1px solid #1e293b; cursor: pointer; transition: all .15s; }
.kg-action:hover { border-color: rgba(56,189,248,.5); background: rgba(56,189,248,.06); }

/* Begründung: jede gelbe/rote/blaue Markierung erklärt sich selbst */
.kg-why {
  position: relative; padding: .55rem .65rem .55rem .8rem; border-radius: .5rem; font-size: 11px; line-height: 1.45; color: #e2e8f0;
  background: linear-gradient(135deg, var(--st-bg), rgba(5,7,12,.6) 70%);
  border: 1px solid color-mix(in srgb, var(--st) 40%, #1e293b);
  box-shadow: 0 0 20px -10px var(--st);
}
.kg-why::before { content: ""; position: absolute; left: 0; top: .45rem; bottom: .45rem; width: 3px; border-radius: 3px; background: var(--st); box-shadow: 0 0 8px var(--st); }
.kg-why .why-title { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--st); margin-bottom: .2rem; }
.kg-checks { display: grid; gap: .2rem; }
.kg-check { display: grid; grid-template-columns: 7px auto 1fr; align-items: baseline; gap: .45rem; padding: .25rem .4rem; border-radius: .35rem; background: #05070c; border: 1px solid rgba(30,41,59,.7); font-size: 10.5px; }
.kg-check .pulse-dot { width: 6px; height: 6px; transform: translateY(-1px); }
.kg-check .lbl { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #cbd5e1; white-space: nowrap; }
.kg-check .det { color: #94a3b8; text-align: right; }
.kg-check[data-status="warn"], .kg-check[data-status="error"] { border-color: color-mix(in srgb, var(--st) 40%, #1e293b); }
.kg-check[data-status="warn"] .det, .kg-check[data-status="error"] .det { color: #f1f5f9; }
.kg-rel .why { display: block; font-size: 9.5px; color: color-mix(in srgb, var(--st) 70%, #cbd5e1); margin-top: .1rem; white-space: normal; }

/* Hardware-Rack im Widget: ein Segment je Gerät, gruppiert nach Ebene */
.pulse-rack { display: grid; gap: .2rem; }
.pulse-rack .tier { display: flex; align-items: center; gap: .3rem; }
.pulse-rack .tier-label { width: 44px; flex-shrink: 0; font: 600 8.5px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .06em; color: #475569; }
.pulse-rack .units { display: flex; flex-wrap: wrap; gap: 3px; }
.pulse-rack button {
  display: inline-flex; align-items: center; gap: .2rem; height: 16px; padding: 0 .3rem; border-radius: 3px; cursor: pointer;
  font-size: 9px; color: #cbd5e1; background: var(--st-bg);
  border: 1px solid color-mix(in srgb, var(--st) 35%, transparent);
  box-shadow: inset 2px 0 0 var(--st);
  transition: transform .15s, border-color .2s;
}
.pulse-rack button:hover { border-color: var(--st); transform: translateY(-1px); }
.pulse-rack button[data-status="error"] { animation: pulse-glow .9s ease-in-out infinite; }
.pulse-warnline { display: flex; align-items: flex-start; gap: .3rem; color: #fcd34d; cursor: pointer; }
.pulse-warnline:hover { color: #fde68a; }

@media (prefers-reduced-motion: reduce) {
  .pulse-ecg path, .pulse-card-icon, .pulse-dot, .pulse-rack button { animation: none !important; }
}
@media (max-width: 640px) {
  .kg-legend { font-size: 9px; gap: .2rem .45rem; padding: .25rem .4rem; }
  .kg-legend .text-slate-500 { display: none; }
}

/* ------------------------------------------------------------------------
   Phase 11 · Jarvis-Autopilot — Budget-Balken je Engine, Schalter, Verlauf
   Segmente: andere (Daniel & Agenten) · Autopilot · noch frei für Autopilot;
   Marker: Autopilot-Anteil (gestrichelt) und Reserve-Grenze (rot).
   ------------------------------------------------------------------------ */
.autopilot-card .pulse-card-icon { animation-duration: 2.4s; }
.autopilot-card[data-status="unknown"] .pulse-card-icon { animation: none; opacity: .6; }
.ap-btn {
  width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 6px; font-size: 9px;
  color: #cbd5e1; background: rgba(5, 7, 12, .6); border: 1px solid #1e293b; cursor: pointer; transition: all .2s;
}
.ap-btn:hover { color: #fff; border-color: #818cf8; box-shadow: 0 0 10px -3px #818cf8; }
.ap-btn:disabled { opacity: .4; cursor: wait; }
.ap-switch { position: relative; width: 30px; height: 16px; cursor: pointer; }
.ap-switch input { position: absolute; opacity: 0; inset: 0; }
.ap-switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #1e293b; border: 1px solid #334155; transition: all .25s;
}
.ap-switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 999px;
  background: #64748b; transition: all .25s;
}
.ap-switch input:checked + span { background: linear-gradient(90deg, #6366f1, #22d3ee); border-color: transparent; box-shadow: 0 0 12px -2px #6366f1; }
.ap-switch input:checked + span::after { left: 16px; background: #fff; }
.ap-switch input:focus-visible + span { outline: 2px solid #818cf8; outline-offset: 2px; }

.ap-now {
  display: flex; gap: .45rem; align-items: flex-start; padding: .35rem .45rem; border-radius: .45rem;
  background: rgba(5, 7, 12, .6); border: 1px solid color-mix(in srgb, var(--st) 35%, #1e293b);
}
.ap-now .ap-now-icon { color: var(--st); margin-top: 1px; }
.ap-now[data-status="ok"] .ap-now-icon { animation: pulse-beat 1.2s ease-in-out infinite; }
.ap-now a { color: #a5b4fc; text-decoration: underline dotted; cursor: pointer; }

.ap-budget { cursor: default; }
.ap-track {
  position: relative; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 2px;
  background: repeating-linear-gradient(135deg, #0f172a 0 4px, #111a2c 4px 8px); border: 1px solid #1e293b;
}
.ap-track > .seg { position: absolute; top: 0; bottom: 0; }
.ap-track > .seg.others { background: #475569; }
.ap-track > .seg.mine { background: linear-gradient(90deg, #6366f1, #22d3ee); box-shadow: 0 0 8px #6366f1; }
.ap-track > .seg.free { background: rgba(99, 102, 241, .22); border-right: 1px solid rgba(165, 180, 252, .6); }
.ap-track > .mark { position: absolute; top: -1px; bottom: -1px; width: 0; border-left: 1px dashed #a5b4fc; }
.ap-track > .mark.reserve { border-left: 2px solid #fb7185; }
.ap-budget[data-ok="false"] .ap-track > .seg.free { display: none; }
.ap-legend { display: flex; gap: .6rem; font-size: 9px; color: #64748b; }
.ap-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }

.ap-hist { display: flex; align-items: center; gap: .35rem; padding: .15rem .3rem; border-radius: .3rem; cursor: pointer; color: #94a3b8; }
.ap-hist:hover { background: rgba(99, 102, 241, .1); color: #e2e8f0; }
.ap-hist .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-hist .n { font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; color: #64748b; }

.ap-settings { padding: .45rem; border-radius: .45rem; background: rgba(5, 7, 12, .7); border: 1px solid #312e81; }
.ap-settings label { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: #94a3b8; }
.ap-settings input[type="number"], .ap-settings input[type="text"] {
  width: 5.5rem; background: #05070c; border: 1px solid #1e293b; border-radius: .3rem; padding: .1rem .3rem; color: #fff; text-align: right;
}
.ap-settings input[type="range"] { flex: 1; accent-color: #818cf8; max-width: 7rem; }

.kanban-ap-chip {
  display: inline-flex; align-items: center; gap: .2rem; padding: 0 .35rem; border-radius: 999px; font-size: 9px; font-weight: 600;
  color: #e0e7ff; background: rgba(99, 102, 241, .18); border: 1px solid rgba(129, 140, 248, .45);
}
.kanban-ap-chip[data-ap="running"] { animation: pulse-glow 1.4s ease-in-out infinite; --st: #818cf8; }
.kanban-ap-chip[data-ap="waiting"], .kanban-ap-chip[data-ap="failed"] { color: #fde68a; background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .45); }
.kanban-ap-chip[data-ap="review"] { color: #a7f3d0; background: rgba(52, 211, 153, .14); border-color: rgba(52, 211, 153, .45); }
