:root {
  /* Werkstatt — warmes, helles Tageslicht */
  --bg: #EEE9E2;
  --surface: #FAF8F5;
  --surface-2: #F1EDE7;
  --card: #ffffff;
  --border: #E4DED5;
  --border-strong: #D5CEC4;
  --border-soft: #F1EDE7;

  --ink: #23211E;
  --muted: #5C564D;
  --label: #615B51;
  --faint: #6E675C;
  --faint-2: #B8AFA2;

  /* Ein Akzent: Perlblau */
  --accent: #7C93D4;
  --accent-deep: #3D4F8F;
  --accent-soft: #AFC0F0;
  --accent-tint: #EEF1FB;
  --accent-tint-2: #DDE4F7;
  --on-accent: #23211E;      /* dunkle Tinte auf perlblauen Flächen */

  --ok: #4F7A52;
  --ok-tint: #E8EFE6;
  --danger: #AF4233;
  --danger-tint: #F7E9E5;

  /* Bühne — warmes Dunkel für den Dialog */
  --stage-1: #332E28;
  --stage-2: #241F1B;
  --stage-3: #1A1714;
  --stage-line: rgba(255, 255, 255, 0.1);
  --stage-text: #EDE6DA;
  --stage-muted: #D6CCBE;
  --stage-faint: #B8AFA2;
  --stage-action: #BEB2A2;

  --radius: 14px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --appbar-h: 56px;
  --bottomnav-h: 74px;
  --sidebar-w: 248px;
  --shadow-card: 0 1px 2px rgba(35, 33, 30, 0.05);
  --shadow-pop: 0 16px 40px rgba(35, 33, 30, 0.14);

  --font-sans: 'Instrument Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Inline-SVG-Icons erben die Textfarbe. */
.ic { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.ic svg { display: block; }

/* ============ App-Shell ============ */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

#sidebar { display: none; }

#frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Top-App-Bar */
#appbar {
  height: var(--appbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
#back {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--faint);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#back:hover { background: var(--surface-2); color: var(--ink); }
#appbar-title {
  flex: 1;
  margin: 0 4px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#appbar-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.appbar-btn {
  background: none;
  border: none;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.appbar-btn:hover { background: var(--surface-2); }
.appbar-btn.text { font-size: 14px; font-weight: 500; color: var(--accent-deep); }
.appbar-btn.text:hover { background: var(--accent-tint); }

/* Scroll-Bereich */
#screen { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.screen { padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; animation: fade 0.18s ease; }
.screen.immersive { padding: 0; max-width: none; height: 100%; display: flex; flex-direction: column; animation: none; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Bottom-Nav (mobil) */
#bottomnav {
  flex: 0 0 auto;
  display: flex;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 20;
}
#bottomnav button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
  padding-top: 4px;
}
#bottomnav button .ic svg { width: 22px; height: 22px; }
#bottomnav button.active { color: var(--ink); font-weight: 500; }
#app.immersive #bottomnav { display: none; }

/* ============ Desktop: Seitenleiste ============ */
@media (min-width: 900px) {
  #app { flex-direction: row; }
  #sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    gap: 20px;
  }
  .brand {
    display: flex; align-items: center; gap: 9px;
    font-family: var(--font-serif); font-weight: 500; font-size: 19px; color: var(--ink);
    padding: 4px 10px;
  }
  .brand .ic svg { width: 20px; height: 20px; }
  .sidenav { display: flex; flex-direction: column; gap: 3px; }
  .sidenav button {
    display: flex; align-items: center; gap: 12px;
    background: none; border: none; color: var(--muted);
    padding: 11px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; text-align: left;
  }
  .sidenav button .ic svg { width: 20px; height: 20px; }
  .sidenav button:hover { background: var(--surface-2); color: var(--ink); }
  .sidenav button.active { background: var(--accent-tint); color: var(--accent-deep); }
  #bottomnav { display: none; }
  .screen { padding: 28px 32px 44px; }
  .screen.immersive { padding: 0; }
}

/* ============ Bausteine ============ */
.block { margin: 0 0 24px; }
.block:last-child { margin-bottom: 0; }
.block-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--label); margin: 0 0 10px; font-weight: 600;
}

.pagehead { margin: 2px 0 22px; }
.pagehead h2 { margin: 0 0 5px; font-family: var(--font-serif); font-weight: 500; font-size: 27px; line-height: 1.2; }
.pagehead p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

