:root {
  --bg-0: #04070d;
  --bg-1: #060a14;
  --bg-2: #0a1120;
  --accent-1: #ff8c00;
  --accent-2: #ffd700;
  --accent-glow: rgba(255, 160, 0, 0.55);
  --text-0: #eef2f8;
  --text-1: #9db0c9;
  --danger: #ff5555;
  --panel-border: rgba(255, 180, 60, 0.18);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(ellipse at 50% 20%, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text-0);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- Login screen ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, var(--bg-2) 0%, var(--bg-0) 100%);
  z-index: 50;
}

.login-card {
  width: min(360px, 90vw);
  padding: 40px 32px;
  border-radius: 20px;
  background: rgba(10, 16, 30, 0.7);
  border: 1px solid var(--panel-border);
  text-align: center;
  box-shadow: 0 0 60px rgba(255, 150, 0, 0.08);
}

.login-orb {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent-1) 60%, transparent 75%);
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px var(--accent-glow);
  animation: pulse-idle 3.2s ease-in-out infinite;
}

.login-card h1 {
  margin: 0 0 4px;
  letter-spacing: 0.3em;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-sub { color: var(--text-1); margin: 0 0 24px; font-size: 0.9rem; }

#login-form { display: flex; flex-direction: column; gap: 12px; }

#login-password {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-0);
  font-size: 1rem;
}

#login-form button {
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  color: #14100a;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
}

.login-error {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 14px;
}

/* ---------- App shell ---------- */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(6, 10, 20, 0.6);
  backdrop-filter: blur(8px);
}

.brand {
  font-weight: 800;
  letter-spacing: 0.35em;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  font-size: 0.8rem;
  color: var(--text-1);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-1);
  box-shadow: 0 0 8px var(--accent-glow);
}

.ghost-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-1);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}
.ghost-btn:hover { color: var(--text-0); border-color: var(--accent-1); }

.main-area {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* ---------- Core Orb ---------- */
.core-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 18px;
}

.core {
  position: relative;
  width: 260px;
  height: 260px;
}

/* Outermost faint holographic shell — very slow, adds depth behind the rings */
.core-shell {
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 205, 90, 0.28);
  box-shadow: 0 0 24px rgba(255, 160, 0, 0.12) inset;
  animation: spin-rev 42s linear infinite;
  will-change: transform;
}

.core-center {
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6d8, var(--accent-2) 40%, var(--accent-1) 75%);
  box-shadow: 0 0 30px var(--accent-glow);
  animation: pulse-core 3.6s ease-in-out infinite;
  will-change: transform;
}

.core-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
  filter: blur(18px);
  opacity: 0.7;
  animation: pulse-glow 3.6s ease-in-out infinite;
  will-change: transform, opacity;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent-2);
  border-right-color: var(--accent-1);
  filter: drop-shadow(0 0 6px var(--accent-glow));
  will-change: transform;
}

/* Four concentric ring layers, alternating rotation direction and border
   style, so each ring reads as a distinct depth plane (parallax feel)
   instead of one flat gradient sphere. */
.ring-1 { inset: 0; animation: spin 9s linear infinite; opacity: 0.9; }
.ring-2 {
  inset: 14%;
  animation: spin-rev 7s linear infinite;
  opacity: 0.75;
  border-style: dashed;
  border-top-color: var(--accent-1);
  border-right-color: var(--accent-2);
}
.ring-3 { inset: 26%; animation: spin 5s linear infinite; opacity: 0.6; border-bottom-color: var(--accent-1); border-left-color: transparent; }
.ring-4 {
  inset: 34%;
  animation: spin-rev 11s linear infinite;
  opacity: 0.5;
  border: 1px dotted var(--accent-2);
  border-top-color: var(--accent-2);
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes spin-rev { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }

/* Continuous breathing pulse on the core itself — always active, not tied
   to a state, per Julian's request. Transform-only (no box-shadow) so this
   stays on the GPU compositor instead of triggering a repaint every frame;
   the "stronger glow at peak" impression comes from .core-glow's own
   opacity/scale animation (pulse-glow), which is already synced to the
   same 3.6s cycle and peaks in lockstep with this scale-up. */
@keyframes pulse-core {
  0%, 100% { transform: scale(0.95); }
  50% { transform: scale(1.05); }
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; transform: scale(0.97); }
  50% { opacity: 0.88; transform: scale(1.1); }
}
@keyframes pulse-idle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---------- Particles ---------- */
/* Each .particle-orbit is a full-size absolutely-positioned wrapper that
   rotates (transform only — cheap on mobile GPUs); the dot inside is
   offset from center via translateX(var(--radius)), so rotating the
   wrapper makes the dot sweep a circle without any per-frame layout work.
   Radius/duration/direction/delay are randomized per-particle in app.js
   and passed in as inline custom properties. */
.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.particle-orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation-name: spin;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-duration: var(--orbit-duration, 12s);
  animation-direction: var(--orbit-direction, normal);
  will-change: transform;
}

