/*
 * Prompt-Generator – "Bauplan"-Look
 * Links das Zeichenpapier (Idee), rechts der Blaupausen-Bogen (Master-Prompt).
 */

:root {
  --paper: #E6E9EF;
  --panel: #F7F8FB;
  --ink: #121521;
  --graphite: #555C6E;
  --rule: #CBD0DB;
  --rule-strong: #9AA2B4;
  --cobalt: #2343D1;
  --cobalt-deep: #1A33A6;
  --cobalt-ink: #1D38B5;
  --on-cobalt: #F3F6FF;
  --on-cobalt-dim: #C3CEFA;
  --grid: rgba(255, 255, 255, .06);
  --grid-major: rgba(255, 255, 255, .11);
  --frame: rgba(255, 255, 255, .3);
  --signal: #D9361C;
  --focus: #2343D1;
  --shadow: 0 1px 0 rgba(18, 21, 33, .04), 0 12px 32px -18px rgba(18, 21, 33, .35);

  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Archivo', system-ui, sans-serif;
  --mono: 'Martian Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1017;
    --panel: #151925;
    --ink: #E7EAF2;
    --graphite: #9BA2B5;
    --rule: #272D3E;
    --rule-strong: #3B4358;
    --cobalt: #1E3AB8;
    --cobalt-deep: #2A4AE0;
    --cobalt-ink: #8EA4FF;
    --signal: #FF5A3C;
    --focus: #8EA4FF;
    --shadow: 0 16px 40px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0D1017; --panel: #151925; --ink: #E7EAF2; --graphite: #9BA2B5; --rule: #272D3E; --rule-strong: #3B4358;
  --cobalt: #1E3AB8; --cobalt-deep: #2A4AE0; --cobalt-ink: #8EA4FF; --signal: #FF5A3C; --focus: #8EA4FF;
  --shadow: 0 16px 40px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px clamp(16px, 3vw, 40px) 10px;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.wordmark-glyph {
  width: 18px; height: 18px;
  border-radius: 4px;
  background:
    linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px) 0 0 / 6px 6px,
    linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px) 0 0 / 6px 6px,
    var(--cobalt);
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  font-size: 14px;
  font-weight: 500;
}
.topbar-btn:hover { border-color: var(--rule-strong); }
.count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
}
.count:empty { display: none; }

/* ---------- Werkbank ---------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(24px, 3vw, 44px);
  align-items: start;
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 40px) 56px;
}

/* ---------- Linke Seite: Idee ---------- */
.composer { min-width: 0; padding-top: clamp(8px, 2vw, 24px); }

h1 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: clamp(2.3rem, 4.4vw, 4rem);
  line-height: .98;
  letter-spacing: -.025em;
  text-wrap: balance;
}
h1 span { color: var(--cobalt-ink); }

.lede {
  max-width: 54ch;
  margin: 0 0 36px;
  color: var(--graphite);
  font-size: 1.05rem;
  line-height: 1.55;
}

.step { margin: 0 0 30px; }

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--graphite);
}
.step-no {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border: 1.5px solid var(--cobalt-ink);
  border-radius: 5px;
  color: var(--cobalt-ink);
  font-size: 11px;
  letter-spacing: 0;
}
.optional {
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: none;
  opacity: .8;
}

/* Ideenfeld */
.idea-box {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.idea-box:focus-within { border-color: var(--cobalt-ink); }
.idea-box.nudge { animation: nudge .38s ease; }
@keyframes nudge {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

textarea#idea {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 18px 20px 8px;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  font-size: 1.06rem;
  line-height: 1.6;
  resize: vertical;
}
textarea#idea:focus { outline: none; }
textarea#idea::placeholder { color: var(--graphite); opacity: .75; }

.interim {
  min-height: 0;
  margin: 0;
  padding: 0 20px;
  color: var(--cobalt-ink);
  font-style: italic;
  font-size: .98rem;
}
.interim:not(:empty) { padding-bottom: 10px; }
.interim:not(:empty)::before { content: '… '; opacity: .6; }

.idea-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-top: 1px dashed var(--rule);
}