/* Navigations-/Listenzeilen */
.list { display: flex; flex-direction: column; gap: 9px; }
.navrow {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 13px; min-height: 58px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.12s, transform 0.05s;
}
.navrow.tappable { cursor: pointer; }
.navrow.tappable:hover { border-color: var(--border-strong); }
.navrow.tappable:active { transform: scale(0.995); }
.navrow.danger .navrow-title { color: var(--danger); }
.navrow-lead {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--ink);
}
.navrow-lead svg { width: 19px; height: 19px; }
.navrow-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.navrow-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navrow-sub { font-size: 13px; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--faint-2); flex: 0 0 auto; line-height: 0; display: inline-flex; }
.chev svg { width: 18px; height: 18px; }

.badge {
  flex: 0 0 auto; background: var(--surface-2); color: var(--label);
  border-radius: 999px; font-size: 12px; font-weight: 500; padding: 3px 9px; min-width: 22px; text-align: center;
}
.badge.status-ready { background: var(--ok-tint); color: var(--ok); }
.badge.status-error { background: var(--danger-tint); color: var(--danger); }
.badge.status-processing, .badge.status-pending { background: var(--accent-tint-2); color: var(--accent-deep); }

.empty {
  color: var(--muted); font-size: 14px; text-align: center; padding: 30px 16px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
  line-height: 1.6;
}

.iconbtn {
  background: none; border: 1px solid transparent; border-radius: 9px;
  padding: 5px 10px; font-size: 12.5px; font-weight: 500; color: var(--faint);
}
.iconbtn:hover { border-color: var(--border-strong); color: var(--ink); }
.iconbtn.danger { color: var(--danger); }
.iconbtn.danger:hover { border-color: var(--danger-soft, var(--danger)); }

.rowactions { display: flex; gap: 4px; flex: 0 0 auto; }

/* Chips / Segmented control */
.segmented {
  display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; margin-bottom: 20px; overflow-x: auto;
}
.segmented button {
  flex: 1; white-space: nowrap; background: none; border: none; color: var(--muted);
  padding: 9px 12px; border-radius: 9px; font-size: 13px; font-weight: 500;
}
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-card); }

/* ============ Formulare ============ */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 13px; color: var(--ink); font-weight: 500; }
.field-hint { font-size: 12.5px; color: var(--faint); line-height: 1.45; }
input, textarea, select {
  width: 100%; background: var(--card); border: 1px solid var(--border-strong);
  color: var(--ink); padding: 12px 13px; border-radius: 10px; font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--faint-2); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea { resize: vertical; min-height: 54px; line-height: 1.55; }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236E675C' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 38px;
}
input[type="checkbox"] { width: auto; }
.checkline {
  display: flex; align-items: center; gap: 11px; font-size: 14.5px; color: var(--ink);
  padding: 11px 13px; background: var(--card); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 8px;
}
.checkline input { width: auto; accent-color: var(--accent); width: 18px; height: 18px; }

.btn-primary {
  background: var(--accent); color: var(--on-accent); border: none; border-radius: 10px;
  padding: 14px 16px; font-size: 15px; font-weight: 600; margin-top: 4px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-ghost {
  background: var(--card); border: 1px solid var(--border-strong); color: var(--ink);
  border-radius: 10px; padding: 12px 14px; font-size: 14px; font-weight: 500;
}
.btn-ghost:hover { border-color: var(--faint-2); }

.inline-add { display: flex; gap: 8px; margin-bottom: 16px; }
.inline-add select, .inline-add input { flex: 1; }
.inline-add button { flex: 0 0 auto; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--bottomnav-h) + 18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 12px 30px rgba(124, 147, 212, 0.4); z-index: 15;
  display: inline-flex; align-items: center; justify-content: center;
}
.fab svg { width: 24px; height: 24px; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

/* ============ Drehbuch-Editor (Ablauf) ============ */
.sp-group {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px; margin-bottom: 14px; box-shadow: var(--shadow-card);
}
.sp-grouphead { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.sp-grouphead input { flex: 1; font-weight: 500; }
.sp-settings { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
@media (min-width: 620px) { .sp-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; } }

.info-banner {
  background: var(--accent-tint); border: 1px solid var(--accent-tint-2); border-radius: var(--radius);
  padding: 12px 14px; font-size: 13.5px; color: var(--accent-deep); margin-bottom: 16px;
  display: flex; gap: 8px; align-items: center; justify-content: space-between; line-height: 1.5;
}
.info-banner button { background: none; border: none; color: var(--accent-deep); font-weight: 600; font-size: 13.5px; text-decoration: underline; text-decoration-color: var(--accent-soft); }

/* ============ Story (Erzählung) ============ */
.story-output {
  white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; min-height: 220px;
  font-family: var(--font-serif); line-height: 1.75; font-size: 17px; color: var(--ink);
  text-wrap: pretty;
}

/* ============ Dashboard (Nutzung) ============ */
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; margin-bottom: 24px; }
@media (min-width: 620px) { .stat-row { grid-template-columns: repeat(3, 1fr); } }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-card); }
.stat-tile .value { font-family: var(--font-serif); font-size: 27px; font-weight: 500; line-height: 1.1; }
.stat-tile .label { font-size: 12.5px; color: var(--label); margin-top: 6px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--label); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============ Chat — die Bühne (dunkel) ============ */
#app.immersive #appbar {
  background: var(--stage-2);
  border-bottom: 1px solid var(--stage-line);
}
#app.immersive #appbar-title { color: #fff; }
#app.immersive #back { color: var(--stage-muted); }
#app.immersive #back:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
#app.immersive .appbar-btn { color: var(--stage-muted); }
#app.immersive .appbar-btn:hover { background: rgba(255, 255, 255, 0.08); }

