/*
 * Theme-System: alle Farben/Schatten ausschließlich über CSS-Variablen,
 * damit Light/Dark nur durch Umschalten des Variablen-Sets entsteht (siehe
 * [data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515;
  --surface: #1d1d1c;
  --surface-alt: #272725;
  --border: #343432;
  --border-soft: #2b2b29;
  --text: #f4f4f2;
  --text-muted: #b5b5b0;
  --text-faint: #8f8f8a;
  --accent: #f4f4f2;
  --accent-strong: #d8d8d4;
  --on-accent: #171717;
  --input-bg: #191918;
  --input-border: #3a3a37;
  --secondary-bg: #1d1d1c;
  --secondary-hover-bg: #292927;
  --danger-bg: #7a2f2f;
  --danger-hover: #9a3a3a;
  --danger-border: #7a2f2f;
  --danger-text: #ffffff;
  --status-error-text: #d98f8f;
  --score-low-bg: #33201f;
  --score-low-border: #603434;
  --score-low-text: #d48787;
  --score-mid-bg: #322b18;
  --score-mid-border: #5c4c28;
  --score-mid-text: #d7b65e;
  --score-high-bg: #1f2b22;
  --score-high-border: #3a5240;
  --score-high-text: #88b78c;
  --tint-hover: rgba(255,255,255,.06);
  --focus-ring: rgba(244,244,242,.14);
  --shadow-card: 0 1px 2px rgba(0,0,0,.35);
  --shadow-result: 0 3px 14px rgba(0,0,0,.4);
}
[data-theme="dark"] unten) statt durch verstreute harte Farbwerte im
 * restlichen CSS. Das data-theme-Attribut sitzt auf <html> und wird sehr
 * früh (kleines Inline-Script im <head> von index.html, VOR dem Laden
 * dieser Datei) sowie zur Laufzeit vom Umschalter-Button in app.js
 * gesetzt - siehe THEME_STORAGE_KEY dort.
 */
:root {
  color-scheme: light;

  /* Flächen - sehr helles, dezent lila getöntes Grundklima statt reinem
     Weiß, damit sich Karten sichtbar (aber ruhig) davon abheben. Kein
     sichtbarer "Buntlook" - Grauton mit minimalem kühlem Einschlag. */
  --bg: #f6f5fa;
  --surface: #ffffff;
  --surface-alt: #f9f8fc;
  --border: #d8d3e2;
  --border-soft: #e6e1ee;

  /* Text */
  --text: #111111;
  --text-muted: #5f5a68;
  --text-faint: #8f899a;

  /* Akzente: neutrales Dunkelgrau mit demselben ganz leichten kühlen
     Einschlag wie der Hintergrund - kein sichtbares Lila, nur stimmig zum
     Gesamtbild statt eines reinen Kohlegraus. */
  --accent: #66616f;
  --accent-strong: #514d59;
  --on-accent: #ffffff;

  /* Inputs */
  --input-bg: #ffffff;
  --input-border: #d3cddf;

  /* Sekundärer Button */
  --secondary-bg: #ffffff;
  --secondary-hover-bg: #f1eef7;

  /* Destruktive Aktionen ("Löschen") - einziger bewusst farbiger Akzent,
     sehr zurückhaltendes Dunkelrot statt kräftigem Rot. */
  --danger-bg: #7a2f2f;
  --danger-hover: #5f2323;
  --danger-border: #7a2f2f;
  --danger-text: #ffffff;
  /* Fehlermeldungstext (.status.error) - eigene Variable statt direkt
     --danger-bg, damit sich Button- und Textkontrast unabhängig
     voneinander fein abstimmen lassen (im Dark Theme muss der Text heller
     sein als die Button-Fläche, um auf dunklem Grund lesbar zu bleiben). */
  --status-error-text: #7a2f2f;

  /* Gedeckte, dezente Bewertungsfarben (Prüfmodus-Score) - kein Rot/Gelb/
     Grün als Ampelfarbe, siehe .rating-score.rating-* weiter unten. */
  --score-low-bg: #ecdcdc;
  --score-low-border: #d9baba;
  --score-low-text: #7a3b3b;
  --score-mid-bg: #ece3c9;
  --score-mid-border: #ddcca0;
  --score-mid-text: #7a5c1e;
  --score-high-bg: #dce8dc;
  --score-high-border: #bcd6bc;
  --score-high-text: #3f6b46;

  /* Sehr dezente, kaum wahrnehmbare Hover-/Fokus-Tönungen - bewusst ohne
     Buntfarbe, nur abgeleitet vom jeweiligen Theme (hell -> abdunkeln,
     dunkel -> aufhellen). */
  --tint-hover: rgba(17, 17, 17, 0.045);
  --focus-ring: rgba(17, 17, 17, 0.08);

  /* Karten deutlich runder als Buttons/Inputs - "bewusst gestaltetes
     Werkzeug" statt Formular, siehe .panel unten. */
  --radius: 14px;
  --radius-sm: 10px;

  /* Sehr dezente, leicht warm-violett getönte Schatten (statt reinem
     Schwarz) - passend zum getönten Hintergrund, aber weiterhin kaum
     wahrnehmbar. */
  --shadow-card: 0 1px 2px rgba(40, 35, 50, 0.06);
  --shadow-result: 0 2px 10px rgba(40, 35, 50, 0.08);
}

