:root {
  --bg-0: #05060d;
  --bg-1: #0a0f1f;
  --glass: rgba(20, 28, 48, 0.45);
  --glass-2: rgba(30, 40, 66, 0.35);
  --stroke: rgba(120, 170, 255, 0.16);
  --stroke-hi: rgba(120, 200, 255, 0.5);
  --cyan: #45e0ff;
  --blue: #4d7cff;
  --violet: #9b6bff;
  --gold: #ffd27a;
  --text: #e7f1ff;
  --muted: #8ea3c8;
  --danger: #ff6b81;
  --ok: #5cffb0;
  --grad: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--violet));
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Animierter Aurora-Hintergrund */
body::before, body::after {
  content: ""; position: fixed; z-index: 0; pointer-events: none;
  width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.5;
}
body::before {
  background: radial-gradient(circle, var(--blue), transparent 60%);
  top: -25vmax; left: -15vmax; animation: drift1 22s ease-in-out infinite alternate;
}
body::after {
  background: radial-gradient(circle, var(--violet), transparent 60%);
  bottom: -25vmax; right: -15vmax; animation: drift2 26s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(12vmax, 10vmax) scale(1.2); } }
@keyframes drift2 { to { transform: translate(-12vmax, -8vmax) scale(1.15); } }

#bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120,170,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,170,255,0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at center, #000 25%, transparent 78%);
}

/* Topbar */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 28px;
}
.logo {
  font-weight: 800; letter-spacing: 6px; font-size: 20px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(77, 124, 255, 0.4));
}
.subtitle { color: var(--muted); font-size: 12px; letter-spacing: 0.5px; }
.mode-select {
  margin-left: auto; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--glass); color: var(--cyan); border: 1px solid var(--stroke-hi);
  border-radius: 999px; padding: 8px 14px; outline: none; backdrop-filter: blur(14px);
}
.mode-select option { background: #0a0f1f; color: var(--text); }

.status-pill {
  font-size: 12px; padding: 8px 16px; font-weight: 500;
  border: 1px solid var(--stroke); border-radius: 999px; color: var(--gold);
  background: var(--glass); backdrop-filter: blur(14px);
  display: inline-flex; align-items: center; gap: 8px;
}
.status-pill::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: blink 2s infinite;
}
@keyframes blink { 50% { opacity: 0.3; } }

/* Layout */
.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 300px 1fr 300px; gap: 18px;
  padding: 6px 28px 28px; height: calc(100% - 74px);
}

.panel.side {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 22px; overflow-y: auto;
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
}
.panel h2 {
  font-size: 11px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--muted); margin: 0 0 14px; font-weight: 700;
}

.center { display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 0; }

