:root {
  color-scheme: dark;
  --void: #030912;
  --deep: #071a2b;
  --reactor: #5fe6ff;
  --reactor-soft: #b6f6ff;
  --line: rgba(95, 230, 255, 0.16);
  --text: #d3f1f8;
  --muted: #7196a6;
  --amber: #ffb547;
  --level: 0;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(31, 120, 160, 0.22), transparent 70%),
    linear-gradient(180deg, var(--deep), var(--void) 70%);
  background-color: var(--void);
  color: var(--text);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: calc(var(--safe-t) + 14px) 18px calc(var(--safe-b) + 14px);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Kopfzeile */
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.clock { display: flex; flex-direction: column; line-height: 1.15; }
#time { font-size: 1.6rem; font-weight: 500; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
#date { font-size: 0.85rem; color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); padding-top: 6px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--reactor); box-shadow: 0 0 10px var(--reactor); }
body[data-state="thinking"] .status i, body[data-state="transcribing"] .status i { background: var(--amber); box-shadow: 0 0 10px var(--amber); }

/* Reaktor */
.stage { display: flex; flex-direction: column; align-items: center; padding-top: 2vh; }
.reactor {
  width: min(78vw, 44vh, 400px); aspect-ratio: 1; padding: 0; border: 0; background: none;
  cursor: pointer; border-radius: 50%; touch-action: manipulation;
}
.reactor:focus-visible { outline: 2px solid var(--reactor); outline-offset: 6px; }
.reactor svg { width: 100%; height: 100%; overflow: visible; }
.ticks line { stroke: var(--reactor); stroke-opacity: 0.35; stroke-width: 2; }
.ticks line.major { stroke-opacity: 0.8; stroke-width: 3; }
.ring { fill: none; stroke: var(--reactor); transition: stroke 0.4s, stroke-opacity 0.4s; }
.ring-outer { stroke-width: 3; stroke-opacity: 0.55; stroke-dasharray: 110 16 34 16; }
.ring-mid { stroke-width: 14; stroke-opacity: 0.85; stroke-dasharray: 44 9; }
.ring-arc { stroke-width: 4; stroke-opacity: 0.7; stroke-dasharray: 190 60 40 60; }
.ring-inner { stroke-width: 2; stroke-opacity: 0.45; }
.spin { transform-origin: 200px 200px; animation: spin 60s linear infinite; }
.spin-b { animation-duration: 90s; animation-direction: reverse; }
.spin-c { animation-duration: 40s; }
.core-wrap { transform-origin: 200px 200px; transform: scale(calc(0.9 + var(--level) * 0.35)); transition: transform 0.08s linear; }
.core { opacity: calc(0.75 + var(--level) * 0.25); animation: breathe 5s ease-in-out infinite; transform-origin: 200px 200px; }

body[data-state="listening"] .spin { animation-duration: 14s; }
body[data-state="listening"] .spin-b { animation-duration: 20s; }
body[data-state="listening"] .ring-mid { stroke-opacity: 1; }
body[data-state="thinking"] .ring, body[data-state="transcribing"] .ring { stroke: var(--amber); }
body[data-state="thinking"] .spin, body[data-state="transcribing"] .spin { animation-duration: 3s; }
body[data-state="thinking"] .spin-b, body[data-state="transcribing"] .spin-b { animation-duration: 5s; }
body[data-state="speaking"] .core { animation: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(0.94); } }

.hint { margin: 14px 0 0; color: var(--muted); font-size: 0.95rem; text-align: center; min-height: 1.4em; }

/* Verlauf */
.log {
  overflow-y: auto; padding: 8px 2px 12px; display: flex; flex-direction: column; gap: 14px;
  max-width: 640px; width: 100%; margin: 0 auto;
  mask-image: linear-gradient(transparent, #000 28px);
  -webkit-mask-image: linear-gradient(transparent, #000 28px);
}
.turn { display: flex; flex-direction: column; gap: 6px; }
.turn .you { color: var(--muted); font-size: 0.9rem; }
.turn .you::before { content: "Du: "; }
.turn .jarvis { font-size: 1.05rem; line-height: 1.5; white-space: pre-wrap; }
.turn .jarvis.error { color: var(--amber); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a, .chips span {
  font-size: 0.78rem; color: var(--reactor); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; text-decoration: none;
}

/* Eingabe */
.dock { display: flex; flex-direction: column; gap: 10px; max-width: 640px; width: 100%; margin: 0 auto; }
.ask { display: flex; gap: 8px; }
.ask input, .login input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text);
  background: rgba(7, 26, 43, 0.7); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.ask input:focus, .login input:focus { outline: none; border-color: var(--reactor); }
button { font: inherit; }
.ask button, .login button {
  border: 1px solid var(--reactor); background: rgba(95, 230, 255, 0.12); color: var(--reactor);
  border-radius: 12px; padding: 0 16px; font-weight: 600; cursor: pointer;
}
.ask button:focus-visible, .wake:focus-visible, .login button:focus-visible { outline: 2px solid var(--reactor); outline-offset: 2px; }
.wake {
  align-self: center; background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 0.85rem; cursor: pointer;
}
.wake[aria-pressed="true"] { color: var(--reactor); border-color: var(--reactor); }

/* Anmeldung */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(3, 9, 18, 0.92); padding: 24px; }
.login[hidden] { display: none; }
.login form { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); }
.login h1 { font-weight: 500; font-size: 1.4rem; margin: 0 0 6px; text-align: center; }
.login button { padding: 12px; }
.err { color: var(--amber); min-height: 1.2em; margin: 0; font-size: 0.9rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .spin, .core { animation: none !important; }
  .core-wrap { transition: none; }
}
@media (min-height: 760px) { .stage { padding-top: 5vh; } }