/* Mikrofon: schlichter Pill-Knopf */
.mic {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.mic:hover:not(:disabled) { border-color: var(--rule-strong); background: var(--paper); }
.mic:disabled { opacity: .4; }
.mic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic .stop-icon { display: none; fill: currentColor; stroke: none; }
.mic.live { border-color: var(--signal); background: var(--signal); color: #fff; }
.mic.live:hover { background: var(--signal); filter: brightness(1.08); }
.mic.live .mic-icon { display: none; }
.mic.live .stop-icon { display: block; }

/* Pegel: fünf kleine Balken */
.meter {
  --lvl: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 18px;
}
.meter i {
  display: block;
  width: 3px;
  height: calc(4px + var(--lvl) * var(--k) * 14px);
  max-height: 18px;
  border-radius: 2px;
  background: var(--signal);
  transition: height .08s linear;
}
.meter i:nth-child(1), .meter i:nth-child(5) { --k: .5; }
.meter i:nth-child(2), .meter i:nth-child(4) { --k: .85; }
.meter i:nth-child(3) { --k: 1.1; }

.mic-status {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--graphite);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.idea-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--graphite);
  white-space: nowrap;
}

.text-btn {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--cobalt-ink);
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn.danger { color: var(--signal); }

.icon-btn.small { width: 32px; height: 32px; border-radius: 8px; color: var(--graphite); }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.small circle { fill: var(--panel); }
.icon-btn.small[aria-expanded="true"] { background: var(--paper); color: var(--ink); }

/* Dünner Ladebalken fürs Sprachmodell */
.mic-progress {
  height: 3px;
  margin: 0 12px 8px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--rule);
}
.mic-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cobalt-ink);
  transition: width .3s ease;
}

.mic-msg {
  margin: 10px 2px 0;
  color: var(--signal);
  font-size: .86rem;
  line-height: 1.45;
}

.mic-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin: 12px 0 0;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  font-size: .88rem;
  color: var(--graphite);
}
.mic-options .hint { flex-basis: 100%; margin: 0; font-size: .82rem; line-height: 1.45; }
.mic-options .hint:empty { display: none; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.inline-field select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: .88rem;
}

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
  line-height: 1.4;
}
.check input {
  flex: none;
  width: 17px; height: 17px;
  margin: 1px 0 0;
  accent-color: var(--cobalt);
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.examples-label {
  margin-right: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--graphite);
}
.example {
  padding: 6px 12px;
  border: 1px dashed var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  font-size: .86rem;
  color: var(--ink);
}
.example:hover { border-style: solid; border-color: var(--cobalt-ink); color: var(--cobalt-ink); }

/* Bereichs-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  font-size: .92rem;
  font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--rule-strong); }
.chip[aria-checked="true"] {
  border-color: var(--cobalt);
  background: var(--cobalt);
  color: #fff;
}
.chip .guess { font-weight: 400; opacity: .78; }

/* Feinschliff */
.tune > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 0;
  margin: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.tune > summary::-webkit-details-marker { display: none; }
.tune > summary::after {
  content: '';
  width: 8px; height: 8px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .15s;
}
.tune[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.tune[open] > summary { border-bottom-style: dashed; }

.tune-grid {
  display: grid;
  gap: 18px;
  padding: 18px 0 6px;
}
.tune-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.tune-row legend {
  float: left;
  padding: 0;
  font-size: .9rem;
  font-weight: 600;
}
.tune-row .hint {
  grid-column: 2;
  margin: 0;
  color: var(--graphite);
  font-size: .82rem;
  line-height: 1.4;
}
.tune-row.toggles { align-items: start; }
.tune-row.toggles .check { grid-column: 2; font-size: .93rem; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  justify-self: start;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  padding: 6px 13px;
  border-radius: 7px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--graphite);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.seg span:hover { color: var(--ink); }
.seg input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(18, 21, 33, .14); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.tune-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  margin-top: 4px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: .85rem;
  font-weight: 600;
}
.field.wide { grid-column: 1 / -1; }
.field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--panel);
  font-weight: 400;
  font-size: .93rem;
}
.field input:focus { outline: none; border-color: var(--cobalt-ink); }
.field input::placeholder { color: var(--graphite); opacity: .7; }

/* Erstellen-Knopf */
.generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius);
  background: var(--cobalt);
  color: #fff;
  font-family: var(--display);
  font-stretch: 112%;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -.005em;
  box-shadow: 0 14px 30px -16px rgba(35, 67, 209, .8);
  transition: background .15s, transform .1s;
}
.generate:hover { background: var(--cobalt-deep); }
.generate:active { transform: translateY(1px); }
.generate kbd {
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  font-stretch: 100%;
  opacity: .85;
}
.touch .generate kbd { display: none; }