/*
 * Dunkles, leicht lila-graues Theme (bewusst kein reines Schwarz/Weiß) -
 * aktiviert über [data-theme="dark"] auf <html>. Überschreibt ausschließlich
 * die Variablen oben; der Rest des CSS bleibt unverändert, da er nirgends
 * harte Farbwerte statt der Variablen verwendet (Ausnahme: einzelne, bewusst
 * theme-neutrale Schwarzschatten wie bei .primary-button, siehe dort).
 */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #15131a;
  --surface: #1f1c27;
  --surface-alt: #282431;
  --border: #4a4357;
  --border-soft: #393344;

  --text: #f4f1f8;
  --text-muted: #b8b0c4;
  --text-faint: #8f879b;

  --accent: #7b7488;
  --accent-strong: #958da3;
  --on-accent: #ffffff;

  --input-bg: #181620;
  --input-border: #4a4357;

  --secondary-bg: #211e29;
  --secondary-hover-bg: #2b2733;

  --danger-bg: #7a2f2f;
  --danger-hover: #9a3a3a;
  --danger-border: #7a2f2f;
  --danger-text: #ffffff;
  --status-error-text: #d98f8f;

  --score-low-bg: #33201f;
  --score-low-border: #603434;
  --score-low-text: #b55b5b;
  --score-mid-bg: #322b18;
  --score-mid-border: #5c4c28;
  --score-mid-text: #c9a646;
  --score-high-bg: #1f2b22;
  --score-high-border: #3a5240;
  --score-high-text: #6f9f73;

  --tint-hover: rgba(255, 255, 255, 0.06);
  --focus-ring: rgba(244, 241, 248, 0.14);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-result: 0 3px 14px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

/* Nutzt auf Desktop nahezu die volle Breite - nur noch moderate, feste
   16px-Seitenränder (width: calc(100% - 32px)) statt einer schmalen,
   zentrierten Spalte, gedeckelt bei 1720px auf sehr breiten Bildschirmen.
   max-width fängt den Fall ab, in dem width größer als 1720px würde (CSS
   klemmt den berechneten Wert automatisch am max-width) - keine
   horizontale Scrollbar, da die Breite nie über 100% - 32px hinausgeht. */
main {
  max-width: 1180px;
  width: calc(100% - 32px);
  margin: 0 auto;
  padding: 16px 0 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Kompakter Header: Titel + Moduswechsel als eine zusammengehörige Gruppe
   links, Theme-Umschalter rechts - spart deutlich vertikalen Platz
   gegenüber einer eigenen, breiten Umschalter-Zeile darunter. Bricht auf
   schmalen Bildschirmen per flex-wrap sauber um. */
.app-header {
  max-width: 1180px;
  width: calc(100% - 32px);
  margin: 0 auto;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}

.app-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.header-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-button {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 0.85rem;
}

.account-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(300px, calc(100vw - 32px));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-result);
}

.account-email {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-page[hidden],
#appShell[hidden] {
  display: none !important;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-result);
  padding: 26px;
}

