:root {
  --bg: #0b0614;
  --panel: rgba(28, 16, 48, 0.62);
  --line: rgba(196, 140, 255, 0.18);
  --text: #f3eaff;
  --muted: #a993c9;
  --pink: #ff4fd8;
  --violet: #9b5cff;
  --blue: #5c8cff;
  --cyan: #4fe3ff;
  --user: rgba(92, 140, 255, 0.16);
  --err: #ff7a9c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Sora", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60vmax 40vmax at 15% 10%, rgba(255, 79, 216, 0.18), transparent 60%),
    radial-gradient(50vmax 40vmax at 90% 30%, rgba(92, 140, 255, 0.16), transparent 60%),
    radial-gradient(50vmax 50vmax at 50% 110%, rgba(155, 92, 255, 0.22), transparent 60%),
    var(--bg);
}
.bg::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 4px);
  pointer-events: none;
}
.brand {
  font-weight: 600; letter-spacing: 0.42em; font-size: 2.4rem;
  color: #ffd6f6;
  text-shadow: 0 0 6px var(--pink), 0 0 22px rgba(255, 79, 216, 0.55), 0 0 44px rgba(155, 92, 255, 0.45);
}
.brand.small { font-size: 1.05rem; letter-spacing: 0.36em; }

/* Login */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); padding: 32px 24px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  backdrop-filter: blur(14px);
}
.sub { color: var(--muted); margin: 4px 0 24px; }
.login input, .login button {
  width: 100%; padding: 14px 16px; border-radius: 12px; font: inherit;
}
.login input { background: rgba(0,0,0,0.35); color: var(--text); border: 1px solid var(--line); margin-bottom: 12px; }
.login input:focus { outline: 2px solid var(--violet); outline-offset: 1px; }
.login button { border: 0; color: #fff; font-weight: 600; cursor: pointer; background: linear-gradient(90deg, var(--pink), var(--violet)); }
.err { color: var(--err); min-height: 1.5em; margin: 10px 0 0; font-size: 0.9rem; }

/* App */
.app {
  height: 100%; display: grid; grid-template-rows: auto auto 1fr auto;
  max-width: 760px; margin: 0 auto;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
.top { display: flex; align-items: center; gap: 12px; padding: 12px 0 4px; }
.meta { flex: 1; display: flex; gap: 10px; justify-content: flex-end; font: 12px "JetBrains Mono", monospace; color: var(--muted); }
#state { text-transform: uppercase; letter-spacing: 0.12em; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 0; }
.icon-btn .wave { fill: none; stroke-width: 2; stroke-linecap: round; }
.icon-btn[aria-pressed="false"] .wave { opacity: 0.15; }

/* Avatar */
.stage { display: grid; justify-items: center; padding: 4px 0 8px; }
.avatar { position: relative; width: clamp(140px, 30vh, 240px); aspect-ratio: 1; }
.avatar video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; mask-image: radial-gradient(circle, #000 62%, transparent 72%); }
.holo { position: absolute; inset: 0; display: grid; place-items: center; }
.ring { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 79, 216, 0.5); box-shadow: 0 0 30px rgba(155, 92, 255, 0.35), inset 0 0 30px rgba(92, 140, 255, 0.2); }
.r1 { inset: 6%; animation: spin 18s linear infinite; border-style: dashed; }
.r2 { inset: 18%; border-color: rgba(79, 227, 255, 0.45); animation: spin 11s linear infinite reverse; }
.core {
  width: 46%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 4%, var(--pink) 18%, var(--violet) 52%, rgba(92,140,255,0.2) 75%);
  box-shadow: 0 0 60px rgba(255, 79, 216, 0.55), 0 0 120px rgba(155, 92, 255, 0.35);
  animation: breathe 4.5s ease-in-out infinite;
}
.mouth { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); display: flex; gap: 4px; align-items: center; height: 22px; opacity: 0; transition: opacity .2s; }
.mouth i { width: 4px; height: 4px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transition: height .08s; }
.avatar[data-state="speaking"] .mouth { opacity: 1; }
.avatar[data-state="thinking"] .core { animation: breathe 1.1s ease-in-out infinite; }
.avatar[data-state="listening"] .r2 { border-color: var(--pink); animation-duration: 3s; }
.avatar[data-state="listening"] .core { box-shadow: 0 0 80px rgba(79, 227, 255, 0.7); }
.status { margin: 6px 0 0; min-height: 1.4em; font-size: 0.85rem; color: var(--muted); text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.08); filter: brightness(1.15); } }

/* Verlauf */
.log { overflow-y: auto; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); border: 1px solid rgba(92, 140, 255, 0.3); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; backdrop-filter: blur(10px); }
.msg.error { border-color: var(--err); color: var(--err); }
.msg strong { color: #fff; }

/* Eingabe */
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 14px; }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; padding: 12px 14px; border-radius: 16px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); font: inherit; backdrop-filter: blur(10px);
}
.composer textarea:focus { outline: 2px solid var(--violet); outline-offset: 1px; }
.mic, .send { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; }
.mic { background: var(--panel); border: 1px solid var(--line); }
.mic svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic.on { background: var(--pink); box-shadow: 0 0 24px var(--pink); }
.send { background: linear-gradient(135deg, var(--pink), var(--violet)); }
.send svg { width: 20px; fill: #fff; }
.send:disabled { opacity: 0.4; }

@media (prefers-reduced-motion: reduce) { .ring, .core { animation: none !important; } }