.screen.immersive {
  background: linear-gradient(168deg, var(--stage-1) 0%, var(--stage-2) 52%, var(--stage-3) 100%);
}
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 20px 20px 8px; }

/* Figuren-Rede: keine Blase — Serifenprosa wie im Drehbuch. */
.msg { max-width: 100%; white-space: pre-wrap; }
.msg.assistant {
  color: var(--stage-text); font-family: var(--font-serif); font-size: 17px; line-height: 1.7;
  display: flex; flex-direction: column; gap: 8px; text-wrap: pretty;
}
.msg.assistant .who {
  font-family: var(--font-serif); font-size: 11px; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent-soft);
}
.msg.assistant .body { margin: 0; }
.msg.assistant .body em, .msg.assistant .body i { color: var(--stage-action); }

/* Konversationsmodus (Messenger): Assistenz-Nachrichten als linksbündige Blasen,
   Sans-Font, mehrere kurze Blasen untereinander. Nur additiv über .chatmode aktiv;
   der Storytelling-Modus (ohne die Klasse) bleibt unverändert. */
.messages.chatmode { gap: 8px; }
.messages.chatmode .msg.assistant {
  align-self: flex-start; max-width: 82%;
  background: rgba(255, 255, 255, 0.07); color: var(--stage-text);
  border-radius: 16px 16px 16px 5px; padding: 10px 14px;
  font-family: var(--font-sans); font-size: 15px; line-height: 1.55; gap: 3px;
}
.messages.chatmode .msg.assistant .who {
  font-family: var(--font-sans); font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: none; color: var(--accent-soft);
}
.messages.chatmode .msg.assistant .body em, .messages.chatmode .msg.assistant .body i {
  font-style: normal; color: inherit;
}

/* Tippindikator (Realismus „verzögert antworten"): drei pulsierende Punkte in
   einer Messenger-Blase. Nur im Konversationsmodus sichtbar/gestylt. */
.messages.chatmode .msg.assistant.typing {
  flex-direction: row; align-items: center; gap: 5px; padding: 12px 14px;
}
.messages.chatmode .msg.assistant.typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--stage-faint); opacity: 0.5;
  animation: typing-dot 1.2s infinite ease-in-out;
}
.messages.chatmode .msg.assistant.typing .dot:nth-child(2) { animation-delay: 0.18s; }
.messages.chatmode .msg.assistant.typing .dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 0.95; transform: translateY(-3px); }
}

/* Eigene Eingabe: die einzige Blase. */
.msg.user {
  align-self: flex-end; max-width: 82%;
  background: rgba(175, 192, 240, 0.16); color: #FBF2E9;
  border-radius: 16px 16px 5px 16px; padding: 12px 15px;
  font-family: var(--font-sans); font-size: 15px; line-height: 1.6;
}
.msg.user .who { display: none; }