.auth-card h2 {
  margin: 6px 0 8px;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.auth-intro {
  margin: 0 0 22px;
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-card form {
  display: grid;
  gap: 14px;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-card .text-input {
  max-width: none;
}

.auth-card .primary-button {
  margin-top: 4px;
  width: 100%;
}


/* Titel und Moduswechsel gehören optisch zusammen - ein gemeinsamer
   Abstand von 20px (im gewünschten 16-24px-Bereich) statt weit auseinander
   auf entgegengesetzten Seiten des Headers. Eigene flex-wrap-Gruppe, damit
   Titel+Switch auf schmalen Bildschirmen zusammenbleiben und nur der
   Theme-Umschalter bei Bedarf in eine eigene Zeile fällt. */
.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  min-width: 0;
}

.brand-block {
  min-width: 150px;
}

.eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.app-header h1 {
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 4px 0 0;
  color: var(--text);
}

/* Theme-Umschalter (Hell/Dunkel) - sitzt rechts im Header, bewusst als
   kompakter, sekundär gestalteter Button (kein eigenes Buntfarben-Icon-
   Design). Nutzt dieselben Theme-Variablen wie .secondary-button, damit er
   sich in Light und Dark automatisch stimmig einfügt: helle Fläche/grauer
   Rand/dunkler Text im Light Theme, dunkle Fläche/heller Text/sichtbarer
   Rand im Dark Theme. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--secondary-bg);
  border-color: var(--border);
  color: var(--text);
}

.theme-toggle:hover:not(:disabled) {
  background: var(--secondary-hover-bg);
  border-color: var(--border);
  color: var(--text);
}

/* .btn.theme-toggle statt nur .theme-toggle: höhere Selektor-Spezifität
   als die allgemeine .btn-Regel (min-height: 44px u. a.) - gleiches Muster
   wie bei .btn.mode-tab weiter unten, sonst bliebe der Button trotz dieser
   Regel in voller Buttongröße statt kompakt. */
.btn.theme-toggle {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 0.85rem;
}

.theme-toggle-icon {
  font-size: 0.95rem;
  line-height: 1;
}

/* Moduswahl (Prüfen/Memento) - kompakte, in den Header integrierte
   Segment-Control statt einer großen eigenen Zeile: bewusst ruhiger als
   die Hauptaktionsbuttons im Arbeitsbereich. Ein heller "Track" mit zwei
   Tabs, aktiver Tab = weiße Fläche mit dunklem Rahmen und fetterer
   Schrift, inaktiver Tab = nahezu unsichtbar bis Hover. Nutzt weiterhin
   dieselben primary-/secondary-button-Klassen wie zuvor (keine
   JS-Änderung nötig, siehe setMode() in app.js) - hier nur mit
   spezifischeren Selektoren gezielt überschrieben, damit echte
   Primary-Buttons wie "Text prüfen" optisch weiterhin die stärkste Aktion
   auf der Seite bleiben. inline-flex statt flex + kein flex:1 auf den
   Tabs: die Control ist jetzt nur so breit wie ihr Inhalt, nicht mehr
   volle Breite. */
.mode-switch {
  display: inline-flex;
  flex-shrink: 0;
  gap: 3px;
  padding: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: calc(var(--radius-sm) + 4px);
}

/* .btn.mode-tab statt nur .mode-tab: höhere Selektor-Spezifität als die
   allgemeine .btn-Regel (die u. a. min-height: 44px setzt) - sonst würde
   die spätere .btn-Regel bei gleicher Spezifität gewinnen und die Tabs
   blieben trotz dieser Regel 44px hoch statt kompakt. */
.btn.mode-tab {
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  min-height: 30px;
  font-size: 0.85rem;
}

.mode-tab.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  box-shadow: none;
}

.mode-tab.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.mode-tab.secondary-button {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  font-weight: 600;
}

.mode-tab.secondary-button:hover:not(:disabled) {
  background: var(--tint-hover);
  border-color: transparent;
  color: var(--text);
}

.mode-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Gemeinsamer Ergebnisbereich im Prüfmodus (Bewertung + Verbesserter Text):
   auf schmalen Bildschirmen eine Spalte (DOM-Reihenfolge = gestapelte
   Reihenfolge: Bewertung vor Verbesserter Text), ab 900px zweispaltig -
   links eine kompakte Bewertungs-Sidebar (~28%), rechts der deutlich
   breitere Hauptbereich für den verbesserten Text. align-items:start
   verhindert, dass die kürzere Sidebar künstlich auf die Höhe der
   Hauptspalte gestreckt wird. */
.proofread-result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 900px) {
  .proofread-result-grid {
    grid-template-columns: minmax(240px, 28%) 1fr;
    align-items: start;
  }
}

