:root {
  --bg: #0b0d10;
  --panel: #15191f;
  --panel-2: #1c222a;
  --line: #242b34;
  --text: #e9eef4;
  --text-dim: #b9c3cf;
  --muted: #8b95a3;
  --accent: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  /* Feste App-Shell: body scrollt nie, nur .cards/.transcript. Mit min-height:100dvh
     konnte eine Spalte voller Karten den Transkriptstreifen und die Actionbar unter den
     Viewport schieben — auf dem Handy sah das aus, als würde nicht mehr zugehört. */
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  /* Flex statt fester grid-template-rows: .hint/.cards setzen display:none wenn leer,
     sonst rutscht die 1fr-Zeile in die Actionbar und die Buttons werden riesig. */
  display: flex;
  flex-direction: column;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  -webkit-text-size-adjust: 100%;
}

/* Kopf */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 8px;
}

.brand { font-size: 15px; letter-spacing: 0.02em; color: var(--muted); }
.brand strong { color: var(--text); font-weight: 600; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }

.status[data-state="live"] { color: var(--accent); border-color: #1f4630; }
.status[data-state="live"] .dot { background: var(--accent); animation: pulse 1.6s ease-out infinite; }
.status[data-state="connecting"] { color: var(--warn); }
.status[data-state="connecting"] .dot { background: var(--warn); }
.status[data-state="error"] { color: var(--error); border-color: #4a2528; }
.status[data-state="error"] .dot { background: var(--error); }

@keyframes pulse {
  from { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  to { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
}

/* Pegel */
.level {
  height: 4px;
  margin: 6px 2px 0;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 80ms linear;
}

/* Hinweise */
.hint { margin: 8px 2px 0; font-size: 13px; color: var(--error); }
.hint:empty { display: none; }

/* Inhalt */
main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 10px 0;
}

.cards {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}
.cards:empty { display: none; }

.card {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
}
.card h2 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.card p { margin: 0; font-size: 18px; line-height: 1.4; white-space: pre-wrap; }
.card.is-pending p { color: var(--muted); }
/* Skeleton while the first tokens are on their way. */
.card.is-pending p:empty::after { content: 'denkt…'; animation: blink 1.2s ease-in-out infinite; }

@keyframes blink {
  50% { opacity: 0.35; }
}

.transcript {
  flex: 0 0 auto;
  max-height: 30dvh;
  padding-top: 10px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.interim { margin: 0; min-height: 1.4em; font-size: 15px; color: var(--muted); }

.finals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.finals li { font-size: 15px; color: var(--text-dim); }

/* Actionbar */
.actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}

.btn {
  min-height: 52px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.btn:disabled { opacity: 0.4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06230f; }
.btn.primary.recording { background: var(--error); border-color: var(--error); color: #2b0808; }
.btn:active:not(:disabled) { transform: scale(0.98); }

@media (prefers-reduced-motion: reduce) {
  .status .dot { animation: none; }
}
