
  *, *::before, *::after { box-sizing: border-box; }

  /* ── Theme: dark (default) — ported 1:1 from V2 ───────────────── */
  :root, [data-theme="dark"] {
    --bg-0: #000;
    --bg-1: #0a0a0c;
    --bg-2: #131316;
    --bg-3: #1c1c20;
    --bg-4: #28282e;
    --fg-0: #fafafa;
    --fg-1: #a1a1aa;
    --fg-2: #71717a;
    --fg-3: #3f3f46;
    --accent: #a1a1aa;
    --accent-glow: rgba(255, 255, 255, 0.12);
    --accent-soft: rgba(255, 255, 255, 0.06);
    --sel-bg: rgba(86, 140, 255, 0.60);                          /* Textmarkierung: muss auffallen, nicht passen */
    --sel-fg: #fff;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --line: rgba(255, 255, 255, 0.06);
    --line-strong: rgba(255, 255, 255, 0.12);
    --glass: rgba(20, 20, 24, 0.72);
    --bg-grad: radial-gradient(ellipse at 50% -30%, #1a1a22 0%, #000 55%);
    --shadow-card: 0 24px 48px -24px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.02);
    --shadow-stage: 0 30px 60px -30px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.02);
    --send-bg: var(--fg-0);
    --send-fg: #000;
  }
  [data-theme="light"] {
    --bg-0: #fafafa;
    --bg-1: #fff;
    --bg-2: #f4f4f5;
    --bg-3: #e4e4e7;
    --bg-4: #d4d4d8;
    --fg-0: #18181b;
    --fg-1: #52525b;
    --fg-2: #71717a;
    --fg-3: #a1a1aa;
    --accent: #52525b;
    --accent-glow: rgba(0, 0, 0, 0.12);
    --accent-soft: rgba(0, 0, 0, 0.05);
    --sel-bg: rgba(56, 120, 255, 0.40);
    --sel-fg: #0b0b0d;
    --line: rgba(0, 0, 0, 0.06);
    --line-strong: rgba(0, 0, 0, 0.12);
    --glass: rgba(255, 255, 255, 0.78);
    --bg-grad: radial-gradient(ellipse at 50% -30%, #f0f0f5 0%, #fafafa 55%);
    --shadow-card: 0 24px 48px -24px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.02);
    --shadow-stage: 0 30px 60px -30px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.02);
    --send-bg: #18181b;
    --send-fg: #fff;
  }

  :root {
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-2xl: 28px;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
    --t: 220ms cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
    /* S1: measured prompt-dock height (ResizeObserver writes this at runtime).
       Fallback 180px matches the previous phone magic number; the stage uses it
       to reserve scroll room so output never hides behind the growing dock. */
    --dock-h: 180px;
  }

  html, body {
    height: 100vh;
    height: 100dvh;
    margin: 0;
    background: var(--bg-grad);
    color: var(--fg-0);
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv02', 'cv11', 'ss01';
    letter-spacing: -0.005em;
    transition: background 300ms ease, color 300ms ease;
  }
  ::selection { background: var(--sel-bg); color: var(--sel-fg); }
  input::selection, textarea::selection { background: var(--sel-bg); color: var(--sel-fg); }
  button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
  button { background: none; border: none; cursor: pointer; padding: 0; color: inherit; }
  input, textarea, select { outline: none; }
  textarea { resize: none; }

  /* ── Top bar ───────────────────────────────────────────────── */
  .top {
    position: fixed; inset: 0 0 auto 0;
    height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--s5);
    /* N3: respect the landscape notch (iPhone quer) — pull the bar in past the
       sensor housing. env() resolves to 0 where there is no safe area. */
    padding-left: max(var(--s5), env(safe-area-inset-left));
    padding-right: max(var(--s5), env(safe-area-inset-right));
    z-index: 30;
  }
  .brand {
    display: flex; align-items: center; gap: var(--s3);
    flex-shrink: 0;
    font-weight: 600; font-size: 14px;
    letter-spacing: -0.01em;
  }
  .brand-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 16px var(--accent-glow);
  }
  .brand-name { color: var(--fg-0); white-space: nowrap; }
  .brand-sub  { color: var(--fg-2); font-weight: 400; font-size: 12px; margin-left: var(--s2); }

  .mode-tabs {
    position: absolute; left: 50%; transform: translateX(-50%);
    display: flex; gap: 2px;
    padding: 4px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 999px;
  }
  .mode-tab {
    padding: 6px 14px;
    font-size: 12px; font-weight: 500;
    color: var(--fg-1);
    border-radius: 999px;
    transition: var(--t-fast);
    display: inline-flex; align-items: center; gap: 6px;
  }
  .mode-tab:hover { color: var(--fg-0); }
  .mode-tab.on {
    background: var(--bg-4);
    color: var(--fg-0);
    box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 0 0 0.5px rgba(255,255,255,0.06);
  }
  [data-theme="light"] .mode-tab.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
  .mode-tab svg { flex-shrink: 0; }
  .mode-tab[disabled] { opacity: 0.45; cursor: not-allowed; }
  /* Auf schmalen Schirmen scrollt die Reiterzeile. tabsFade() setzt die
     Klassen; die Maske zeigt, dass rechts bzw. links noch Reiter liegen. */
  .mode-tabs.scroll-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
  .mode-tabs.scroll-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); }
  .mode-tabs.scroll-l.scroll-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }

  .top-right { display: flex; align-items: center; gap: var(--s2); font-size: 12px; }
  .cost {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; line-height: 1;
    color: var(--fg-1);
    padding: 7px 12px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--t-fast);
  }
  .cost:hover { border-color: var(--line-strong); color: var(--fg-0); }
  .cost span { color: var(--fg-2); }
  .cost b { color: var(--fg-0); font-weight: 500; font-variant-numeric: tabular-nums; }

  /* ── Geldzaehler (Schritt 5) ──────────────────────────────── */
  .spend-card { max-width: 560px; width: 92vw; max-height: 86vh; overflow-y: auto; }
  /* Lip-Sync-Dialog (2026-10-04) */
  .lip-card { max-width: 460px; width: 92vw; }
  .lip-zeile { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--fg-1); }
  .lip-info, .lip-preis { font-size: 13px; color: var(--fg-2); min-height: 18px; margin-top: 6px; }
  .lip-modelle { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 6px; }
  .lip-modell { display: flex; gap: 8px; align-items: baseline; font-size: 13px; cursor: pointer; }
  .lip-modell span { color: var(--fg-2); }
  .spend-ranges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 18px; }
  .spend-range {
    display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
    padding: 10px; text-align: left; cursor: pointer;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm);
    transition: var(--t-fast);
  }
  .spend-range:hover { border-color: var(--line-strong); }
  .spend-range.on { border-color: var(--fg-2); background: var(--bg-3); }
  .spend-range-label { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2); }
  .spend-range-eur {
    font-family: 'JetBrains Mono', monospace; font-size: 15px; color: var(--fg-0);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .spend-range-jobs { font-size: 10px; color: var(--fg-3); }
  .spend-sec { margin-bottom: 18px; }
  .spend-sec-head {
    font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--fg-2); margin-bottom: 8px;
  }
  .spend-bars {
    display: flex; align-items: flex-end; gap: 2px;
    height: 54px; border-bottom: 1px solid var(--line);
  }
  .spend-bar { flex: 1; min-height: 1px; background: var(--bg-4); border-radius: 2px 2px 0 0; }
  .spend-bar.on { background: var(--fg-2); }
  .spend-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12px; }
  .spend-row-name {
    flex: 0 0 40%; color: var(--fg-1);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .spend-row-track { flex: 1; height: 6px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
  .spend-row-track i { display: block; height: 100%; background: var(--fg-2); border-radius: 999px; }
  .spend-row-eur {
    flex: 0 0 78px; text-align: right;
    font-family: 'JetBrains Mono', monospace; color: var(--fg-0);
    font-variant-numeric: tabular-nums;
  }
  .owner-badge {
    cursor: pointer; position: relative;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
    padding: 5px 10px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 999px;
  }
  .owner-badge.pn-neu::after, .owner-badge.pn-alarm::after {
    content: ''; position: absolute; top: -2px; right: -2px;
    width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  }
  .owner-badge.pn-alarm::after { background: var(--err); }
  .auth-card.pn-card { max-width: 620px; max-height: 84vh; overflow-y: auto; }
  .pn-sek { margin-top: var(--s3); font-size: 12px; }
  .pn-sek > b { display: block; margin-bottom: 4px; color: var(--fg-0); }
  .pn-zeile { padding: 4px 0; border-top: 1px solid var(--line); color: var(--fg-1); line-height: 1.5; }
  .pn-anb { display: inline-block; min-width: 72px; font-family: 'JetBrains Mono', monospace; color: var(--fg-0); }
  .pn-zeile code { font-size: 11px; }
  .pn-dim { color: var(--fg-2); }
  .pn-fehl, .pn-alarm-t { color: var(--err); }
  .ws-pill {
    font-size: 11px;
    padding: 6px 10px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--fg-1);
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ws-pill b { color: var(--fg-0); font-weight: 500; }
  .icon-btn {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--fg-1);
    transition: var(--t-fast);
  }
  .icon-btn:hover { background: var(--bg-2); color: var(--fg-0); }
  /* Hilfe-Modus (2026-09-20) */
  #hilfeBtn.on { background: var(--fg-0); color: var(--bg-0); }
  body.hilfe-an, body.hilfe-an * { cursor: help !important; }
  .hilfe-ziel { outline: 2px solid var(--warn) !important; outline-offset: 2px; border-radius: 6px; }
  #hilfeCard { position: fixed; z-index: 9999; width: min(340px, calc(100vw - 24px)); padding: 10px 12px 9px; border-radius: 10px; background: var(--bg-1); border: 1px solid var(--line-strong); box-shadow: 0 12px 32px rgba(0,0,0,.35); color: var(--fg-0); font-size: 12.5px; line-height: 1.45; cursor: default !important; }
  #hilfeCard * { cursor: default !important; }
  #hilfeCard h4 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--fg-0); }
  #hilfeCard p { margin: 0; white-space: pre-wrap; color: var(--fg-1); }
  #hilfeCard .hilfe-acts { display: flex; gap: 6px; justify-content: flex-end; margin-top: 9px; }
  #hilfeCard .hilfe-acts button { height: 24px; padding: 0 10px; border-radius: 6px; background: var(--bg-3); color: var(--fg-1); font-size: 11px; cursor: pointer !important; transition: var(--t-fast); }
  #hilfeCard .hilfe-acts button:hover { background: var(--bg-4); color: var(--fg-0); }
  #hilfeCard .hilfe-acts button.primary { background: var(--fg-0); color: var(--bg-0); }
  #hilfeCard .hilfe-acts button.primary:hover { background: var(--fg-1); }

  /* ── Konto-Blatt (<=1100px) ───────────────────────────────────────
     Auf schmalen Schirmen buendelt ein Knopf, was in der Kopfzeile keinen
     Platz hat: Ausgaben, Gelernt, Theme, Passwort, Abmelden, Projektwechsel.
     Auf dem Desktop bleibt der Knopf unsichtbar — dort stehen die Knoepfe
     selbst in der Zeile. Das Blatt ruft dieselben Funktionen wie sie. */
  #acctBtn { display: none; }
  .acct-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg-2);
    border-top: 1px solid var(--line-strong);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 6px var(--s3) calc(var(--s3) + env(safe-area-inset-bottom));
    box-shadow: 0 -24px 64px -16px rgba(0,0,0,0.5);
    z-index: 42;
    max-height: calc(100dvh - 20px); overflow-y: auto;
  }
  .acct-sheet::before {
    content: ''; display: block; width: 36px; height: 4px; border-radius: 2px;
    background: var(--line-strong); margin: 4px auto 8px;
  }
  .acct-head {
    padding: 6px var(--s2) 10px; font-size: 12px; color: var(--fg-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .acct-head b { color: var(--fg-0); font-weight: 500; }
  .acct-row {
    display: flex; align-items: center; gap: var(--s3);
    width: 100%; min-height: 48px; padding: 0 var(--s2);
    border-radius: var(--r-sm); font-size: 14px; color: var(--fg-0);
    text-align: left; transition: var(--t-fast);
  }
  .acct-row:hover { background: var(--bg-3); }
  .acct-row svg { flex: 0 0 auto; color: var(--fg-1); }
  .acct-row b {
    margin-left: auto; font-family: 'JetBrains Mono', monospace;
    font-size: 12px; font-weight: 500; color: var(--fg-1);
    font-variant-numeric: tabular-nums;
  }
  .acct-row.danger { color: var(--err); }
  .acct-sep { height: 1px; background: var(--line); margin: 6px 0; }

  /* ── Stage ────────────────────────────────────────────────── */
  .stage {
    position: fixed;
    top: 56px; left: 0; right: 0; bottom: 0;
    display: grid;
    place-items: center;
    padding: var(--s5);
    padding-bottom: max(280px, calc(var(--dock-h, 180px) + var(--row-h, 0px) + var(--stock-h, 0px) + var(--s6)));
  }
  .stage-inner {
    position: relative;
    width: 100%;
    max-width: 1100px;
    aspect-ratio: 16 / 9;
    background:
      linear-gradient(180deg, rgba(255,255,255,0.025) 0%, transparent 100%),
      var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-2xl);
    overflow: hidden;
    transition: var(--t);
    box-shadow: var(--shadow-stage);
  }
  .stage-inner.has-output { background: #000; }
  [data-theme="light"] .stage-inner.has-output { background: #18181b; }
  .stage-inner.busy {
    border-color: var(--accent-soft);
    box-shadow: var(--shadow-stage), 0 0 80px -20px var(--accent-glow);
  }
  .stage-empty {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--s3);
    pointer-events: none;
    padding: var(--s5);
    text-align: center;
  }
  .stage-empty .pulse {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.18), rgba(255,255,255,0.02));
    border: 1px solid var(--line-strong);
    position: relative;
  }
  [data-theme="light"] .stage-empty .pulse {
    background: radial-gradient(circle at 35% 35%, rgba(0,0,0,0.08), rgba(0,0,0,0.02));
  }
  .stage-empty .pulse::after {
    content: '';
    position: absolute; inset: -8px;
    border-radius: 50%;
    border: 1px solid var(--line);
    animation: pulse 3s ease-out infinite;
  }
  @keyframes pulse {
    0%   { transform: scale(0.95); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
  }
  .stage-empty .title {
    font-size: 28px; font-weight: 300;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, var(--fg-0) 0%, var(--fg-1) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .stage-empty .sub {
    font-size: 13px; color: var(--fg-2); font-weight: 400;
    max-width: 480px;
  }
  .stage-media { width: 100%; height: 100%; object-fit: contain; display: none; }

  /* Viererblock: mehrere Ergebnisse desselben Prompts nebeneinander. Liegt als
     eigene Ebene UEBER der Stage, damit die Einzelansicht unangetastet bleibt --
     ein Klick auf eine Kachel uebergibt an genau diese Einzelansicht, mit allen
     Knoepfen, die es dort schon gibt (Download, Bearbeiten, Video, 4K, Urteil). */
  .stage-block { position: absolute; inset: 0; display: none; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 6px; padding: 6px; background: #000; z-index: 3; }
  .stage-block.show { display: grid; }
  .stage-block.zwei { grid-template-rows: 1fr; }
  .block-kachel { position: relative; overflow: hidden; border-radius: var(--r-sm); background: var(--bg-2, #111); border: 1px solid var(--line); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color var(--t-fast); }
  .block-kachel:hover { border-color: var(--fg-1); }
  .block-kachel.tot { cursor: default; }
  .block-kachel.tot:hover { border-color: var(--line); }
  .block-kachel img, .block-kachel video { width: 100%; height: 100%; object-fit: contain; display: block; }
  .block-nr { position: absolute; top: 6px; left: 8px; font-size: 10px; letter-spacing: .08em; padding: 2px 7px; border-radius: 99px; background: rgba(0,0,0,.62); color: #fff; pointer-events: none; }
  .block-warte { display: flex; flex-direction: column; align-items: center; gap: 9px; font-size: 11px; color: var(--fg-1); }
  .block-dreh { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--fg-1); animation: blockdreh .9s linear infinite; }
  @keyframes blockdreh { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .block-dreh { animation: none; } }
  /* Ein Fehlschlag bleibt SICHTBAR stehen. Er verschwindet nicht und rueckt die
     anderen nicht zusammen -- sonst sieht ein halber Block aus wie ein ganzer. */
  .block-fehler { font-size: 11px; color: var(--fg-1); text-align: center; padding: 14px; line-height: 1.5; }
  .block-fehler b { display: block; font-size: 12px; color: var(--fg-0); margin-bottom: 4px; font-weight: 600; }
  .block-fuss { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 11px; color: var(--fg-1); background: rgba(0,0,0,.66); padding: 5px 13px; border-radius: 99px; pointer-events: none; z-index: 4; }
  [data-theme="light"] .block-fuss { background: rgba(0,0,0,.72); color: #e4e4e7; }
  .stage-media.show { display: block; }

  /* ── Ergebnis-Zeile ──────────────────────────────────────────────────
     Liegt zwischen Stage und Prompt-Dock. Verankert am gemessenen
     --dock-h, damit sie mitwandert, wenn das Eingabefeld waechst; ihre
     eigene Hoehe meldet sie als --row-h zurueck, damit die Stage darueber
     Platz reserviert statt sich dahinter zu schieben. */
  .result-row {
    position: fixed;
    bottom: calc(var(--dock-h, 180px) + var(--s5) + var(--s3));
    left: 50%; transform: translateX(-50%);
    width: calc(100% - var(--s7)); max-width: 1100px;
    z-index: 15;
    display: none;
  }
  .result-row.show { display: block; }
  .result-head { display: flex; align-items: baseline; gap: var(--s3); padding: 0 2px 6px; }
  .result-title { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
  .result-count { font-size: 11px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
  .result-all { margin-left: auto; font-size: 11px; color: var(--fg-2); transition: var(--t-fast); }
  .result-all:hover { color: var(--fg-0); }
  .result-strip { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 2px 6px; }
  .result-strip::-webkit-scrollbar { height: 6px; }
  .result-strip::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
  .res-tile {
    position: relative; flex: 0 0 auto;
    width: 96px; height: 96px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--bg-1); overflow: hidden; cursor: pointer;
    transition: var(--t-fast);
  }
  .res-tile:focus-visible { outline: 2px solid var(--fg-0); outline-offset: 1px; }
  /* Aufgreifen + Papierkorb direkt an der Kachel (2026-09-16). Am Rechner erst
     beim Zeigen, am Telefon immer -- dort gibt es kein Hover. */
  .res-acts { position: absolute; left: 4px; top: 4px; display: flex; gap: 3px; opacity: 0; transition: var(--t-fast); }
  .res-tile:hover .res-acts, .res-tile:focus-within .res-acts { opacity: 1; }
  .res-act { width: 22px; height: 22px; border: 0; border-radius: 6px; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 12px; line-height: 22px; padding: 0; cursor: pointer; transition: var(--t-fast); }
  .res-act:hover { background: rgba(0, 0, 0, 0.9); }
  .res-act-del:hover { background: var(--err); }
  @media (hover: none) { .res-acts { opacity: 1; } }
  .res-tile:hover { border-color: var(--line-strong); }
  .res-tile.on { border-color: var(--fg-0); box-shadow: 0 0 0 1px var(--fg-0); }
  .res-tile img, .res-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
  .res-status { width: 100%; height: 100%; display: grid; place-items: center; text-align: center; font-size: 11px; color: var(--fg-2); padding: 6px; }
  .res-status.failed { color: var(--err); }
  .res-badge {
    position: absolute; right: 4px; bottom: 4px;
    font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 999px;
    background: var(--glass); border: 1px solid var(--line); color: var(--fg-1);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }

  /* ── Lernschleife (Schritt 7) ───────────────────────────────────────
     Das Urteil sitzt als kleine Marke auf der Ergebnis-Kachel: er soll auf
     einen Blick sehen, was schon zaehlt, und nicht zweimal ueber dasselbe
     Bild urteilen. Der Coach-Chip haengt in der Werkzeugzeile des Docks --
     dort, wo der Prompt entsteht, nicht in einem Fenster daneben. */
  .res-mark {
    position: absolute; left: 4px; top: 4px;
    width: 17px; height: 17px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 10px; line-height: 1;
    border: 1px solid var(--line-strong); background: var(--glass);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .res-mark.gut { color: var(--ok); }
  .res-mark.schlecht { color: var(--err); }
  .stage-action.urteil.on-gut { background: var(--ok); border-color: var(--ok); color: #0a1a0f; }
  .stage-action.urteil.on-schlecht { background: var(--err); border-color: var(--err); color: #1a0a0a; }
  .rule-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .rule-txt { flex: 1 1 auto; font-size: 12px; line-height: 1.45; color: var(--fg-1); }
  .rule-scope { flex: 0 0 auto; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
  .rule-w { flex: 0 0 34px; height: 4px; border-radius: 2px; background: var(--line-strong); overflow: hidden; }
  .rule-w i { display: block; height: 100%; background: var(--accent); }
  .rule-del { flex: 0 0 auto; border: none; background: none; cursor: pointer; font-size: 12px; color: var(--fg-3); padding: 2px 4px; }
  .rule-del:hover { color: var(--err); }
  .rule-row.archived .rule-txt { opacity: 0.45; text-decoration: line-through; }
  .rule-scope.modell { color: var(--accent); }
  /* E3: das eine Wort nach dem Urteil. Schwebt ueber dem Dock, damit der Blick
     beim Ergebnis bleibt; verschwindet mit Wort, mit X oder von selbst. */
  .wort-chips {
    position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 70;
    display: none; flex-wrap: wrap; align-items: center; gap: 6px;
    width: max-content; max-width: min(92vw, 640px); padding: 10px 12px; border-radius: 14px;
    background: var(--glass); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .wort-chips.show { display: flex; }
  .wc-frage { flex: 0 0 100%; font-size: 11px; color: var(--fg-2); }
  .wort-chip {
    font: inherit; font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
    background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-1);
  }
  .wort-chip:hover { border-color: var(--fg-3); }
  .wort-chips input {
    font: inherit; font-size: 12px; padding: 5px 10px; border-radius: 999px; width: 150px;
    background: transparent; border: 1px dashed var(--line); color: var(--fg-1);
  }
  .wc-zu { font: inherit; font-size: 12px; padding: 4px 8px; border-radius: 999px; background: transparent; border: 0; color: var(--fg-3); cursor: pointer; }
  .wc-zu:hover { color: var(--fg-1); }

  /* ── Stammregal (Schritt 6) ─────────────────────────────────────────
     Dauermaterial des Kunden: Logo, Produktfotos, Hausfarben. Es haengt am
     KUNDEN, nicht am Projekt, und ist darum in jedem seiner Projekte da --
     die eine erlaubte Ausnahme von "ein neues Projekt zeigt nichts Altes".
     Es sitzt ueber der Ergebnis-Zeile und meldet seine Hoehe als --stock-h
     zurueck, damit die Buehne darueber nicht dahinter scrollt. */
  .stock-row {
    position: fixed;
    bottom: calc(var(--dock-h, 180px) + var(--row-h, 0px) + var(--s5) + var(--s5));
    left: 50%; transform: translateX(-50%);
    width: calc(100% - var(--s7)); max-width: 1100px;
    z-index: 15;
    display: none;
  }
  .stock-row.show { display: block; }
  .stock-head { display: flex; align-items: baseline; gap: var(--s3); padding: 0 2px 6px; }
  .stock-title { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
  .stock-client { font-size: 11px; color: var(--fg-3); }
  .stock-add { font-size: 11px; color: var(--fg-2); transition: var(--t-fast); }
  .stock-add:hover { color: var(--fg-0); }
  .stock-hint { margin-left: auto; font-size: 11px; color: var(--fg-3); }
  .stock-strip { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 2px 6px; align-items: flex-start; }
  .stock-strip::-webkit-scrollbar { height: 6px; }
  .stock-strip::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
  .stock-empty { font-size: 12px; color: var(--fg-3); padding: 4px 2px; }
  .stock-tile { position: relative; flex: 0 0 auto; width: 76px; }
  .stock-thumb {
    position: relative; width: 76px; height: 76px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--bg-1); overflow: hidden; cursor: pointer;
    display: grid; place-items: center;
    transition: var(--t-fast);
  }
  .stock-thumb:hover { border-color: var(--line-strong); }
  .stock-tile.on .stock-thumb { border-color: var(--fg-0); box-shadow: 0 0 0 1px var(--fg-0); }
  .stock-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .stock-pos {
    position: absolute; left: 4px; bottom: 4px;
    font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 999px;
    background: var(--glass); border: 1px solid var(--line); color: var(--fg-0);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .stock-del {
    position: absolute; top: 3px; right: 3px;
    width: 18px; height: 18px; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, 0.62); color: #fff;
    font-size: 11px; line-height: 18px; padding: 0;
    cursor: pointer; opacity: 0; transition: var(--t-fast);
  }
  .stock-tile:hover .stock-del, .subj-img:hover .stock-del, .stock-del:focus { opacity: 1; }
  /* Papierkorb des Regals: Wiederherstellen sitzt links neben dem X. */
  .stock-restore { right: 24px; }
  /* Mehrfachauswahl (2026-09-16): Haekchen unten rechts, damit es weder der
     Position (unten links) noch der Lupe (oben links) ins Gehege kommt. */
  .stock-check, .lib-check {
    position: absolute; right: 4px; bottom: 4px;
    width: 20px; height: 20px; border-radius: 6px;
    border: 2px solid #fff; background: rgba(0, 0, 0, 0.45); color: #fff;
    font-size: 12px; line-height: 16px; text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); pointer-events: none;
  }
  .lib-check { right: 6px; bottom: 6px; }
  .stock-check.on, .lib-check.on { background: var(--fg-0); color: var(--bg-0); border-color: var(--fg-0); }
  .stock-tile.sel .stock-thumb { border-color: var(--fg-0); box-shadow: 0 0 0 1px var(--fg-0); }
  .stock-add.on { color: var(--fg-0); }
  .stock-selbar { display: inline-flex; gap: var(--s2); align-items: baseline; font-size: 11px; color: var(--fg-2); }
  .stock-sel-trash:hover, .stock-sel-purge:hover { color: var(--err); }
  .stock-name {
    width: 100%; margin-top: 4px; padding: 2px 4px;
    font-size: 10px; text-align: center; color: var(--fg-1);
    background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
    transition: var(--t-fast);
  }
  .stock-name::placeholder { color: var(--fg-3); }
  .stock-name:hover { border-color: var(--line); }
  .stock-name:focus { border-color: var(--line-strong); background: var(--bg-2); color: var(--fg-0); outline: none; }

  /* ── Bibliothek: Motive (Personen, Produkte) ─────────────────────────
     Ein Motiv ist die Klammer um mehrere Bilder: eine Person hat Gesicht,
     Koerper vorne und hinten, ein Produkt Vorder- und Rueckseite. Als lose
     Regalkacheln zerfiele das beim naechsten Upload, weil sie nur der
     Dateiname zusammenhaelt. Darum eine Karte je Motiv, und die Bilder
     liegen darin -- in der Reihenfolge, in der sie ans Modell gehen. */
  .lib-tabs { display: flex; gap: 2px; }
  .lib-tab {
    font-size: 11px; padding: 2px 8px; border-radius: var(--r-sm);
    color: var(--fg-3); border: 1px solid transparent; transition: var(--t-fast);
  }
  .lib-tab:hover { color: var(--fg-1); }
  .lib-tab.on { color: var(--fg-0); border-color: var(--line-strong); background: var(--bg-2); }
  .subj-strip { display: flex; gap: var(--s3); overflow-x: auto; padding: 2px 2px 6px; align-items: flex-start; }
  .subj-strip::-webkit-scrollbar { height: 6px; }
  .subj-strip::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
  .subj-empty { font-size: 12px; color: var(--fg-3); padding: 4px 2px; }
  .subj-card {
    flex: 0 0 auto; min-width: 200px; max-width: 340px;
    padding: 6px 8px 8px; border: 1px solid var(--line);
    border-radius: var(--r-md); background: var(--bg-1);
  }
  .subj-head { display: flex; align-items: center; gap: 4px; }
  .subj-name {
    flex: 1 1 auto; min-width: 0; padding: 1px 4px;
    font-size: 12px; color: var(--fg-0); background: transparent;
    border: 1px solid transparent; border-radius: var(--r-sm); transition: var(--t-fast);
  }
  .subj-name:hover { border-color: var(--line); }
  .subj-name:focus { border-color: var(--line-strong); background: var(--bg-2); outline: none; }
  .subj-btn {
    flex: 0 0 auto; font-size: 10px; padding: 1px 6px; border-radius: var(--r-sm);
    color: var(--fg-3); border: 1px solid var(--line); transition: var(--t-fast);
  }
  .subj-btn:hover { color: var(--fg-0); border-color: var(--line-strong); }
  .subj-btn.subj-x { border-color: transparent; }
  .subj-btn.subj-x:hover { color: var(--fg-0); border-color: var(--line); }
  /* Der Steckbrief. Eine Zeile, bis man hineinklickt -- er ist Beiwerk beim
     Ueberfliegen und Hauptsache beim Pflegen. */
  .subj-notes {
    width: 100%; margin-top: 3px; padding: 2px 4px; resize: none;
    font-size: 10px; line-height: 1.35; color: var(--fg-2); font-family: inherit;
    background: transparent; border: 1px solid transparent;
    border-radius: var(--r-sm); height: 18px; overflow: hidden; transition: var(--t-fast);
  }
  .subj-notes::placeholder { color: var(--fg-3); }
  .subj-notes:hover { border-color: var(--line); }
  .subj-notes:focus { border-color: var(--line-strong); background: var(--bg-2); color: var(--fg-0); outline: none; height: 54px; overflow: auto; }
  .subj-imgs { display: flex; gap: var(--s2); margin-top: 6px; align-items: flex-start; }
  .subj-img { width: 62px; flex: 0 0 auto; }
  .subj-thumb {
    position: relative; width: 62px; height: 62px; overflow: hidden;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--bg-2); cursor: pointer; transition: var(--t-fast);
  }
  .subj-thumb:hover { border-color: var(--line-strong); }
  .subj-img.on .subj-thumb { border-color: var(--fg-0); box-shadow: 0 0 0 1px var(--fg-0); }
  .subj-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .subj-role {
    width: 100%; margin-top: 3px; padding: 1px 2px;
    font-size: 9px; color: var(--fg-2); font-family: inherit;
    background: transparent; border: 1px solid transparent;
    border-radius: var(--r-sm); transition: var(--t-fast);
  }
  .subj-role:hover { border-color: var(--line); }
  .subj-role:focus { border-color: var(--line-strong); background: var(--bg-2); outline: none; }
  .subj-addimg {
    width: 62px; height: 62px; flex: 0 0 auto; font-size: 18px; color: var(--fg-3);
    border: 1px dashed var(--line); border-radius: var(--r-sm); transition: var(--t-fast);
  }
  .subj-addimg:hover { color: var(--fg-0); border-color: var(--line-strong); }
  /* Woher das Motiv gilt. Anklickbar, weil "die Person nehme ich doch oefter"
     kein Neuanlegen erzwingen darf. */
  .subj-scope {
    margin-top: 5px; font-size: 9px; letter-spacing: 0.04em; color: var(--fg-3);
    border: 1px solid transparent; border-radius: var(--r-sm); padding: 1px 4px;
    transition: var(--t-fast);
  }
  .subj-scope:hover { color: var(--fg-1); border-color: var(--line); }
  /* Ein Motiv, das im Prompt landet, sieht man dem Knopf an. */
  .subj-btn.on { color: var(--fg-0); border-color: var(--fg-0); }

  /* ── Was von den Motiven im Prompt landet ───────────────────────────
     Sitzt UEBER dem Prompt-Feld, nicht darunter und nicht im Server: was
     ans Modell geht, muss vorher zu lesen sein. Kein Motiv an -> die Zeile
     ist gar nicht da, damit sie niemandem im Weg steht. */
  .pm-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
    padding: 7px var(--s4) 0; font-size: 10px;
  }
  .pm-lead { color: var(--fg-3); letter-spacing: 0.04em; }
  .pm-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 3px 2px 7px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--fg-1); background: var(--bg-2);
  }
  .pm-chip.leer { color: var(--fg-3); border-style: dashed; }
  .pm-chip button {
    width: 14px; height: 14px; border: 0; border-radius: 50%; padding: 0;
    font-size: 10px; line-height: 14px; color: var(--fg-3);
    background: transparent; cursor: pointer; transition: var(--t-fast);
  }
  .pm-chip button:hover { color: var(--fg-0); background: var(--line); }
  .pm-see {
    font-size: 10px; color: var(--fg-3); border: 0; background: transparent;
    text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
  }
  .pm-see:hover { color: var(--fg-1); }
  .pm-preview {
    margin: 5px var(--s4) 0; padding: 7px 9px; max-height: 132px; overflow: auto;
    font-size: 10px; line-height: 1.5; white-space: pre-wrap; color: var(--fg-2);
    background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-sm);
  }

  /* ── @ im Prompt: die Liste der Referenzen ────────────────────────────
     Sitzt UEBER dem Feld, weil die Leiste am unteren Bildrand klebt --
     nach unten waere sie ausserhalb des Fensters. */
  /* ── Lichtkasten ───────────────────────────────────────────────────────
     Zwei aehnliche Referenzen sind auf einer 44-Pixel-Kachel nicht zu
     unterscheiden. Der Lichtkasten zeigt eine gross und blaettert mit ← →
     durch DIESELBE Liste, aus der geklickt wurde -- Vergleichen ist der
     Zweck, nicht Einzelansicht. Ton und Film laufen hier ebenfalls; vorher
     musste beides erst heruntergeladen werden. */
  .lb {
    position: fixed; inset: 0; z-index: 240;
    display: none; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.86);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    padding: var(--s5);
  }
  .lb.show { display: flex; }
  .lb-buehne {
    position: relative; display: flex; flex-direction: column;
    align-items: center; gap: var(--s3); max-width: 92vw; max-height: 88vh;
  }
  .lb-buehne img, .lb-buehne video {
    max-width: 84vw; max-height: 74vh; object-fit: contain;
    border-radius: var(--r-md); background: var(--bg-1); display: block;
  }
  .lb-ton {
    display: flex; flex-direction: column; align-items: center; gap: var(--s3);
    padding: var(--s5) var(--s6); border-radius: var(--r-lg, 12px);
    background: var(--bg-2); border: 1px solid var(--line-strong);
  }
  .lb-ton .lb-icon { font-size: 38px; opacity: .55; }
  .lb-ton audio { width: 320px; max-width: 68vw; }
  .lb-txt { font-size: 12px; color: var(--fg-2); text-align: center; max-width: 84vw; }
  .lb-txt b { color: var(--fg-0); font-weight: 600; }
  .lb-nav {
    position: absolute; top: 40%; transform: translateY(-50%);
    width: 42px; height: 62px; border: 0; border-radius: var(--r-md);
    background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 24px;
    line-height: 62px; padding: 0; cursor: pointer; transition: var(--t-fast);
  }
  .lb-nav:hover { background: rgba(0, 0, 0, 0.8); }
  .lb-nav.zurueck { left: -54px; }
  .lb-nav.vor { right: -54px; }
  /* Auf schmalen Schirmen ist neben der Buehne kein Platz -- dann sitzen die
     Pfeile innen auf dem Bild, statt aus dem Fenster zu ragen. */
  @media (max-width: 900px) {
    .lb-nav.zurueck { left: 4px; }
    .lb-nav.vor { right: 4px; }
  }
  .lb-zu {
    position: fixed; top: 14px; right: 16px;
    width: 34px; height: 34px; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 14px;
    padding: 0; cursor: pointer; transition: var(--t-fast);
  }
  .lb-zu:hover { background: rgba(0, 0, 0, 0.85); }
  /* Die Lupe sitzt in derselben Ecke-auf-Hover-Bauweise wie das Kreuz, nur
     links, damit die beiden sich nicht in die Quere kommen. */
  .lb-lupe {
    position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, 0.62); color: #fff;
    font-size: 10px; line-height: 18px; padding: 0;
    cursor: pointer; opacity: 0; transition: var(--t-fast);
  }
  .stock-tile:hover .lb-lupe, .subj-img:hover .lb-lupe, .lb-lupe:focus { opacity: 1; }
  /* Regalkacheln, die kein Bild sind: der Film zeigt sein erstes Einzelbild,
     der Ton eine Platte mit Symbol. Vorher stand hier ein kaputtes <img>. */
  .stock-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
  .stock-thumb .lib-play { width: 26px; height: 26px; font-size: 10px; }
  .stock-art {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; width: 100%; height: 100%; font-size: 20px; color: var(--fg-2);
  }
  .stock-art span { font-size: 8px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3); }
  .refrow-bild.lupe { cursor: zoom-in; }
  .refplay {
    width: 26px; height: 26px; padding: 0; border-radius: 50%;
    background: var(--bg-0); border: 1px solid var(--line-strong);
    color: var(--fg-1); font-size: 10px; cursor: pointer; transition: var(--t-fast);
  }
  .refplay:hover { color: var(--fg-0); border-color: var(--fg-2); }
  .at-menu {
    position: absolute; left: var(--s4); right: var(--s4); bottom: calc(100% + 6px);
    max-height: 280px; overflow: auto; z-index: 40;
    background: var(--bg-2); border: 1px solid var(--line-strong);
    border-radius: var(--r-lg, 12px); box-shadow: var(--shadow-card); padding: 5px;
  }
  .at-gruppe {
    padding: 7px 8px 3px; font-size: 9px; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--fg-3);
  }
  .at-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 5px 7px; border-radius: var(--r-sm); text-align: left;
  }
  .at-item.on, .at-item:hover { background: var(--bg-3); }
  .at-thumb {
    width: 30px; height: 30px; flex: 0 0 auto; border-radius: 5px;
    object-fit: cover; background: var(--bg-1); border: 1px solid var(--line);
  }
  .at-thumb.leer { display: inline-block; }
  .at-name {
    font-size: 12px; color: var(--fg-0);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .at-meta { margin-left: auto; flex: 0 0 auto; font-size: 10px; color: var(--fg-3); }
  .at-leer { padding: 10px; font-size: 11px; color: var(--fg-3); line-height: 1.5; }

  /* ── F1 result-action bar (overlay on a finished image) ─────────────── */
  .stage-actions {
    position: absolute; bottom: var(--s5); left: 50%; transform: translateX(-50%);
    display: none; align-items: center; gap: var(--s2);
    padding: 6px; z-index: 6;
    background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--line-strong); border-radius: 999px;
  }
  .stage-actions.show { display: inline-flex; }
  .stage-action {
    border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--fg-0);
    font-size: 12px; font-weight: 500; padding: 8px 16px; border-radius: 999px;
    cursor: pointer; transition: var(--t);
  }
  .stage-action:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
  .stage-action:disabled { opacity: 0.5; cursor: default; }
  /* Runde Symbol-Knoepfe (Download, Urteil, Schliessen) und der eine
     hervorgehobene (Final). Die Leiste traegt damit Symbole statt Woerter —
     Muster: Higgsfield/Krea, Aktionen am Bild, nicht als Wortreihe. */
  .stage-action.ico { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }
  .stage-action.primary { background: var(--fg-0); border-color: var(--fg-0); color: var(--bg-0); }
  .stage-action.primary:hover { background: var(--fg-1); border-color: var(--fg-1); color: var(--bg-0); }
  #actWeiter { display: inline-flex; align-items: center; gap: 6px; }
  .act-more { position: relative; display: inline-flex; }
  .act-menu {
    position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
    display: none; flex-direction: column; gap: 2px; min-width: 210px; padding: 6px;
    background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
    box-shadow: 0 18px 48px -12px rgba(0,0,0,0.55); z-index: 8;
  }
  .act-menu.open { display: flex; }
  .act-menu .stage-action { border: 0; background: none; border-radius: var(--r-md); text-align: left; padding: 9px 12px; font-size: 13px; }
  .act-menu .stage-action:hover { background: var(--bg-3); color: var(--fg-0); }

  /* ── Desktop-Werkzeuge (2026-10-02): Mehr-Menue, Konfig-Pillen, Verlauf.
     Alle drei gibt es nur ab 1101px (siehe dort); darunter bleibt alles,
     wie es war. ─────────────────────────────────────────────────────── */
  .mode-more, .cfg-pills, .feed, .feed-back { display: none; }
  .mode-more {
    order: 99; align-items: center; gap: 6px; padding: 6px 10px;
    font-size: 12px; font-weight: 500; color: var(--fg-1);
    border-radius: 999px; transition: var(--t-fast);
  }
  .mode-more:hover, .mode-more[aria-expanded="true"] { color: var(--fg-0); background: var(--bg-3); }
  .mode-menu {
    position: fixed; z-index: 60; min-width: 220px; padding: 6px;
    background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
    box-shadow: 0 18px 48px -12px rgba(0,0,0,0.55);
  }
  .mode-menu[hidden] { display: none; }
  .mode-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; border-radius: var(--r-md);
    font-size: 13px; color: var(--fg-0); text-align: left;
  }
  .mode-menu button:hover { background: var(--bg-3); }
  .mode-menu button svg { color: var(--fg-2); flex: 0 0 auto; }

  .cfg-pills { flex-wrap: wrap; gap: 6px; padding: 2px 12px 6px; }
  .cfg-pill {
    display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px;
    max-width: 100%; min-width: 0;
    border: 1px solid var(--line); border-radius: 999px; background: var(--bg-3);
    font-size: 12px; color: var(--fg-2); transition: var(--t-fast);
  }
  .cfg-pill b { color: var(--fg-0); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .cfg-pill:hover { border-color: var(--line-strong); background: var(--bg-4); }
  .cfg-pill.on { border-color: var(--fg-2); }
  .cfg-pill.modell b { max-width: 190px; }
  .cfg-pill.alle { padding: 0 9px; color: var(--fg-1); }
  .cfg-pill svg { flex: 0 0 auto; }
  .field.cfg-flash { animation: cfgFlash 0.9s ease-out; border-radius: var(--r-md); }
  @keyframes cfgFlash { 0% { background: var(--accent-glow); } 100% { background: transparent; } }

  /* Modell-Karten statt Auswahlliste: Name, Anbieter, Preis je Einheit und
     was das Modell kann — die Entscheidung faellt an diesen Angaben, und die
     standen vorher nirgends. Zugeklappt nur das gewaehlte Modell. */
  .mcards { display: flex; flex-direction: column; gap: 4px; }
  .mcard {
    display: flex; flex-direction: column; gap: 4px; width: 100%;
    padding: 9px 11px; text-align: left;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-3);
    transition: var(--t-fast);
  }
  .mcard:hover { border-color: var(--line-strong); }
  .mcard.on { border-color: var(--fg-1); background: var(--bg-4); }
  .mc-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .mc-top b { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mc-preis { flex: 0 0 auto; font-size: 11px; color: var(--fg-1); font-variant-numeric: tabular-nums; }
  .mc-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11px; color: var(--fg-3); }
  .mc-sub i { font-style: normal; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-2); }
  .mc-wechsel { margin-left: auto; font-size: 11px; color: var(--fg-1); }

  .feed-group { margin: 0 0 28px; }
  .feed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-width: 0; }
  .feed-prompt { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .feed-meta { flex: 0 0 auto; font-size: 11px; color: var(--fg-3); white-space: nowrap; }
  .feed-meta b { color: var(--fg-2); font-weight: 500; }
  .feed-redo {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
    height: 26px; padding: 0 10px; border-radius: 999px;
    border: 1px solid var(--line); font-size: 11px; color: var(--fg-1);
    transition: var(--t-fast);
  }
  .feed-redo:hover { border-color: var(--line-strong); color: var(--fg-0); background: var(--bg-3); }
  .feed-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
  .feed-tile {
    position: relative; flex: 0 0 auto; height: clamp(200px, 28vh, 340px); max-width: 100%;
    border-radius: var(--r-md); overflow: hidden; cursor: pointer;
    background: var(--bg-2); border: 1px solid var(--line);
  }
  .feed-tile:hover { border-color: var(--line-strong); }
  .feed-tile:focus-visible { outline: 2px solid var(--fg-1); outline-offset: 2px; }
  .feed-tile > img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .ft-status { height: 100%; display: grid; place-items: center; align-content: center; gap: 6px; padding: 12px; text-align: center; font-size: 12px; color: var(--fg-2); }
  .feed-tile.failed .ft-status { color: var(--err); }
  .feed-tile.running .ft-status::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%; margin: 0 auto;
    background: var(--fg-1); animation: blink 1.2s ease-in-out infinite;
  }
  .ft-badge {
    position: absolute; left: 8px; bottom: 8px; padding: 3px 7px; border-radius: 999px;
    font-size: 10px; line-height: 1.2; color: var(--fg-0);
    background: var(--glass); border: 1px solid var(--line);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .ft-acts { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; opacity: 0; transition: var(--t-fast); }
  .feed-tile:hover .ft-acts, .feed-tile:focus-within .ft-acts { opacity: 1; }
  .ft-act {
    width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px;
    color: var(--fg-0); background: var(--glass); border: 1px solid var(--line-strong);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .ft-act:hover { background: var(--bg-4); }
  .ft-act.del:hover { color: var(--err); }
  .feed-alle { display: inline-flex; font-size: 12px; color: var(--fg-1); padding: 4px 0 12px; }
  .feed-alle:hover { color: var(--fg-0); }
  .feed-back.show {
    display: inline-flex; align-items: center; gap: 6px;
    position: absolute; left: 12px; top: 12px; z-index: 6;
    height: 30px; padding: 0 12px; border-radius: 999px;
    font-size: 12px; color: var(--fg-0);
    background: var(--glass); border: 1px solid var(--line-strong);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  }
  .feed-back.show:hover { background: var(--bg-3); }

  .phase {
    /* left/right 0 + margin auto + max-content: zentriert, ohne dass left:50% die
       verfuegbare Breite halbiert (das liess Modellname und Abbrechen umbrechen). */
    position: absolute; top: var(--s5); left: 0; right: 0; margin: 0 auto;
    width: max-content; max-width: calc(100% - 2 * var(--s5));
    display: none; align-items: center; gap: var(--s3);
    padding: 10px 18px;
    background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 12px; color: var(--fg-0);
    z-index: 5;
  }
  .phase.show { display: inline-flex; }
  .phase .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s ease-in-out infinite; flex: 0 0 auto; }
  .phase .sep { flex: 0 0 auto; }
  @keyframes blink { 50% { opacity: 0.3; } }
  .phase .label { font-weight: 500; white-space: nowrap; }
  .phase .sep { color: var(--fg-3); }
  .phase .meta { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Hintergrund-Auftraege: Plakette oben rechts, Liste darunter (je Zeile ein Abbrechen). */
  .hg-badge { position: absolute; top: var(--s5); right: var(--s5); z-index: 6; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
  .hg-badge[hidden], .hg-list[hidden] { display: none; }
  .hg-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; color: var(--fg-0); cursor: pointer; }
  .hg-btn .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s ease-in-out infinite; }
  .hg-list { display: flex; flex-direction: column; gap: 4px; min-width: 260px; max-width: 380px; padding: 8px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line-strong); border-radius: 12px; font-size: 12px; color: var(--fg-0); }
  .hg-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
  .hg-row .hg-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
  .hg-row .hg-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hg-x { border: 1px solid var(--line); background: transparent; color: var(--fg-1); border-radius: 6px; padding: 2px 7px; cursor: pointer; font-size: 11px; flex: none; }
  .hg-x:hover { color: var(--fg-0); border-color: var(--line-strong); }

  /* ── Prompt dock (floating) ────────────────────────────── */
  .prompt-dock {
    position: fixed;
    bottom: var(--s5); left: 50%; transform: translateX(-50%);
    width: calc(100% - var(--s7));
    max-width: 920px;
    z-index: 20;
  }
  .prompt-shell {
    position: relative;   /* Anker fuer das @-Menue */
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
    transition: var(--t-fast);
  }
  .prompt-shell:focus-within {
    border-color: rgba(255,255,255,0.18);
    box-shadow: var(--shadow-card), 0 0 60px -20px var(--accent-glow);
  }
  [data-theme="light"] .prompt-shell:focus-within { border-color: rgba(0,0,0,0.18); }
  .prompt-input {
    width: 100%;
    background: transparent;
    border: 0;
    padding: 18px 20px 4px 20px;
    font-size: 15px;
    color: var(--fg-0);
    min-height: 48px;
    max-height: 220px;
    font-family: inherit;
  }
  .prompt-input::placeholder { color: var(--fg-2); font-weight: 300; }
  .prompt-tools {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px 10px 12px;
    gap: var(--s2);
    flex-wrap: wrap;
  }
  .prompt-tools-l { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
  .prompt-tools-r { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
  .tool-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--fg-1);
    font-size: 12px; font-weight: 500;
    transition: var(--t-fast);
  }
  .tool-btn:hover { background: var(--bg-3); color: var(--fg-0); }
  .tool-chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--fg-1);
    font-size: 11px; font-weight: 500;
    transition: var(--t-fast);
    font-family: 'JetBrains Mono', monospace;
  }
  .tool-chip:hover { background: var(--bg-4); color: var(--fg-0); }
  .tool-chip b { color: var(--fg-0); font-weight: 500; }
  .send-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--send-bg);
    color: var(--send-fg);
    display: grid; place-items: center;
    transition: var(--t-fast);
  }
  .send-btn:hover { transform: scale(1.05); }
  .send-btn:disabled { background: var(--bg-4); color: var(--fg-3); cursor: not-allowed; transform: none; }
  /* Prompt-Chat: solange der Prompt nicht steht, schickt der Knopf Text ans Gespraech — gedaempft statt Akzent. */
  .send-btn.chat { background: var(--bg-4); color: var(--fg-0); box-shadow: inset 0 0 0 1px var(--line-strong); }
  .cost-chip {
    display: inline-flex; align-items: center;
    height: 28px; padding: 0 10px;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--fg-1);
    font-size: 11px; font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    transition: var(--t-fast);
  }
  .cost-chip.loading { opacity: 0.45; }

  /* ── Drawer ──────────────────────────────────────────────── */
  .drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t);
    z-index: 40;
  }
  [data-theme="light"] .drawer-backdrop { background: rgba(0,0,0,0.2); }
  .drawer-backdrop.show { opacity: 1; pointer-events: auto; }
  .drawer {
    position: fixed;
    right: var(--s5); bottom: var(--s5);
    width: 440px;
    max-height: calc(100vh - 100px);   /* N1: vh fallback for old engines */
    max-height: calc(100dvh - 100px);  /* dvh: stable against mobile URL-bar */
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-xl);
    box-shadow: 0 24px 64px -16px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.02);
    opacity: 0; transform: translateY(20px) scale(0.96); pointer-events: none;
    transition: var(--t);
    z-index: 41;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .drawer.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
  .drawer-head {
    padding: var(--s4) var(--s5);
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--line);
  }
  .drawer-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
  .drawer-tabs {
    display: flex; gap: 2px;
    padding: var(--s2) var(--s4);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .drawer-tabs::-webkit-scrollbar { display: none; }
  .drawer-tab {
    padding: 8px 12px;
    font-size: 12px; font-weight: 500;
    color: var(--fg-2);
    border-radius: 8px;
    transition: var(--t-fast);
    white-space: nowrap;
  }
  .drawer-tab:hover { color: var(--fg-0); }
  .drawer-tab.on { color: var(--fg-0); background: var(--bg-3); }
  .drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--s4) var(--s5);
  }
  .drawer-body::-webkit-scrollbar { width: 6px; }
  .drawer-body::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

  .field { display: flex; flex-direction: column; margin-bottom: var(--s4); }
  .field > label {
    font-size: 11px; font-weight: 500;
    color: var(--fg-1); text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: var(--s2);
    font-family: 'JetBrains Mono', monospace;
  }
  .field > .hint { font-size: 11px; color: var(--fg-2); margin-top: 6px; }
  .pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
  .pill {
    height: 30px; padding: 0 12px;
    background: var(--bg-3);
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px; font-weight: 500;
    color: var(--fg-1);
    transition: var(--t-fast);
    display: inline-flex; align-items: center; gap: 6px;
  }
  .pill:hover { color: var(--fg-0); border-color: var(--line-strong); }
  .pill.on {
    background: var(--bg-0);
    color: var(--fg-0);
    border-color: var(--fg-0);
  }
  [data-theme="light"] .pill.on { background: #fff; border-color: var(--fg-0); }
  .pill .mono { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--fg-2); }
  .pill.on .mono { color: var(--fg-1); }

  .sel-input {
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--fg-0);
    transition: var(--t-fast);
    width: 100%;
    font-family: inherit;
    appearance: none; padding-right: 32px; cursor: pointer;
  }
  .sel-input:focus { border-color: var(--line-strong); }

  /* ── Referenz-Panel ──────────────────────────────────────────────────
     Eine Liste statt drei verstreuter Kachelfelder. Jede Zeile ist EINE
     Referenz und zeigt alles, was ueber sie zu wissen ist: Bild, Name,
     die Marke, mit der der Prompt sie anspricht, ihre Rolle, und wie man
     sie wieder loswird. Reihenfolge = Nummerierung, darum ist sie
     ziehbar. */
  .refpanel { border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); overflow: hidden; }
  .refpanel-head {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-bottom: 1px solid var(--line);
    font-size: 11px; color: var(--fg-2);
    font-family: 'JetBrains Mono', monospace; letter-spacing: 0.04em;
  }
  .refpanel-head .zaehler { color: var(--fg-1); font-variant-numeric: tabular-nums; }
  .refpanel-head .voll { color: var(--warn, #fbbf24); }
  .refpanel-list { display: flex; flex-direction: column; }
  .refpanel-leer { padding: 18px 12px; text-align: center; font-size: 12px; color: var(--fg-2); }
  .refrow {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto 26px;
    align-items: center; gap: 10px;
    padding: 8px 12px; border-bottom: 1px solid var(--line);
  }
  .refrow:last-child { border-bottom: 0; }
  /* Ton ist ein eigener Abschnitt im selben Panel. Die kraeftigere Linie trennt
     ihn von der Bildliste — ohne sie liest man die beiden Zaehler als eine Reihe.
     Die Tonzeile hat keine Marke und keine Rolle, also auch nur drei Spalten. */
  .refpanel-head.ton, .refpanel-head.video { border-top: 3px solid var(--line); }
  .refrow.ton, .refrow.video { grid-template-columns: 44px minmax(0, 1fr) 26px 26px; }
  .refrow.zieht { opacity: .4; }
  .refrow.ziel { box-shadow: inset 0 2px 0 0 var(--fg-0); }
  .refrow-bild {
    width: 44px; height: 44px; border-radius: 8px; overflow: hidden;
    border: 1px solid var(--line); background: var(--bg-3);
    display: flex; align-items: center; justify-content: center;
    cursor: grab; flex: 0 0 auto;
  }
  .refrow-bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .refrow-txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .refrow-name {
    font-size: 12px; color: var(--fg-0);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .refrow-sub { font-size: 10px; color: var(--fg-2); }
  .reftok {
    height: 24px; padding: 0 9px; border-radius: 6px;
    background: var(--bg-0); border: 1px solid var(--line-strong);
    font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-1);
    cursor: pointer; white-space: nowrap; transition: var(--t-fast);
  }
  .reftok:hover { color: var(--fg-0); border-color: var(--fg-0); }
  .reftok[disabled] { cursor: default; opacity: .55; }
  .refrolle {
    height: 26px; padding: 0 6px; border-radius: 6px;
    background: var(--bg-3); border: 1px solid var(--line);
    font-size: 11px; color: var(--fg-1); font-family: inherit; cursor: pointer;
  }
  .refdel {
    width: 24px; height: 24px; border: 0; border-radius: 6px; padding: 0;
    background: transparent; color: var(--fg-2); font-size: 12px; cursor: pointer;
  }
  .refdel:hover { color: var(--fg-0); background: var(--bg-3); }
  .refpanel-fuss { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); }
  .refmodus {
    margin: 0; padding: 7px 12px;
    border-bottom: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    background: var(--bg-2);
    font-size: 10px; color: var(--fg-2); line-height: 1.5;
  }
  .refmodus b { color: var(--fg-1); font-weight: 600; }
  .refnote {
    padding: 7px 12px; border-top: 1px solid var(--line);
    font-size: 10px; color: var(--fg-2); line-height: 1.5;
  }

  .toast {
    position: fixed; top: 72px; left: 50%; transform: translateX(-50%) translateY(-20px);
    padding: 10px 18px;
    background: var(--bg-3);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 12px;
    color: var(--fg-0);
    opacity: 0;
    transition: var(--t);
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 16px 40px -16px rgba(0,0,0,0.6);
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.err { border-color: var(--err); color: var(--err); }
  .toast.ok  { border-color: var(--ok);  color: var(--ok); }

  /* ── Auth gate (ported from /cx SPA, restyled to Higgsfield) ── */
  .auth-overlay {
    position: fixed; inset: 0;
    display: none; align-items: center; justify-content: center;
    background: var(--bg-grad);
    z-index: 200;
    padding: var(--s5);
  }
  .auth-overlay.show { display: flex; }
  .auth-card {
    width: 100%; max-width: 380px;
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
    padding: var(--s6);
  }
  .auth-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
  .auth-card .auth-sub { color: var(--fg-2); font-size: 13px; margin-bottom: var(--s4); }
  .auth-field { margin: var(--s3) 0; }
  .auth-field label {
    display: block; font-size: 11px; color: var(--fg-1);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--s2);
    font-family: 'JetBrains Mono', monospace;
  }
  .auth-field input {
    width: 100%; padding: 10px 12px;
    background: var(--bg-3); border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px; color: var(--fg-0);
  }
  .auth-field input:focus { border-color: var(--line-strong); }
  .auth-err { color: var(--err); font-size: 13px; min-height: 18px; margin: 4px 0; }
  .auth-submit {
    width: 100%; height: 40px;
    background: var(--fg-0); color: var(--bg-0);
    border-radius: 10px; font-size: 14px; font-weight: 600;
    box-shadow: none;
    transition: var(--t-fast);
  }
  .auth-submit:hover { filter: brightness(1.05); }
  .auth-submit:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
  .auth-hint { margin-top: var(--s4); font-size: 12px; line-height: 1.55; color: var(--fg-2); }
  .auth-hint code { font-family: 'JetBrains Mono', monospace; font-size: 11px; background: var(--bg-3); padding: 1px 5px; border-radius: 4px; color: var(--fg-1); }

  /* ── STARTSEITE: Kunde -> Projekt (Schritt 3, 2026-08-26) ────────────────
     Liegt VOR dem Studio und nicht darin: solange kein Projekt gewaehlt ist,
     gibt es keine Buehne, keine Historie und keinen Generieren-Knopf. Zwei
     Spalten, weil die Auswahl genau zwei Stufen hat; auf schmalen Schirmen
     untereinander. Optik uebernimmt die Auth-Karte (bg-2 / line-strong /
     r-xl), damit sich Anmeldung und Auswahl wie eine Vorhalle anfuehlen. */
  .ws-overlay {
    position: fixed; inset: 0;
    display: none; align-items: center; justify-content: center;
    background: var(--bg-grad);
    z-index: 190;
    padding: var(--s5);
    overflow-y: auto;
  }
  .ws-overlay.show { display: flex; }
  .ws-card {
    width: 100%; max-width: 760px;
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
    padding: var(--s6);
    margin: auto;
  }
  .ws-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
  .ws-card .ws-sub { color: var(--fg-2); font-size: 13px; margin-bottom: var(--s5); }
  .ws-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
  @media (max-width: 640px) {
    .ws-cols { grid-template-columns: 1fr; }
    .spend-ranges { grid-template-columns: repeat(2, 1fr); }
  }
  .ws-col-head {
    display: flex; align-items: baseline; justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--fg-1); margin-bottom: var(--s2);
  }
  .ws-col-head .ws-count { color: var(--fg-3); }
  .ws-list {
    display: flex; flex-direction: column; gap: 6px;
    max-height: 320px; overflow-y: auto;
    padding-right: 2px;
  }
  .ws-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 10px 12px;
    background: var(--bg-3); color: var(--fg-0);
    border: 1px solid var(--line); border-radius: 10px;
    font-size: 14px; line-height: 1.35;
    transition: var(--t-fast);
  }
  .ws-item:hover { border-color: var(--line-strong); background: var(--bg-4); }
  .ws-item-main { flex: 1; min-width: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; background: none; }
  /* Archivieren steht bewusst leise daneben: es ist der einzige Weg, eine Zeile
     loszuwerden. Geloescht wird hier nichts — die Arbeit bleibt lesbar. */
  .ws-act {
    flex: none; opacity: 0; padding: 4px 8px; border-radius: 7px;
    font-size: 11px; color: var(--fg-2); border: 1px solid transparent;
    transition: var(--t-fast); white-space: nowrap;
  }
  .ws-item:hover .ws-act, .ws-act:focus { opacity: 1; }
  .ws-act:hover { color: var(--fg-0); border-color: var(--line-strong); background: var(--bg-2); }
  .ws-item.active { border-color: var(--fg-1); background: var(--bg-4); }
  .ws-item .ws-meta {
    display: block; margin-top: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; color: var(--fg-2);
    font-variant-numeric: tabular-nums;
  }
  .ws-item.archived { opacity: 0.55; }
  .ws-empty {
    padding: 14px 12px; border: 1px dashed var(--line-strong); border-radius: 10px;
    color: var(--fg-2); font-size: 13px;
  }
  .ws-new { display: flex; gap: 6px; margin-top: var(--s3); }
  .ws-new input {
    flex: 1; min-width: 0; padding: 9px 12px;
    background: var(--bg-3); border: 1px solid var(--line);
    border-radius: 8px; font-size: 13px; color: var(--fg-0);
  }
  .ws-new input:focus { border-color: var(--line-strong); }
  .ws-new button {
    padding: 0 14px; height: 36px;
    background: var(--fg-0); color: var(--bg-0);
    border-radius: 8px; font-size: 13px; font-weight: 600;
    transition: var(--t-fast); white-space: nowrap;
  }
  .ws-new button:disabled { opacity: 0.4; cursor: not-allowed; }
  .ws-err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: var(--s3); }
  .ws-foot {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line);
  }
  .ws-foot .ws-hint { color: var(--fg-2); font-size: 12px; }
  .ws-archive-toggle {
    background: none; color: var(--fg-2); font-size: 12px;
    border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
    transition: var(--t-fast);
  }
  .ws-archive-toggle:hover { color: var(--fg-0); border-color: var(--line-strong); }
  .ws-archive-toggle.on { color: var(--fg-0); border-color: var(--line-strong); }

  /* Kopfzeile im Studio: welcher Kunde, welches Projekt, was hat es gekostet.
     Klick fuehrt zurueck in die Vorhalle — der einzige Weg, das Projekt zu
     wechseln, damit ein Wechsel nie unbemerkt passiert. */
  .pj-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 10px; margin-left: var(--s3);
    background: var(--bg-3); border: 1px solid var(--line);
    border-radius: 999px; font-size: 12px; color: var(--fg-0);
    transition: var(--t-fast); max-width: 340px;
  }
  .pj-pill:hover { border-color: var(--line-strong); background: var(--bg-4, var(--bg-3)); }
  .pj-pill:hover .pj-chev { color: var(--fg-0); }
  .pj-pill .pj-sep { color: var(--fg-3); }
  /* Ohne dieses Zeichen liest sich die Pille als Anzeige, nicht als Schalter --
     der Weg zurueck zur Kunden-/Projektwahl stand vorher nur im title. */
  .pj-pill .pj-chev { color: var(--fg-3); font-size: 10px; margin-left: 2px; transition: var(--t-fast); }
  .pj-pill .pj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pj-pill .pj-spend {
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    color: var(--fg-2); font-variant-numeric: tabular-nums;
  }

  /* Tablet/desktop narrowing: hide tab labels to keep the centered pill compact.
     Scoped to >768px so the phone breakpoint can re-show labels (scrollable). */
  @media (min-width: 769px) and (max-width: 1100px) {
    .mode-tab span:not(.mono) { display: none; }
    .mode-tab { padding: 6px 8px; }
    /* Kopfzeile: gemessen 2026-09-10 bei 820px lagen Passwort und Abmelden
       ausserhalb des Schirms. Untertitel weg, Pillen gedeckelt, die drei
       Icon-Knoepfe wandern ins Konto-Blatt. */
    .brand-sub { display: none; }
    .ws-pill { max-width: 140px; }
    .pj-pill { max-width: 240px; min-width: 0; }
    #themeToggle, #pwBtn, #logoutBtn { display: none; }
    #acctBtn { display: grid; }
  }
  @media (min-width: 769px) and (max-width: 1000px) {
    .stage { padding: var(--s4); padding-bottom: max(300px, calc(var(--dock-h, 180px) + var(--row-h, 0px) + var(--stock-h, 0px) + var(--s6))); }
    .drawer { width: calc(100% - var(--s5) * 2); }
  }

  /* ════════════════════════════════════════════════════════════════════
     RESPONSIVE — additive. Desktop (>1024px, fine pointer) untouched.
     Breakpoints: phone <=768px · tablet 769-1024px · touch via pointer:coarse.
     ════════════════════════════════════════════════════════════════════ */

  /* ── PHONE (<=768px) — reflow the fixed layers ───────────────────── */
  @media (max-width: 768px) {
    :root { --tabs-h: 50px; }

    /* Library-Filter: EINE Zeile. Filter scrollen, Aktualisieren bleibt rechts. */
    #libBar { flex-wrap: nowrap; gap: 8px; }
    #libFilters { flex: 1 1 auto; min-width: 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    #libFilters::-webkit-scrollbar { display: none; }
    .lib-filter { flex: 0 0 auto; white-space: nowrap; }
    .lib-refresh { flex: 0 0 auto; }
    #libGrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

    /* Kopfzeile. Gemessen 2026-09-10 bei 390px: die rechte Gruppe war 673px
       breit, Ausgaben/Gelernt/Theme/Passwort/Abmelden lagen ausserhalb des
       Schirms. Jetzt: Marke, Projekt-Pille (schrumpft mit Ellipsis), Konto. */
    .top {
      padding: env(safe-area-inset-top) var(--s3) 0;
      padding-left: max(var(--s3), env(safe-area-inset-left));
      padding-right: max(var(--s3), env(safe-area-inset-right));
      height: calc(56px + env(safe-area-inset-top));
      gap: var(--s2);
      overflow-x: hidden;
    }
    .brand { gap: var(--s2); }
    .brand-sub { display: none; }
    .top-right { flex: 1 1 auto; min-width: 0; justify-content: flex-end; gap: var(--s1); }
    #ownerBadge, #wsPill, #spendChip, #brainChip, #themeToggle, #pwBtn, #logoutBtn { display: none; }
    #acctBtn { display: grid; }
    .pj-pill { flex: 1 1 auto; min-width: 0; max-width: none; margin-left: 0; padding: 5px 8px; }
    .pj-pill .pj-name { flex: 1 1 auto; min-width: 0; }
    .pj-pill .pj-spend { display: none; }

    /* Reiter: feste Zeile unter der Kopfzeile, Icon ueber Beschriftung.
       Acht Reiter teilen sich die Breite (390px: 46px je Reiter). Kommt ein
       neunter (C4D, nur Owner), scrollt die Zeile — tabsFade() zeigt den Rand. */
    .mode-tabs {
      position: fixed;
      left: 0; right: 0;
      top: calc(56px + env(safe-area-inset-top));
      height: var(--tabs-h); box-sizing: border-box;
      transform: none;
      border-radius: 0;
      border-left: 0; border-right: 0; border-top: 0;
      justify-content: flex-start; align-items: center;
      gap: 2px;
      padding: 0 var(--s2);
      padding-left: max(var(--s2), env(safe-area-inset-left));
      padding-right: max(var(--s2), env(safe-area-inset-right));
      overflow-x: auto;
      flex-wrap: nowrap;
      scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
      z-index: 29;
    }
    .mode-tabs::-webkit-scrollbar { display: none; }
    .mode-tabs .mode-tab {
      flex: 1 0 auto; min-width: 44px;
      flex-direction: column; justify-content: center; gap: 2px;
      padding: 5px 3px;
      font-size: 10px; line-height: 1.2; letter-spacing: 0;
      border-radius: 10px;
      white-space: nowrap;
    }
    .mode-tabs .mode-tab svg { width: 16px; height: 16px; }
    .mode-tab span:not(.mono) { display: inline; }

    /* Buehne: volle Breite, Platz fuer Reiterzeile oben und Dock, Ergebnis-
       Zeile und Regal unten (alle drei gemessen: --dock-h, --row-h, --stock-h). */
    .stage {
      top: calc(56px + var(--tabs-h) + env(safe-area-inset-top));
      padding: var(--s3);
      padding-left: max(var(--s3), env(safe-area-inset-left));
      padding-right: max(var(--s3), env(safe-area-inset-right));
      padding-bottom: calc(var(--dock-h, 180px) + var(--row-h, 0px) + var(--stock-h, 0px) + var(--s5) + var(--s1));
    }
    .stage-inner {
      aspect-ratio: auto;
      height: 100%;
      max-width: 100%;
    }

    /* Dock: volle Breite, unten ueber der Safe-Area. */
    .prompt-dock {
      left: 0; right: 0; bottom: 0;
      width: 100%;
      max-width: none;
      transform: none;
    }
    .prompt-shell {
      border-radius: var(--r-lg) var(--r-lg) 0 0;
      border-bottom: 0;
      padding-bottom: env(safe-area-inset-bottom);
    }
    .prompt-input { min-height: 64px; max-height: 120px; padding: 14px 16px 2px; }
    /* Werkzeuge in EINER Zeile: links scrollt, rechts (Anzahl, Preis, Senden)
       steht fest. Vorher brach die Zeile um, und der Sende-Knopf lag links in
       Zeile zwei; im Edit-Modus kostete das der Buehne 170px. */
    .prompt-tools { flex-wrap: nowrap; gap: var(--s2); padding: 4px 8px 8px 8px; }
    .prompt-tools-l {
      flex: 1 1 auto; min-width: 0; flex-wrap: nowrap;
      overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
      gap: 4px;
    }
    .prompt-tools-l::-webkit-scrollbar { display: none; }
    .prompt-tools-r { flex: 0 0 auto; flex-wrap: nowrap; gap: 6px; }
    .prompt-tools-l > *, #editRail > *, #dirRail > * { flex: 0 0 auto; white-space: nowrap; }
    #editRail.show, #dirRail.show { flex-wrap: nowrap; }
    #chatLog { max-height: 22vh; }
    .tool-btn { padding: 0 8px; }
    /* Edit: die Maskenleiste (Pinsel, Rechteck, Punkt, Groesse, Clear — gemessen
       410px) bekommt eine eigene volle Zeile unter der Werkzeugzeile. In der
       scrollenden Zeile lag sie hinter dem Coach-Chip ausserhalb des Schirms.
       Kostet 44px Buehne, nur in Edit. display:contents hebt die Kinder von
       .prompt-tools-l eine Ebene hoch, damit die Leiste umbrechen kann, waehrend
       Anzahl/Preis/Senden rechts in Zeile eins bleiben. */
    html[data-mode="edit"] .prompt-tools { flex-wrap: wrap; }
    html[data-mode="edit"] .prompt-tools-l { display: contents; }
    html[data-mode="edit"] .prompt-tools-r { margin-left: auto; }
    html[data-mode="edit"] #editRail.show { order: 10; flex: 1 0 100%; display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    html[data-mode="edit"] #editRail::-webkit-scrollbar { display: none; }

    /* C4D rail: own horizontally scrollable row, no uncontrolled wrap. */
    .c4d-rail.show {
      display: flex;
      flex-wrap: nowrap;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      max-width: 100%;
    }
    .c4d-rail::-webkit-scrollbar { display: none; }
    .c4d-rail .c4d-tool, .c4d-rail .c4d-brush { flex: 0 0 auto; }
    .c4d-brush input[type=range] { width: 120px; }

    /* Drawer → Blatt von unten, mit Griff. Wischen am Kopf schliesst (JS). */
    .drawer {
      left: 0; right: 0; bottom: 0;
      width: 100%; max-width: none;
      max-height: 85vh;   /* N1: vh fallback */
      max-height: 85dvh;
      border-radius: var(--r-xl) var(--r-xl) 0 0;
      border-left: 0; border-right: 0; border-bottom: 0;
      transform: translateY(100%);
      padding-bottom: env(safe-area-inset-bottom);
    }
    .drawer.show { transform: translateY(0); }
    .drawer::before { content: ''; flex: 0 0 auto; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 0; }
    .drawer-head { padding-top: var(--s2); }

    .history-grid { grid-template-columns: 1fr !important; }

    /* Ergebnis-Zeile: schmalere Kacheln, damit sie der Buehne nicht die
       halbe Hoehe wegnimmt. */
    .result-row { width: 100%; bottom: calc(var(--dock-h, 180px) + var(--s2)); }
    .result-row .result-head { padding-left: var(--s3); padding-right: var(--s3); }
    .result-strip { padding-left: var(--s3); padding-right: var(--s3); }
    .res-tile { width: 64px; height: 64px; }

    /* Regal: eine scrollbare Kopfzeile, kein Erklaertext, kleinere Kacheln.
       Gemessen vorher 94px — mehr als ein Fuenftel der Buehne bei 390x844.
       In Brain/Library/Cut ganz weg: dort gibt es keinen Prompt, an den es
       sich haengen koennte (Modus steht als data-mode am <html>). */
    .stock-row { width: 100%; bottom: calc(var(--dock-h, 180px) + var(--row-h, 0px) + var(--s2) + var(--s3)); }
    .stock-row .stock-head {
      flex-wrap: nowrap; align-items: center; gap: var(--s2);
      padding: 0 var(--s3) 4px; overflow-x: auto; scrollbar-width: none; white-space: nowrap;
    }
    .stock-row .stock-head::-webkit-scrollbar { display: none; }
    .stock-row .stock-head > * { flex: 0 0 auto; }
    .stock-hint, .stock-empty, .subj-empty, .stock-title, .stock-client { display: none; }
    .stock-strip, #subjStrip { padding-left: var(--s3); padding-right: var(--s3); }
    .stock-tile { width: 56px; }
    .stock-thumb { width: 56px; height: 56px; }
    html[data-mode="library"] .stock-row, html[data-mode="cut"] .stock-row { display: none; }
  }

  /* ── TABLET PORTRAIT (iPad hochkant) — drawer as bottom-sheet too ── */
  @media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait),
         (min-width: 769px) and (max-width: 834px) {
    .stage { padding-bottom: max(240px, calc(var(--dock-h, 180px) + var(--row-h, 0px) + var(--stock-h, 0px) + var(--s6))); }
    .drawer {
      left: 0; right: 0; bottom: 0;
      width: 100%; max-width: none;
      max-height: 80vh;   /* N1: vh fallback */
      max-height: 80dvh;
      border-radius: var(--r-xl) var(--r-xl) 0 0;
      border-left: 0; border-right: 0; border-bottom: 0;
      transform: translateY(100%);
      padding-bottom: env(safe-area-inset-bottom);
    }
    .drawer.show { transform: translateY(0); }
    .drawer::before { content: ''; flex: 0 0 auto; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 0; }
  }

  /* ── TOUCH (pointer:coarse) — tap targets >=44px, no iOS auto-zoom ── */
  @media (pointer: coarse) {
    /* iOS auto-zooms any focused input with font-size < 16px. Force 16px. */
    .prompt-input, .sel-input, .auth-field input, #durationNum,
    input, textarea, select { font-size: 16px; }

    /* Tap targets >=44px. */
    .icon-btn { width: 44px; height: 44px; }
    .send-btn { width: 44px; height: 44px; }
    .mode-tab { padding: 11px 14px; }
    .tool-btn { height: 44px; }
    .tool-chip { min-height: 44px; }   /* S2: was 38px */
    .c4d-tool { height: 44px; }        /* S2: was 40px */
    .pill { height: 40px; }
    .drawer-tab { padding: 12px 14px; }
    .lib-act { min-width: 44px; height: 40px; }       /* Library per-card actions (Block 3) */
    .lib-act-wide { width: auto; }
    .lib-filter, .lib-refresh { height: 38px; }

    /* Fatter, easier touch slider. */
    .c4d-brush input[type=range] { height: 28px; }

    /* Momentum scroll on touch containers. */
    .drawer-body, .drawer-tabs { -webkit-overflow-scrolling: touch; }
  }
  /* Safe-area fuer das schwebende Dock (iPad). Nur ab 769px: am Telefon liegt
     das Dock am unteren Rand (Telefon-Block oben), und diese Regel stand
     spaeter in der Datei — gemessen 2026-09-10: 24px Luft unter dem Dock bei
     390x844, das Regal ragte 5px ins Dock. */
  @media (pointer: coarse) and (min-width: 769px) {
    .prompt-dock { bottom: calc(var(--s5) + env(safe-area-inset-bottom)); }
  }

  /* ── C4D stage overlay (P6) — pixel-exact canvas painting, ported from V1 ── */
  /* Two stacked canvases: imgCanvas (the snapshot at native pixel size) and
     maskCanvas (the red paint layer, SAME native dimensions). Both are scaled to
     the stage purely via CSS width/height — the native canvas backing-store stays
     at the image's naturalWidth/naturalHeight, which is what makes the painting
     pixel-exact (display→native mapping happens in canvasCoords). */
  #c4dStage { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: var(--s4); }
  #c4dStage.show { display: flex; }
  #c4dCanvasWrap { position: relative; line-height: 0; }
  #c4dImgCanvas, #c4dMaskCanvas { position: absolute; left: 0; top: 0; border-radius: var(--r-md); }
  #c4dImgCanvas { position: relative; }   /* the image canvas defines the box size */
  #c4dMaskCanvas { cursor: crosshair; touch-action: none; }

  /* ── Edit (F2) mask-inpaint stage — SAME pixel-exact pattern as C4D, but a fully
     ISOLATED second canvas pair + state, so the C4D path can never regress. Only
     visible in mode=edit when a source image is loaded into the mask canvas. */
  #editStage { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: var(--s4); }
  #editStage.show { display: flex; }
  #editCanvasWrap { position: relative; line-height: 0; }
  #editImgCanvas, #editMaskCanvas { position: absolute; left: 0; top: 0; border-radius: var(--r-md); }
  #editImgCanvas { position: relative; }   /* the image canvas defines the box size */
  #editMaskCanvas { cursor: crosshair; touch-action: none; }
  /* Edit control rail — sits in the prompt dock's left tool group when mode=edit */
  #editRail { display: none; align-items: center; gap: 6px; flex-wrap: wrap; }
  #editRail.show { display: inline-flex; }
  .edit-tool { height: 30px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
  .edit-tool.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .edit-tool:hover { border-color: var(--accent); }
  .edit-brush { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); }
  .edit-brush input { width: 70px; }

  /* C4D control rail — sits in the prompt dock's left tool group when mode=c4d */
  .c4d-rail { display: none; align-items: center; gap: var(--s2); flex-wrap: wrap; }
  .c4d-rail.show { display: inline-flex; }
  .c4d-led { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-3); box-shadow: none; }
  .c4d-led.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
  .c4d-led.off { background: var(--err); box-shadow: 0 0 10px var(--err); }
  .c4d-tool {
    height: 28px; padding: 0 10px; border-radius: 8px;
    background: var(--bg-3); color: var(--fg-1);
    font-size: 12px; font-weight: 500; transition: var(--t-fast);
  }
  .c4d-tool:hover { background: var(--bg-4); color: var(--fg-0); }
  .c4d-tool.on { background: var(--bg-4); color: var(--fg-0); }
  .c4d-tool.act { background: var(--bg-3); color: var(--fg-0); border: 1px solid var(--line-strong); }
  .c4d-tool.act:hover { background: var(--bg-4); }
  .c4d-tool.go { background: var(--fg-0); color: var(--bg-0); }
  .c4d-tool.go:disabled { background: var(--bg-4); color: var(--fg-3); cursor: not-allowed; }
  .c4d-brush { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--fg-1); font-family: 'JetBrains Mono', monospace; }
  .c4d-brush input[type=range] { width: 90px; accent-color: var(--accent); }
  .c4d-tool:disabled { opacity: .35; cursor: not-allowed; filter: grayscale(.6); }
  .c4d-status { font-size: 11px; color: var(--fg-2); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* C4D plan box — shows Claude's plan, awaiting confirm/cancel before /apply */
  #c4dPlanWrap { display: none; margin-top: var(--s2); }
  #c4dPlanWrap.show { display: block; }
  #c4dPlanBox {
    background: var(--bg-1); border: 1px solid var(--accent);
    border-radius: var(--r-md); padding: 14px 16px;
    font-size: 15px; line-height: 1.6; color: var(--fg-0);
    max-height: min(52vh, 620px); overflow: auto; white-space: pre-wrap;
    user-select: text; cursor: text;
  }
  /* Text-Markieren muss KNALLEN (Tahir 08.07: "text markieren sollte sichtbarer sein") */
  #c4dPlanBox ::selection, #c4dPlanBox::selection { background: #ffd400; color: #111; }
  .c4d-msg {
    margin: 0 0 10px; padding: 10px 14px; border-radius: 12px;
    max-width: 94%; white-space: pre-wrap; user-select: text;
    background: var(--bg-2); border: 1px solid var(--bg-3);
  }
  .c4d-msg .who { display: block; font-size: 11px; opacity: .6; margin-bottom: 4px; letter-spacing: .5px; text-transform: uppercase; }
  .c4d-msg.du { background: rgba(255, 74, 94, .13); border-color: rgba(255, 74, 94, .4); margin-left: 6%; }
  .c4d-msg.merk { border-color: #3fa96b; background: rgba(63, 169, 107, .12); }
  .c4d-msg.merk .who { color: #3fa96b; opacity: 1; }
  .c4d-msg.aktion { border-color: #ffd400; background: rgba(255, 212, 0, .10); }
  .c4d-msg.aktion .who { color: #ffd400; opacity: 1; }
  #c4dPlanActions { display: flex; gap: var(--s2); margin-top: var(--s2); }

  /* ── Director (Phase 3) ─────────────────────────────────────────────────── */
  /* Control rail in the prompt dock's left group (mode=director only). */
  #dirRail { display: none; align-items: center; gap: var(--s2); flex-wrap: wrap; }
  #dirRail.show { display: inline-flex; }
  .dir-tool {
    height: 30px; padding: 0 12px; border-radius: 8px;
    background: var(--bg-3); color: var(--fg-1);
    font-size: 12px; font-weight: 500; transition: var(--t-fast);
  }
  .dir-tool:hover { background: var(--bg-4); color: var(--fg-0); }
  .dir-tool.go { background: var(--fg-0); color: var(--bg-0); }
  .dir-tool.go:disabled { background: var(--bg-4); color: var(--fg-3); cursor: not-allowed; }
  .dir-refs { font-size: 11px; color: var(--fg-2); }

  /* Director stage: plan review (whole chain) + per-step progress. */
  #dirStage { display: none; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 4px; overflow: auto; max-height: calc(100dvh - 200px); }
  #dirStage.show { display: block; }
  #dirUnderstanding { font-size: 13px; line-height: 1.55; color: var(--fg-1); margin-bottom: 12px; }
  #dirUnderstanding b { color: var(--fg-0); }
  #dirVoiceRow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
  .dir-voice-label { font-size: 11px; color: var(--fg-2); }
  .dir-voice-hint { font-size: 11px; color: var(--fg-2); font-style: italic; }
  .dir-voice-sel {
    height: 28px; max-width: 320px; border-radius: 7px; background: var(--bg-0); color: var(--fg-0);
    border: 1px solid var(--line-strong); padding: 0 8px; font-family: inherit; font-size: 12px;
  }
  .dir-voice-sel:focus { border-color: var(--accent); }
  #dirSteps { display: flex; flex-direction: column; gap: 10px; }
  .dir-step {
    background: var(--bg-1); border: 1px solid var(--line-strong);
    border-radius: var(--r-md); padding: 12px 14px; transition: var(--t-fast);
  }
  .dir-step.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .dir-step.done { border-color: var(--ok); }
  .dir-step.failed { border-color: var(--err); }
  .dir-step-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
  .dir-step-label { font-size: 13px; font-weight: 600; color: var(--fg-0); }
  .dir-step-meta { font-size: 11px; color: var(--fg-2); font-family: 'JetBrains Mono', monospace; }
  .dir-step-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--fg-2); }
  .dir-step-badge.active { background: var(--accent); color: #fff; }
  .dir-step-badge.done { background: var(--ok); color: #fff; }
  .dir-step-badge.failed { background: var(--err); color: #fff; }
  .dir-step-prompt { font-size: 11px; line-height: 1.45; color: var(--fg-1); margin-top: 6px; white-space: pre-wrap; }
  .dir-step-chain { font-size: 10px; color: var(--fg-2); margin-top: 4px; }
  .dir-step-speech { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
  .dir-speech-label { display: block; font-size: 10px; color: var(--fg-2); margin-bottom: 4px; }
  .dir-speech-input {
    width: 100%; box-sizing: border-box; resize: vertical; font-size: 12px; line-height: 1.4;
    padding: 6px 8px; border-radius: 6px; background: var(--bg-0); color: var(--fg-0);
    border: 1px solid var(--line-strong); font-family: inherit;
  }
  .dir-speech-input:focus { outline: none; border-color: var(--accent); }
  .dir-speech-onscreen { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--fg-2); margin-top: 5px; cursor: pointer; }
  .dir-step-media { margin-top: 8px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
  .dir-step-media img, .dir-step-media video { width: 100%; display: block; max-height: 240px; object-fit: contain; background: #000; }
  #dirActions { display: flex; gap: var(--s2); margin-top: 14px; }
  .dir-btn { height: 36px; padding: 0 16px; border-radius: 8px; background: var(--bg-3); color: var(--fg-1); font-size: 13px; font-weight: 500; transition: var(--t-fast); }
  .dir-btn:hover { background: var(--bg-4); color: var(--fg-0); }
  .dir-btn.go { background: var(--fg-0); color: var(--bg-0); }
  .dir-btn.go:disabled { background: var(--bg-4); color: var(--fg-3); cursor: not-allowed; }

  /* Library: prominent full-stage asset grid. position:absolute+inset:0 so it OWNS
     the whole stage-inner area and scrolls internally (like #c4dStage/#editStage) —
     NOT a block child inside the 16:9 aspect box, which would clip + hide most assets. */
  #libraryStage { display: none; position: absolute; inset: 0; overflow: auto; padding: 12px 14px; }
  #libraryStage.show { display: block; }

  /* CUT: full-stage assembler surface (owner-only). Same absolute+inset:0 pattern as
     #libraryStage so it OWNS the stage-inner area and scrolls internally. */
  #cutStage { display: none; position: absolute; inset: 0; overflow: auto; padding: 12px 14px; }
  #cutStage.show { display: block; }
  #cutInner { max-width: 1100px; margin: 0 auto; }
  #cutBar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; position: sticky; top: -12px; background: var(--bg-0); padding: 10px 2px; z-index: 2; }
  #cutBar select, .cut-btn { height: 32px; border-radius: 8px; font-size: 12px; font-weight: 500; transition: var(--t-fast); }
  #cutProject { padding: 0 10px; background: var(--bg-3); color: var(--fg-0); border: 1px solid var(--line-strong); min-width: 180px; font-family: inherit; }
  #cutNewName { height: 32px; border-radius: 8px; font-size: 12px; padding: 0 10px; background: var(--bg-3); color: var(--fg-0); border: 1px solid var(--line-strong); min-width: 180px; font-family: inherit; }
  .cut-btn { padding: 0 14px; background: var(--bg-3); color: var(--fg-1); }
  .cut-btn:hover { background: var(--bg-4); color: var(--fg-0); }
  .cut-btn.go { background: var(--fg-0); color: var(--bg-0); }
  .cut-btn.go:disabled { background: var(--bg-4); color: var(--fg-3); cursor: not-allowed; }
  #cutSaveState { font-size: 11px; color: var(--fg-2); margin-left: auto; font-family: 'JetBrains Mono', monospace; }
  #cutPlayerWrap { background: #000; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
  #cutPlayer { width: 100%; max-height: 42vh; display: block; background: #000; }
  #cutStrip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
  .cut-tile { flex: 0 0 auto; width: 132px; background: var(--bg-1); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; transition: var(--t-fast); }
  .cut-tile:hover { border-color: var(--line-strong); }
  .cut-tile.sel { border-color: var(--fg-0); }
  .cut-tile video { width: 100%; height: 74px; object-fit: cover; display: block; background: #000; pointer-events: none; }
  .cut-tile-meta { padding: 5px 7px; font-size: 10px; color: var(--fg-2); font-family: 'JetBrains Mono', monospace; }
  .cut-tile-idx { display: inline-block; background: var(--bg-4); color: var(--fg-0); border-radius: 5px; padding: 0 5px; margin-right: 5px; }
  .cut-tile-trans { color: var(--accent); }
  #cutInspector { background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; display: none; }
  #cutInspector.show { display: block; }
  .cut-insp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
  .cut-insp-row label { font-size: 11px; color: var(--fg-2); display: flex; align-items: center; gap: 5px; }
  .cut-insp-row input[type=number], .cut-insp-row select { height: 30px; border-radius: 7px; background: var(--bg-0); color: var(--fg-0); border: 1px solid var(--line-strong); padding: 0 8px; font-family: inherit; font-size: 12px; }
  .cut-insp-row input[type=number] { width: 82px; }
  #cutLibHead { font-size: 12px; color: var(--fg-2); margin: 4px 2px 10px; }
  #cutLib { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .cut-lib-card { background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; transition: var(--t-fast); }
  .cut-lib-card:hover { border-color: var(--line-strong); }
  .cut-lib-card video { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; pointer-events: none; }
  .cut-lib-card .cut-lib-cap { padding: 6px 8px; font-size: 10px; color: var(--fg-2); font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #cutLibEmpty { font-size: 12px; color: var(--fg-2); padding: 8px 2px; }
  /* CUT M1: dossier badges, analyze button, popover, preview hint, strip poster */
  #cutPreviewHint { display: none; font-size: 11px; color: var(--fg-2); font-style: italic; margin: -6px 2px 12px; }
  .cut-tile { position: relative; }
  .cut-tile-badge { position: absolute; top: 5px; right: 5px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; line-height: 1; border: 1px solid var(--line-strong); background: var(--bg-3); color: var(--fg-1); pointer-events: none; }
  .cut-tile-badge.done { background: #157a3a; border-color: #157a3a; color: #fff; }
  .cut-tile-badge.warn { background: #b25a0c; border-color: #b25a0c; color: #fff; }
  .cut-tile-badge.run { background: var(--bg-4); color: var(--fg-0); }
  .cut-lib-card { position: relative; }
  .cut-lib-card video { background: linear-gradient(135deg, var(--bg-2), var(--bg-3)); }
  .cut-lib-badge { position: absolute; top: 6px; right: 6px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; line-height: 1; border: 1px solid var(--line-strong); background: var(--bg-3); color: var(--fg-1); }
  .cut-lib-badge.info { cursor: pointer; }
  .cut-lib-badge.done { background: #157a3a; border-color: #157a3a; color: #fff; }
  .cut-lib-badge.warn { background: #b25a0c; border-color: #b25a0c; color: #fff; }
  .cut-lib-badge.run { background: var(--bg-4); color: var(--fg-0); }
  .cut-lib-badge.fail { background: #8a1f1f; border-color: #8a1f1f; color: #fff; font-weight: 700; }
  .cut-lib-analyze { position: absolute; top: 6px; left: 6px; z-index: 2; height: 24px; padding: 0 8px; border-radius: 7px; background: rgba(0,0,0,0.62); color: #fff; font-size: 10px; font-weight: 600; border: 1px solid rgba(255,255,255,0.25); cursor: pointer; transition: var(--t-fast); }
  .cut-lib-analyze:hover { background: rgba(0,0,0,0.85); }
  #cutPop { position: fixed; z-index: 60; right: 20px; bottom: 20px; width: 340px; max-width: calc(100vw - 40px); max-height: 72vh; overflow: auto; background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: 14px; padding: 16px; box-shadow: 0 14px 44px rgba(0,0,0,0.5); }
  #cutPop h4 { font-size: 13px; margin: 0 0 10px; color: var(--fg-0); }
  .cut-pop-close { position: absolute; top: 10px; right: 12px; cursor: pointer; color: var(--fg-2); background: none; border: none; font-size: 15px; }
  .cut-pop-close:hover { color: var(--fg-0); }
  .cut-pop-row { font-size: 11px; color: var(--fg-1); margin-bottom: 7px; line-height: 1.5; }
  .cut-pop-row b { color: var(--fg-2); font-weight: 600; }
  .cut-pop-maengel { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
  .cut-mangel { font-size: 11px; padding: 5px 8px; border-radius: 7px; background: var(--bg-3); border-left: 3px solid var(--fg-3); color: var(--fg-1); }
  .cut-mangel.hoch { border-left-color: #d05a1a; }
  .cut-mangel.mittel { border-left-color: #c99a00; }
  .cut-mangel.niedrig { border-left-color: var(--fg-3); }
  .cut-mangel b { text-transform: uppercase; font-size: 9px; letter-spacing: 0.04em; color: var(--fg-2); margin-right: 4px; }
  .cut-pop-trim { width: 100%; margin-top: 12px; height: 32px; border-radius: 8px; background: var(--fg-0); color: var(--bg-0); font-size: 12px; font-weight: 600; border: none; cursor: pointer; }
  .cut-pop-trim:disabled { background: var(--bg-4); color: var(--fg-3); cursor: not-allowed; }
  /* CUT M2: scorecard, assistant panel (suggestions + memory), confidence chips */
  #cutScorecard { display: none; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; margin-bottom: 12px; font-size: 12px; color: var(--fg-1); }
  #cutScorecard.show { display: flex; }
  .cut-sc-metric { display: inline-flex; align-items: baseline; gap: 5px; }
  .cut-sc-metric b { font-size: 15px; color: var(--fg-0); font-family: 'JetBrains Mono', monospace; }
  .cut-sc-metric span { color: var(--fg-2); }
  .cut-sc-sep { width: 1px; height: 16px; background: var(--line); }
  #cutAssist { background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
  #cutAssistTabs { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
  .cut-assist-tab { height: 30px; padding: 0 14px; border-radius: 8px; background: var(--bg-3); color: var(--fg-2); font-size: 12px; font-weight: 500; transition: var(--t-fast); }
  .cut-assist-tab:hover { color: var(--fg-0); }
  .cut-assist-tab.on { background: var(--fg-0); color: var(--bg-0); }
  .cut-assist-spacer { margin-left: auto; }
  #cutSuggestEmpty, #cutMemoryEmpty { font-size: 12px; color: var(--fg-2); padding: 6px 2px; }
  .cut-sug { background: var(--bg-0); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
  .cut-sug.resolved { opacity: 0.55; }
  .cut-sug-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
  .cut-sug-op { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-4); color: var(--fg-0); border-radius: 5px; padding: 2px 7px; }
  .cut-konf { font-size: 10px; font-weight: 600; border-radius: 999px; padding: 2px 9px; }
  .cut-konf.hoch { background: #157a3a; color: #fff; }
  .cut-konf.mittel { background: #b25a0c; color: #fff; }
  .cut-konf.niedrig { background: var(--bg-4); color: var(--fg-2); }
  .cut-sug-grund { font-size: 12px; color: var(--fg-1); line-height: 1.5; margin-bottom: 8px; }
  .cut-sug-frames { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
  .cut-sug-frames img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #000; }
  .cut-sug-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .cut-sug-btn { height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12px; font-weight: 500; transition: var(--t-fast); }
  .cut-sug-btn.ok { background: var(--fg-0); color: var(--bg-0); }
  .cut-sug-btn.no { background: var(--bg-3); color: var(--fg-1); }
  .cut-sug-btn.adj { background: var(--bg-3); color: var(--fg-1); }
  .cut-sug-btn.job { background: var(--bg-3); color: var(--accent); }
  .cut-sug-btn:hover { filter: brightness(1.12); }
  .cut-sug-done { font-size: 11px; color: var(--fg-2); font-style: italic; }
  .cut-mem { background: var(--bg-0); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 9px; display: flex; align-items: flex-start; gap: 10px; }
  .cut-mem-body { flex: 1; min-width: 0; }
  .cut-mem-regel { font-size: 12px; color: var(--fg-1); line-height: 1.5; }
  .cut-mem-meta { font-size: 10px; color: var(--fg-2); font-family: 'JetBrains Mono', monospace; margin-top: 4px; }
  .cut-mem-w { display: inline-block; background: var(--bg-4); color: var(--fg-0); border-radius: 5px; padding: 1px 6px; margin-right: 6px; }
  .cut-mem-acts { display: flex; gap: 6px; flex-shrink: 0; }
  .cut-mem-btn { height: 26px; padding: 0 9px; border-radius: 7px; background: var(--bg-3); color: var(--fg-1); font-size: 11px; transition: var(--t-fast); }
  .cut-mem-btn:hover { background: var(--bg-4); color: var(--fg-0); }
  .cut-mem-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  #libInner { max-width: 1100px; margin: 0 auto; }
  #libBar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; position: sticky; top: -12px; background: var(--bg-0); padding: 10px 2px; z-index: 2; }
  #libFilters { display: flex; gap: 6px; }
  .lib-filter { height: 30px; padding: 0 14px; border-radius: 999px; background: var(--bg-3); color: var(--fg-2); font-size: 12px; font-weight: 500; transition: var(--t-fast); }
  .lib-filter:hover { color: var(--fg-0); }
  .lib-filter.on { background: var(--fg-0); color: var(--bg-0); }
  .lib-refresh { height: 30px; padding: 0 14px; border-radius: 8px; background: var(--bg-3); color: var(--fg-1); font-size: 12px; transition: var(--t-fast); }
  .lib-refresh:hover { background: var(--bg-4); color: var(--fg-0); }
  .lib-refresh.on { background: var(--fg-0); color: var(--bg-0); }
  #libTools { display: flex; gap: 6px; }
  .lib-filter-trash { margin-left: 6px; }
  /* Mehrfachauswahl + Papierkorb (2026-09-16) */
  .lib-selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-1); font-size: 12px; color: var(--fg-1); }
  .lib-selbar .lib-refresh { height: 28px; }
  .lib-sel-trash:hover, .lib-sel-purge:hover { background: var(--err); color: #fff; }
  .lib-card.sel { border-color: var(--fg-0); box-shadow: 0 0 0 1px var(--fg-0); }
  #libGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
  .lib-card { background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; transition: var(--t-fast); }
  .lib-card:hover { border-color: var(--line-strong); }
  .lib-media { position: relative; aspect-ratio: 1; background: var(--bg-3); cursor: pointer; overflow: hidden; }
  .lib-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
  /* Kachel ohne Vorschaubild: Platzhalter-Symbol klein und ruhig, kein kaputtes Bild-Icon. */
  img.thumb-miss { object-fit: contain !important; background: var(--bg-3); opacity: .7; }
  .lib-thumb-status { display: grid; place-items: center; color: var(--fg-2); font-size: 18px; font-family: 'JetBrains Mono', monospace; }
  .lib-badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); border-radius: 6px; padding: 1px 6px; font-size: 12px; }
  .lib-type { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
  .lib-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px 0; font-size: 10px; color: var(--fg-2); font-family: 'JetBrains Mono', monospace; }
  .lib-model { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lib-when { flex-shrink: 0; }
  .lib-prompt { padding: 4px 9px 0; font-size: 11px; line-height: 1.4; color: var(--fg-1); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .lib-acts { display: flex; gap: 6px; padding: 8px 9px; margin-top: auto; }
  .lib-act { width: 32px; height: 28px; border-radius: 7px; background: var(--bg-3); color: var(--fg-1); font-size: 13px; transition: var(--t-fast); }
  .lib-act:hover { background: var(--bg-4); color: var(--fg-0); }
  .lib-act.on { color: #f5c518; }
  .lib-act-del:hover { background: var(--err); color: #fff; }
  .lib-act-wide { width: auto; padding: 0 12px; font-size: 12px; }
  .lib-projtag { font-size: 10px; color: var(--fg-2); padding: 3px 9px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lib-fav-badge { position: absolute; bottom: 6px; left: 6px; color: #f5c518; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
  .lib-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 13px; pointer-events: none; }
  .lib-thumb-failed { color: var(--err); font-size: 12px; font-family: inherit; }
  .lib-empty { text-align: center; color: var(--fg-2); font-size: 13px; padding: 40px 20px; }
  .jobs-retry { margin-left: 8px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg-2); color: var(--fg-0); font: inherit; font-size: 12px; cursor: pointer; }
  .jobs-retry:disabled { opacity: .6; cursor: default; }

  /* Library und Cut zeichnen die ganze Buehne selbst. Der leere
     Zustand darunter ("Make an image") schien durch — gemessen 2026-09-10
     am Telefon, auf dem Desktop genauso. */
  .stage-inner:has(#libraryStage.show, #cutStage.show) .stage-empty { display: none !important; }
  .phase-cancel { margin-left: 10px; height: 22px; padding: 0 10px; border-radius: 6px; background: var(--err); color: #fff; font-size: 11px; font-weight: 500; flex: 0 0 auto; white-space: nowrap; }
  .phase-cancel:hover { opacity: .9; }

  /* Prompt-Chat (2026-09-17): das Prompt-Feld ist der Chat. Verlauf, Rueck-
     fragen und die fertige Prompt-Karte liegen im Dock UEBER dem Eingabefeld;
     das Panel erscheint erst mit Inhalt — leer sieht das Dock aus wie vorher. */
  #chatWrap { display: none; padding: 10px 12px 0; }
  #chatWrap.show { display: block; }
  #chatHead { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 11px; color: var(--fg-2); }
  #chatHead b { color: var(--fg-1); font-weight: 600; }
  .chat-ampel { display: inline-flex; align-items: center; gap: 5px; }
  .chat-ampel::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); }
  .chat-ampel.offen::before { background: var(--warn); }
  .chat-ampel.bereit::before { background: var(--ok); }
  .chat-ampel.aus::before { background: var(--err); }
  .chat-mini { margin-left: auto; height: 22px; padding: 0 9px; border-radius: 6px; background: var(--bg-3); color: var(--fg-2); font-size: 11px; transition: var(--t-fast); }
  .chat-mini:hover { background: var(--bg-4); color: var(--fg-0); }
  /* Umschalter Prompt bauen | Reden (2026-09-20) */
  .pc-modus { display: inline-flex; align-items: center; height: 22px; padding: 2px; gap: 2px; border-radius: 7px; background: var(--bg-3); }
  .pc-modus button { height: 18px; padding: 0 9px; border-radius: 5px; background: transparent; color: var(--fg-2); font-size: 11px; font-weight: 500; line-height: 1; transition: var(--t-fast); }
  .pc-modus button:hover { color: var(--fg-0); }
  .pc-modus button.on { background: var(--fg-0); color: var(--bg-0); font-weight: 600; }
  #chatTalkAktion { display: flex; padding: 8px 2px 0; }
  #chatTalkAktion[hidden] { display: none; }
  .pc-zu-prompt { height: 26px; padding: 0 12px; border-radius: 999px; background: var(--fg-0); color: var(--bg-0); font-size: 12px; font-weight: 600; transition: var(--t-fast); }
  .pc-zu-prompt:hover { background: var(--fg-1); }
  .pc-zu-prompt:disabled { opacity: .6; cursor: default; }
  #chatLog { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow-y: auto; padding: 2px; }
  .pc-msg { max-width: 88%; padding: 7px 11px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
  .pc-user { align-self: flex-end; background: var(--fg-0); color: var(--bg-0); border-bottom-right-radius: 4px; }
  .pc-bot { align-self: flex-start; background: var(--bg-1); border: 1px solid var(--line); color: var(--fg-0); border-bottom-left-radius: 4px; }
  .pc-karte { align-self: flex-start; max-width: 92%; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg-2); font-size: 12px; display: flex; flex-direction: column; gap: 5px; }
  .pc-karte-titel { font-weight: 600; color: var(--fg-0); }
  .pc-karte-preis { font-weight: 600; color: var(--fg-0); }
  .pc-karte-info { color: var(--fg-2); font-size: 11.5px; }
  .pc-karte-prompt { color: var(--fg-1); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 7.5em; overflow: auto; }
  .pc-karte-knoepfe { display: flex; gap: 6px; margin-top: 2px; }
  .pc-karte-knoepfe button { height: 24px; padding: 0 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; }
  .pc-karte-knoepfe .los { background: var(--fg-0); color: var(--bg-0); }
  .pc-karte-knoepfe .weg { background: transparent; color: var(--fg-2); border: 1px solid var(--line); }
  .pc-karte.erledigt .pc-karte-knoepfe { display: none; }
  .pc-werkzeug { align-self: flex-start; color: var(--fg-2); font-size: 11px; padding: 0 4px; }
  .pc-sys { align-self: flex-start; background: transparent; border: 1px dashed var(--line-strong); color: var(--fg-2); font-size: 11.5px; }
  .pc-wartet { opacity: .6; font-style: italic; }
  /* Referenz im Text: Mini-Bild + Kuerzel statt Dateiname. */
  .pc-ref { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; height: 20px; padding: 0 5px 0 1px; border-radius: 6px; background: var(--bg-3); color: var(--fg-0); font-family: 'JetBrains Mono', monospace; font-size: 10.5px; font-weight: 600; line-height: 1; }
  .pc-ref img { width: 18px; height: 18px; border-radius: 4px; object-fit: cover; background: var(--bg-4); }
  .pc-user .pc-ref { background: rgba(255,255,255,.18); color: inherit; }
  .pc-frage { align-self: flex-start; max-width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0 2px 4px; }
  .pc-frage-text { font-size: 12px; color: var(--fg-1); }
  .pc-chip { height: 26px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--fg-1); font-size: 12px; transition: var(--t-fast); }
  .pc-chip:hover { border-color: var(--accent); color: var(--fg-0); }
  .pc-chip:disabled { opacity: .5; cursor: default; }
  .pc-chip.gewaehlt { background: var(--fg-0); color: var(--bg-0); border-color: var(--fg-0); }
  #chatFinal { margin-top: 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-1); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
  #chatFinal[hidden] { display: none; }
  #chatFinal.entwurf { border-style: dashed; }
  #chatFinal.entwurf #chatFinalArt { color: var(--warn); }
  .chat-final-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--fg-2); }
  .chat-final-head b { color: var(--fg-0); font-weight: 600; }
  #promptFinal { width: 100%; resize: vertical; min-height: 56px; max-height: 200px; padding: 7px 9px; border-radius: 8px; background: var(--bg-0); color: var(--fg-0); border: 1px solid var(--line); font-family: 'JetBrains Mono', monospace; font-size: 11.5px; line-height: 1.45; }
  #promptFinal:focus { outline: none; border-color: var(--accent); }
  .chat-final-neg { font-size: 11px; color: var(--fg-2); font-family: 'JetBrains Mono', monospace; }
  .chat-final-neg[hidden] { display: none; }
  .chat-slots { display: flex; flex-wrap: wrap; gap: 4px; }
  .chat-slot { font-size: 10px; padding: 2px 7px; border-radius: 999px; background: var(--bg-3); color: var(--fg-2); }
  .chat-slot.user { color: var(--fg-0); background: var(--bg-4); }
  .chat-slot.answer { color: var(--ok); }
  .chat-slot.rule { color: var(--accent); }
  .chat-slot.default { border: 1px dashed var(--line-strong); background: transparent; }
  .chat-warn { font-size: 11px; color: var(--warn); }
  .chat-warn[hidden] { display: none; }
  /* Referenz-Balken: Foto + Kuerzel (R1, R2 …) statt Dateiname; Rolle als kleines Select. */
  #refBar { display: none; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }
  #refBar.show { display: flex; }
  .refchip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 2px 6px 2px 2px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
  .refchip img { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; background: var(--bg-3); }
  .refchip-k { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; color: var(--fg-0); padding: 0 5px; height: 22px; border-radius: 4px; background: transparent; transition: var(--t-fast); }
  .refchip-k:hover { background: var(--bg-4); }
  .refchip-rolle { height: 22px; border-radius: 5px; background: var(--bg-3); color: var(--fg-1); border: 1px solid var(--line); font-size: 11px; padding: 0 4px; }
  .refchip-rolle.fehlt { border-color: var(--warn); color: var(--warn); }
  /* Vorschlag des Prompt-Chats: sichtbar als Vorschlag, nie als Entscheidung. Der Haken uebernimmt ihn. */
  .refchip-rolle.vorschlag { border-color: var(--accent); color: var(--accent); border-style: dashed; }
  .refchip-ok { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); color: var(--bg-0); font-size: 12px; font-weight: 700; line-height: 1; transition: var(--t-fast); }
  .refchip-ok:hover { filter: brightness(1.1); }
  .refchip-hilfe { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--fg-2); font-size: 12px; font-weight: 600; align-self: center; transition: var(--t-fast); }
  .refchip-hilfe:hover { border-color: var(--accent); color: var(--fg-0); }
  .pc-frage-hint { font-size: 11px; color: var(--accent); }
  .refchip-slot { font-size: 11px; color: var(--fg-2); padding: 0 4px; }

  /* ══════════════════════════════════════════════════════════════════════
     ZWEI SPALTEN (Schritt 4) — nur ab 1101px.
     Darunter bleibt alles wie bisher: Buehne mit reserviertem Fussraum,
     schwebendes Prompt-Dock, Drawer als Bottom-Sheet. Diese Bloecke stehen
     auf position:fixed und kuemmern sich nicht darum, in welchem Eltern-
     element sie haengen — der Umbau des HTML aendert dort also nichts.
     Ab 1101px wird daraus ein Raster: links die Leiste mit allem, was in die
     Generierung geht, rechts die Buehne mit allem, was herauskommt.
     ══════════════════════════════════════════════════════════════════════ */
  @media (min-width: 1101px) {
    .work {
      position: fixed;
      top: 56px; left: 0; right: 0; bottom: 0;
      display: grid;
      grid-template-columns: var(--rail-w, 400px) minmax(0, 1fr);
      overflow: hidden;
    }
    .rail {
      position: relative;
      display: flex; flex-direction: column;
      min-height: 0; overflow: hidden;
      background: var(--bg-1);
      border-right: 1px solid var(--line);
    }
    .canvas-col {
      position: relative;
      display: flex; flex-direction: column;
      min-height: 0; overflow: hidden;
      padding: var(--s5) var(--s5) var(--s4);
    }

    /* Die Einstellungen sind KEINE Spalte mehr (2026-10-02): die mittlere
       Spalte kostete die Buehne ueberall echte Breite und stand meist
       unbeachtet daneben. Was beim Arbeiten sichtbar bleiben muss — Modell,
       Format, Dauer, Aufloesung, Anzahl, Entwurf — steht jetzt als Pillen
       direkt ueber dem Prompt (#cfgPills) und wird von keinem Chat-Verlauf
       weggeschoben: das war der Grund fuer die Spalte [Tahir 2026-09-20].
       Ein Klick auf eine Pille oeffnet das volle Fenster neben der Leiste,
       ueber der Buehne; Esc, das Kreuz oder ein Klick daneben schliesst es.
       Muster: Higgsfield/Krea/Runway — Einstellungen am Prompt, nicht daneben. */
    .work > .drawer {
      left: calc(var(--rail-w, 400px) + 12px); right: auto;
      top: 68px; bottom: 12px;
      width: 380px; max-height: none;
      transform: translateX(-8px) scale(0.99);
      z-index: 41;
    }
    .work > .drawer.show { transform: none; }
    /* Bibliothek und Schnitt haben kein Prompt-Feld (das Dock ist dort aus):
       die Leiste schrumpft auf die Reiter, die Buehne bekommt die Breite. */
    html[data-mode="library"] .work, html[data-mode="cut"] .work { grid-template-columns: 220px minmax(0, 1fr); }
    html[data-mode="library"] .work > .drawer, html[data-mode="cut"] .work > .drawer { display: none; }
    /* Nur DIESER Hintergrund bleibt aus (das Fenster verdeckt die Buehne nicht
       ganz, abgedunkelt wird nichts). Bis 2026-10-02 stand hier die Klasse
       .drawer-backdrop — damit waren auf dem Desktop auch Ausgaben, Gelernt,
       Passwort und Anbieter-News unsichtbar: sie nutzen dieselbe Klasse. */
    #drawerBackdrop { display: none !important; }
    /* Die Pillen ersetzen den Settings-Knopf. */
    #btnSettings { display: none; }

    /* Prompt und Generieren sitzen am Fuss der Leiste — der letzte Schritt
       vor dem Geldausgeben steht damit unter dem, was er verbraucht. */
    .rail > .prompt-dock {
      position: static;
      width: auto; max-width: none; transform: none;
      flex: 1 1 auto; min-height: 0; z-index: auto;
      display: flex; flex-direction: column; justify-content: flex-end;
      padding: var(--s3) var(--s4) var(--s4);
      border-top: 0;
      background: var(--bg-1);
    }
    /* Die Huelle darf bis zur Leistenhoehe wachsen und schrumpft dann von
       innen: nur der Chat-Verlauf gibt nach (und scrollt), Eingabefeld, Karte
       und Werkzeuge behalten ihre Hoehe. Vorher war der Verlauf bei 30vh
       abgeschnitten, obwohl darueber die halbe Leiste leer stand. */
    .rail > .prompt-dock .prompt-shell { border-radius: var(--r-lg); display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; }
    .rail > .prompt-dock .prompt-shell > * { flex: 0 0 auto; }
    .rail > .prompt-dock #chatWrap.show { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
    .rail > .prompt-dock #chatLog { flex: 1 1 auto; min-height: 60px; max-height: none; }

    /* Der Prompt ist der wichtigste Teil des Fensters, also bekommt er den
       Platz: fuenf Zeilen Grundhoehe statt einer, und Raum bis 420px, bevor
       er scrollt. Bezahlt wird das aus dem Drawer darueber — der scrollt
       ohnehin — und aus der Breite der Buehne. In Pixeln, nicht in vh: die
       Obergrenze wird unten in JS mit getComputedStyle ausgelesen, und ein
       Wert, den der Browser als "42vh" zurueckgeben darf, waere dort still
       eine 42. [Tahir 2026-08-31]
       Die Grundhoehe ist eine min-height, keine height: das JS setzt beim
       Messen height auf 48px zurueck, und nur min-height ueberlebt das. */
    .rail > .prompt-dock .prompt-input {
      min-height: 140px;
      max-height: 420px;
      font-size: 16px;
      line-height: 1.55;
      padding: 16px 18px 6px 18px;
    }

    /* Buehne fuellt ihre Spalte, statt unten 280px fuer schwebende Leisten
       freizuhalten, die es hier nicht mehr gibt. */
    .canvas-col > .stage {
      position: static;
      top: auto; left: auto; right: auto; bottom: auto;
      padding: 0;
      flex: 1; min-height: 0;
    }
    /* Die Buehne wird ueber die HOEHE bemessen, nicht ueber die Breite: die
       Spalte ist auf dem Desktop breiter als hoch, also ist die Hoehe die
       knappe Groesse. width:auto laesst das 16:9 daraus folgen. Wird die Spalte
       doch einmal schmaler als 16:9, greift max-width und das Ergebnis bekommt
       oben und unten Balken — sichtbar bleibt es in beiden Faellen ganz. */
    .canvas-col .stage-inner {
      height: 100%; width: auto;
      max-width: 100%; max-height: 100%;
    }

    /* Ergebnisse und Stammmaterial stehen unter der Buehne in derselben
       Spalte, nicht mehr davor. */
    .canvas-col > .result-row,
    .canvas-col > .stock-row {
      position: static;
      bottom: auto; left: auto; transform: none;
      width: 100%; max-width: none;
      flex: 0 0 auto;
      margin-top: var(--s4);
    }

    /* Die Reiter sitzen am Kopf der Leiste und duerfen umbrechen. Eine Zeile
       reicht fuer zehn Reiter nirgends: in der Kopfzeile ueberdeckten sie den
       Ausgaben-Chip, in einer 420px-Spalte muessten sie scrollen — und was
       man scrollen muss, findet man nicht. Umbruch zeigt alle auf einmal.
       Die Pillen-Kulisse faellt weg; die Leiste ist die Kulisse. */
    .rail > .mode-tabs {
      position: static; transform: none;
      flex: 0 0 auto;
      flex-wrap: wrap;
      gap: 4px;
      padding: var(--s3) var(--s4);
      background: transparent;
      border: 0; border-bottom: 1px solid var(--line);
      border-radius: 0;
      justify-content: flex-start;
    }
    .rail > .mode-tabs .mode-tab { flex: 0 0 auto; }
    /* Eine Reiterzeile statt zwei (2026-10-02): Bild, Video, 3D vorn, die
       Bibliothek als Symbol, alles Seltene (Edit, Vid→Vid, Director, Cut,
       C4D) im Mehr-Menue. Edit und Video sind ohnehin ueber die Ergebnis-
       Aktionen erreichbar. Steht man in einem Nebenmodus, bleibt dessen
       Reiter sichtbar — man sieht immer, wo man ist. */
    .rail > .mode-tabs { flex-wrap: nowrap; align-items: center; }
    .rail > .mode-tabs .mode-tab[data-mode="edit"]:not(.on),
    .rail > .mode-tabs .mode-tab[data-mode="v2v"]:not(.on),
    .rail > .mode-tabs .mode-tab[data-mode="director"]:not(.on),
    .rail > .mode-tabs .mode-tab[data-mode="cut"]:not(.on),
    .rail > .mode-tabs .mode-tab[data-mode="c4d"]:not(.on) { display: none; }
    .rail > .mode-tabs .mode-tab[data-mode="library"] { margin-left: auto; }
    .rail > .mode-tabs .mode-tab[data-mode="library"] span { display: none; }
    .mode-more { display: inline-flex; }
    .rail > .mode-tabs .mode-tab { order: 1; }
    .rail > .mode-tabs .mode-tab[data-mode="library"] { order: 98; }

    /* Pillen direkt am Prompt: Modell, Format, Dauer, Aufloesung, Ton,
       Referenzen, Entwurf. Sie stehen in der Prompt-Huelle und werden von
       keinem Chat-Verlauf weggeschoben. */
    .cfg-pills { display: flex; }

    /* Verlauf statt leerer Buehne: steht nichts auf der Buehne, zeigt die
       Spalte alle Laeufe dieses Projekts. Die Ergebnis-Zeile ist dann doppelt
       und tritt zurueck; sobald ein Ergebnis gross steht, kommt sie wieder. */
    html.feed-on .canvas-col > .feed {
      display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto;
      margin: calc(-1 * var(--s5)) calc(-1 * var(--s5)) calc(-1 * var(--s4));
      padding: var(--s5);
    }
    html.feed-on .canvas-col > .stage,
    html.feed-on .canvas-col > .result-row { display: none; }

    /* Ergebnis gross: "Schliessen" ist "← Verlauf" oben links. */
    #actNew { display: none; }

    /* Kopfzeile: Ausgaben bleiben sichtbar (Geld gehoert ins Blickfeld),
       Gelernt, Design, Passwort und Abmelden wandern ins Konto-Menue — als
       Dropdown oben rechts statt als Blatt von unten. */
    #themeToggle, #pwBtn, #logoutBtn, #brainChip { display: none; }
    #acctBtn { display: grid; }
    .acct-ov { background: transparent !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
    .acct-ov .acct-sheet {
      top: 52px; right: 16px; left: auto; bottom: auto; width: 320px;
      border: 1px solid var(--line-strong); border-radius: var(--r-lg);
      padding: 6px; box-shadow: 0 18px 48px -12px rgba(0,0,0,0.55);
    }
    .acct-ov .acct-sheet::before { display: none; }

    /* Der Titel ("Einstellungen · Video") ist der Kopf der mittleren Spalte —
       ohne ihn stuende dort eine Reiterzeile ohne Namen. Das Schliessen-Kreuz
       daneben bleibt aus (siehe oben). */
  }

  /* 769–1100px: hier greift weder die Telefon-Regel noch die Zwei-Spalten-
     Ansicht. Ohne eigene Regel faenden die Reiter nach dem Umzug keinen
     positionierten Vorfahren mehr und lagen irgendwo. Also dieselbe eigene
     Zeile unter der Kopfzeile wie auf dem Telefon. */
  @media (min-width: 769px) and (max-width: 1100px) {
    .mode-tabs {
      position: fixed;
      left: 0; right: 0; top: 56px;
      transform: none;
      border-radius: 0; border-left: 0; border-right: 0; border-top: 0;
      justify-content: flex-start;
      gap: 4px;
      padding: 6px var(--s5);
      overflow-x: auto;
      flex-wrap: nowrap;
      scrollbar-width: none;
      z-index: 29;
    }
    .mode-tabs::-webkit-scrollbar { display: none; }
    .mode-tab { flex: 0 0 auto; }
    /* Die Reiterzeile ist fixed und lag UEBER dem Buehnenanfang (Buehne begann
       bei 56px, die Zeile reicht bis ~98px). Und die Buehne hielt 16:9 —
       gemessen 2026-09-10: iPad hochkant 300px Leerraum unter ihr, Telefon
       quer 147px ueber den oberen Rand hinaus. Jetzt fuellt sie die Hoehe. */
    :root { --tabs-h: 42px; }
    .mode-tabs { height: var(--tabs-h); box-sizing: border-box; align-items: center; padding-top: 0; padding-bottom: 0; }
    .stage { top: calc(56px + var(--tabs-h)); }
    .stage-inner { aspect-ratio: auto; height: 100%; max-width: 100%; }
    html[data-mode="library"] .stock-row, html[data-mode="cut"] .stock-row { display: none; }
  }

  /* ── QUERFORMAT auf dem Telefon (Hoehe <= 500px) ─────────────────────
     Gemessen 844x390: Kopfzeile + Reiter + Dock + Regal brauchten mehr Hoehe
     als da ist. Also alles flacher: Kopfzeile 44px, Reiter nur als Icons,
     Dock knapp, Regal weg (ueber die Einstellungen weiter erreichbar). */
  @media (max-width: 1100px) and (max-height: 500px) {
    :root { --tabs-h: 38px; }
    .top { height: calc(44px + env(safe-area-inset-top)); }
    .icon-btn { width: 36px; height: 36px; }
    .mode-tabs { top: calc(44px + env(safe-area-inset-top)); height: var(--tabs-h); box-sizing: border-box; align-items: center; padding-top: 0; padding-bottom: 0; }
    .mode-tabs .mode-tab { flex: 0 0 auto; flex-direction: row; padding: 0 10px; min-height: 30px; min-width: 0; }
    .mode-tab span:not(.mono) { display: none; }
    .stage {
      top: calc(44px + var(--tabs-h) + env(safe-area-inset-top));
      padding: var(--s2);
      padding-bottom: calc(var(--dock-h, 120px) + var(--row-h, 0px) + var(--s4));
    }
    .stage-inner { aspect-ratio: auto; height: 100%; max-width: 100%; }
    .prompt-input { min-height: 40px; max-height: 64px; padding: 10px 14px 0; }
    .prompt-tools { padding: 2px 8px 6px; }
    .tool-btn, .tool-chip { height: 36px; min-height: 36px; }
    .send-btn { width: 38px; height: 38px; }
    .stock-row { display: none !important; }
    .res-tile { width: 56px; height: 56px; }
    .drawer { max-height: 94vh; max-height: 94dvh; }
    .prompt-dock { bottom: max(8px, env(safe-area-inset-bottom)); }
    .result-row { bottom: calc(var(--dock-h, 120px) + var(--s4)); }
    /* Werkzeuge in EINER Zeile (wie am Telefon hochkant): links scrollt, rechts
       steht fest. Gemessen 844x390 in Edit: drei Zeilen, Buehne nur 101px. */
    .prompt-tools { flex-wrap: nowrap; gap: var(--s2); }
    .prompt-tools-l { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; gap: 6px; }
    .prompt-tools-l::-webkit-scrollbar { display: none; }
    .prompt-tools-r { flex: 0 0 auto; flex-wrap: nowrap; }
    .prompt-tools-l > *, #editRail > *, #dirRail > * { flex: 0 0 auto; white-space: nowrap; }
    #editRail.show, #dirRail.show { flex-wrap: nowrap; }
  }

  /* Library und Cut haben kein Dock — die Buehne braucht unten keinen
     Platz dafuer. --dock-h bleibt sonst beim letzten Messwert stehen: das
     versteckte Dock meldet 0, und writeDockH liest 0 als "nicht gemessen".
     Gemessen 2026-09-10 am Telefon: 208px Leerraum unter dem Brain-Chat. */
  @media (max-width: 1100px) {
    html[data-mode="library"] .stage, html[data-mode="cut"] .stage { padding-bottom: var(--s3); }
  }

  /* Breiten der beiden linken Spalten nach Schirm. Text- und Einstellungs-
     Spalte wachsen mit, die Buehne bekommt den Rest. Nachgerechnet:
       1280x720  → Buehne 580px breit  (16:9 aus der Hoehe waeren ~700: breitenbegrenzt)
       1920x1080 → Buehne 1000px breit (aus der Hoehe ~1500: breitenbegrenzt, ~560px hoch)
       2560x1440 → Buehne 1640px breit (aus der Hoehe ~2300: breitenbegrenzt)
     Die Einstellungs-Spalte kostet die Buehne also ueberall echte Breite.
     Das ist der Tausch [Tahir 2026-09-20]: "das Video-Fenster ist gross genug",
     die Einstellungen muessen sichtbar bleiben, wenn der Chat laeuft. */
  @media (min-width: 1440px) { .work { --rail-w: 440px; } }
  @media (min-width: 1600px) { .work { --rail-w: 480px; } }
  @media (min-width: 1920px) { .work { --rail-w: 520px; } }