.proofread-result-sidebar,
.proofread-result-main {
  margin: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

/* Ergebnis-/Dokumentbereiche (Bewertung, Memento-Notiz, Verbesserter Text)
   heben sich minimal von reinen Eingabe-Karten ab - etwas kräftigerer
   Schatten, sonst identische Kartenoptik (keine neue Fläche/Farbe). */
.panel-result {
  box-shadow: var(--shadow-result);
}

/* Vereinheitlichte Beschriftung für alle Bereichs-Labels (Rohnotiz,
   Memento-Notiz, Text zum Prüfen, Bewertung, Verbesserter Text) UND den
   "Einstellungen"-Aufklapper - gleiche Schriftfamilie/-größe/-gewicht
   überall (dezente Großbuchstaben-"Eyebrow"-Optik statt normalem
   Fließtext, wie in ruhigen professionellen Werkzeugen üblich). Nur
   display/cursor/padding bleiben je Element unterschiedlich (Label vs.
   klickbarer <summary>). */
.panel > label,
.settings-grid label,
.settings-panel summary {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.panel > label,
.settings-grid label {
  display: block;
}

.text-area,
.text-input {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
}

/* Mehrzeilige Felder (Rohnotiz, Memento-Notiz, Prüfen-Ein-/Ausgabe,
   Prompts) nutzen die volle, breite Panel-Breite. Einzeilige Felder
   (API-Modus, Modell, Keys, Worker-URL, Graph ID) bleiben dagegen bewusst
   auf eine gut lesbare Breite begrenzt - sonst würden z. B. ein API-Key-Feld
   oder ein Dropdown auf großen Bildschirmen unnötig und schlecht lesbar über
   die volle Container-Breite gezogen. */
.text-input {
  max-width: 480px;
}

.text-area:focus,
.text-input:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Placeholder-Text dezent, aber in beiden Themes klar erkennbar (statt dem
   browserabhängigen Default) - nutzt denselben gedämpften Grauton wie die
   Tastenkürzel-Hinweise. */
.text-area::placeholder,
.text-input::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

/* Etwas weniger hoch als früher (war 180px) - reduziert die vertikale
   Gesamthöhe insbesondere im Prüfmodus spürbar, bleibt aber per
   resize:vertical frei vergrößerbar. Betrifft die Eingabefelder Rohnotiz
   und Text zum Prüfen. */
.text-area-large {
  min-height: 130px;
}

/* "Dokumentvorschau"-Optik für Ergebnisbereiche (Memento-Notiz, Verbesserter
   Text): mehr Innenabstand, größere Zeilenhöhe, etwas größere Schrift und
   ein minimal helleres Rahmenlicht als normale Eingabefelder - bleiben
   technisch editierbare <textarea>-Elemente (Kopieren/Nachbearbeiten
   weiterhin möglich), wirken optisch aber wie eine ruhige Textfläche statt
   einem Formularfeld. Höhe bewusst knapper als zuvor (war 240px), damit
   Ergebnis und Buttons im Prüfmodus ohne starkes Scrollen sichtbar sind. */
.text-area-document {
  min-height: 210px;
  padding: 20px 22px;
  line-height: 1.75;
  font-size: 1.03rem;
  background: var(--surface);
  border-color: var(--border);
}

.prompt-area {
  min-height: 260px;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
}

/* Button + Tastenkürzel als kleine Einheit: das Kürzel steht dezent
   darunter statt in einer separaten, breiten Infozeile oben in der App
   (siehe index.html, Buttons "Text prüfen"/"Verbesserten Text
   kopieren"/"In Memento übernehmen"/"In Memento-Format umwandeln"/"An
   Memento senden"). align-items:flex-start auf .actions sorgt dafür, dass
   alle Buttons oben bündig ausgerichtet bleiben, auch wenn manche eine
   Kürzel-Zeile darunter haben und andere nicht. */
.action-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.shortcut-hint {
  font-size: 0.7rem;
  color: var(--text-faint);
  padding-left: 2px;
  line-height: 1;
}

/* Tonfall/Ziel-Auswahl (siehe TONE_OPTIONS in app.js) + "Text prüfen" als
   EINE gemeinsame Aktionszeile - Auswahl links, Button rechts daneben,
   statt zwei getrennter, gestückelt wirkender Zeilen. flex-wrap sorgt
   dafür, dass bei zu wenig Platz sauber umgebrochen wird (Auswahl über
   dem Button), auf Desktop bleibt beides in einer Zeile. align-items:
   flex-start statt center, weil der Button zusätzlich noch eine
   Tastenkürzel-Zeile darunter hat (.action-item) - flex-start richtet
   .tone-field und den Button an der GLEICHEN Oberkante aus (siehe
   min-height:44px auf .tone-select, identisch zur Button-Mindesthöhe),
   das Tastenkürzel hängt dann einfach darunter, ohne die Ausrichtung von
   Auswahl und Button zu verschieben. */
.tone-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.tone-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tone-row-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Bewusst kein voller .text-input (max-width:480px würde hier trotzdem
   deutlich breiter wirken als nötig): schrumpft auf Inhaltsbreite.
   min-height:44px passend zur Button-Mindesthöhe (siehe .btn), damit
   Auswahl und "Text prüfen" auf derselben Zeilenbasis sitzen. */
.tone-select {
  width: auto;
  max-width: 220px;
  min-height: 44px;
  padding: 10px 30px 10px 12px;
  font-size: 0.9rem;
}

/* Zeigt "Tonfall: <Auswahl>" dezent unter dem "Bewertung"-Label, siehe
   renderRating() in app.js - nutzt bewusst dieselbe dezente Optik wie
   .shortcut-hint statt einer eigenen neuen Farbe/Größe. */
.tone-result-label {
  display: block;
  margin: -6px 0 12px;
}

.tone-result-label:empty {
  display: none;
}

/* Einstellung "Nach Spracheingabe direkt an Memento senden" - eigene Zeile
   mit Checkbox statt Select/Textfeld. Selektor bewusst ".settings-panel
   .checkbox-field" (statt nur ".checkbox-field"): braucht höhere
   Spezifität als ".panel > label" oben (Uppercase-"Eyebrow"-Optik für alle
   normalen Feld-Labels), da dieses Label sonst dieselbe kleine
   Großbuchstaben-Optik statt eines normal lesbaren Checkbox-Texts bekäme. */
.settings-panel .checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 18px;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Statuszeile: bewusst ein eigenständiges Element UNTER der jeweiligen
   Buttonleiste (kein Kind von .actions mehr) - dadurch steht sie immer an
   derselben, vorhersehbaren Stelle direkt unter den Buttons, die sie
   betrifft, statt (wie zuvor teils der Fall) neben einem thematisch
   unpassenden Button in einer anderen Karte zu erscheinen. Kompakt und
   platzsparend (kleine Schrift, wenig Abstand nach oben) statt eines
   zusätzlichen großen Höhenblocks. Bleibt bewusst ohne kräftige Farben
   (Erfolg = fett/neutral, Fehler = dezentes Danger-Rot). */
.status {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.settings-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

/* Gemeinsame Struktur aller Buttons - bewusst OHNE Farbe hier, damit jeder
   Button eine der drei semantischen Klassen unten tragen muss und nicht
   versehentlich ungestylt/falsch eingefärbt bleibt. */
.btn {
  appearance: none;
  border: 1px solid transparent;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* Primäre Buttons: die eigentliche Hauptaktion eines Bereichs (Text
   prüfen, Verbesserten Text kopieren, In Memento-Format umwandeln, An
   Memento senden, Einstellungen/Prompt speichern) - bewusst die visuell
   kräftigste Fläche auf der Seite, kräftiger als der jetzt sehr ruhige
   Moduswechsel oben. */
.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

/* Sekundäre Buttons: unterstützende Aktionen (Kopieren, In Memento
   übernehmen, Graph ID abrufen, Standardprompt wiederherstellen). */
.secondary-button {
  background: var(--secondary-bg);
  border-color: var(--border);
  color: var(--text);
}

.secondary-button:hover:not(:disabled) {
  background: var(--secondary-hover-bg);
  border-color: var(--border);
  color: var(--text);
}

/* Danger-Buttons: ausschließlich für "Löschen"-Aktionen (Rohnotiz/Notiz
   löschen, Einstellungen löschen) - der einzige bewusst farbige Akzent im
   gesamten Design, und auch der nur sehr zurückhaltend dunkelrot. */
.danger-button {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.danger-button:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--danger-text);
}

/* Erfolgsmeldungen bewusst ohne Farbe (kein Grün) - nur etwas kräftiger
   als der neutrale Text, um "gespeichert"/"gesendet" hervorzuheben. */
.status.success {
  color: var(--text);
  font-weight: 600;
}

/* Fehlermeldungen nutzen denselben dezenten Danger-Ton wie die
   "Löschen"-Buttons statt eines grellen Rots - der einzige zugelassene
   Farbakzent laut Vorgabe. */
.status.error {
  color: var(--status-error-text);
  font-weight: 600;
}

.settings-panel summary {
  cursor: pointer;
  padding: 4px 0;
}

.settings-panel[open] summary {
  margin-bottom: 16px;
}

.settings-grid {
  display: grid;
  gap: 8px 12px;
  margin-bottom: 14px;
}

.settings-grid > * {
  margin-bottom: 10px;
}

.input-with-button {
  display: flex;
  gap: 8px;
  max-width: 560px;
}

.input-with-button .text-input {
  flex: 1;
  max-width: none;
}

.graph-picker {
  margin: 8px 0 16px;
  padding: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

/*
 * Bewertungsbereich: kompakte, immer vertikal gestapelte Sidebar (großer
 * Zahlenwert in einer eigenen, hellgrau hinterlegten Fläche, darunter
 * "von 10", darunter die Hinweise als Bulletpoints) - bewusst kein
 * nebeneinander-Layout mehr, da .rating-box jetzt ausschließlich innerhalb
 * der schmalen .proofread-result-sidebar-Spalte auftritt (siehe
 * .proofread-result-grid oben) und dort als kompakte Info-Spalte wirken
 * soll, nicht als große eigene Karte. Nur die Zahl selbst bekommt per
 * .rating-low/.rating-mid/.rating-high einen dezenten Farbakzent (siehe
 * renderRating() in app.js); alles andere hier bleibt Schwarz-Weiß-Grau.
 */
.proofread-result-sidebar {
  padding: 18px;
}

.rating-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rating-score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.rating-score {
  min-width: 60px;
  text-align: center;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.rating-scale {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Gedeckte, dezente Farbakzente je Bewertungsbereich - bewusst kein
   kräftiges Rot/Gelb/Grün (keine Ampelfarben), um im Schwarz-Weiß-Grau-
   Design nicht aus dem Rahmen zu fallen. Über Theme-Variablen, damit die
   Dark-Theme-Varianten (heller/lesbarer als im Light Theme) automatisch
   greifen - siehe [data-theme="dark"] oben. */
.rating-score.rating-low {
  background: var(--score-low-bg);
  border-color: var(--score-low-border);
  color: var(--score-low-text);
}

.rating-score.rating-mid {
  background: var(--score-mid-bg);
  border-color: var(--score-mid-border);
  color: var(--score-mid-text);
}

.rating-score.rating-high {
  background: var(--score-high-bg);
  border-color: var(--score-high-border);
  color: var(--score-high-text);
}

.rating-hints {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.55;
  color: var(--text);
}

.rating-hints li {
  margin-bottom: 7px;
  font-size: 0.9rem;
}

.rating-hints li:last-child {
  margin-bottom: 0;
}

.debug-box {
  margin-top: 18px;
  padding: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.debug-box summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.debug-box .text-area {
  margin-top: 8px;
  min-height: 120px;
  font-size: 0.82rem;
}

.debug-box .btn {
  margin-top: 8px;
}

/* Generischer Sichtbarkeits-Umschalter (per !important, damit er unabhängig
   von der Deklarationsreihenfolge z. B. gegenüber "display: grid" auf
   .settings-grid gewinnt - beides sind einfache Klassenselektoren mit
   gleicher Spezifität). */
.hidden {
  display: none !important;
}

.hint {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 12px 0 0;
}

/* Bewusst ohne Farbe (kein Gelb/Orange) - nur fett, um sich vom normalen
   Hinweistext abzuheben. */
.hint-warning {
  color: var(--text);
  font-weight: 600;
}

kbd {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.8rem;
  color: var(--text);
}

@media (max-width: 640px) {
  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .account-popover {
    left: 0;
    right: auto;
  }
}


/* Memento design sync: exact neutral palette and calmer spacing */
:root {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-alt: #ecebe6;
  --border: #deddd8;
  --border-soft: #e8e7e2;
  --text: #171717;
  --text-muted: #747474;
  --text-faint: #92928e;
  --accent: #111111;
  --accent-strong: #2a2a2a;
  --on-accent: #ffffff;
  --input-bg: #fafafa;
  --input-border: #deddd8;
  --secondary-bg: #ffffff;
  --secondary-hover-bg: #f0efea;
  --danger-bg: #7a2f2f;
  --danger-hover: #5f2323;
  --danger-border: #7a2f2f;
  --danger-text: #ffffff;
  --status-error-text: #7a2f2f;
  --tint-hover: rgba(17,17,17,.045);
  --focus-ring: rgba(17,17,17,.09);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-card: none;
  --shadow-result: none;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515;
  --surface: #1d1d1c;
  --surface-alt: #272725;
  --border: #343432;
  --border-soft: #2b2b29;
  --text: #f4f4f2;
  --text-muted: #b5b5b0;
  --text-faint: #8f8f8a;
  --accent: #f4f4f2;
  --accent-strong: #d8d8d4;
  --on-accent: #171717;
  --input-bg: #191918;
  --input-border: #3a3a37;
  --secondary-bg: #1d1d1c;
  --secondary-hover-bg: #292927;
  --focus-ring: rgba(244,244,242,.14);
  --shadow-card: none;
  --shadow-result: none;
}

main,
.app-header {
  max-width: 900px;
}

.app-header {
  padding-top: 22px;
  padding-bottom: 18px;
}

.app-header h1 {
  font-size: clamp(2rem, 7vw, 3rem);
}

.brand-block {
  min-width: 0;
}

.panel {
  border-color: var(--border);
  padding: 22px;
}

.mode-switch {
  background: var(--surface);
  border-color: var(--border);
  border-radius: 14px;
}

.btn.mode-tab {
  border-radius: 11px;
  padding: 8px 16px;
  min-height: 36px;
}

.primary-button {
  font-weight: 800;
  box-shadow: none;
}

.text-area,
.text-input {
  border-color: var(--border);
  border-radius: 12px;
}

.theme-toggle,
.account-button {
  border-radius: 12px;
}

.auth-card {
  border-color: var(--border);
  border-radius: 24px;
  box-shadow: none;
}

@media (max-width: 640px) {
  main,
  .app-header {
    width: calc(100% - 32px);
  }

  .app-header-bar {
    gap: 14px;
  }

  .header-left {
    width: 100%;
    justify-content: space-between;
    gap: 14px;
  }

  .mode-switch {
    margin-left: auto;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .panel {
    padding: 18px;
  }
}


.account-app-link {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}


/* Scriptum 1.0.0: mobile header/navigation aligned with Memento */
.app-header {
  position: relative;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.header-actions {
  margin-left: auto;
  flex-wrap: nowrap;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  box-shadow: none;
}

.theme-toggle:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.theme-toggle-icon {
  display: block;
  font-size: 17px;
  line-height: 1;
}

.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
}

.app-header > h1 {
  margin-top: 8px;
}

.mode-switch {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: auto;
  margin-top: 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.mode-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 60px;
  width: 60px;
  height: 48px;
  min-width: 60px;
  min-height: 48px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
}

.mode-icon-button.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.mode-icon-button svg {
  display: block;
}

@media (max-width: 640px) {
  .app-header {
    padding-top: 22px;
    padding-bottom: 18px;
  }

  .app-header-bar,
  .header-left {
    display: contents;
  }

  .brand-row {
    width: 100%;
  }

  .app-header > h1 {
    margin-top: 8px;
    font-size: 34px;
    line-height: 1.02;
    letter-spacing: -0.045em;
  }

  .mode-switch {
    margin-left: 0;
    margin-top: 18px;
  }

  .header-actions {
    width: auto;
    justify-content: flex-end;
  }

  .account-button {
    min-height: 32px;
  }
}


/* Scriptum Einstellungen: gleiche Navigationslogik wie Memento */
.workspace-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  white-space: nowrap;
}

.workspace-toggle.private {
  background: var(--surface-alt);
  color: var(--text);
}

.settings-view {
  gap: 14px;
}

.settings-tabs {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 0 12px;
  background: var(--bg);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tabs button {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 11px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.settings-tabs button.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.settings-tab-panel[hidden] {
  display: none !important;
}

.settings-prompts-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section-head {
  margin-bottom: 18px;
}

.settings-section-head h2 {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.settings-view .checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.settings-divider {
  height: 1px;
  margin: 24px 0 18px;
  background: var(--border-soft);
}

.settings-reset-panel {
  padding-top: 8px;
  padding-bottom: 8px;
}

.settings-account-email {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: .95rem;
  overflow-wrap: anywhere;
}

.settings-account-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

.settings-logout-button {
  margin-left: 8px;
}

@media (max-width: 640px) {
  .workspace-toggle {
    min-height: 32px;
    padding: 0 11px;
    font-size: 11px;
  }

  .settings-tabs {
    margin-top: -2px;
  }

  .settings-account-link,
  .settings-logout-button {
    width: 100%;
    margin-left: 0;
  }

  .settings-logout-button {
    margin-top: 10px;
  }
}


/* Feinabgleich mit Memento auf schmalen Smartphones */
@media (max-width: 420px) {
  .app-header > h1 {
    font-size: 32px;
  }

  .mode-icon-button {
    height: 46px;
    min-height: 46px;
    border-radius: 13px;
  }
}



/* Scriptum v1.1: ein durchgehender Text-Workflow */
#reflectMode[hidden] {
  display: none !important;
}

.workflow-stack {
  gap: 14px;
}

.workflow-step {
  margin: 0;
}

.workflow-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.workflow-step-head > div:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.workflow-step-head label {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text);
}

.workflow-step-number {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.workflow-step-caption {
  color: var(--text-faint);
  font-size: 0.74rem;
  line-height: 1.25;
  text-align: right;
}

.workflow-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
}

.workflow-options .tone-field {
  flex-wrap: wrap;
}

.workflow-options .tone-select {
  max-width: 260px;
  min-height: 38px;
}

.workflow-rating {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.workflow-rating .rating-score-block {
  padding: 0;
  background: transparent;
  border: 0;
  min-width: 62px;
}

.workflow-rating .rating-score {
  min-width: 50px;
  padding: 6px 10px;
  font-size: 1.45rem;
}

.workflow-rating .rating-scale {
  margin-top: 4px;
}

.workflow-rating .rating-hints {
  margin: 2px 0 0;
  padding-left: 18px;
  flex: 1;
}

.workflow-step .text-area-large {
  min-height: 150px;
}

.workflow-step .text-area-document {
  min-height: 180px;
}

@media (max-width: 820px) {
  .workflow-stack {
    gap: 10px;
  }

  .workflow-step {
    padding: 14px;
  }

  .workflow-step-head {
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .workflow-step-caption {
    max-width: 42%;
    font-size: 0.68rem;
  }

  .workflow-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .workflow-options .tone-field {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .workflow-options .tone-select {
    width: 100%;
    max-width: none;
    min-height: 38px;
  }

  .workflow-rating {
    padding: 9px 10px;
    gap: 10px;
  }

  .workflow-rating .rating-hints {
    font-size: 0.82rem;
  }

  .workflow-step .text-area-large,
  .workflow-step .text-area-document {
    min-height: 145px;
    padding: 14px;
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .workflow-step .actions {
    gap: 8px;
  }

  .workflow-step .btn {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* Scriptum v1.1.3: actual Memento header structure + mobile rules */
.topTitleBlock {
  min-width: 0;
}

.brandRow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brandControls {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.themeToggle {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.workspaceToggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 3px 7px;
  color: var(--text-muted);
  font: inherit;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  white-space: nowrap;
}

.workspaceToggle.private {
  background: var(--surface-alt);
  color: var(--text);
}

.iconButton {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  padding: 0;
}

@media (max-width: 760px) {
  .app-header.topbar {
    width: calc(100% - 44px);
    max-width: none;
    margin: 0 auto;
    padding: 20px 0 0;
    border-bottom: 0;
    display: block;
  }

  .topTitleBlock {
    width: 100%;
  }

  .brandRow {
    justify-content: space-between;
    gap: 12px;
  }

  .app-header.topbar .eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
  }

  .app-header.topbar h1 {
    margin: 8px 0 0;
    font-size: 34px;
    line-height: 1.02;
    letter-spacing: -.045em;
    white-space: nowrap;
  }

  .themeToggle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 17px;
  }

  .workspaceToggle {
    min-height: auto;
    padding: 7px 11px;
    gap: 4px;
    font-size: 11px;
  }

  .app-header.topbar .topActions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 9px;
    margin: 18px 0 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .app-header.topbar .iconButton {
    width: 100%;
    min-width: 0;
    height: 48px;
    min-height: 48px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: none;
  }

  .app-header.topbar .iconButton.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
  }
}

@media (max-width: 420px) {
  .app-header.topbar {
    width: calc(100% - 36px);
  }

  .app-header.topbar h1 {
    font-size: 32px;
  }

  .app-header.topbar .topActions {
    gap: 7px;
  }

  .app-header.topbar .iconButton {
    height: 46px;
    min-height: 46px;
    border-radius: 13px;
  }
}


/* Scriptum v1.1.4: final header parity with Memento */
@media (max-width: 760px) {
  .app-header.topbar h1 {
    font-weight: 700;
  }
}


/* Scriptum v1.1.5: calibrated against same-device Memento/Scriptum screenshots */
@media (max-width: 760px) {
  .app-header.topbar {
    width: calc(100% - 28px);
  }

  .app-header.topbar .eyebrow {
    font-size: 9.5px;
  }

  .app-header.topbar h1 {
    font-size: 29px;
    font-weight: 700;
  }

  .app-header.topbar .topActions {
    gap: 7px;
  }

  .app-header.topbar .iconButton {
    height: 41px;
    min-height: 41px;
    border-radius: 13px;
  }
}

@media (max-width: 420px) {
  .app-header.topbar {
    width: calc(100% - 28px);
  }

  .app-header.topbar h1 {
    font-size: 29px;
  }

  .app-header.topbar .iconButton {
    height: 41px;
    min-height: 41px;
    border-radius: 13px;
  }
}


/* Scriptum v1.1.6: tablet/desktop shell aligned with Memento.
   Phone layout <=640px stays untouched. */
@media (min-width: 641px) {
  #appShell {
    width: min(760px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px 22px 96px;
  }

  #appShell > .app-header,
  #appShell > main {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  #appShell > .app-header {
    padding: 0;
    border-bottom: 0;
  }

  #appShell > main {
    padding: 16px 0 48px;
  }

  .app-header.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
  }

  .app-header.topbar .eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
  }

  .app-header.topbar h1 {
    margin: 4px 0 0;
    transform: none;
    font-size: clamp(34px, 8vw, 52px);
    line-height: 1;
    font-weight: 700;
    letter-spacing: -.045em;
  }

  .app-header.topbar .topActions {
    width: auto;
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .app-header.topbar .iconButton {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 12px;
  }

  .themeToggle {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    font-size: 16px;
  }

  .workspaceToggle {
    min-height: auto;
    padding: 3px 7px;
    font-size: 9px;
  }

  .workflow-stack {
    gap: 18px;
  }
}

/* On tablet-sized viewports Memento switches to the stacked app header.
   Mirror that behavior exactly for Scriptum. */
@media (min-width: 641px) and (max-width: 820px) {
  #appShell {
    width: 100%;
    padding: 20px 22px 112px;
  }

  .app-header.topbar {
    display: block;
  }

  .topTitleBlock {
    width: 100%;
  }

  .brandRow {
    justify-content: space-between;
    gap: 12px;
  }

  .app-header.topbar h1 {
    margin-top: -10px;
    transform: translateY(-9px);
    font-size: 34px;
    line-height: 1.02;
  }

  .themeToggle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 17px;
  }

  .workspaceToggle {
    padding: 7px 11px;
    font-size: 11px;
  }

  .app-header.topbar .topActions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 9px;
    margin-top: 18px;
  }

  .app-header.topbar .iconButton {
    width: 100%;
    min-width: 0;
    height: 48px;
    min-height: 48px;
    border-radius: 14px;
  }
}


/* Scriptum v1.1.7: true Memento-style two-column desktop layout */
@media (min-width: 821px) {
  #appShell {
    width: min(1320px, 100%);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 30px 32px 18px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 260px minmax(0, 900px);
    grid-template-rows: minmax(0, 1fr);
    justify-content: center;
    gap: 56px;
  }

  #appShell > .app-header {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    align-self: start;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    border-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
  }

  #appShell > .app-header .topTitleBlock {
    width: 100%;
  }

  #appShell > .app-header .brandRow {
    width: 100%;
    justify-content: space-between;
  }

  #appShell > .app-header .eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
  }

  #appShell > .app-header h1 {
    margin: 4px 0 0;
    transform: none;
    font-size: 48px;
    line-height: .98;
    font-weight: 700;
    letter-spacing: -.045em;
  }

  #appShell > .app-header .topActions {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  #appShell > .app-header .iconButton {
    flex: 0 0 42px;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 12px;
  }

  #appShell > .app-header .themeToggle {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    font-size: 16px;
  }

  #appShell > .app-header .workspaceToggle {
    min-height: auto;
    padding: 3px 7px;
    font-size: 9px;
  }

  #appShell > main {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin: 0;
    padding: 0 8px 18px 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  #appShell > main > .mode-panel {
    min-width: 0;
    width: 100%;
  }

  #appShell .workflow-stack {
    gap: 18px;
  }
}


/* Datum für die Übergabe an Memento. */
.memento-transfer-options {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 4px;
}

.memento-transfer-options label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.memento-date-input {
  width: auto;
  min-width: 170px;
  padding: 9px 11px;
}

@media (max-width: 520px) {
  .memento-transfer-options {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .memento-date-input {
    width: 100%;
    max-width: none;
  }
}
