:root {
  --bg: #0f1117;
  --bg2: #161a23;
  --card: #1c212e;
  --card-hover: #232a3a;
  --border: #2c3447;
  --text: #e8ecf4;
  --muted: #8d97ab;
  --accent: #6c8cff;
  --accent-hover: #87a1ff;
  --green: #3ecf8e;
  --red: #ff5c6c;
  --amber: #f5b350;
}

* { box-sizing: border-box; }

/* ---------- Scrollbalken: dezent im ganzen System ---------- */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(141, 151, 171, 0.28) transparent;
}
/* Chromium/Edge/Safari */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(141, 151, 171, 0.25);
  border-radius: 999px;
  /* transparenter Rand + padding-box = schwebender, abgerückter Daumen */
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(141, 151, 171, 0.5);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: clip;
}
audio { max-width: 100%; }

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 1.5rem; }
h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }

nav { display: flex; gap: 6px; flex: 1; }

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { color: var(--text); background: var(--card); font-weight: 600; }

.status-pill {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.ok { color: var(--green); }
.status-pill.warn { color: var(--amber); }
.status-pill.err { color: var(--red); }

/* Pod-Schalter in der Kopfzeile (Betriebsmodus „Pod manuell") */
.pod-switch {
  display: flex;
  align-items: center;
  margin: 0;   /* hebt label-Formularabstand (margin-bottom) auf - sonst sitzt der Schalter zu hoch */
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.pod-switch.on { color: var(--green); }
.pod-switch input { position: absolute; opacity: 0; pointer-events: none; }
.pod-switch-slider {
  position: relative;
  flex: none;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.2s;
}
.pod-switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.pod-switch input:checked + .pod-switch-slider { background: var(--green); }
.pod-switch input:checked + .pod-switch-slider::after { transform: translateX(16px); background: #fff; }
.pod-switch input:disabled + .pod-switch-slider { opacity: 0.5; }

/* Aktivierungs-Overlay: dunkelt die Oberfläche ab, bis das Studio im Pod bereit ist */
.pod-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 10, 16, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pod-overlay-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 38px;
  text-align: center;
  max-width: min(420px, 92vw);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.pod-overlay-card h3 { margin: 0 0 8px; font-size: 1.15rem; }
.pod-overlay-card p { margin: 0 0 18px; font-size: 0.9rem; }
.pod-overlay-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: pod-overlay-spin 0.9s linear infinite;
}
@keyframes pod-overlay-spin { to { transform: rotate(360deg); } }

main { max-width: 1100px; margin: 0 auto; padding: 28px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--red); }

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
h2 { margin: 0; font-size: 1.4rem; }

button, .button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .button:hover { background: var(--card-hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button.big { font-size: 1.05rem; padding: 13px 22px; width: 100%; margin-top: 14px; }

/* ---------- Stimmen-Grid ---------- */
.voices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.voice-card { cursor: pointer; transition: border-color 0.15s, transform 0.1s; }
.voice-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.voice-card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.voice-card .meta { font-size: 0.84rem; color: var(--muted); margin-top: 10px; display: flex; gap: 14px; }
.voice-card-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.voice-card .delete-x { background: none; border: none; color: var(--muted); padding: 2px 6px; font-size: 1rem; }
.voice-card .delete-x:hover { color: var(--red); }

.badge {
  font-size: 0.74rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ready { background: rgba(62, 207, 142, 0.15); color: var(--green); }
.badge.draft { background: rgba(245, 179, 80, 0.15); color: var(--amber); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  border: 2px dashed var(--border);
  border-radius: 14px;
}

/* ---------- Stimm-Detail ---------- */
.link-back {
  background: none; border: none; color: var(--muted);
  padding: 0; margin-bottom: 14px; font-size: 0.9rem;
}
.link-back:hover { color: var(--text); background: none; }

.detail-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 20px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.edit-pencil {
  background: none;
  border: none;
  font-size: 1rem;
  padding: 4px 6px;
  opacity: 0.55;
}
.edit-pencil:hover { opacity: 1; background: var(--card); border-radius: 8px; }
.name-edit { display: flex; align-items: center; gap: 8px; }
.name-edit input { font-size: 1.2rem; font-weight: 600; max-width: 340px; }
.name-edit button { padding: 8px 13px; }

.card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.action-card { cursor: pointer; text-align: center; transition: border-color 0.15s; }
.action-card:hover { border-color: var(--accent); }
.action-card .action-icon { font-size: 2rem; margin-bottom: 8px; }
.action-card h3 { margin: 0 0 8px; }
.action-card p { color: var(--muted); font-size: 0.86rem; margin: 0; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 30px;
  text-align: center;
  margin-bottom: 24px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--bg2); }
.upload-zone input { display: none; }
.upload-zone p { margin: 4px 0; }
#upload-progress { margin-top: 10px; font-size: 0.85rem; color: var(--muted); text-align: left; }

.section-title { margin: 24px 0 12px; }

.samples-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.sample-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
}
.sample-row.excluded { opacity: 0.45; }
.sample-row .sample-label { flex: 1; min-width: 0; }
.sample-row .sample-label .name { font-size: 0.92rem; }
.sample-row .sample-label .sub { font-size: 0.78rem; color: var(--muted); }
.sample-row audio { height: 34px; max-width: 260px; }
.sample-row .kind-icon { font-size: 1.1rem; }

.build-bar { display: block; }
.build-bar h3 { margin: 0 0 6px; }
.build-bar > p { margin: 0 0 4px; }
.build-bar audio { width: 100%; margin-top: 10px; display: block; }
.build-controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.build-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  margin-bottom: 0;
}
.build-controls select { width: 180px; }
.build-controls button { white-space: nowrap; margin: 0; }

select, input[type="text"], input[type="number"], input[type="email"], input[type="password"], textarea {
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}
textarea { resize: vertical; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); }

