/* aidesia Web-UI — Dark Theme */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-tertiary: #1c1f2e;
  --bg-input: #232636;
  --text-primary: #e4e4e7;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6c8aff;
  --accent-dim: #3d5afe33;
  --user-bg: #2a3154;
  --lisa-bg: #1e2235;
  --border: #2a2d3e;
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --pillar-technical: #4a9eff;
  --pillar-transversal: #4caf50;
  --pillar-language: #ff9800;
  --pillar-knowledge: #ab47bc;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh; /* iOS Safari: volle Höhe inkl. dynamischer Browser-UI */
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* === Welcome Screen === */

#welcome-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 1000;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#welcome-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.welcome-content {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
  letter-spacing: 0.05em;
}

.welcome-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
}

/* Vereinfachter, aber schöner Orb (atmet einladend) */
.welcome-orb-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-orb-halo {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(110, 160, 255, 0.4) 0%,
    rgba(80, 120, 220, 0.15) 50%,
    transparent 72%);
  -webkit-filter: blur(16px);
  filter: blur(16px);
  animation: welcomeHalo 4s ease-in-out infinite;
}

.welcome-orb-core {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%,
    #d4b4ff 0%, #a78bfa 20%, #6d5bfa 50%, #3a2d8c 80%, #1a1050 100%);
  box-shadow:
    0 0 70px rgba(167, 139, 250, 0.55),
    inset 0 0 60px rgba(109, 91, 250, 0.5);
  animation: welcomeBreathe 4s ease-in-out infinite;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* Welcome-Orb wechselt Farbe bei Persona-Wahl */
.welcome-orb-wrapper.persona-lisa .welcome-orb-core {
  background: radial-gradient(circle at 35% 28%, #d4b4ff 0%, #a78bfa 20%, #6d5bfa 50%, #3a2d8c 80%, #1a1050 100%);
  box-shadow: 0 0 70px rgba(167, 139, 250, 0.55), inset 0 0 60px rgba(109, 91, 250, 0.5);
}
.welcome-orb-wrapper.persona-jonas .welcome-orb-core {
  background: radial-gradient(circle at 35% 28%, #b4d0ff 0%, #5bc0fa 20%, #3a7bd6 50%, #1a3a6c 80%, #0d1a3c 100%);
  box-shadow: 0 0 70px rgba(91, 192, 250, 0.55), inset 0 0 60px rgba(58, 123, 214, 0.5);
}
.welcome-orb-wrapper.persona-robin .welcome-orb-core {
  background: radial-gradient(circle at 35% 28%, #b4ffd4 0%, #5bfab4 20%, #3ad68a 50%, #1a6c4a 80%, #0d3c28 100%);
  box-shadow: 0 0 70px rgba(91, 250, 180, 0.55), inset 0 0 60px rgba(58, 214, 138, 0.5);
}
.welcome-orb-wrapper.persona-lisa .welcome-orb-halo {
  background: radial-gradient(circle, rgba(167, 139, 250, 0.4) 0%, rgba(109, 91, 250, 0.15) 50%, transparent 72%);
}
.welcome-orb-wrapper.persona-jonas .welcome-orb-halo {
  background: radial-gradient(circle, rgba(91, 192, 250, 0.4) 0%, rgba(58, 123, 214, 0.15) 50%, transparent 72%);
}
.welcome-orb-wrapper.persona-robin .welcome-orb-halo {
  background: radial-gradient(circle, rgba(91, 250, 180, 0.4) 0%, rgba(58, 214, 138, 0.15) 50%, transparent 72%);
}

@keyframes welcomeBreathe {
  0%, 100% { -webkit-transform: scale(1); transform: scale(1); }
  50%      { -webkit-transform: scale(1.06); transform: scale(1.06); }
}

@keyframes welcomeHalo {
  0%, 100% { -webkit-transform: scale(1); transform: scale(1); opacity: 0.8; }
  50%      { -webkit-transform: scale(1.15); transform: scale(1.15); opacity: 1; }
}

.welcome-description {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* --- Persona-Auswahl --- */

.persona-selection { margin: 0 0 1.2rem; }

.persona-options {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.persona-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  font-family: inherit;
  min-width: 80px;
}
.persona-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(124, 154, 255, 0.3);
}
.persona-btn.selected {
  background: rgba(124, 154, 255, 0.15);
  border-color: #5b7cfa;
  color: #fff;
}

.persona-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
.persona-lisa  { background: radial-gradient(circle at 40% 40%, #a78bfa, #6d5bfa, #3a2d8c); }
.persona-jonas { background: radial-gradient(circle at 40% 40%, #5bc0fa, #3a7bd6, #1a3a6c); }
.persona-robin { background: radial-gradient(circle at 40% 40%, #5bfab4, #3ad68a, #1a6c4a); }

.persona-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.welcome-mode-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

.welcome-mode-buttons {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 440px;
  margin-bottom: 1rem;
}

.welcome-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 18px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease,
              filter 0.15s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 96px;
}

.welcome-btn-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 4px;
}

.welcome-btn-label {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.welcome-btn-sub {
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.85;
  line-height: 1.2;
}

.welcome-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #7fa5ff 0%, #5478e6 60%, #3e5bc8 100%);
  border: none;
  box-shadow:
    0 6px 22px rgba(90, 124, 250, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.welcome-btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow:
    0 8px 28px rgba(90, 124, 250, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.welcome-btn-primary:active {
  transform: translateY(1px);
  filter: brightness(0.95);
}

.welcome-btn-secondary {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.welcome-btn-secondary:hover {
  background: var(--bg-input);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.welcome-btn-secondary:active {
  transform: translateY(1px);
}

.welcome-btn:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

.welcome-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .welcome-title { font-size: 2rem; }
  .welcome-subtitle { font-size: 0.95rem; margin-bottom: 2rem; }
  .welcome-orb-wrapper { width: 140px; height: 140px; }
  .welcome-orb-core { width: 120px; height: 120px; }
  .welcome-description { font-size: 0.95rem; margin-bottom: 1.5rem; }
  .welcome-mode-buttons { flex-direction: column; gap: 10px; }
  .welcome-btn { min-height: 72px; padding: 14px; }
  .welcome-btn-icon { font-size: 1.4rem; }
}

/* === Themen-Einstiegskarten (im Chat, nach Begruessung) === */

.topic-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 16px 16px;
  max-width: 520px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.topic-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  color: var(--text-secondary);
  font-family: inherit;
}
.topic-card:hover {
  background: rgba(124, 154, 255, 0.1);
  border-color: rgba(124, 154, 255, 0.3);
}

.topic-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; }
.topic-text { display: flex; flex-direction: column; gap: 2px; }
.topic-text strong { font-size: 0.85rem; color: var(--text-primary); }
.topic-text span { font-size: 0.75rem; color: var(--text-muted); }

@media (max-width: 480px) {
  .topic-cards { grid-template-columns: 1fr; max-width: 100%; }
}

/* === Layout === */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* iOS Safari: korrekte Höhe mit dynamischer Browser-UI */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 12px;
}

.header-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.header-hint.recording {
  color: var(--error);
  font-style: normal;
  font-weight: 500;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* === Chat Panel === */

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* === Lisa Orb (ChatGPT-Voice-Style, Safari-kompatibel) ===
 * Innere Layer sind selbst runde Kreise (kleiner als der Orb)
 * → Kein overflow:hidden, kein mix-blend-mode → rendert überall zuverlässig.
 */

.orb-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 0 20px;
  flex-shrink: 0;
}

.orb {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Äußeres weiches Glow-Feld */
.orb-halo {
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(110, 160, 255, 0.35) 0%,
    rgba(80, 120, 220, 0.18) 40%,
    transparent 72%
  );
  -webkit-filter: blur(16px);
  filter: blur(16px);
  opacity: 0.85;
  animation: orbHalo 7s ease-in-out infinite;
}

@keyframes orbHalo {
  0%, 100% { -webkit-transform: scale(1); transform: scale(1); opacity: 0.75; }
  50%      { -webkit-transform: scale(1.1); transform: scale(1.1); opacity: 1; }
}

/* Haupt-Sphäre (bleibt immer perfekt rund) */
.orb-core {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 28%,
    #b4d0ff 0%,
    #7fa5ff 18%,
    #5478e6 45%,
    #2d4099 75%,
    #14205c 100%
  );
  box-shadow:
    0 0 70px rgba(110, 160, 255, 0.5),
    inset 0 0 60px rgba(40, 70, 180, 0.45),
    inset 0 0 120px rgba(20, 35, 90, 0.6);
  animation: orbBreathe 6s ease-in-out infinite;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* --- Persona-Orb-Farbvarianten --- */
.orb-container.persona-lisa .orb-core {
  background: radial-gradient(circle at 35% 28%, #d4b4ff 0%, #a78bfa 18%, #6d5bfa 45%, #3a2d8c 75%, #1a1050 100%);
  box-shadow: 0 0 70px rgba(167, 139, 250, 0.5), inset 0 0 60px rgba(109, 91, 250, 0.45), inset 0 0 120px rgba(58, 45, 140, 0.6);
}
.orb-container.persona-jonas .orb-core {
  background: radial-gradient(circle at 35% 28%, #b4d0ff 0%, #5bc0fa 18%, #3a7bd6 45%, #1a3a6c 75%, #0d1a3c 100%);
  box-shadow: 0 0 70px rgba(91, 192, 250, 0.5), inset 0 0 60px rgba(58, 123, 214, 0.45), inset 0 0 120px rgba(26, 58, 108, 0.6);
}
.orb-container.persona-robin .orb-core {
  background: radial-gradient(circle at 35% 28%, #b4ffd4 0%, #5bfab4 18%, #3ad68a 45%, #1a6c4a 75%, #0d3c28 100%);
  box-shadow: 0 0 70px rgba(91, 250, 180, 0.5), inset 0 0 60px rgba(58, 214, 138, 0.45), inset 0 0 120px rgba(26, 108, 74, 0.6);
}

/* Innere Farb-Layer: selbst runde Kreise, kleiner als Core -- kein Clipping noetig */
.orb-layer {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.layer-1 {
  top: 10%; left: 10%;
  width: 80%; height: 80%;
  background: conic-gradient(
    from 0deg,
    rgba(130, 180, 255, 0.8),
    rgba(90, 140, 240, 0.5),
    rgba(150, 200, 255, 0.9),
    rgba(80, 130, 220, 0.4),
    rgba(110, 170, 255, 0.8),
    rgba(70, 120, 210, 0.5),
    rgba(130, 180, 255, 0.8)
  );
  opacity: 0.7;
  -webkit-filter: blur(10px);
  filter: blur(10px);
  animation: orbRotate 14s linear infinite;
}

.layer-2 {
  top: 20%; left: 20%;
  width: 60%; height: 60%;
  background: conic-gradient(
    from 90deg,
    rgba(120, 210, 255, 0.7),
    rgba(130, 110, 240, 0.5),
    rgba(80, 150, 240, 0.8),
    rgba(140, 190, 255, 0.6),
    rgba(90, 130, 230, 0.5),
    rgba(120, 210, 255, 0.7)
  );
  opacity: 0.6;
  -webkit-filter: blur(8px);
  filter: blur(8px);
  animation: orbRotateReverse 18s linear infinite;
}

.layer-3 {
  top: 25%; left: 25%;
  width: 50%; height: 50%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(180, 215, 255, 0.8) 0%,
    rgba(110, 160, 240, 0.4) 40%,
    transparent 75%
  );
  opacity: 0.7;
  -webkit-filter: blur(6px);
  filter: blur(6px);
  animation: orbSwirl 9s ease-in-out infinite;
}

/* Glanzlicht oben links (Glaskugel-Effekt) */
.orb-highlight {
  position: absolute;
  top: 14%;
  left: 20%;
  width: 38%;
  height: 32%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.15) 45%,
    transparent 75%
  );
  -webkit-filter: blur(3px);
  filter: blur(3px);
  pointer-events: none;
  animation: orbHighlight 8s ease-in-out infinite;
}

/* === Keyframes (alle transform-basiert, Safari-freundlich) === */

@keyframes orbBreathe {
  0%, 100% { -webkit-transform: scale(1); transform: scale(1); }
  50%      { -webkit-transform: scale(1.04); transform: scale(1.04); }
}

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

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

@keyframes orbSwirl {
  0%, 100% { -webkit-transform: translate(0, 0) scale(1); transform: translate(0, 0) scale(1); }
  33%      { -webkit-transform: translate(15%, -8%) scale(1.15); transform: translate(15%, -8%) scale(1.15); }
  66%      { -webkit-transform: translate(-10%, 10%) scale(0.9); transform: translate(-10%, 10%) scale(0.9); }
}

@keyframes orbHighlight {
  0%, 100% { -webkit-transform: translate(0, 0) scale(1); transform: translate(0, 0) scale(1); opacity: 0.9; }
  50%      { -webkit-transform: translate(8%, 5%) scale(1.15); transform: translate(8%, 5%) scale(1.15); opacity: 1; }
}

/* === Listening: kräftigerer Glow, schnellere Farbrotation === */
.orb.listening .orb-halo {
  background: radial-gradient(
    circle,
    rgba(140, 185, 255, 0.5) 0%,
    rgba(100, 150, 240, 0.25) 40%,
    transparent 72%
  );
  opacity: 1;
  animation-duration: 3s;
}

.orb.listening .orb-core {
  box-shadow:
    0 0 90px rgba(130, 180, 255, 0.7),
    inset 0 0 70px rgba(60, 100, 220, 0.5),
    inset 0 0 130px rgba(30, 50, 130, 0.7);
  animation-duration: 3s;
}

.orb.listening .layer-1 { animation-duration: 7s; opacity: 0.85; }
.orb.listening .layer-2 { animation-duration: 9s; opacity: 0.75; }
.orb.listening .layer-3 { animation-duration: 4s; opacity: 0.85; }

/* === Speaking: pulsierender Morph via Scale, hellere Blautöne === */
.orb.speaking .orb-halo {
  background: radial-gradient(
    circle,
    rgba(180, 215, 255, 0.65) 0%,
    rgba(130, 170, 250, 0.35) 40%,
    transparent 72%
  );
  opacity: 1;
  animation-duration: 1.5s;
}

.orb.speaking .orb-core {
  box-shadow:
    0 0 120px rgba(150, 200, 255, 0.9),
    inset 0 0 80px rgba(100, 150, 240, 0.55),
    inset 0 0 140px rgba(50, 80, 180, 0.7);
  -webkit-filter: brightness(1.2) saturate(1.2);
  filter: brightness(1.2) saturate(1.2);
  animation: orbSpeak 1.2s ease-in-out infinite;
}

.orb.speaking .layer-1 { animation-duration: 4s; opacity: 1; }
.orb.speaking .layer-2 { animation-duration: 5s; opacity: 0.9; }
.orb.speaking .layer-3 { animation-duration: 2s; opacity: 1; }

@keyframes orbSpeak {
  0%   { -webkit-transform: scale(1);    transform: scale(1); }
  20%  { -webkit-transform: scale(1.1);  transform: scale(1.1); }
  40%  { -webkit-transform: scale(1.03); transform: scale(1.03); }
  60%  { -webkit-transform: scale(1.12); transform: scale(1.12); }
  80%  { -webkit-transform: scale(1.05); transform: scale(1.05); }
  100% { -webkit-transform: scale(1);    transform: scale(1); }
}

/* === Processing: langsamer, tiefer Puls === */
.orb.processing .orb-core {
  animation: orbProcess 2s ease-in-out infinite;
  -webkit-filter: brightness(0.9);
  filter: brightness(0.9);
}

@keyframes orbProcess {
  0%, 100% { -webkit-transform: scale(0.95); transform: scale(0.95); }
  50%      { -webkit-transform: scale(1.05); transform: scale(1.05); }
}

/* === Messages === */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Chat Bubbles */

.msg {
  max-width: 75%;
  padding: 10px 16px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-lisa {
  align-self: flex-start;
  background: var(--lisa-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-lisa .msg-text strong {
  color: var(--accent);
  font-weight: 600;
}

.msg-lisa .msg-text em {
  font-style: italic;
  color: var(--text-primary);
}

.msg-lisa .msg-text ul,
.msg-lisa .msg-text ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.msg-lisa .msg-text li {
  margin: 3px 0;
  line-height: 1.5;
}

.msg-lisa .msg-text ul { list-style-type: disc; }
.msg-lisa .msg-text ol { list-style-type: decimal; }

.msg-user {
  align-self: flex-end;
  background: var(--user-bg);
  border-bottom-right-radius: 4px;
}

.msg-label {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.msg-lisa .msg-label { color: var(--accent); }

.msg-error {
  align-self: center;
  background: #3a1c1c;
  border: 1px solid var(--error);
  color: var(--error);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.msg.streaming .msg-text::after {
  content: "\25CF";
  animation: blink 1s infinite;
  margin-left: 4px;
  color: var(--accent);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === Input Area === */

.input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 24px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.mic-btn, .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.mic-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.mic-btn:hover:not(:disabled) { background: var(--bg-input); color: var(--text-primary); }
.mic-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.mic-btn.recording {
  background: var(--error);
  color: white;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,67,54,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(244,67,54,0); }
}

.send-btn {
  background: var(--accent);
  color: white;
}

.send-btn:hover { filter: brightness(1.15); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

#textInput {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}

#textInput:focus { border-color: var(--accent); }
#textInput::placeholder { color: var(--text-muted); }

/* === Status Panel === */

.status-panel {
  width: 300px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.status-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.status-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Phase Pipeline */

.phase-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 0;
}

.phase-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  flex-shrink: 0;
  transition: all 0.3s;
  position: relative;
}

.phase-dot.completed {
  background: var(--accent);
  border-color: var(--accent);
}

.phase-dot.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.phase-dot.active::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  background: var(--accent);
  border-radius: 50%;
  animation: phasePulse 2s infinite;
}

@keyframes phasePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.phase-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 8px;
}

.phase-line.completed { background: var(--accent); }

.phase-dot[title] { cursor: help; }

/* Current Phase */

.current-phase .phase-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.current-phase .phase-progress {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Profile Fields */

.profile-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-field {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.profile-field .label {
  color: var(--text-muted);
}

.profile-field .value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Competencies */

.competency-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.comp-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.comp-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.comp-chip[data-pillar="technical"] .dot { background: var(--pillar-technical); }
.comp-chip[data-pillar="transversal"] .dot { background: var(--pillar-transversal); }
.comp-chip[data-pillar="language"] .dot { background: var(--pillar-language); }
.comp-chip[data-pillar="knowledge"] .dot { background: var(--pillar-knowledge); }

.empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Session Footer */

.status-footer {
  margin-top: auto;
  border-bottom: none;
}

.session-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* === Action Buttons im Status-Panel === */

.action-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.action-btn:hover { filter: brightness(1.1); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.action-btn-secondary {
  margin-top: 8px;
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.action-btn-secondary:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.session-id-display {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* === Modal === */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px;
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.modal-actions .action-btn {
  width: auto;
  padding: 8px 16px;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.close-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* === Report === */

.report-body {
  overflow-y: auto;
  padding: 24px 32px;
  color: var(--text-primary);
}

.report-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.report-section { margin-bottom: 28px; }

.report-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.report-section h3 .count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 6px;
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 20px;
  font-size: 14px;
}

.report-meta .label { color: var(--text-muted); }
.report-meta .value { color: var(--text-primary); font-weight: 500; }

.report-profile {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 24px;
}

.report-profile .field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.report-profile .field .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.report-profile .field .value {
  font-size: 14px;
  color: var(--text-primary);
}

/* Kompetenz-Radar */

.radar-wrapper {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 16px 0;
}

.radar-svg {
  flex-shrink: 0;
  width: 280px;
  height: 280px;
}

.radar-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radar-legend .item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.radar-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.radar-legend .label { flex: 1; color: var(--text-secondary); }
.radar-legend .count { color: var(--text-primary); font-weight: 600; }

/* Kompetenz-Liste pro Pillar */

.pillar-group { margin-bottom: 14px; }

.pillar-group h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pillar-group h4::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.pillar-group.technical h4::before { background: var(--pillar-technical); }
.pillar-group.transversal h4::before { background: var(--pillar-transversal); }
.pillar-group.language h4::before { background: var(--pillar-language); }
.pillar-group.knowledge h4::before { background: var(--pillar-knowledge); }

.pillar-competencies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* KI-Analyse (Markdown) */

.analysis-content {
  font-size: 14px;
  line-height: 1.65;
}

.analysis-content h2 {
  font-size: 15px;
  color: var(--accent);
  margin-top: 20px;
  margin-bottom: 8px;
  font-weight: 600;
}

.analysis-content h2:first-child { margin-top: 0; }

.analysis-content p { margin-bottom: 10px; color: var(--text-primary); }
.analysis-content ul { margin-left: 20px; margin-bottom: 10px; }
.analysis-content li { margin-bottom: 4px; color: var(--text-primary); }

/* Chat-Historie */

.chat-history {
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.chat-history .turn {
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-history .turn .role {
  font-weight: 600;
  margin-right: 6px;
}

.chat-history .turn.assistant .role { color: var(--accent); }
.chat-history .turn.user .role { color: var(--text-secondary); }

/* === Sessions-Liste === */

.sessions-body {
  overflow-y: auto;
  padding: 16px 24px;
}

.session-item {
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.session-item:hover {
  border-color: var(--accent);
  background: var(--bg-input);
}

.session-item.current {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.session-item .info { flex: 1; }

.session-item .session-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.session-item .session-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: ui-monospace, Menlo, monospace;
}

.session-item .session-stats {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* === Print-Optimierung (PDF) === */

@media print {
  body { background: white; color: black; }
  .app, .main, .header, .status-panel, .chat-panel,
  #sessionsModal, .no-print { display: none !important; }

  .modal {
    position: static !important;
    padding: 0 !important;
    display: block !important;
  }
  .modal-backdrop { display: none !important; }
  .modal-content {
    max-width: 100% !important;
    max-height: none !important;
    border: none !important;
    background: white !important;
    box-shadow: none !important;
  }

  .report-body {
    color: black !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .report-section h3,
  .report-section h4,
  .report-profile .field .label,
  .analysis-content h2,
  .radar-legend .label {
    color: #444 !important;
  }

  .report-profile .field,
  .pillar-competencies .comp-chip,
  .chat-history {
    background: #f5f5f5 !important;
    border-color: #ddd !important;
    color: black !important;
  }

  .chat-history { max-height: none !important; overflow: visible !important; }

  .analysis-content h2 { color: #2d4099 !important; }

  .radar-svg circle, .radar-svg polygon, .radar-svg line {
    stroke: #333 !important;
  }
  .radar-svg .data-shape { fill: rgba(45, 64, 153, 0.3) !important; stroke: #2d4099 !important; }

  .pillar-group.technical h4::before { background: #4a9eff !important; }
  .pillar-group.transversal h4::before { background: #4caf50 !important; }
  .pillar-group.language h4::before { background: #ff9800 !important; }
  .pillar-group.knowledge h4::before { background: #ab47bc !important; }
}

/* === Responsive === */

@media (max-width: 768px) {
  .status-panel { display: none; }
  .report-profile { grid-template-columns: 1fr; }
  .radar-wrapper { flex-direction: column; }
}