.msg .usage { display: none; }               /* Prinzip: keine Rohdaten/Token-Zahlen auf der Bühne */
.msg .sources { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.msg .sources .srchead { font-size: 11px; color: var(--stage-faint); }
.msg .srcchip { font-size: 11px; color: var(--stage-muted); background: rgba(255, 255, 255, 0.07); border-radius: 999px; padding: 2px 9px; }
.msg .msgctrl { margin-top: 2px; display: flex; gap: 16px; align-items: center; }
.msg .msgctrl button {
  font-size: 12px; padding: 0; background: none; border: none; color: var(--stage-faint);
  display: inline-flex; align-items: center; gap: 5px;
}
.msg .msgctrl button:hover { color: var(--stage-text); }
.msg .msgctrl button svg { width: 13px; height: 13px; }

.empty { }
.screen.immersive .empty { background: rgba(255, 255, 255, 0.04); border-color: var(--stage-line); color: var(--stage-faint); margin: 0 20px; }

/* Composer */
.composer {
  flex: 0 0 auto; display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
}
.composer .composer-input {
  flex: 1; min-height: 46px; max-height: 140px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid transparent; color: var(--stage-text);
  border-radius: 14px; padding: 13px 15px; line-height: 1.4;
}
.composer .composer-input::placeholder { color: var(--stage-faint); }
.composer .composer-input:focus { outline: none; border-color: rgba(175, 192, 240, 0.4); box-shadow: none; }
.composer button {
  flex: 0 0 auto; width: 46px; height: 46px; align-self: flex-end;
  background: var(--accent); border: none; color: var(--on-accent); border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer button svg { width: 19px; height: 19px; }
.composer button:disabled { opacity: 0.5; }

/* Drehbuch-Fortschritt auf der Bühne */
.sp-progress {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px 12px; background: var(--stage-2); border-bottom: 1px solid var(--stage-line);
}
.sp-progress .sp-label { flex: 1; min-width: 0; font-size: 11px; letter-spacing: 0.06em; color: var(--stage-faint); }
.sp-progress .sp-label b { color: var(--accent-soft); font-weight: 600; }
.sp-progress button {
  background: rgba(255, 255, 255, 0.08); border: none; border-radius: 999px;
  padding: 7px 12px; font-size: 12.5px; color: var(--stage-muted); display: inline-flex; align-items: center; gap: 6px;
}
.sp-progress button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.sp-progress button:disabled { opacity: 0.35; }

/* ============ Toast ============ */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); border: none; color: #FAF8F5;
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-pop);
  opacity: 0; transition: opacity 0.22s, transform 0.22s; pointer-events: none; max-width: 90vw; z-index: 50; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }
@media (min-width: 900px) { #toast { bottom: 24px; left: auto; right: 24px; transform: translateY(20px); } #toast.show { transform: translateY(0); } }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Redesign: Karten, Tabs, Start, Suche, Zeitleiste ============ */

/* Segmented als Tab-Leiste (Welt-/Szene-/Bibliothek-Detail) */
.segmented.tabs { margin-bottom: 16px; }

/* Karten (Welt / Szene) */
.card-list { display: flex; flex-direction: column; gap: 11px; }
.wcard, .scard {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow-card); transition: border-color 0.12s, transform 0.05s;
}
.wcard:hover, .scard:hover { border-color: var(--border-strong); }
.wcard:active, .scard:active { transform: scale(0.995); }
.wcard-head, .scard-head { display: flex; align-items: flex-start; gap: 12px; }
.wcard-title, .scard-title { flex: 1; font-family: var(--font-serif); font-weight: 500; font-size: 19px; line-height: 1.25; }
.scard-title { font-size: 17px; }
.wcard-desc, .scard-sub { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.wcard .chev, .scard .chev { color: var(--faint-2); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.chip.accent { color: var(--on-accent); background: var(--accent-tint-2); }

/* Gestrichelte „Neue …"-Karte */
.add-card {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 15px 16px; color: var(--muted); font-size: 15px; font-weight: 500;
}
.add-card:hover { border-color: var(--faint-2); color: var(--ink); }
.add-card svg { width: 19px; height: 19px; }

/* Start: „Weiterspielen"-Dunkelkarte */
.resume-card {
  background: var(--ink); border-radius: var(--radius-lg); padding: 18px;
  display: flex; flex-direction: column; gap: 13px; color: #fff;
}
.resume-loc { font-size: 12px; color: var(--accent-soft); }
.resume-title { font-family: var(--font-serif); font-weight: 500; font-size: 21px; line-height: 1.25; color: #fff; }
.resume-snippet { margin: 0; font-size: 14px; line-height: 1.55; color: var(--stage-muted); }
.resume-progress { display: flex; align-items: center; gap: 5px; }
.resume-progress .bar { height: 4px; flex: 1; background: rgba(255, 255, 255, 0.22); border-radius: 9px; }
.resume-progress .bar.on { background: var(--accent); }
.resume-progress .resume-beat { flex: 0 0 auto; font-size: 11px; color: var(--stage-faint); margin-left: 6px; }
.resume-btn {
  height: 44px; background: var(--accent); color: var(--on-accent); border: none; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 15px;
}
.resume-btn svg { width: 15px; height: 15px; }

/* Start: „Neu anfangen"-Kacheln */
.start-tiles { display: flex; gap: 10px; }
.start-tile {
  flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  font-size: 14px; font-weight: 500; color: var(--ink); box-shadow: var(--shadow-card);
}
.start-tile:hover { border-color: var(--border-strong); }
.start-tile svg { width: 20px; height: 20px; }

/* Suche */
.searchbar {
  display: flex; align-items: center; gap: 9px; background: var(--surface-2);
  border-radius: 12px; padding: 0 12px; height: 46px; margin-bottom: 16px;
}
.searchbar .ic { color: var(--faint); flex: 0 0 auto; }
.searchbar input { flex: 1; background: none; border: none; padding: 0; height: 100%; font-size: 15px; }
.searchbar input:focus { outline: none; box-shadow: none; }
.search-results .block { margin-bottom: 18px; }

/* Avatar (Initialen) */
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 999px; background: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 500; font-size: 14px; color: var(--accent-soft);
}
.navrow-lead:has(.avatar) { background: none; }

/* Erweitert-Aufklapper */
details.adv { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
details.adv > summary {
  list-style: none; cursor: pointer; padding: 13px 14px; display: flex; align-items: center; gap: 10px;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary .adv-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
details.adv > summary .adv-title { font-size: 15px; font-weight: 500; }
details.adv > summary .adv-sub { font-size: 13px; color: var(--label); }
details.adv > summary .adv-chev { color: var(--faint); transition: transform 0.15s; display: inline-flex; }
details.adv[open] > summary .adv-chev { transform: rotate(180deg); }
details.adv .adv-body { padding: 4px 14px 16px; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--border-soft); }

/* Beat-Zeitleiste (Szene) */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 24px; flex: 0 0 auto; }
.tl-node { width: 24px; height: 24px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; flex: 0 0 auto; border: 1.5px solid var(--border-strong); color: var(--label); background: var(--surface); }
.tl-node.done { background: var(--ink); color: #fff; border-color: var(--ink); }
.tl-node.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tl-line { flex: 1; width: 1.5px; background: var(--border-strong); }
.tl-body { flex: 1; padding-bottom: 12px; }
.tl-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 3px; }
.tl-card.active { border: 1.5px solid var(--accent); }
.tl-card .tl-title { font-size: 15px; font-weight: 500; }
.tl-card .tl-sub { font-size: 12px; color: var(--label); }
.tl-card .tl-sub.active { color: var(--accent-deep); }

/* Szene: Primäraktionen */
.scene-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.btn-dark { height: 48px; background: var(--ink); color: #fff; border: none; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 500; font-size: 15px; }
.btn-dark svg { width: 16px; height: 16px; color: var(--accent); }

/* Modus-Umschalter (Reihe/Zufall) + Switch + Stepper (Ablauf-Editor) */
.modeswitch { background: var(--surface-2); border-radius: 8px; padding: 2px; display: inline-flex; }
.modeswitch button { border: none; background: none; padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--label); }
.modeswitch button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-card); }
.switch { width: 42px; height: 25px; flex: 0 0 auto; background: var(--card); border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px; display: inline-flex; cursor: pointer; }
.switch .knob { width: 19px; height: 19px; border-radius: 999px; background: var(--faint); transition: transform 0.15s, background 0.15s; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on .knob { transform: translateX(17px); background: var(--on-accent); }
.switchline { display: flex; align-items: center; gap: 12px; }
.switchline .switchline-label { flex: 1; font-size: 14px; }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--border-strong); border-radius: 9px; padding: 3px; }
.stepper button { width: 28px; height: 28px; border: none; background: none; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.stepper button:hover { background: var(--surface-2); }
.stepper button svg { width: 14px; height: 14px; }
.stepper .val { min-width: 34px; text-align: center; font-weight: 500; font-size: 15px; }

/* Tab-Unterüberschrift (z. B. „5 Beats · Bearbeiten") + Text-Link */
.tab-subhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tab-subhead .block-title { margin: 0; }
.linkbtn { background: none; border: none; color: var(--accent-deep); font-size: 13px; font-weight: 500; }
.linkbtn:hover { text-decoration: underline; text-decoration-color: var(--accent-soft); }

/* Ablauf-Editor: Einstellungen als Spalte (Switch/Stepper/Modus) */
.sp-settings-col { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

/* Beschriftete Setting-Detailzeilen (Szenen-Detail) */
.detail-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.detail-row { display: flex; gap: 10px; font-size: 14px; line-height: 1.5; }
.detail-key { flex: 0 0 96px; color: var(--label); }
.detail-val { flex: 1; min-width: 0; color: var(--ink); }

/* ============ Interaktive Praktik-Widgets (Chat / dunkle Bühne) ============ */
.msg.event { align-self: center; max-width: 92%; text-align: center; font-size: 12.5px; font-style: italic; color: var(--stage-faint); padding: 2px 0; }
.pw { margin-top: 10px; background: rgba(255,255,255,0.06); border: 1px solid var(--stage-line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.pw.on { border-color: rgba(175,192,240,0.5); background: rgba(175,192,240,0.12); }
.pw.done { opacity: 0.7; }
.pw-head { display: flex; align-items: center; gap: 8px; }
.pw-name { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; color: var(--stage-text); }
.pw-kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--stage-faint); }
.pw-state { font-size: 12px; color: var(--accent-soft); }
.pw.done .pw-state { color: var(--stage-faint); }
.pw-time { font-family: var(--font-serif); font-size: 24px; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.pw-bar { height: 4px; background: rgba(255,255,255,0.14); border-radius: 9px; overflow: hidden; }
.pw-bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 9px; transition: width 0.5s linear; }
.pw-cancel { align-self: flex-start; background: rgba(255,255,255,0.08); border: none; color: var(--stage-muted); border-radius: 999px; padding: 6px 14px; font-size: 12.5px; }
.pw-cancel:hover { background: rgba(255,255,255,0.14); color: #fff; }

/* ============ Admin-Panel (Nutzerverwaltung) ============ */
/* Admins sehen nur das Panel — App-Navigation ausblenden. */
.admin-mode #sidebar,
.admin-mode #bottomnav { display: none !important; }

.admin-user .navrow-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  white-space: normal; overflow: visible;
}
.admin-actions { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.admin-actions .iconbtn { border-color: var(--border); }

/* ============ Regie-Leiste (Director Engine) ============ */
/* Sitzt im Chat (dunkle „Bühne") unter der Ablauf-Leiste. Rein informativ. */
.director-bar {
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 7px;
  padding: 9px 18px 11px; background: var(--stage-2); border-bottom: 1px solid var(--stage-line);
}
.director-bar.landing { background: linear-gradient(90deg, var(--stage-2), rgba(124, 147, 212, 0.14)); }
.director-bar .db-head { display: flex; align-items: center; gap: 9px; }
.director-bar .db-tag {
  flex: 0 0 auto; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--on-accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px;
}
.director-bar .db-beat { flex: 1; min-width: 0; font-size: 12px; color: var(--stage-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.director-bar .db-phase { flex: 0 0 auto; font-size: 11px; letter-spacing: 0.04em; color: var(--stage-faint); }
.director-bar .db-log {
  flex: 0 0 auto; background: rgba(255, 255, 255, 0.08); border: none; border-radius: 999px;
  padding: 3px 10px; font-size: 11px; color: var(--stage-muted); cursor: pointer;
}
.director-bar .db-log:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* Beat-Graph-Editor (im Ablauf-Screen, helle Werkstatt) */
.sp-graph-beat { border-top: 1px solid var(--border); padding: 10px 0; }
.sp-graph-beat:first-child { border-top: none; }
.sp-graph-from { font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.sp-transition { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); padding: 3px 0; }
.sp-graph-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.sp-graph-add select, .sp-graph-add input { flex: 1 1 110px; min-width: 100px; }
.director-bar.landing .db-phase { color: var(--accent-soft); font-weight: 600; }
.director-bar .db-progress { height: 3px; background: rgba(255, 255, 255, 0.12); border-radius: 9px; overflow: hidden; }
.director-bar .db-progress > span { display: block; height: 100%; background: var(--accent); border-radius: 9px; transition: width 0.4s ease; }
.director-bar .db-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--stage-faint); font-variant-numeric: tabular-nums; }
.director-bar .db-practices { display: flex; flex-wrap: wrap; gap: 6px; }
.director-bar .db-practices .chip { font-size: 11px; padding: 3px 9px; }