label { display: block; margin-bottom: 14px; font-size: 0.9rem; }
label > input, label > select, label > textarea { margin-top: 6px; }

/* ---------- Studio ---------- */
/* stretch: die Verlauf-Karte waechst immer auf die Hoehe der linken Seite mit */
.studio-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: stretch; }
.history-card { display: flex; flex-direction: column; }
.history-card h3 { margin-top: 0; }
@media (min-width: 901px) {
  /* height:0 + min-height:100%: die Karte traegt nicht zur Zeilenhoehe bei -
     allein die linke Seite bestimmt die Hoehe, die Liste fuellt und scrollt */
  .history-card { height: 0; min-height: 100%; }
}
@media (max-width: 900px) { .studio-grid { grid-template-columns: 1fr; } .card-row { grid-template-columns: 1fr; } }

details { margin: 10px 0; }
summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.adv-grid { padding-top: 12px; }
.adv-grid label { display: flex; flex-direction: column; gap: 4px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.gen-status {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 12px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

#generate-result { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
#generate-result audio { width: 100%; }
.download-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;        /* Abstand zwischen Eintraegen und Scrollbalken */
  margin-right: -8px;
}
.history-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.history-item .h-date {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.history-item .h-copy {
  background: none;
  border: none;
  font-size: 0.95rem;
  padding: 2px 6px;
  opacity: 0.6;
}
.history-item .h-copy:hover { opacity: 1; background: var(--card); border-radius: 6px; }
.history-item .h-tempo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.history-item .h-tempo-row select { width: auto; padding: 4px 8px; font-size: 0.82rem; }
.history-item .h-remix { font-size: 0.78rem; padding: 5px 11px; }
.history-item .h-text {
  font-size: 0.84rem;
  margin-bottom: 8px;
  white-space: pre-wrap;     /* Zeilenumbrueche und Leerzeichen wie eingegeben */
  overflow-wrap: anywhere;
  max-height: 8.4em;         /* ~6 Zeilen, danach scrollen statt wachsen */
  overflow-y: auto;
  /* Scrollbalken unsichtbar - scrollen geht weiter, Volltext liefert der Kopieren-Button */
  scrollbar-width: none;
}
.history-item .h-text::-webkit-scrollbar { display: none; }
.history-item .h-meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.history-item audio { width: 100%; height: 34px; }
.history-item .h-actions { display: flex; gap: 8px; margin-top: 8px; }
.history-item .h-actions button, .history-item .h-actions a { font-size: 0.78rem; padding: 4px 10px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: min(480px, 92vw);
}
.modal-box h2 { margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: end; gap: 10px; margin-top: 8px; }

/* ---------- Recorder ---------- */
.recorder {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.recorder-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}
.recorder-head h2 { font-size: 1.1rem; }

.rec-panel { max-width: 760px; margin: 0 auto; padding: 36px 24px; width: 100%; }
.rec-panel ul { line-height: 1.9; color: var(--muted); }

.rec-progress { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
#rec-counter { font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.rec-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.rec-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
}
.rec-dot.done { background: var(--green); }
.rec-dot.current { background: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }

.teleprompter {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px;
  margin-bottom: 18px;
  text-align: center;
}
.rec-instruction { color: var(--amber); font-size: 0.92rem; margin-bottom: 16px; }
.rec-text { font-size: 1.5rem; line-height: 1.6; }

#level-meter { width: 100%; height: 48px; border-radius: 8px; background: var(--bg2); display: block; margin-bottom: 16px; }

.rec-controls { display: flex; align-items: center; gap: 18px; justify-content: center; margin-bottom: 16px; }
.record-btn {
  font-size: 1.05rem;
  padding: 14px 28px;
  border-radius: 999px;
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 600;
}
.record-btn.recording { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.65; } }
.rec-timer { font-variant-numeric: tabular-nums; font-size: 1.1rem; color: var(--muted); }

.rec-review { text-align: center; margin-bottom: 16px; }
.rec-review audio { width: 100%; margin-bottom: 12px; }
.rec-review-actions { display: flex; justify-content: center; gap: 12px; }

.rec-nav { display: flex; justify-content: space-between; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 400;
  display: flex; align-items: center; justify-content: center;
}
.login-box { width: min(420px, 92vw); text-align: center; padding: 36px; }
.login-logo { font-size: 3rem; margin-bottom: 4px; }
.login-box h2 { margin: 0 0 18px; }
.login-box label { text-align: left; }
.login-box .big { margin-top: 4px; }
#login-code { text-align: center; font-size: 1.4rem; letter-spacing: 0.4em; }
.dev-hint {
  background: rgba(245, 179, 80, 0.12);
  border: 1px solid var(--amber);
  color: var(--amber);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
}

.link-recovery {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 18px;
  padding: 4px;
}
.link-recovery:hover { color: var(--text); background: none; }

/* ---------- Verwaltung: SMTP & Notfallcodes ---------- */
.smtp-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0 14px;
}
@media (max-width: 700px) { .smtp-grid { grid-template-columns: 1fr; } }
.smtp-options { display: flex; gap: 22px; margin-bottom: 14px; }
label.inline {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 0;
  color: var(--muted);
}
.smtp-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.recovery-codes {
  background: var(--bg2);
  border: 1px solid var(--amber);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.recovery-codes pre {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  line-height: 1.9;
  margin: 8px 0;
  user-select: all;
}

/* ---------- Header: Benutzer ---------- */
.user-area { display: flex; align-items: center; gap: 10px; }
.small-btn { padding: 5px 12px; font-size: 0.82rem; }

/* ---------- Verwaltung ---------- */
.admin-form {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.admin-form label { margin-bottom: 0; }
@media (max-width: 800px) { .admin-form { grid-template-columns: 1fr; } }

.user-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row .u-info { flex: 1; }
.user-row .u-info .name { font-weight: 600; }
.user-row .u-info .email { font-size: 0.84rem; color: var(--muted); }
.role-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.role-badge.admin { color: var(--accent); border-color: var(--accent); }

/* ---------- Studio: Sprecher ---------- */
.speakers-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.speaker-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.speaker-row { display: flex; align-items: center; gap: 10px; }
.speaker-row .sp-label {
  font-size: 0.84rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 76px;
}
.speaker-row select { flex: 1; }
.speaker-row .sp-remove { padding: 6px 10px; }
.speaker-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.speaker-hint button { font-size: 0.78rem; padding: 4px 10px; }

/* ---------- Studio: Text-Badges & Stil-Tipps ---------- */
.text-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 0.9rem;
}
.text-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-btn {
  font-size: 0.76rem;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge-btn:hover { color: var(--text); border-color: var(--accent); background: var(--card-hover); }
.style-tips { margin-top: 10px; }
.style-tips ul { margin: 10px 0 4px; padding-left: 20px; line-height: 1.7; }
.style-tips code {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}

.seed-row { display: flex; gap: 8px; }
.seed-row input { flex: 1; }

.pod-control { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.pod-live { font-size: 0.9rem; color: var(--muted); }
.pod-live.running { color: var(--green); }
.pod-live.stopped { color: var(--amber); }
.pod-live.error { color: var(--red); }

/* ---------- Prompting-Agent ---------- */
.agent-btn {
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  font-size: 0.95rem;
  background: linear-gradient(135deg, rgba(108, 140, 255, 0.16), rgba(108, 140, 255, 0.06));
  border: 1px solid var(--accent);
  color: var(--text);
  font-weight: 600;
}
.agent-btn:hover { background: rgba(108, 140, 255, 0.25); }

.agent-box {
  width: min(760px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 22px 26px;
}
.agent-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.agent-head h2 { margin: 0; font-size: 1.15rem; }
.agent-head-actions { display: flex; gap: 8px; }

.agent-step { display: flex; flex-direction: column; min-height: 0; }
.agent-question { font-size: 1.05rem; margin: 6px 0 16px; }

.agent-speaker-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.agent-speaker-list label.inline { padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; }

.agent-messages {
  flex: 1;
  min-height: 200px;
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 10px 4px 2px;  /* rechts Luft zum Scrollbalken */
}
.agent-msg { max-width: 92%; }
.agent-msg.user {
  align-self: flex-end;
  background: rgba(108, 140, 255, 0.18);
  border: 1px solid var(--accent);
  border-radius: 12px 12px 2px 12px;
  padding: 10px 14px;
  white-space: pre-wrap;
  font-size: 0.9rem;
}
.agent-msg.assistant {
  align-self: flex-start;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  padding: 10px 14px;
  font-size: 0.9rem;
}
.agent-msg.assistant .a-text { white-space: pre-wrap; }
.agent-codebox {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 10px;
  margin: 10px 0 4px;
  overflow: hidden;
}
.agent-codebox pre {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.84rem;
  max-height: 260px;
  overflow-y: auto;
}
.agent-codebox .cb-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.agent-codebox .cb-actions button { font-size: 0.8rem; padding: 5px 12px; }

.agent-thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 0.88rem;
}
.agent-input-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: flex-end;
}
.agent-input-row textarea { flex: 1; resize: none; }
.agent-input-row button { padding: 11px 18px; font-size: 1.05rem; }

/* ---------- Pod-Warte-Banner ---------- */
.pod-banner {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--amber);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 0.92rem;
  z-index: 240;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- Install-Banner (PWA) ---------- */
.install-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 94vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 0.92rem;
  z-index: 250;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.55);
}
.install-actions { display: flex; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  z-index: 300;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.toast.error { border-color: var(--red); color: var(--red); }


/* =====================================================================
   Responsive: Tablets & Smartphones
   ===================================================================== */
@media (max-width: 760px) {
  /* ---- Header: zwei Zeilen - oben Marke + Status, darunter die Tabs ---- */
  header {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .brand { order: 1; }
  h1 { font-size: 1rem; white-space: nowrap; }
  .logo { font-size: 1.3rem; }
  .user-area { order: 2; margin-left: auto; }
  /* Erzwungener Umbruch: Status-Pill bekommt eine eigene, zentrierte Zeile */
  header::before { content: ""; flex-basis: 100%; order: 3; }
  .status-pill { order: 4; margin: 0 auto; font-size: 0.74rem; padding: 5px 10px; }
  /* Schalter sitzt exakt an der Stelle der Status-Pill (die ist dann ausgeblendet) */
  .pod-switch { order: 4; margin: 0 auto; font-size: 0.74rem; padding: 4px 10px; }
  .user-area #user-name { display: none; }   /* Name steckt im Abmelden-Kontext */
  nav {
    order: 5;
    flex: 1 1 100%;
    gap: 4px;
  }
  .tab { flex: 1; text-align: center; padding: 10px 4px; }

  main { padding: 16px 14px calc(40px + env(safe-area-inset-bottom)); }
  h2 { font-size: 1.2rem; }
  .view-head { flex-wrap: wrap; gap: 10px; }
  .detail-head { flex-wrap: wrap; gap: 10px; }
  .card { padding: 16px; }

  /* Eingaben: 16px verhindert das automatische Heranzoomen von iOS */
  select, input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], textarea { font-size: 16px; }

  /* ---- Stimm-Detail ---- */
  .build-bar { flex-direction: column; align-items: stretch; }
  .build-controls { width: 100%; }
  .build-controls label { flex: 1; }
  .build-controls .primary { flex: 1; }
  .sample-row { padding: 10px 12px; }
  .sample-row audio { flex: 1 1 100%; max-width: none; order: 10; }
  .upload-zone { padding: 22px 14px; }

  /* ---- Studio ---- */
  .studio-grid { gap: 16px; }
  .history-list { max-height: none; }
  .download-row .button { flex: 1; text-align: center; }
  .text-head { font-size: 0.86rem; }

  /* ---- Verwaltung ---- */
  .admin-form .primary { width: 100%; }
  .smtp-actions button { flex: 1; }
  .pod-control { flex-direction: column; align-items: stretch; }

  /* ---- Aufnahme ---- */
  .recorder-head { padding: 10px 12px; }
  .rec-panel { padding: 18px 14px; }
  .teleprompter { padding: 20px 14px; }
  .rec-text { font-size: 1.18rem; }
  .rec-controls { gap: 12px; }
  .record-btn { font-size: 0.95rem; padding: 12px 20px; }
  .rec-nav button { flex: 1; }
  .rec-nav { gap: 10px; }
  .rec-review-actions { flex-wrap: wrap; gap: 10px; }
  .rec-review-actions button { flex: 1; white-space: nowrap; }

  /* ---- Modal & Login ---- */
  .modal-box { padding: 20px 16px; width: min(480px, 94vw); }
  .login-box { padding: 28px 18px; }

  /* ---- Schwebende Elemente ---- */
  .pod-banner {
    top: calc(108px + env(safe-area-inset-top));
    width: min(94vw, 560px);
    font-size: 0.85rem;
    padding: 10px 14px;
  }
  .install-banner {
    padding: 14px;
    font-size: 0.88rem;
  }
  .install-actions { width: 100%; }
  .install-actions button { flex: 1; }
  .toast {
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: max-content;
    max-width: 92vw;
    text-align: center;
  }
}

/* Sehr schmale Geräte */
@media (max-width: 400px) {
  h1 { font-size: 0.92rem; }
  .status-pill { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .badge-btn { font-size: 0.72rem; padding: 4px 8px; }
  .voice-card .meta { flex-wrap: wrap; gap: 6px 14px; }
}