/* ---------- Rechte Seite: Blaupause ---------- */
.sheet {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 96px);
  height: calc(100dvh - 96px);
  min-height: 520px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--cobalt);
  color: var(--on-cobalt);
  box-shadow: 0 30px 60px -30px rgba(26, 51, 166, .65);
}
.sheet::before {
  content: '';
  position: absolute;
  inset: 9px;
  border: 1px solid var(--frame);
  border-radius: 11px;
  pointer-events: none;
  z-index: 1;
}

.sheet-head {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 22px 26px 14px;
  border-bottom: 1px solid var(--frame);
  margin: 0 9px;
  padding-left: 17px;
  padding-right: 17px;
}
.sheet-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.stale {
  padding: 4px 10px;
  border: 1px solid #FFD27A;
  border-radius: 999px;
  background: rgba(255, 210, 122, .14);
  color: #FFE3A8;
  font-family: var(--mono);
  font-size: 10.5px;
}
.stale:hover { background: rgba(255, 210, 122, .26); }
.sheet-actions { display: flex; gap: 8px; margin-left: auto; }
.sheet-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 9px;
  background: transparent;
  color: var(--on-cobalt);
  font-size: .88rem;
  font-weight: 600;
  transition: background .12s;
}
.sheet-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.sheet-btn.primary { background: #fff; border-color: #fff; color: #1A33A6; }
.sheet-btn.primary:hover:not(:disabled) { background: #E4E9FF; }
.sheet-btn.done { background: #CFF5DD; border-color: #CFF5DD; color: #0E5A2C; }
.sheet-btn:disabled { opacity: .4; }
.sheet :focus-visible { outline-color: #fff; }

.sheet-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 9px;
  padding: 0 4px;
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
  background-attachment: local;
  scrollbar-color: rgba(255, 255, 255, .35) transparent;
  scrollbar-width: thin;
}
.sheet-body:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }

.sheet-empty {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 100%;
  max-width: 44ch;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
  color: var(--on-cobalt-dim);
  font-size: .95rem;
  line-height: 1.6;
}
.sheet-empty p { margin: 0; }
.empty-title {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: 1.7rem;
  line-height: 1.1;
  color: var(--on-cobalt);
}

#output {
  margin: 0;
  padding: 18px 16px 32px;
  font-family: var(--mono);
  font-stretch: 75%;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}
#output .ln { display: block; min-height: 1.75em; }
#output .ln.h {
  margin-top: 1.1em;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: .01em;
}
#output .ln.h:first-child { margin-top: 0; }
#output .ln.li { padding-left: 2ch; text-indent: -2ch; }
#output .ln.li.num { padding-left: 3ch; text-indent: -3ch; }
#output .ln.tag, #output .ln.quote, #output .mk { color: var(--on-cobalt-dim); opacity: .8; }
#output .ln.tag { font-weight: 600; }
#output b { font-weight: 700; color: #fff; }

#output.plot .ln {
  animation: plot .42s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i) * 11ms);
}
@keyframes plot {
  from { opacity: 0; clip-path: inset(0 100% 0 0); }
  to { opacity: 1; clip-path: inset(0 0 0 0); }
}

/* Schriftfeld wie auf einer technischen Zeichnung */
.titleblock {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 1.05fr 1.35fr 1.1fr;
  margin: 0 9px 9px;
  border-top: 1px solid var(--frame);
}
.titleblock > div {
  min-width: 0;
  padding: 9px 12px 11px;
  border-left: 1px solid var(--frame);
}
.titleblock > div:first-child { border-left: 0; padding-left: 17px; }
.titleblock dt {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--on-cobalt-dim);
}
.titleblock dd {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-stretch: 75%;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ---------- Verlauf ---------- */
dialog.history {
  width: min(620px, calc(100vw - 32px));
  max-height: min(78vh, 760px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .5);
}
dialog.history[open] { display: flex; flex-direction: column; }
dialog.history::backdrop { background: rgba(13, 16, 23, .55); }
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 4px 22px;
}
.dlg-head h2 {
  margin: 0;
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: 1.5rem;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}
.icon-btn:hover { background: var(--paper); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dlg-note { margin: 0; padding: 0 22px 12px; color: var(--graphite); font-size: .88rem; }
.history-list {
  flex: 1;
  margin: 0;
  padding: 0 12px;
  list-style: none;
  overflow: auto;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.history-list li + li { border-top: 1px dashed var(--rule); }
.history-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 12px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.history-item:hover { background: var(--paper); }
.hi-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--cobalt-ink);
}
.hi-idea { font-size: .93rem; line-height: 1.45; }
.history-empty { padding: 28px 10px; color: var(--graphite); text-align: center; }
.dlg-foot { display: flex; justify-content: flex-end; padding: 12px 22px 16px; }