.particle-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 6px 1px var(--accent-glow);
  transform: translate(-50%, -50%) translateX(var(--radius, 100px));
  animation: twinkle 3.2s ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
  will-change: transform, opacity;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: translate(-50%, -50%) translateX(var(--radius, 100px)) scale(0.7); }
  50% { opacity: 1; transform: translate(-50%, -50%) translateX(var(--radius, 100px)) scale(1.3); }
}

/* State: idle (default, slow) — uses base animation speeds above */
.core-idle .ring-1 { animation-duration: 9s; }
.core-idle .ring-2 { animation-duration: 7s; }
.core-idle .ring-3 { animation-duration: 5s; }
.core-idle .ring-4 { animation-duration: 11s; }

/* State: listening — faster, tighter pulses, cooler edge highlight */
.core-listening .ring-1 { animation-duration: 3.2s; }
.core-listening .ring-2 { animation-duration: 2.4s; }
.core-listening .ring-3 { animation-duration: 1.8s; }
.core-listening .ring-4 { animation-duration: 4.2s; }
.core-listening .core-shell { animation-duration: 18s; }
.core-listening .core-center { animation-duration: 1.6s; }
.core-listening .core-glow { animation-duration: 1.8s; opacity: 0.9; }
.core-listening .particles { filter: brightness(1.2) hue-rotate(-8deg); }

/* State: speaking — fastest, most intense */
.core-speaking .ring-1 { animation-duration: 1.6s; }
.core-speaking .ring-2 { animation-duration: 1.2s; }
.core-speaking .ring-3 { animation-duration: 0.9s; }
.core-speaking .ring-4 { animation-duration: 2s; }
.core-speaking .core-shell { animation-duration: 9s; }
.core-speaking .core-center { animation-duration: 0.9s; }
.core-speaking .core-glow { animation-duration: 0.7s; opacity: 1; }
.core-speaking .particles { filter: brightness(1.5); }

.mic-warning {
  max-width: 420px;
  text-align: center;
  color: var(--danger);
  font-size: 0.85rem;
  padding: 0 20px;
}

.interim-transcript {
  min-height: 1.4em;
  max-width: 520px;
  text-align: center;
  color: var(--text-1);
  font-size: 0.95rem;
  padding: 0 20px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--panel-border);
  background: rgba(6, 10, 20, 0.55);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 0.85rem;
  color: var(--text-1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.35;
  word-wrap: break-word;
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  color: #16110a;
  border-bottom-right-radius: 4px;
}

.msg-jarvis {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-0);
  border-bottom-left-radius: 4px;
}

.msg-system {
  align-self: center;
  color: var(--danger);
  font-size: 0.78rem;
  text-align: center;
}

.text-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--panel-border);
}

#text-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-0);
}

.text-form button {
  padding: 0 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  color: #14100a;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Bottom bar / talk button ---------- */
.bottom-bar {
  display: flex;
  justify-content: center;
  padding: 22px 0 calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--panel-border);
  background: rgba(6, 10, 20, 0.6);
}

.talk-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.75rem;
  color: #17120a;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent-1) 70%);
  box-shadow: 0 0 25px var(--accent-glow), 0 0 6px rgba(255,255,255,0.15) inset;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.talk-btn:hover { transform: scale(1.04); }

.talk-btn[aria-pressed="true"] {
  background: radial-gradient(circle at 35% 30%, #ff5555, #b30000 70%);
  box-shadow: 0 0 30px rgba(255, 60, 60, 0.6);
  animation: pulse-idle 1.4s ease-in-out infinite;
}

.mobile-only { display: none; }
.sidebar-toggle-btn { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .main-area { flex-direction: column; }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    height: 55vh;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 30;
  }
  .sidebar.open { transform: translateY(0); }

  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .ghost-btn.mobile-only { margin-left: 0; }

  .sidebar-toggle-btn {
    position: fixed;
    right: 16px;
    bottom: calc(120px + env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    z-index: 25;
    font-size: 1.3rem;
    background: rgba(10, 16, 30, 0.8);
  }

  .core { width: 200px; height: 200px; }
  .topbar { padding: 10px 14px; }
  .brand { letter-spacing: 0.2em; font-size: 0.95rem; }
}

/* ---------- Settings modal (Integrationen) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.modal-card {
  width: min(480px, 92vw);
  max-height: 82vh;
  overflow-y: auto;
  padding: 24px;
  border-radius: 18px;
  background: rgba(10, 16, 30, 0.92);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 60px rgba(255, 150, 0, 0.1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: var(--text-0);
}

.integrations-list { display: flex; flex-direction: column; gap: 14px; }

.integrations-loading, .integrations-error { color: var(--text-1); font-size: 0.9rem; }
.integrations-error { color: var(--danger); }

.integration-card {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.integration-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.integration-name { font-weight: 600; color: var(--text-0); }

.integration-badge {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
}
.integration-badge.connected { color: #7CFFB2; border-color: rgba(124, 255, 178, 0.4); }
.integration-badge.disconnected { color: var(--text-1); }

.integration-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.integration-form input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-0);
  font-size: 0.9rem;
}

.integration-action {
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--accent-1);
  color: var(--accent-1);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.85rem;
}
.integration-action:hover { background: rgba(255, 140, 0, 0.12); }

.integration-error { color: var(--danger); font-size: 0.8rem; margin: 0; min-height: 1em; }