/* Reaktor / Orb */
.reactor {
  position: relative; width: 200px; height: 200px; margin: 6px 0 2px;
  display: flex; align-items: center; justify-content: center;
}
.ring { position: absolute; border-radius: 50%; border: 1.5px solid; }
.r1 { width: 200px; height: 200px; border-color: rgba(69,224,255,0.35); border-style: dashed; animation: spin 20s linear infinite; }
.r2 { width: 150px; height: 150px; border-color: rgba(155,107,255,0.4); animation: spin 13s linear infinite reverse; }
.r3 { width: 102px; height: 102px; border-color: transparent; border-top-color: var(--gold); border-right-color: var(--cyan); animation: spin 7s linear infinite; }
.core {
  width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, var(--cyan) 35%, var(--blue) 70%, var(--violet) 100%);
  box-shadow: 0 0 40px rgba(69,224,255,0.7), 0 0 90px rgba(77,124,255,0.5), inset 0 0 20px rgba(255,255,255,0.4);
  animation: breathe 4s ease-in-out infinite;
}
.reactor.thinking .core { animation: breathe 0.9s ease-in-out infinite; }
.reactor.thinking .r3 { animation-duration: 2.5s; }
.reactor.listening .core { background: radial-gradient(circle at 35% 30%, #fff, var(--gold) 40%, #ff9e45 100%); box-shadow: 0 0 50px rgba(255,210,122,0.8), 0 0 100px rgba(255,158,69,0.5); }
.reactor.listening .ring { border-color: rgba(255,210,122,0.5); }
#wave { position: absolute; bottom: -64px; width: 320px; height: 78px; opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

.status-line {
  margin-top: 74px; font-size: 13px; color: var(--muted);
  letter-spacing: 0.5px; height: 18px; font-weight: 500;
}

/* Chat */
.chat {
  flex: 1 1 0; min-height: 0; width: 100%; max-width: 740px; margin: 14px 0;
  overflow-y: auto; overscroll-behavior: contain; padding: 6px 4px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg {
  max-width: 82%; padding: 13px 17px; border-radius: 18px; line-height: 1.55;
  font-size: 14.5px; white-space: pre-wrap;
  animation: rise 0.35s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.msg.user {
  align-self: flex-end; color: #06101f;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-bottom-right-radius: 6px;
}
.msg.jarvis {
  align-self: flex-start;
  background: var(--glass-2); border: 1px solid var(--stroke);
  backdrop-filter: blur(10px); border-bottom-left-radius: 6px;
}
.msg .who { display: block; font-size: 10px; letter-spacing: 1.5px; opacity: 0.65; margin-bottom: 5px; text-transform: uppercase; font-weight: 700; }

/* Eingabe */
.input-bar {
  width: 100%; max-width: 740px; display: flex; gap: 10px; padding: 8px;
  background: var(--glass); border: 1px solid var(--stroke);
  border-radius: 999px; backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
.input-bar input {
  flex: 1; background: transparent; border: none;
  color: var(--text); padding: 10px 16px; font-size: 15px; outline: none;
}
.input-bar input::placeholder { color: var(--muted); }

.btn {
  background: var(--grad); border: none; color: #06101f; font-weight: 700;
  border-radius: 999px; padding: 11px 22px; cursor: pointer; font-size: 14px;
  transition: transform 0.12s, box-shadow 0.2s; box-shadow: 0 6px 18px rgba(77,124,255,0.4);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(77,124,255,0.55); }
.btn:active { transform: translateY(0); }
.btn.small { padding: 9px 14px; }
.btn.mic {
  background: var(--glass-2); color: var(--cyan); border: 1px solid var(--stroke);
  font-size: 18px; box-shadow: none; padding: 11px 15px;
}
.btn.mic.active { background: var(--gold); color: #06101f; animation: micpulse 1.2s infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,210,122,0.6);} 50% { box-shadow: 0 0 0 12px rgba(255,210,122,0);} }

/* Aufgaben */
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-row input {
  flex: 1; background: var(--glass-2); border: 1px solid var(--stroke);
  border-radius: 12px; color: var(--text); padding: 10px 12px; outline: none; font-size: 14px;
}
.add-row input:focus { border-color: var(--stroke-hi); }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-list li {
  display: flex; align-items: center; gap: 10px; font-size: 14px;
  padding: 11px 13px; background: var(--glass-2); border: 1px solid var(--stroke);
  border-radius: 12px; transition: 0.15s; animation: rise 0.3s;
}
.task-list li:hover { border-color: var(--stroke-hi); }
.task-list li.done span { text-decoration: line-through; opacity: 0.45; }
.task-list li span { flex: 1; cursor: pointer; }
.task-list li .del { cursor: pointer; color: var(--danger); opacity: 0.6; font-size: 13px; }
.task-list li .del:hover { opacity: 1; }

.notes {
  width: 100%; min-height: 130px; resize: vertical;
  background: var(--glass-2); border: 1px solid var(--stroke);
  border-radius: 12px; color: var(--text); padding: 12px; outline: none;
  font-family: inherit; font-size: 14px; line-height: 1.5;
}
.notes:focus { border-color: var(--stroke-hi); }

/* Skills */
.skill-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  margin-bottom: 10px; background: var(--glass-2); border: 1px solid var(--stroke);
  color: var(--text); border-radius: 14px; padding: 13px 15px; cursor: pointer;
  transition: 0.18s; font-size: 14px; font-weight: 500;
}
.skill-btn:hover {
  border-color: var(--stroke-hi); transform: translateX(3px);
  background: linear-gradient(135deg, rgba(69,224,255,0.12), rgba(155,107,255,0.12));
}

.setting { display: flex; align-items: center; gap: 10px; font-size: 13.5px; margin-bottom: 12px; color: var(--text); cursor: pointer; }
.setting input { accent-color: var(--cyan); width: 16px; height: 16px; }

/* Overlays (Karte / Dokument) */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 6, 13, 0.72); backdrop-filter: blur(8px);
  animation: rise 0.25s;
}
.overlay.hidden { display: none; }
.overlay-card {
  width: min(880px, 92vw); height: min(620px, 86vh);
  background: var(--glass); border: 1px solid var(--stroke-hi);
  border-radius: var(--radius); box-shadow: var(--shadow), 0 0 60px rgba(69,224,255,0.25);
  display: flex; flex-direction: column; overflow: hidden;
}
.overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--stroke);
  font-weight: 700; letter-spacing: 0.5px; color: var(--cyan);
}
.overlay-head > div { display: flex; gap: 10px; align-items: center; }
.overlay-close {
  background: transparent; border: 1px solid var(--stroke); color: var(--text);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.overlay-close:hover { border-color: var(--danger); color: var(--danger); }

/* Neon-Karte */
#map { flex: 1; width: 100%; background: #05060d; }
#map.leaflet-container { font-family: inherit; }
.map-card #map .leaflet-tile-pane {
  filter: hue-rotate(190deg) saturate(1.6) brightness(1.05) contrast(1.1);
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(10,22,40,0.95); color: var(--text);
  border: 1px solid var(--stroke-hi); box-shadow: 0 0 20px rgba(69,224,255,0.4);
}
.leaflet-popup-content { font-size: 13px; }
.leaflet-control-zoom a {
  background: var(--glass-2) !important; color: var(--cyan) !important;
  border: 1px solid var(--stroke) !important;
}

/* Dokument */
.doc-body {
  flex: 1; width: 100%; resize: none; border: none; outline: none;
  background: rgba(0,0,0,0.25); color: var(--text);
  padding: 22px 26px; font-size: 15px; line-height: 1.7; font-family: inherit;
}

/* Eingabe-Dialog (ask) */
.ask-card { width: min(460px, 92vw); height: auto; }
.ask-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.ask-body input {
  width: 100%; background: var(--glass-2); border: 1px solid var(--stroke-hi);
  border-radius: 12px; color: var(--text); padding: 13px 15px; font-size: 15px; outline: none;
}
.ask-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Code-Ansicht */
.code-body {
  flex: 1; margin: 0; overflow: auto; min-height: 0;
  background: #060a14; padding: 18px 22px;
  border-left: 3px solid var(--cyan);
}
.code-body code {
  font-family: "JetBrains Mono", "Consolas", "Courier New", monospace;
  font-size: 13.5px; line-height: 1.65; color: #d6f3ff;
  white-space: pre; tab-size: 2;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: linear-gradient(var(--blue), var(--violet)); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; height: auto; overflow-y: auto; }
  body { overflow-y: auto; }
  .panel.side { order: 2; }
  .center { order: 1; }
}