/* ---------- Hinweis-Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .45);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Kleinere Bildschirme ---------- */
@media (max-width: 999px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .sheet {
    position: relative;
    top: 0;
    height: auto;
    min-height: 460px;
    scroll-margin-top: 12px;
  }
  .sheet-body { flex: none; max-height: 72vh; min-height: 300px; }
}

@media (max-width: 600px) {
  .lede { margin-bottom: 28px; }
  .tune-row { grid-template-columns: minmax(0, 1fr); }
  .tune-row .hint, .tune-row.toggles .check { grid-column: 1; }
  .tune-fields { grid-template-columns: minmax(0, 1fr); }
  .idea-tools { flex-wrap: wrap; }
  .idea-meta { gap: 10px; }
  .mic-status { order: 5; flex-basis: 100%; }
  .mic-status:empty { display: none; }
  .sheet-head { padding-top: 18px; }
  .sheet-actions { width: 100%; margin-left: 0; }
  .sheet-btn { flex: 1; padding: 0 10px; white-space: nowrap; font-size: .84rem; }
  #output { font-size: 12.5px; padding: 14px 10px 24px; }
  .titleblock { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .titleblock > div { border-left: 0; border-top: 1px solid var(--frame); padding-left: 17px; }
  .titleblock > div:nth-child(even) { border-left: 1px solid var(--frame); padding-left: 12px; }
  .titleblock > div:first-child, .titleblock > div:nth-child(2) { border-top: 0; }
  .titleblock > div:last-child { grid-column: 1 / -1; border-left: 0; padding-left: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- KI-Auswahl im Feinschliff ---------- */
.ai-pick { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.ai-pick select {
  min-width: 0;
  max-width: 100%;
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: .9rem;
  text-overflow: ellipsis;
}

/* ---------- KI-Status über dem Bogen ---------- */
.ai-status {
  position: relative;
  z-index: 2;
  margin: 0 9px;
  padding: 10px 17px 12px;
  border-bottom: 1px solid var(--frame);
}
.ai-status-row { display: flex; align-items: center; gap: 12px; }
.ai-phase {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-stretch: 87.5%;
  font-size: 11.5px;
  color: var(--on-cobalt);
}
.ai-status .sheet-btn { min-height: 30px; padding: 0 12px; font-size: .82rem; }
.ai-bar {
  position: relative;
  height: 3px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, .18);
}
.ai-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: #fff;
  transition: width .3s ease;
}
.ai-bar.busy span {
  position: absolute;
  width: 35%;
  animation: busy 1.4s ease-in-out infinite;
}
@keyframes busy {
  from { left: -35%; }
  to { left: 100%; }
}

/* ---------- Panels im Bogen (Auswahl, Anmeldung, Fehler, Live-Ansicht) ---------- */
.ai-panel {
  max-width: 560px;
  margin: 0 auto;
  padding: 36px 18px 32px;
}
.panel-title {
  margin: 0 0 8px;
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.15;
  color: #fff;
}
.panel-sub {
  margin: 0 0 10px;
  color: var(--on-cobalt-dim);
  font-size: .93rem;
  line-height: 1.55;
}
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.choose-grid { display: grid; gap: 10px; margin-top: 20px; }
.choose-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  color: var(--on-cobalt);
  text-align: left;
  font-size: .88rem;
  line-height: 1.45;
  transition: background .12s, border-color .12s;
}
.choose-card:hover:not(:disabled) { background: rgba(255, 255, 255, .14); border-color: #fff; }
.choose-card:disabled { opacity: .45; }
.choose-card strong { font-size: 1rem; color: #fff; }
.choose-card span { color: var(--on-cobalt-dim); }
.choose-card b { color: #fff; font-weight: 600; }
.choose-card em { font-style: normal; color: #FFE3A8; }
.choose-card em:empty { display: none; }
.choose-card.quiet { background: transparent; border-style: dashed; }
.cc-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  color: #1A33A6 !important;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
}

.live-list { display: grid; gap: 14px; margin: 22px 0 0; }
.live-list dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--on-cobalt-dim);
}
.live-list dd { margin: 3px 0 0; color: #fff; font-size: .95rem; line-height: 1.5; }
