:root {
  --bg: #0b0f14;
  --card: #141a22;
  --text: #e8eef6;
  --muted: #8fa3b8;
  --accent: #3fa9f5;
  --ok: #35d07f;
  --warn: #f5c451;
  --bad: #f2635f;
  --radius: 18px;
}

* { box-sizing: border-box; }

/* Muss VOR allen anderen Regeln stehen: ohne !important gewinnt jede
   display-Angabe (z. B. `.overlay { display: grid }`) gegen das hidden-Attribut
   und das ausgeblendete Element bleibt sichtbar. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { display: flex; flex-direction: column; }

/* ---------- Anmeldung ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 10;
  padding: 24px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
}
.card h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: .01em; }
input {
  background: #0e141b;
  border: 1px solid #24303d;
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  font-size: 16px;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  background: var(--accent);
  color: #04121f;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
}
button.ghost { background: transparent; color: var(--muted); border: 1px solid #24303d; font-weight: 500; padding: 10px 14px; }
button:disabled { opacity: .5; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.error { color: var(--bad); margin: 0; font-size: 14px; }

/* ---------- Geruest: vier feste Bereiche ----------
   Kopf | Kreis | Verlauf (scrollt) | Fuss
   Der Kreis braucht eine EIGENE Zeile: im scrollenden Bereich schob ihn jeder neue
   Satz nach oben aus dem Bild. */
main {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100%;
  /* dvh statt % : auf dem Handy schrumpft die Hoehe, wenn die Tastatur aufgeht --
     sonst schiebt sich der Fuss unter die Tastatur. */
  height: 100dvh;
}
#scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.bar { border-color: #1b242e; background: var(--bg); }
.bar.top {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px 14px;
  border-bottom: 1px solid #1b242e;
}
.bar.bottom {
  display: grid;
  gap: 8px;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom)) 14px;
  border-top: 1px solid #1b242e;
}
#app-title { font-weight: 600; white-space: nowrap; }
.icon {
  background: transparent;
  color: var(--text);
  border: 1px solid #24303d;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
}
select {
  flex: 1;
  background: #0e141b;
  color: var(--text);
  border: 1px solid #24303d;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}

/* ---------- Schnellzugriff im Fuss ---------- */
.shortcuts { display: flex; gap: 8px; overflow-x: auto; }
.shortcuts button {
  flex: 1 0 auto;
  background: var(--card);
  color: var(--text);
  border: 1px solid #24303d;
  font-weight: 500;
  font-size: 14px;
  padding: 12px 14px;
  white-space: nowrap;
}
.shortcuts button.wirkt { border-color: var(--accent); }

/* ---------- Verlaufsliste ---------- */
.gespraechsliste { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.gespraech {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: #101720;
  border: 1px solid #24303d;
  border-radius: 12px;
  overflow: hidden;
}
/* Das gerade laufende Gespraech hervorheben -- sonst raet man, welches gemeint ist. */
.gespraech.laeuft { border-color: var(--accent); }
.gespraech-kopf {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 11px 12px;
  color: var(--text);
}
.gespraech-titel { font-weight: 500; line-height: 1.25; }
.gespraech-weg {
  background: transparent;
  border: 0;
  border-left: 1px solid #24303d;
  color: var(--muted);
  padding: 0 14px;
  font-size: 16px;
}
.gespraech-weg:hover { color: var(--bad); }
#gespraech-neu { margin-bottom: 6px; }
/* Pause: angehalten heisst rot -- das muss man auf einen Blick sehen, sonst redet
   man in ein stilles Mikrofon. */
.shortcuts button.an {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
  font-weight: 600;
}

/* ---------- Burgermenue ---------- */
#veil { position: fixed; inset: 0; background: rgba(4, 8, 12, .6); z-index: 20; }
#drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, 330px);
  background: var(--card);
  border-right: 1px solid #24303d;
  z-index: 21;
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  gap: 10px;
  overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.drawer-head #drawer-title { flex: 1; }
#menu { display: grid; gap: 6px; }
#menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 12px;
  font-size: 16px;
  font-weight: 500;
}
#menu button:active { background: #1b2531; }
#menu button .emoji { font-size: 18px; }
.drawer-note { margin-top: auto; }

/* ---------- Bühne (eigene Zeile, bleibt stehen) ---------- */
#stage { display: grid; place-items: center; gap: 8px; padding: 18px 16px 12px; }
#stage #hint { text-align: center; }
.orb {
  width: min(58vw, 220px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, #1d2a38, #101821 70%);
  border: 2px solid #24303d;
  transition: border-color .25s, box-shadow .25s, transform .12s;
  font-weight: 600;
  letter-spacing: .01em;
}
.orb[data-state="listening"] { border-color: var(--ok); box-shadow: 0 0 0 8px rgba(53,208,127,.09); }
.orb[data-state="thinking"]  { border-color: var(--warn); box-shadow: 0 0 0 8px rgba(245,196,81,.09); }
.orb[data-state="speaking"]  { border-color: var(--accent); box-shadow: 0 0 0 8px rgba(63,169,245,.10); }
.orb[data-state="error"]     { border-color: var(--bad); }
.orb:active { transform: scale(.98); }

/* ---------- Transkript ---------- */
#transcript {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.line { max-width: 92%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.line.user { align-self: flex-end; background: #1d3a52; }
.line.assistant { align-self: flex-start; background: var(--card); }
.line.sys { align-self: center; color: var(--muted); font-size: 13px; padding: 2px; }

/* ---------- Fuß: nur der Schnellzugriff ---------- */
#interrupt { margin-top: 4px; }
.switch { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.switch input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent); }

/* ---------- Seite im Menü: Zustand und Einstellungen ---------- */
#page-state { display: grid; gap: 8px; }
#page-state h2 {
  margin: 14px 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
#page-state button { justify-self: start; }
#mic-state { line-height: 1.6; white-space: pre-line; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
