/* ==========================================================================
   SEMIO – Stylesheet nach Material Design 3 (Material You)
   Farbrollen aus der Ausgangsfarbe Petrol, Formen, Erhebung und Zustandsebenen
   nach M3. Für die Unterstützte Kommunikation angepasst: Schrift Atkinson
   Hyperlegible (für Lesbarkeit entwickelt), Wortarten nach Fitzgerald-Schlüssel,
   deutlicher Rahmen beim Zeigen (Maus, Kopfmaus, Augensteuerung), keine Animationen.
   ========================================================================== */

@font-face { font-family: 'Atkinson Hyperlegible'; src: url('../fonts/atkinson-hyperlegible-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('../fonts/atkinson-hyperlegible-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

/* ---------- Material-3-Farbrollen (Ausgangsfarbe Petrol #006a6a) ---------
   Die md-*-Werte sind die Farbrollen nach Material Design 3. Darunter werden
   sie den Namen zugeordnet, die die App verwendet. */
:root {
  --md-primary: #006a6a; --md-on-primary: #ffffff;
  --md-primary-container: #9cf1f0; --md-on-primary-container: #002020;
  --md-secondary: #4a6363; --md-on-secondary: #ffffff;
  --md-secondary-container: #cce8e7; --md-on-secondary-container: #051f1f;
  --md-error: #ba1a1a; --md-on-error: #ffffff; --md-error-container: #ffdad6;
  --md-surface: #f4fbfa; --md-on-surface: #161d1d; --md-on-surface-variant: #3f4948;
  --md-surface-container-lowest: #ffffff; --md-surface-container-low: #eff5f4; --md-surface-container: #e9efee;
  --md-surface-container-high: #e3e9e8; --md-surface-container-highest: #dde4e3;
  --md-outline: #6f7979; --md-outline-variant: #bec9c8;
  --md-card: #ffffff;  /* Kartenfläche: hell = weiß, dunkel = surface-container-high */
  --md-inverse-surface: #2b3231; --md-inverse-on-surface: #ecf2f1; --md-inverse-primary: #80d5d4;
  --md-elev-1: 0 1px 2px rgb(0 0 0 / .3), 0 1px 3px 1px rgb(0 0 0 / .15);
  --md-elev-3: 0 1px 3px rgb(0 0 0 / .3), 0 4px 8px 3px rgb(0 0 0 / .15);

  /* Fitzgerald-Schlüssel */
  --wc-pron: #f0bf00; --wc-verb: #2b9a4d; --wc-noun: #ef7d1a; --wc-adj: #2f7be0; --wc-quest: #8c4bd6;
  --wc-social: #de4f96; --wc-neg: #d63434; --wc-misc: #8b9493; --wc-folder: #5c6766; --wc-nav: #161d1d;

  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --md-primary: #80d5d4; --md-on-primary: #003737;
    --md-primary-container: #004f4f; --md-on-primary-container: #9cf1f0;
    --md-secondary: #b0cccb; --md-on-secondary: #1b3534;
    --md-secondary-container: #324b4b; --md-on-secondary-container: #cce8e7;
    --md-error: #ffb4ab; --md-on-error: #690005; --md-error-container: #93000a;
    --md-surface: #0e1514; --md-on-surface: #dde4e3; --md-on-surface-variant: #bec9c8;
    --md-surface-container-lowest: #090f0f; --md-surface-container-low: #161d1d; --md-surface-container: #1a2121;
    --md-surface-container-high: #252b2b; --md-surface-container-highest: #303636;
    --md-outline: #889392; --md-outline-variant: #3f4948;
    --md-card: #252b2b;
    --md-inverse-surface: #dde4e3; --md-inverse-on-surface: #2b3231; --md-inverse-primary: #006a6a;
    --wc-pron: #f5cc2e; --wc-verb: #4cbc6c; --wc-noun: #ff9440; --wc-adj: #63a2ff; --wc-quest: #b07cf0;
    --wc-social: #f27ab4; --wc-neg: #f05a5a; --wc-misc: #a3adac; --wc-folder: #c3cdcc; --wc-nav: #dde4e3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --md-primary: #80d5d4; --md-on-primary: #003737;
  --md-primary-container: #004f4f; --md-on-primary-container: #9cf1f0;
  --md-secondary: #b0cccb; --md-on-secondary: #1b3534;
  --md-secondary-container: #324b4b; --md-on-secondary-container: #cce8e7;
  --md-error: #ffb4ab; --md-on-error: #690005; --md-error-container: #93000a;
  --md-surface: #0e1514; --md-on-surface: #dde4e3; --md-on-surface-variant: #bec9c8;
  --md-surface-container-lowest: #090f0f; --md-surface-container-low: #161d1d; --md-surface-container: #1a2121;
  --md-surface-container-high: #252b2b; --md-surface-container-highest: #303636;
  --md-outline: #889392; --md-outline-variant: #3f4948;
  --md-card: #252b2b;
  --md-inverse-surface: #dde4e3; --md-inverse-on-surface: #2b3231; --md-inverse-primary: #006a6a;
  --wc-pron: #f5cc2e; --wc-verb: #4cbc6c; --wc-noun: #ff9440; --wc-adj: #63a2ff; --wc-quest: #b07cf0;
  --wc-social: #f27ab4; --wc-neg: #f05a5a; --wc-misc: #a3adac; --wc-folder: #c3cdcc; --wc-nav: #dde4e3;
  color-scheme: dark;
}

/* ---------- Zuordnung: Farbrollen → App ---------------------------------- */
:root {
  --background: var(--md-surface);
  --layer: var(--md-card);
  --layer-2: var(--md-surface-container);
  --layer-hover: var(--md-surface-container-high);
  --layer-active: var(--md-surface-container-highest);
  --field: var(--md-surface-container-lowest);
  --border-subtle: var(--md-outline-variant);
  --border-strong: var(--md-outline);
  --text: var(--md-on-surface);
  --text-2: var(--md-on-surface-variant);
  --interactive: var(--md-primary);
  --tint: var(--md-secondary-container);
  --focus: var(--md-primary);
  --focus-inset: var(--md-surface);
  --gaze: var(--md-on-surface);   /* Rahmen „hier ruht der Blick/Zeiger" – keine Wortart-Farbe */
  --btn-primary: var(--md-primary); --on-primary: var(--md-on-primary);
  --btn-primary-hover: color-mix(in srgb, var(--md-primary) 92%, var(--md-on-primary));
  --btn-primary-active: color-mix(in srgb, var(--md-primary) 84%, var(--md-on-primary));
  --btn-secondary: var(--md-secondary-container); --on-secondary: var(--md-on-secondary-container);
  --btn-secondary-hover: color-mix(in srgb, var(--md-secondary-container) 92%, var(--md-on-secondary-container));
  --btn-secondary-active: color-mix(in srgb, var(--md-secondary-container) 84%, var(--md-on-secondary-container));
  --btn-danger: var(--md-error); --on-danger: var(--md-on-error);
  --btn-danger-hover: color-mix(in srgb, var(--md-error) 90%, var(--md-on-error));
  --support-info: var(--md-primary); --support-success: #2b8a45; --support-warning: #d99a00; --support-error: var(--md-error);
  --shell: var(--md-surface); --shell-text: var(--md-on-surface); --shell-text-2: var(--md-on-surface-variant);
  --shell-btn: var(--md-surface-container-high); --shell-active: var(--md-surface-container-highest); --shell-border: transparent;
  --sh-bg: var(--layer);
  --overlay: rgb(0 0 0 / .32);
  --predict: var(--md-on-surface);
  --scan-bg: var(--md-primary-container);
  --shadow-1: var(--md-elev-1);
  --shadow-2: var(--md-elev-3);

  /* Formen nach Material 3: klein 8, mittel 12, groß 16, sehr groß 28 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 28px;
  --font-scale: 1;
  --gap: 6px;
  --cell-min: 64px;     /* nie unter 60 px Ziel */
  --frame: 4px;         /* einheitlicher Kartenrahmen */
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Grundlagen -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; transition: none !important; animation: none !important; scroll-behavior: auto !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--background); color: var(--text);
  font-family: var(--font); font-size: calc(16px * var(--font-scale)); line-height: 1.4;
  overflow: hidden; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border-radius: var(--r-sm); }
[data-act], [data-hold] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.glyph { width: 20px; height: 20px; flex: none; }

/* ---------- Startbildschirm -------------------------------------------- */
#splash { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--background); color: var(--text); }
.splash-name { font-size: 2.25rem; font-weight: 700; letter-spacing: .18em; }
.splash-status { color: var(--text-2); }

/* ---------- App-Gerüst -------------------------------------------------- */
.app { height: 100dvh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.app > * { flex: none; }
.app > .board { flex: 1 1 0; }
.app > .sentencebar, .app > .quickbar, .app > .board { margin: var(--gap) max(var(--gap), env(safe-area-inset-right)) 0 max(var(--gap), env(safe-area-inset-left)); }
.app > .board { margin-bottom: var(--gap); }

/* ---------- Titelzeile -------------------------------------------------- */
.shell {
  --sh-bg: var(--shell-btn);
  display: flex; align-items: center; gap: 6px; min-height: 60px;
  padding: calc(env(safe-area-inset-top) + 6px) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  background: var(--shell); color: var(--shell-text); border-bottom: 1px solid var(--shell-border);
}
.shell-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 0 6px; }
.shell-brand img { border-radius: var(--r-sm); }
.shell-name { font-weight: 700; letter-spacing: .16em; font-size: 1.05rem; }
.shell-context { display: flex; align-items: baseline; gap: 10px; padding: 0 12px; min-width: 0; }
.shell-page { font-weight: 400; font-size: 1.375rem; white-space: nowrap; }
.shell-profile { color: var(--shell-text-2); font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-status { margin-left: auto; padding: 4px 12px; font-size: .8125rem; color: var(--shell-text-2); background: var(--shell-btn); border-radius: 999px; }
.shell-status[hidden] + .shell-actions { margin-left: auto; }
.shell-actions { display: flex; gap: 6px; }
.shell-btn {
  display: inline-flex; align-items: center; gap: 8px; min-width: 64px; min-height: 48px; padding: 0 20px 0 16px;
  background: var(--shell-btn); color: var(--shell-text); border: 2px solid transparent; border-radius: 999px; font-weight: 700;
}
.shell-btn > span { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.shell-btn small { font-weight: 400; font-size: .6875rem; color: var(--shell-text-2); }
.shell-btn.is-pressed, .shell-btn.is-holding { background: var(--shell-active); }
.shell-btn[aria-disabled="true"] { color: var(--shell-text-2); background: transparent; cursor: default; }
@media (hover: hover) { .shell-btn:not([aria-disabled="true"]):hover { border-color: var(--gaze); } }

/* ---------- Bearbeitungs-Banner ---------------------------------------- */
.edit-banner { display: flex; align-items: center; gap: 12px; margin: var(--gap) var(--gap) 0; padding: 8px 8px 8px 16px; background: var(--md-primary-container); color: var(--md-on-primary-container); border-radius: var(--r-md); }
.edit-banner[hidden] { display: none; }
.edit-banner > .glyph { color: var(--interactive); }
.edit-banner__text { flex: 1; min-width: 0; }

/* ---------- Satzleiste -------------------------------------------------- */
.sentencebar { display: flex; gap: var(--gap); height: calc(96px * var(--font-scale)); min-height: 80px; }
.sentence { flex: 1; min-width: 0; display: flex; align-items: stretch; gap: 6px; padding: 6px; background: var(--md-surface-container-highest); border: 0; border-radius: var(--r-lg); text-align: left; }
.sentence.is-pressed { background: var(--layer-hover); }
.sentence-words { flex: 1; min-width: 0; display: flex; gap: 6px; padding: 0 0 0 2px; overflow-x: auto; scrollbar-width: none; }
.sentence-words::-webkit-scrollbar { display: none; }
.sentence.is-empty .sentence-words::before { content: 'Wörter wählen – hier entsteht der Satz'; align-self: center; color: var(--text-2); padding-left: 10px; }
.chip { flex: none; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; min-width: 68px; padding: 4px 8px 2px; background: var(--layer-2); border-radius: var(--r-sm); border-top: var(--frame) solid var(--wc, var(--border-strong)); }
.chip .card-sym { width: 100%; }
.chip-label { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.chip.card--text .chip-label { display: none; }
.sentence-speak { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 108px; background: var(--btn-primary); color: var(--on-primary); border-radius: var(--r-lg); font-weight: 700; font-size: .9375rem; }
.sentence-speak .glyph { width: 32px; height: 32px; }
.sentence.is-pressed .sentence-speak { background: var(--btn-primary-active); }
.bar-btn { flex: none; width: calc(88px * var(--font-scale)); min-width: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--btn-secondary); color: var(--on-secondary); border: 0; border-radius: var(--r-lg); font-weight: 700; }
.bar-btn .glyph { width: 28px; height: 28px; }
.bar-btn.is-pressed { background: var(--btn-secondary-active); }

/* ---------- Schnellsätze ----------------------------------------------- */
.quickbar { display: flex; gap: var(--gap); height: calc(68px * var(--font-scale)); min-height: 62px; overflow-x: auto; scrollbar-width: none; padding: 3px; margin-inline: calc(-3px); }
.quick { container-type: inline-size; position: relative; flex: 1 0 auto; min-width: 104px; display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 6px; background: var(--layer); border: 0; border-left: 8px solid var(--wc); border-radius: var(--r-md); box-shadow: var(--shadow-1); font-weight: 700; font-size: 1.0625rem; overflow: hidden; }
.quick .card-sym { height: 100%; max-height: 52px; aspect-ratio: 1; flex: none; }
.quick.card--text { justify-content: center; padding-left: 14px; }
.quick.card--text .card-sym { display: none; }
.quick.is-pressed { background: var(--layer-active); }

/* ---------- Raster ------------------------------------------------------ */
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), minmax(var(--cell-min), 1fr));
  grid-template-rows: repeat(var(--rows, 7), minmax(var(--cell-min), 1fr));
  gap: var(--gap); min-height: 0; overflow: auto; padding: 4px;
}

[data-wc="pron"]   { --wc: var(--wc-pron); }
[data-wc="verb"]   { --wc: var(--wc-verb); }
[data-wc="noun"]   { --wc: var(--wc-noun); }
[data-wc="adj"]    { --wc: var(--wc-adj); }
[data-wc="quest"]  { --wc: var(--wc-quest); }
[data-wc="social"] { --wc: var(--wc-social); }
[data-wc="neg"]    { --wc: var(--wc-neg); }
[data-wc="misc"]   { --wc: var(--wc-misc); }
[data-wc="folder"] { --wc: var(--wc-folder); }
[data-wc="nav"]    { --wc: var(--wc-nav); }

/* Wortkarte: weiche Kachel, einheitlicher Rahmen in Wortart-Farbe, Symbol oben, Wort unten */
.card {
  position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0; min-height: 0; padding: 6px 6px 0;
  background: var(--layer); border: var(--frame) solid var(--wc); border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  overflow: hidden; container-type: inline-size;
}
.card.is-pressed { background: var(--layer-active); }
.card-sym { display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; border-radius: calc(var(--r-md) - 6px); }
/* Alle Piktogramme sind beim Speichern auf dieselbe optische Größe zugeschnitten (arasaac.js) */
.card-sym img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.card--photo .card-sym img { object-fit: cover; }
.card-label {
  font-weight: 700; line-height: 1.15; text-align: center;
  /* Einheitlich: gleiche Schriftgröße für alle Karten einer Seite (--maxlen vom Raster) */
  font-size: calc(clamp(.8rem, 1.9vh, 1.3rem) * var(--font-scale));
  font-size: min(calc(clamp(.8rem, 1.9vh, 1.3rem) * var(--font-scale)), calc(100cqi / (var(--maxlen, 8) * .62)));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 0 4px;
}
/* Lange Wörter/Sätze (> 10 Zeichen): gleiche Schriftgröße wie die anderen Karten,
   dafür bis zu zwei Zeilen. Erst wenn auch das nicht reicht, wird die Schrift etwas kleiner. */
.card-label--long {
  white-space: normal; text-overflow: clip; line-height: 1.05;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  font-size: min(calc(clamp(.8rem, 1.9vh, 1.3rem) * var(--font-scale)), calc(100cqi / (var(--maxlen, 8) * .62)), calc(100cqi / (var(--wlen, 8) * .62)));
}
.card-textsym {
  /* Textkarte: Wort groß im Symbolbereich, nie mitten im Wort getrennt – lange Wörter werden kleiner */
  font-weight: 700; text-align: center; line-height: 1.1; overflow-wrap: normal; word-break: keep-all; hyphens: none;
  font-size: min(calc(clamp(.95rem, 2.6vh, 1.7rem) * var(--font-scale)), calc(100cqi / (var(--tlen, 6) * .62)));
}
.card.card--text > .card-label { visibility: hidden; }
.hide-labels .card:not(.card--text) > .card-label { display: none; }

/* ---------- Gruppen (Ordner) eindeutig von Einzelwörtern unterscheiden ----
   Einzelwort = eine flache Karte.  Gruppe = Kartenstapel (zwei Karten dahinter),
   Ordner-Reiter oben und Plakette mit der Anzahl der Wörter darin.
   Erkennbar an der Form – auch ohne Farbe, auch für Farbenblinde. */
.board .card--group {
  margin: 0 8px 8px 0;
  overflow: visible;
  box-shadow:
    4px 4px 0 -1px var(--layer), 4px 4px 0 1px var(--wc),
    8px 8px 0 -1px var(--layer), 8px 8px 0 1px var(--wc);
}
.card--group::before {
  content: ''; position: absolute; left: -4px; top: -4px; width: 46%; height: 10px;
  background: var(--wc); border-radius: var(--r-md) 6px 0 0; pointer-events: none;
}
.card-count {
  position: absolute; top: -4px; right: -4px; min-width: 30px; height: 30px; padding: 0 8px;
  display: grid; place-items: center; background: var(--wc); color: var(--layer); border-radius: 0 var(--r-md) 0 var(--r-sm);
  font-weight: 700; font-size: .875rem; font-variant-numeric: tabular-nums; pointer-events: none;
}
.card--group.is-predicted { box-shadow:
    inset 0 0 0 3px var(--predict),
    4px 4px 0 -1px var(--layer), 4px 4px 0 1px var(--wc),
    8px 8px 0 -1px var(--layer), 8px 8px 0 1px var(--wc); }

/* Wortvorhersage: nur ein ruhiger Innenrahmen – keine Zusatzformen, keine Bewegung */
.card.is-predicted { box-shadow: inset 0 0 0 3px var(--predict); }

/* Per Suche gezeigte Karte („Wo ist das?") – bleibt bis zur nächsten Berührung */
.card.is-found { outline: 6px solid var(--interactive); outline-offset: 2px; background: var(--scan-bg); z-index: 1; }

.cell-empty { background: transparent; }

/* Bearbeitungsmodus */
.card--hidden { opacity: .4; border-style: dashed; }
.cell-add { display: grid; place-items: center; min-width: 0; min-height: 0; background: transparent; border: 2px dashed var(--border-strong); border-radius: var(--r-md); color: var(--text-2); }
.cell-add .glyph { width: 28px; height: 28px; }
.cell-add.is-pressed { background: var(--layer-hover); }
.card.is-moving { outline: 4px solid var(--interactive); outline-offset: 2px; background: var(--scan-bg); z-index: 1; }

/* ---------- Zeigen & Verweilen (Maus, Kopfmaus, Augensteuerung) ---------
   Sobald Zeiger oder Blick auf einem Feld ruht, bekommt es einen dicken
   Rahmen in Tintenfarbe (keine Wortart-Farbe) – noch bevor ausgelöst wird.
   Beim Verweilen füllt sich zusätzlich ein Balken am unteren Rand. */
@media (hover: hover) {
  .card:hover, .quick:hover, .sentence:hover, .bar-btn:hover, .cell-add:hover,
  .kb-key:hover, .kb-sugg:hover, .forms-tile:hover, .search-card:hover, .plan-step:hover, .plan-tab:hover {
    outline: 4px solid var(--gaze); outline-offset: 2px; position: relative; z-index: 2;
  }
  .card:hover, .quick:hover { background: var(--layer-hover); }
  .card--hidden:hover { opacity: .7; }
}
.is-dwelling { outline: 4px solid var(--gaze) !important; outline-offset: 2px; z-index: 2; }
.is-dwelling:not(.card--group):not(.plan-check) { position: relative; }
.is-dwelling::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 10px; width: calc(var(--dwell, 0) * 100%);
  background: var(--interactive); border: 0; border-radius: 0 999px 999px 0; pointer-events: none; z-index: 3;
}
.card.is-dwelling, .quick.is-dwelling { overflow: hidden; }
.card--group.is-dwelling { overflow: visible; }

/* Scanning */
.scan-group { box-shadow: inset 0 0 0 4px var(--interactive) !important; }
.scan-item { outline: 6px solid var(--interactive) !important; outline-offset: 2px; background: var(--scan-bg) !important; z-index: 2; }

/* ==========================================================================
   Bausteine (Bezugspersonen-Bereich, Dialoge)
   ========================================================================== */
.ui-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 24px; border: 1px solid transparent; border-radius: 999px; letter-spacing: .01em; text-align: center; font-weight: 700; cursor: pointer; }
.ui-btn--md { min-height: 42px; padding: 0 16px; gap: 8px; }
.ui-btn--full { width: 100%; justify-content: space-between; text-align: left; }
.ui-btn--primary { background: var(--btn-primary); color: var(--on-primary); }
.ui-btn--primary:hover { background: var(--btn-primary-hover); box-shadow: var(--md-elev-1); }
.ui-btn--primary:active { background: var(--btn-primary-active); }
.ui-btn--secondary { background: var(--btn-secondary); color: var(--on-secondary); }
.ui-btn--secondary:hover { background: var(--btn-secondary-hover); }
.ui-btn--tertiary { background: transparent; color: var(--interactive); border-color: var(--md-outline); }
.ui-btn--tertiary:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.ui-btn--ghost { background: transparent; color: var(--interactive); }
.ui-btn--ghost:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.ui-btn--danger { background: var(--btn-danger); color: var(--on-danger); }
.ui-btn--danger:hover { background: var(--btn-danger-hover); }
.ui-btn--danger-ghost { background: transparent; color: var(--support-error); }
.ui-btn--danger-ghost:hover { background: var(--md-error-container); color: var(--support-error); }
.ui-btn--icon { justify-content: center; padding: 0; width: 48px; color: var(--text); }
.ui-btn:disabled { background: color-mix(in srgb, var(--md-on-surface) 12%, transparent); color: color-mix(in srgb, var(--md-on-surface) 38%, transparent); border-color: transparent; box-shadow: none; cursor: not-allowed; }

.ui-field { margin: 0 0 24px; }
.ui-field[hidden] { display: none; }
.ui-label { display: block; margin-bottom: 8px; font-size: .875rem; font-weight: 700; color: var(--text-2); letter-spacing: .01em; }
.ui-helper { margin: 6px 0 0; font-size: .8125rem; color: var(--text-2); }
.ui-input, .ui-select { width: 100%; min-height: 56px; padding: 0 16px; background: transparent; color: var(--text); border: 1px solid var(--md-outline); border-radius: 4px; font-size: 1rem; }
.ui-input:hover, .ui-select:hover { border-color: var(--md-on-surface); }
.ui-input:focus, .ui-select:focus { outline: none; border-color: var(--interactive); box-shadow: inset 0 0 0 1px var(--interactive); }
.ui-modal .ui-input, .ui-modal .ui-select { background: transparent; }
.ui-input[aria-invalid="true"] { border-color: var(--support-error); box-shadow: inset 0 0 0 1px var(--support-error); }
.ui-select { appearance: none; padding-right: 44px; }
.ui-select-wrap { position: relative; }
.ui-select-wrap::after { content: ''; position: absolute; right: 18px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--text); border-bottom: 2px solid var(--text); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

.ui-toggle__label { display: block; cursor: pointer; }
.ui-toggle__label .ui-label { color: var(--text); font-size: 1rem; }
.ui-toggle__row { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.ui-toggle__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ui-toggle__switch { position: relative; width: 52px; height: 32px; background: var(--md-surface-container-highest); border: 2px solid var(--md-outline); border-radius: 16px; flex: none; }
.ui-toggle__switch::before { content: ''; position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--md-outline); }
.ui-toggle__input:checked + .ui-toggle__switch { background: var(--md-primary); border-color: var(--md-primary); }
.ui-toggle__input:checked + .ui-toggle__switch::before { top: 2px; left: 22px; width: 24px; height: 24px; background: var(--md-on-primary); }
.ui-toggle__input:focus-visible + .ui-toggle__switch { outline: 3px solid var(--focus); outline-offset: 2px; }
.ui-toggle__text { font-size: .875rem; color: var(--text-2); }

.ui-slider__row { display: flex; align-items: center; gap: 12px; }
.ui-slider { flex: 1; min-height: 40px; accent-color: var(--interactive); }
.ui-slider__range { font-size: .8125rem; color: var(--text-2); white-space: nowrap; }
.ui-slider__value { min-width: 76px; min-height: 40px; display: grid; place-items: center; background: var(--layer-2); border-radius: var(--r-sm); font-weight: 700; font-variant-numeric: tabular-nums; }

.ui-notification { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0 0 16px; background: var(--md-surface-container-high); border-left: 6px solid var(--support-info); border-radius: var(--r-md); }
.ui-notification--success { border-left-color: var(--support-success); }
.ui-notification--warning { border-left-color: var(--support-warning); }
.ui-notification--error { border-left-color: var(--support-error); }

.ui-switcher { display: flex; gap: 0; padding: 0; background: transparent; border: 1px solid var(--md-outline); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.ui-switcher__btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; background: transparent; border: 0; border-right: 1px solid var(--md-outline); border-radius: 0; cursor: pointer; font-weight: 700; color: var(--text); }
.ui-switcher__btn:last-child { border-right: 0; }
.ui-switcher__btn:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.ui-switcher__btn[aria-selected="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

/* Dialog */
.ui-modal { padding: 0; border: 0; border-radius: var(--r-xl); background: var(--md-surface-container-high); color: var(--text); max-height: calc(100dvh - 32px); flex-direction: column; box-shadow: var(--shadow-2); overflow: hidden; }
.ui-modal[open] { display: flex; }
.ui-modal::backdrop { background: var(--overlay); }
.ui-modal--xs { width: min(440px, 100vw - 32px); }
.ui-modal--sm { width: min(560px, 100vw - 32px); }
.ui-modal--md { width: min(760px, 100vw - 32px); }
.ui-modal--lg { width: min(1040px, 100vw - 32px); }
.ui-modal--full { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; background: var(--md-surface); }
.ui-modal__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 12px 12px 24px; }
.ui-modal__label { margin: 0 0 4px; font-size: .875rem; font-weight: 700; color: var(--text-2); letter-spacing: .01em; }
.ui-modal__title { margin: 0; font-size: 1.5rem; font-weight: 400; line-height: 1.33; }
.ui-modal__header .ui-btn--icon { background: transparent; width: 52px; min-height: 52px; }
.ui-modal__header .ui-btn--icon:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); border-color: var(--gaze); }
.ui-modal__body { flex: 1; overflow: auto; padding: 8px 24px 24px; }
.ui-modal--full .ui-modal__body { padding: 0; display: flex; min-height: 0; border-top: 1px solid var(--border-subtle); }
.ui-modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 24px; }
.ui-modal__footer .ui-btn { flex: 0 1 auto; min-width: 120px; min-height: 48px; }

/* PIN */
.pin { text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 16px 0 8px; }
.pin-dot { width: 18px; height: 18px; border: 2px solid var(--text); border-radius: 50%; }
.pin-dot.is-filled { background: var(--text); }
.pin-error { min-height: 1.4em; color: var(--support-error); margin: 0 0 8px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-key { min-height: 72px; font-size: 1.75rem; font-weight: 400; background: var(--md-surface-container-highest); border: 2px solid transparent; border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.pin-key:hover { border-color: var(--gaze); }
.pin-key:active { background: var(--layer-active); }
.pin-key .glyph { width: 28px; height: 28px; }

/* Bezugspersonen-Bereich */
.cg { display: flex; flex: 1; min-height: 0; width: 100%; }
.ui-sidenav { --sh-bg: var(--md-surface-container-low); flex: none; width: 280px; overflow-y: auto; background: var(--md-surface-container-low); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.ui-sidenav__item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 24px 0 16px; background: transparent; border: 0; border-radius: 999px; text-align: left; font-weight: 700; color: var(--text-2); cursor: pointer; }
.ui-sidenav__item:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); color: var(--text); }
.ui-sidenav__item[aria-current="true"] { --sh-bg: var(--md-secondary-container); background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.cg-content { flex: 1; overflow-y: auto; padding: 28px 36px 48px; }
.cg-content > * { max-width: 820px; }
.cg-content:focus { outline: none; }
.cg-h { margin: 32px 0 16px; font-size: 1.25rem; font-weight: 700; }
.cg-h:first-child { margin-top: 0; }
.cg-p { margin: 0 0 16px; color: var(--text-2); max-width: 64ch; }
.cg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.cg-list { background: var(--layer); border-radius: var(--r-md); padding: 0 16px; margin-bottom: 8px; box-shadow: var(--shadow-1); }
.cg-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.cg-row:last-child { border-bottom: 0; }
.cg-row__main { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.cg-row__actions { display: flex; flex-wrap: wrap; gap: 4px; }
.cg-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0 0 16px; }
.cg-dl dt { color: var(--text-2); }
.cg-dl dd { margin: 0; }
.cg-content a { color: var(--interactive); }

/* Karten-Editor */
.editor { display: grid; grid-template-columns: 200px 1fr; gap: 32px; }
.editor-side { display: flex; flex-direction: column; gap: 24px; }
.editor-preview { width: 200px; height: 200px; display: grid; }
.editor-preview .card { cursor: default; }
.search-row { display: flex; align-items: flex-end; }
.search-row .ui-field { flex: 1; margin-bottom: 0; }
.sym-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin-top: 12px; max-height: 360px; overflow-y: auto; padding: 2px; }
.sym-result { display: grid; grid-template-rows: 80px auto; justify-items: center; gap: 4px; padding: 8px 4px; background: var(--layer); border: 2px solid transparent; border-radius: var(--r-md); cursor: pointer; font-size: .8125rem; }
.sym-result:hover { border-color: var(--border-strong); }
.sym-result img { width: 80px; height: 80px; object-fit: contain; background: #fff; border-radius: var(--r-sm); }
.sym-result[aria-selected="true"] { border-color: var(--interactive); box-shadow: 0 0 0 3px var(--tint); }

/* Wortformen */
.forms-head { display: flex; align-items: center; gap: 16px; padding: 0 0 16px; border-bottom: var(--frame) solid var(--wc); margin-bottom: 16px; }
.forms-sym { width: 72px; height: 72px; display: grid; }
.forms-sym .card-sym { width: 100%; height: 100%; }
.forms-word { font-size: 1.75rem; font-weight: 700; }
.forms-wc { color: var(--text-2); }
.forms-group { margin-bottom: 16px; }
.forms-title { margin: 0 0 8px; font-size: .875rem; color: var(--text-2); font-weight: 400; }
.forms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.forms-tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 80px; padding: 8px 16px; background: var(--layer); border: 0; border-left: 8px solid var(--wc); border-radius: var(--r-md); box-shadow: var(--shadow-1); cursor: pointer; text-align: left; }
.forms-tile:hover { background: var(--layer-hover); }
.forms-tile:active { background: var(--layer-active); }
.forms-text { font-size: 1.375rem; font-weight: 700; }
.forms-hint { font-size: .8125rem; color: var(--text-2); }

/* Tastatur */
.kb { display: flex; flex-direction: column; gap: 6px; padding: 10px; width: 100%; }
.kb-display { min-height: 72px; display: flex; align-items: center; padding: 0 16px; background: var(--layer); border: 2px solid var(--interactive); border-radius: var(--r-md); font-size: 2rem; font-weight: 700; overflow-x: auto; white-space: pre; }
.kb-suggest { display: flex; gap: 6px; min-height: 88px; overflow-x: auto; padding: 4px; }
.kb-sugg { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; width: 104px; padding: 4px; background: var(--layer); border: var(--frame) solid var(--wc); border-radius: var(--r-md); font-weight: 700; cursor: pointer; overflow: hidden; }
.kb-row { display: flex; gap: 6px; flex: 1; min-height: 60px; }
.kb-key { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--layer); border: 0; border-radius: var(--r-md); box-shadow: var(--shadow-1); font-size: clamp(1.1rem, 3vw, 1.75rem); font-weight: 700; cursor: pointer; }
.kb-key:active { background: var(--layer-active); }
.kb-key--fn { background: var(--btn-secondary); color: var(--on-secondary); font-size: 1rem; }
.kb-key--space { flex: 4; font-size: 1rem; }
.kb-key--primary { flex: 2; background: var(--btn-primary); color: var(--on-primary); font-size: 1rem; }

/* ---------- Schmale Bildschirme ---------------------------------------- */
@media (max-width: 760px) {
  .shell-brand .shell-name, .shell-profile, .shell-btn small { display: none; }
  .shell-brand { padding: 0 4px; }
  .shell-context { padding: 0 8px; }
  .shell-btn { padding: 0 12px; min-width: 48px; }
  .shell-btn > span { display: none; }
  .shell-btn .glyph { width: 24px; height: 24px; }
  .bar-btn { width: 64px; min-width: 64px; }
  .sentence-speak { width: 64px; }
  .sentence-speak__label { display: none; }
  .cg { flex-direction: column; }
  .ui-sidenav { width: 100%; flex-direction: row; overflow-x: auto; padding: 6px; }
  .ui-sidenav__item { width: auto; flex: none; }
  .cg-content { padding: 16px; }
  .editor { grid-template-columns: 1fr; }
  .editor-preview { width: 140px; height: 140px; }
}

/* ---------- Hoher Kontrast --------------------------------------------- */
@media (prefers-contrast: more) { :root { --frame: 5px; --border-subtle: var(--text); } }

/* ---------- Druck: Kommunikationsbuch ---------------------------------- */
#print-root { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  @page board { size: A4 landscape; margin: 8mm; }
  @page portrait { size: A4 portrait; margin: 10mm; }
  body { overflow: visible; background: #fff; color: #000; }
  .app, #splash, dialog { display: none !important; }
  #print-root { display: block; }
  .pb-page { page: board; height: 190mm; display: flex; flex-direction: column; break-after: page; }
  .pb-page:last-child { break-after: auto; }
  .pb-head { display: flex; gap: 16px; align-items: baseline; padding-bottom: 2mm; border-bottom: 1px solid #000; margin-bottom: 2mm; font-size: 11pt; }
  .pb-head span:last-child { margin-left: auto; color: #525252; }
  .pb-grid { flex: 1; display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); gap: 1.2mm; min-height: 0; }
  .pb-cell { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; border: 1mm solid var(--wc, #000); padding: 1mm; min-height: 0; overflow: hidden; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pb-cell--empty { border: 0; }
  .pb-cell img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
  .pb-label { font-weight: 700; font-size: 10pt; white-space: nowrap; }
  .pb-text { font-weight: 700; font-size: 13pt; text-align: center; }
  .pb-foot { padding-top: 1.5mm; font-size: 7pt; color: #525252; }
}

/* ---------- Querformat (Tablet/PC): Schnellsätze als Spalte rechts -------
   Karten werden dadurch höher → größere Symbole. Reihenfolge der Schnellsätze
   bleibt gleich (oben → unten statt links → rechts). */
@media (orientation: landscape) and (min-width: 640px) {
  .app {
    display: grid;
    grid-template-columns: 1fr calc(150px * var(--font-scale));
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "shell shell" "banner banner" "sentence sentence" "board quick";
  }
  .shell { grid-area: shell; }
  .edit-banner { grid-area: banner; }
  .sentencebar { grid-area: sentence; height: calc(88px * var(--font-scale)); }
  .app > .board { grid-area: board; margin-right: 0; }
  .app > .quickbar { grid-area: quick; flex-direction: column; height: auto; min-height: 0; overflow-y: auto; margin: var(--gap) max(var(--gap), env(safe-area-inset-right)) var(--gap) var(--gap); }
  .quick { flex: 1 1 0; min-height: 60px; min-width: 0; flex-direction: column; justify-content: center; padding: 6px 4px 4px; gap: 2px; font-size: 1rem; border-left: 0; border-top: 8px solid var(--wc); }
  .quick .card-sym { flex: 1 1 0; min-height: 0; height: auto; width: 100%; max-height: 64px; aspect-ratio: auto; }
  .quick .card-sym img { width: auto; max-width: 100%; }
  .quickbar .quick-label { font-size: min(1.0625rem, calc(100cqi / 6.2)); }
  .quick.card--text { padding-left: 4px; }
}

/* ---------- Dunkelmodus: Symbole auf heller Fläche ----------------------
   ARASAAC-Piktogramme haben schwarze Konturen auf transparentem Grund –
   auf dunklen Karten würden Strichfiguren unsichtbar. Daher bekommt jedes
   Symbol eine einheitliche helle Fläche (gleiche Größe dank Zuschnitt). */
:root[data-theme="dark"] .card-sym img,
:root[data-theme="dark"] .sym-result img { background: #f6f3ee; border-radius: var(--r-sm); height: 100%; width: auto; max-width: 100%; aspect-ratio: 1 / 1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card-sym img { background: #f6f3ee; border-radius: var(--r-sm); height: 100%; width: auto; max-width: 100%; aspect-ratio: 1 / 1; }
}

/* ---------- Suche ------------------------------------------------------- */
.search-input { font-size: 1.5rem; min-height: 64px; border-radius: 999px; padding: 0 24px; background: var(--md-surface-container-high) !important; border-color: transparent; }
.search .ui-helper { margin: 8px 0 12px; }
.search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.search-hit { display: flex; align-items: stretch; gap: 0; padding: 6px; background: var(--layer); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.search-card {
  flex: none; width: 112px; height: 112px; display: grid; grid-template-rows: minmax(0, 1fr) auto; padding: 6px 6px 2px;
  background: var(--layer); border: var(--frame) solid var(--wc); border-radius: var(--r-md); cursor: pointer; container-type: inline-size;
}
.search-card .card-sym img { width: 100%; height: 100%; object-fit: contain; }
.search-card__label { font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: min(1rem, calc(100cqi / 7)); }
.search-card.card--text .search-card__label { visibility: hidden; }
.search-hit__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 8px 0 0 12px; }
.search-hit__path { font-size: .875rem; color: var(--text-2); }

/* Schnellsätze: Beschriftung passt sich der Breite an, statt abgeschnitten zu werden */
.quick-label { white-space: nowrap; font-size: min(1.0625rem, calc((100cqi - 64px) / 5.4)); }

/* ---------- Symbol-Bearbeitung (wie MetaSearch) -------------------------- */
.card-sym { position: relative; }
.card-sym img { transform: rotate(var(--sym-rot, 0deg)) scaleX(var(--sym-flip, 1)) scale(var(--sym-scale, 1)); }
.card-sym--combo { gap: 2px; }
.card-sym--combo img { width: auto; max-width: 50%; flex: 1 1 0; min-width: 0; }
.card-sym--bg { background: var(--sym-bg); }
.card-sym--frame { box-shadow: inset 0 0 0 3px #1c2127; }
.card-sym--strike::after {
  content: ''; position: absolute; left: 8%; right: 8%; top: 50%; height: 0;
  border-top: max(3px, 6cqi) solid #da1e28; transform: rotate(-35deg); pointer-events: none;
}

/* Editor: Symbol bearbeiten */
.editor-look { margin-top: 8px; border-top: 1px solid var(--border-subtle); padding-top: 12px; }
.editor-look > summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.look { padding-top: 12px; }
.look-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 44px; height: 44px; border: 2px solid var(--border-strong); border-radius: 50%; cursor: pointer; font-weight: 700; color: var(--text-2); }
.swatch[aria-checked="true"] { outline: 3px solid var(--interactive); outline-offset: 2px; }
.search-row { gap: 0; }
.search-lang { flex: 0 0 150px; margin-bottom: 0; }
.search-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.ui-btn.is-active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.ui-link { background: none; border: 0; padding: 0; color: var(--interactive); text-decoration: underline; cursor: pointer; font: inherit; }
.editor-export { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }

/* ---------- Pläne: Ansicht für Nutzer:innen ----------------------------- */
.planview { display: flex; flex-direction: column; gap: 12px; padding: 12px; width: 100%; overflow: auto; }
.plan-tabs { display: flex; gap: 4px; overflow-x: auto; flex: none; }
.plan-tab { min-height: 48px; padding: 0 20px; background: transparent; border: 1px solid var(--md-outline); border-radius: var(--r-sm); font-weight: 700; cursor: pointer; white-space: nowrap; }
.plan-tab[aria-selected="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.plan-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.plan-step {
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center;
  min-height: 190px; padding: 8px; background: var(--layer); border: var(--frame) solid var(--border-subtle); border-radius: var(--r-lg); box-shadow: var(--shadow-1); cursor: pointer; container-type: inline-size;
}
.plan-step .card-sym { width: 100%; min-height: 110px; }
.plan-step__label { font-weight: 700; font-size: 1.2rem; text-align: center; }
.plan-time { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.plan-step.is-now { border-color: var(--interactive); box-shadow: 0 0 0 4px var(--tint); }
.plan-now { position: absolute; top: 0; left: 0; background: var(--btn-primary); color: var(--on-primary); font-weight: 700; padding: 3px 12px; font-size: .875rem; border-radius: calc(var(--r-lg) - 4px) 0 var(--r-sm) 0; }
.plan-step.is-done { opacity: .45; }
.plan-step.is-done .card-sym { filter: grayscale(1); }
.plan-check { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; display: grid; place-items: center; background: var(--support-success); color: #fff; border-radius: 50%; }
.plan-check .glyph { width: 26px; height: 26px; }
.plan-week { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 4px; overflow-x: auto; }
.plan-day { background: var(--layer-2); padding: 8px; border-radius: var(--r-md); display: flex; flex-direction: column; gap: 6px; }
.plan-day h3 { margin: 0 0 4px; font-size: 1rem; }
.plan-day.is-today { box-shadow: inset 0 0 0 3px var(--interactive); background: var(--tint); }
.plan-today { color: var(--interactive); }
.plan-day .plan-step { min-height: 130px; }
.plan-day .plan-step .card-sym { min-height: 70px; }
.plan-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.plan-foot .ui-notification { margin: 0; }

/* Pläne: Editor */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px; margin-bottom: 16px; }
.tpl { display: grid; gap: 4px; justify-items: start; padding: 16px; min-height: 96px; background: var(--layer); border: 0; border-left: 6px solid var(--interactive); border-radius: var(--r-md); box-shadow: var(--shadow-1); text-align: left; cursor: pointer; }
.tpl:hover { background: var(--layer-hover); }
.tpl span { color: var(--text-2); font-size: .875rem; }
.plan-edit-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.plan-edit-row { display: flex; align-items: center; gap: 12px; padding: 8px; background: var(--layer); border-radius: var(--r-md); flex-wrap: wrap; }
.plan-edit-fields { flex: 1; display: flex; gap: 8px; min-width: 200px; }
.plan-edit-fields .ui-field { margin: 0; flex: 1; }
.plan-edit-actions { display: flex; }
.plan-card { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; background: var(--layer); border: var(--frame) solid var(--border-subtle); border-radius: var(--r-md); padding: 4px; container-type: inline-size; }
.plan-card--sm { width: 84px; height: 84px; flex: none; }
.plan-card .card-sym { width: 100%; }
.plan-card__label { font-weight: 700; font-size: .8rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.plan-add-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; margin-top: 8px; }
.plan-add-hit { display: grid; grid-template-rows: 64px auto; justify-items: center; padding: 6px; background: var(--layer); border: 2px solid transparent; border-radius: var(--r-md); cursor: pointer; font-size: .8125rem; }
.plan-add-hit:hover { border-color: var(--interactive); }
.plan-add-hit .card-sym { width: 64px; height: 64px; }
.plan-add-hit img { width: 100%; height: 100%; object-fit: contain; }
.ui-textarea { min-height: 120px; padding: 12px 16px; resize: vertical; line-height: 1.4; }

/* ---------- Pläne & Deckblatt: Druck (A4 hoch) -------------------------- */
@media print {
  .pp-page { page: portrait; min-height: 270mm; display: flex; flex-direction: column; gap: 4mm; break-after: page; }
  .pp-page:last-child { break-after: auto; }
  .pp-page--landscape { page: board; min-height: 185mm; }
  .pp-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid #000; padding-bottom: 2mm; font-size: 14pt; }
  .pp-head span { font-size: 10pt; color: #525252; }
  .pp-card { border: 1mm solid #8d8d8d; background: #fff; padding: 1.5mm; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; break-inside: avoid; }
  .pp-card .card-sym { width: 100%; height: 100%; }
  .pp-card img { width: 100%; height: 100%; object-fit: contain; }
  .pp-card .plan-card__label { font-size: 12pt; }
  .pp-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .pp-step { display: grid; grid-template-rows: auto 48mm auto; justify-items: center; gap: 1.5mm; }
  .pp-step .pp-card { width: 48mm; height: 48mm; }
  .pp-num { font-weight: 700; font-size: 14pt; min-height: 1.2em; }
  .pp-box { width: 8mm; height: 8mm; border: .6mm solid #000; }
  .pp-cards { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 60mm; }
  .pp-card--cut { border: 1mm solid #8d8d8d; outline: .3mm dashed #8d8d8d; outline-offset: 2mm; margin: 3mm; }
  .pp-week { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 1.5mm; }
  .pp-weekday { border: .4mm solid #000; padding: 1.5mm; display: flex; flex-direction: column; gap: 1.5mm; }
  .pp-dayname { font-weight: 700; text-align: center; font-size: 11pt; }
  .pp-weekday .pp-card { height: 30mm; }
  .pp-cover { gap: 6mm; font-size: 14pt; }
  .pp-cover__top { display: flex; gap: 8mm; align-items: center; }
  .pp-cover__photo { width: 60mm; height: 60mm; object-fit: cover; border: 1mm solid #000; }
  .pp-cover__hello { font-size: 16pt; }
  .pp-cover__name { font-size: 40pt; font-weight: 700; line-height: 1.1; }
  .pp-cover__intro { font-size: 16pt; }
  .pp-cover__yn { display: flex; gap: 10mm; padding: 4mm; border: .6mm solid #000; }
  .pp-cover h2 { margin: 4mm 0 0; font-size: 20pt; }
  .pp-cover__tips { font-size: 16pt; line-height: 1.6; padding-left: 8mm; }
  .pp-cover .pb-foot { margin-top: auto; }
}

/* Halten-Balken am Einrichten-Knopf */
.shell-btn--hold { position: relative; }
.shell-btn--hold.is-holding::after { content: ''; position: absolute; left: 0; bottom: 0; height: 4px; width: calc(var(--hold, 0) * 100%); background: var(--interactive); border-radius: 0 0 0 999px; }

/* Toast */
.ui-toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; gap: 8px; align-items: baseline; max-width: min(560px, calc(100vw - 32px));
  min-height: 48px; align-items: center; padding: 14px 20px; background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); border-radius: 4px; box-shadow: var(--shadow-2);
}

/* Fortschritt (Assistent) */
.ui-progress { display: flex; gap: 4px; list-style: none; margin: 0 0 24px; padding: 0; }
.ui-progress__step { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: .8125rem; color: var(--text-2); }
.ui-progress__bar { height: 4px; background: var(--md-secondary-container); border-radius: 999px; }
.ui-progress__step.is-done .ui-progress__bar, .ui-progress__step.is-current .ui-progress__bar { background: var(--interactive); }
.ui-progress__step.is-current { color: var(--text); font-weight: 700; }
@media (max-width: 760px) { .ui-progress__label { display: none; } .ui-progress__step.is-current .ui-progress__label { display: block; } }

/* ---------- Bezugspersonen-Startseite: Kacheln ------------------------- */
.cg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 24px; }
.cg-tile { display: grid; gap: 6px; justify-items: start; align-content: start; min-height: 132px; padding: 20px; background: var(--layer); border: 2px solid transparent; border-radius: var(--r-lg); box-shadow: var(--shadow-1); text-align: left; cursor: pointer; }
.cg-tile:hover { border-color: var(--interactive); }
.cg-tile .glyph { width: 44px; height: 44px; padding: 8px; color: var(--interactive); background: var(--tint); border-radius: var(--r-md); }
.cg-tile strong { font-size: 1.125rem; }
.cg-tile span { color: var(--text-2); font-size: .875rem; }
.cg-tile--primary { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.cg-tile--primary:hover { background: color-mix(in srgb, var(--md-primary-container) 92%, var(--md-on-primary-container)); }
.cg-tile--primary .glyph, .cg-tile--primary span { color: var(--md-on-primary-container); }
.cg-tile--primary .glyph { background: color-mix(in srgb, var(--md-on-primary-container) 12%, transparent); }

/* ---------- Assistent ---------------------------------------------------- */
.wizard { display: flex; flex-direction: column; min-height: 420px; }
.wizard-h { margin: 0 0 8px; font-size: 1.5rem; font-weight: 700; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choices--2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.choice { display: grid; gap: 6px; justify-items: start; align-content: start; padding: 16px; min-height: 120px; background: var(--layer); border: 2px solid var(--border-subtle); border-radius: var(--r-lg); text-align: left; cursor: pointer; }
.choice:hover { border-color: var(--border-strong); }
.choice.is-selected { border-color: var(--interactive); box-shadow: 0 0 0 3px var(--tint); background: var(--layer); }
.choice-badge { font-size: .75rem; font-weight: 700; color: var(--interactive); text-transform: uppercase; letter-spacing: .04em; }
.choice-text { font-size: .8125rem; color: var(--text-2); }
.grid-preview { display: grid; grid-template-columns: repeat(var(--c), 1fr); gap: 2px; padding: 0; width: 100%; aspect-ratio: 4 / 3; margin-bottom: 4px; }
.grid-preview span { background: var(--border-strong); border-radius: 2px; }
.grid-preview span.is-group { background: var(--wc-folder); outline: 1px solid var(--layer); outline-offset: -3px; }
.style-sample { display: flex; gap: 4px; background: #fff; padding: 8px; width: 100%; border-radius: var(--r-sm); }
.style-sample img { width: 20%; aspect-ratio: 1; object-fit: contain; }
.howto { display: flex; gap: 24px; align-items: flex-start; padding: 20px; background: var(--layer-2); border-radius: var(--r-lg); margin-bottom: 16px; flex-wrap: wrap; }
.howto-btn { --sh-bg: var(--shell-btn); display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--shell-btn); color: var(--shell-text); border-radius: 999px; font-weight: 700; position: relative; overflow: hidden; }
.howto-btn::after { content: ''; position: absolute; left: 0; bottom: 0; height: 4px; width: 60%; background: var(--interactive); }
.howto-btn small { display: block; font-weight: 400; font-size: .6875rem; color: var(--shell-text-2); }
.howto-list { margin: 0; padding-left: 20px; line-height: 1.7; flex: 1; min-width: 240px; }
.wizard-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--support-success); font-weight: 700; }
.wizard-ok .glyph { width: 20px; height: 20px; }

/* ---------- Symbol-Bibliothek ------------------------------------------- */
.lib { display: flex; flex: 1; min-height: 0; width: 100%; }
.lib-main { flex: 1; min-width: 0; overflow-y: auto; padding: 16px; }
.lib-toolbar { display: flex; align-items: flex-end; gap: 0; flex-wrap: wrap; }
.lib-toolbar > .ui-field { margin: 0; }
.lib-toolbar > .ui-field:first-child { flex: 1; min-width: 220px; }
.lib-toolbar > .ui-field:nth-child(2) { width: 170px; }
.lib-toolbar .ui-switcher { margin: 0 0 0 16px; }
.lib-cats { display: flex; flex-wrap: wrap; gap: 4px; margin: 16px 0 8px; }
.lib-cat { min-height: 40px; padding: 0 16px; background: transparent; border: 1px solid var(--md-outline); border-radius: var(--r-sm); cursor: pointer; font-weight: 700; }
.lib-cat:hover { background: var(--layer-hover); }
.lib-cat[aria-pressed="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: var(--md-secondary-container); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.lib-item { display: grid; grid-template-rows: 92px auto; justify-items: center; gap: 4px; padding: 8px 4px; background: #fff; color: #1c2127; border: 2px solid var(--border-subtle); border-radius: var(--r-md); cursor: pointer; font-size: .8125rem; }
.lib-item img { width: 92px; height: 92px; object-fit: contain; }
.lib-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item:hover { border-color: var(--border-strong); }
.lib-item[aria-selected="true"] { border-color: var(--interactive); box-shadow: 0 0 0 3px var(--tint); }
.lib-detail { flex: none; width: 320px; overflow-y: auto; padding: 16px; background: var(--layer-2); border-left: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 8px; }
.lib-detail .ui-field { margin-bottom: 8px; }
.lib-preview { width: 180px; border-radius: var(--r-md); overflow: hidden; height: 180px; display: grid; align-self: center; margin-bottom: 8px; }
@media (max-width: 760px) {
  .lib { flex-direction: column; overflow-y: auto; }
  .lib-main { overflow: visible; }
  .lib-detail { width: auto; border-left: 0; border-top: 1px solid var(--border-subtle); }
}

/* Icon-Buttons: einheitlich 48×48, Gefahr in Rot */
.ui-btn--icon { width: 48px; min-height: 48px; border-radius: 50%; }
.ui-btn--icon:disabled { background: transparent; color: var(--border-strong); }
.ui-btn--danger-ghost.ui-btn--icon { color: var(--support-error); }
.ui-btn--danger-ghost.ui-btn--icon:hover { color: var(--support-error); }
.ui-btn--icon[aria-pressed="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

.ui-switcher__btn { white-space: nowrap; padding: 0 16px; }
.lib-toolbar .ui-switcher { margin-bottom: 0; }

/* ---------- Symbol-Editor (Studio) -------------------------------------- */
.studio { display: grid; grid-template-columns: 112px minmax(0, 1fr) 340px; width: 100%; min-height: 0; flex: 1; }
.studio-tools { overflow-y: auto; background: var(--layer-2); border-right: 1px solid var(--border-subtle); padding: 8px 0; }
.studio-group { display: flex; flex-direction: column; padding: 4px 0 10px; border-bottom: 1px solid var(--border-subtle); }
.studio-group__title { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); padding: 4px 10px; }
.studio-tool { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 64px; margin: 0 6px; padding: 8px 4px; background: transparent; border: 0; border-radius: var(--r-md); cursor: pointer; font-weight: 700; font-size: .8125rem; color: var(--text); }
.studio-tool .glyph { width: 26px; height: 26px; }
.studio-tool:hover:not(:disabled) { background: var(--layer-hover); }
.studio-tool:active:not(:disabled) { background: var(--layer-active); }
.studio-tool:disabled { color: var(--border-strong); cursor: default; }
.studio-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; min-height: 0; background: var(--background); }
.studio-canvas-wrap { width: min(100%, calc(100dvh - 260px)); aspect-ratio: 1; }
.studio-canvas { width: 100%; height: 100%; display: block; background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--r-md); touch-action: none; cursor: grab; box-shadow: var(--shadow-2); }
.studio-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.studio-hint { margin: 0; color: var(--text-2); font-size: .875rem; text-align: center; }
.studio-panel { overflow-y: auto; padding: 16px; background: var(--layer-2); border-left: 1px solid var(--border-subtle); }
.studio-sec { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border-subtle); }
.studio-sec h3 { margin: 0 0 12px; font-size: 1rem; }
.studio-sec__head { display: flex; justify-content: space-between; align-items: center; }
.studio-sec__head h3 { margin: 0; }
.studio-sec .ui-field { margin-bottom: 12px; }
.studio-sec .ui-btn--full { margin-bottom: 4px; }
.studio-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; }
.studio-result { aspect-ratio: 1; padding: 6px; background: #fff; border: 2px solid var(--border-subtle); border-radius: var(--r-md); cursor: pointer; }
.studio-result:hover { border-color: var(--interactive); }
.studio-result img { width: 100%; height: 100%; object-fit: contain; }
.studio-colors { display: flex; gap: 8px; }
@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; }
  .studio-tools { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border-subtle); padding: 0; }
  .studio-group { flex-direction: row; border-bottom: 0; border-right: 1px solid var(--border-subtle); padding: 0; }
  .studio-group__title { display: none; }
  .studio-tool { min-width: 72px; }
  .studio-canvas-wrap { width: min(100%, 70vh); }
  .studio-panel { border-left: 0; }
}

/* ---------- Titelzeile auf mittleren Bildschirmen ------------------------
   Viele Knöpfe: schrittweise Zusatztexte ausblenden, zuletzt nur Symbole. */
.shell-status { white-space: nowrap; }
.shell-btn[hidden] { display: none; }
.shell-actions { flex: none; }
.shell-context { flex: 1 1 auto; }
@media (max-width: 1180px) {
  .shell-btn small, .shell-profile, .shell-brand .shell-name { display: none; }
  .shell-btn { padding: 0 14px 0 12px; min-width: 52px; }
}
@media (max-width: 1440px) { .shell-profile { display: none; } }
@media (max-width: 1100px) { .shell-status { display: none; } }
@media (max-width: 960px) {
  .shell-btn > span { display: none; }
  .shell-btn { padding: 0 12px; }
  .shell-btn .glyph { width: 24px; height: 24px; }
}

/* Schnellsätze in einer Zeile (Hochformat): Symbol über dem Wort, gut lesbar */
@media not ((orientation: landscape) and (min-width: 640px)) {
  .quickbar { height: calc(92px * var(--font-scale)); min-height: 80px; }
  .quick { flex: 1 0 0; min-width: 72px; flex-direction: column; justify-content: center; gap: 2px; padding: 4px; border-left: 0; border-top: 8px solid var(--wc); }
  .quick .card-sym { flex: 1 1 0; min-height: 0; height: auto; width: 100%; max-height: 52px; }
  .quick .card-sym img { width: auto; max-width: 100%; }
  .quickbar .quick-label { font-size: min(1rem, calc(100cqi / 5.5)); }
  .quick.card--text { padding-left: 4px; }
}

/* ---------- Meine Sätze -------------------------------------------------- */
.phr-wrap { flex: 1; overflow-y: auto; padding: 16px 24px 32px; }
.phr { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.phr-current { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 20px 24px; background: var(--md-primary-container); color: var(--md-on-primary-container); border-radius: var(--r-xl); }
.phr-current__label { grid-column: 1 / -1; font-size: .875rem; font-weight: 700; }
.phr-current__text { font-size: clamp(1.4rem, 3vw, 2.2rem); font-weight: 700; line-height: 1.2; }
.phr-current__btns { display: flex; gap: 10px; flex-wrap: wrap; }
.phr-big-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 64px; padding: 0 24px; border: 2px solid transparent; border-radius: 999px; background: var(--md-card); color: var(--text); font-weight: 700; font-size: 1.0625rem; cursor: pointer; }
.phr-big-btn .glyph { width: 26px; height: 26px; }
.phr-big-btn--primary { background: var(--btn-primary); color: var(--on-primary); }
.phr-h { margin: 0 0 12px; font-size: 1.375rem; font-weight: 400; }
.phr-empty { margin: 0; padding: 20px 24px; color: var(--text-2); background: var(--md-surface-container); border-radius: var(--r-lg); }
.phr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.phr-item { display: flex; flex-direction: column; background: var(--md-card); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.phr-say { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-height: 108px; padding: 16px 18px; background: transparent; border: 0; border-radius: 0; text-align: left; cursor: pointer; }
.phr-say:hover { background: var(--layer-hover); }
.phr-text { font-size: 1.375rem; font-weight: 700; line-height: 1.25; }
.phr-syms { display: flex; gap: 6px; }
.phr-sym { width: 48px; height: 48px; display: grid; }
.phr-sym .card-sym { width: 100%; height: 100%; }
.phr-sym .card-textsym { font-size: .75rem; }
.phr-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border-subtle); border-top: 1px solid var(--border-subtle); }
.phr-act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 64px; padding: 6px; background: var(--md-card); border: 0; border-radius: 0; font-size: .875rem; font-weight: 700; color: var(--text-2); cursor: pointer; }
.phr-act .glyph { width: 24px; height: 24px; }
.phr-act:hover { background: var(--layer-hover); color: var(--text); }
.phr-act.is-on { color: #b07800; }
:root[data-theme="dark"] .phr-act.is-on { color: var(--wc-pron); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .phr-act.is-on { color: var(--wc-pron); } }
@media (hover: hover) {
  .phr-say:hover, .phr-act:hover, .phr-big-btn:hover, .yn-btn:hover, .yn-small:hover, .big-text:hover {
    outline: 4px solid var(--gaze); outline-offset: -4px;
  }
}
@media (max-width: 760px) { .phr-current { grid-template-columns: 1fr; } .phr-wrap { padding: 12px; } }

/* ---------- Groß zeigen -------------------------------------------------- */
.big-text {
  flex: 1; display: grid; place-items: center; margin: 16px; padding: 24px;
  background: var(--md-card); color: var(--text); border: 0; border-radius: var(--r-xl); cursor: pointer;
  font-size: min(var(--big, 8vw), 22vh); font-weight: 700; line-height: 1.1; text-align: center; overflow-wrap: anywhere;
}

/* ---------- Ja / Nein ---------------------------------------------------- */
.yn { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 16px; min-height: 0; }
.yn-main { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; min-height: 0; }
.yn-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh;
  border: 8px solid transparent; border-radius: var(--r-xl); cursor: pointer; font-weight: 700; font-size: clamp(2.5rem, 9vh, 7rem); color: #fff;
}
.yn-btn .glyph { width: clamp(64px, 22vh, 200px); height: clamp(64px, 22vh, 200px); stroke-width: 3; }
.yn-btn--yes { background: #1f7a3a; }
.yn-btn--no { background: #b3261e; }
.yn-btn.is-said { border-color: var(--gaze); box-shadow: inset 0 0 0 6px var(--md-surface); }
.yn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.yn-small { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 96px; padding: 0 16px; background: var(--md-secondary-container); color: var(--md-on-secondary-container); border: 0; border-radius: var(--r-xl); font-size: 1.375rem; font-weight: 700; cursor: pointer; }
.yn-small .glyph { width: 36px; height: 36px; }
@media (max-width: 760px) { .yn-row { grid-template-columns: 1fr; } .yn-small { min-height: 72px; } }

/* ---------- Symbol-Editor: Blätter, Formen, Fächer ----------------------- */
.studio-stage { justify-content: flex-start; }
.studio-sheets { display: flex; gap: 8px; width: 100%; max-width: calc(100dvh - 260px); min-width: min(100%, 420px); overflow-x: auto; padding: 4px 2px 6px; flex: none; }
.studio-sheet { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 96px; padding: 6px; background: var(--md-surface-container); border: 2px solid transparent; border-radius: var(--r-md); cursor: pointer; font-size: .8125rem; font-weight: 700; color: var(--text-2); }
.studio-sheet:hover { border-color: var(--md-outline); color: var(--text); }
.studio-sheet[aria-selected="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: var(--interactive); }
.studio-sheet__thumb { width: 64px; height: 64px; border-radius: 6px; background: #fff; box-shadow: var(--md-elev-1); }
.studio-sheet__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-sheet--add { justify-content: center; border: 2px dashed var(--md-outline); background: transparent; color: var(--interactive); }
.studio-sheet--add .glyph { width: 32px; height: 32px; margin: 16px 0 12px; }
.studio-sheet--add:disabled { opacity: .4; cursor: not-allowed; }
.studio-canvas-wrap { width: min(100%, calc(100dvh - 380px)); min-width: 240px; }
.studio-tool[aria-pressed="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.studio-shapes { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.studio-shape { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; background: #fff; color: #1c2127; border: 2px solid var(--border-subtle); border-radius: var(--r-md); cursor: pointer; font-size: .8125rem; font-weight: 700; }
.studio-shape:hover { border-color: var(--interactive); }
.studio-shape canvas { width: 56px; height: 56px; }
.studio-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-sec .swatches .swatch[style*="#ffffff"] { box-shadow: inset 0 0 0 1px var(--border-strong); }
@media (max-width: 900px) {
  .studio-sheets { max-width: 100%; }
  .studio-canvas-wrap { width: min(100%, 60vh); }
}

/* ---------- Bearbeitungsmodus: „Antippen öffnet" ------------------------ */
.edit-opens { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.edit-opens__label { font-weight: 700; font-size: .875rem; }
.edit-opens .ui-switcher { margin: 0; background: var(--md-surface); }
.edit-opens .ui-switcher__btn { min-height: 42px; }
.editor-preview[role="button"] { cursor: pointer; border-radius: var(--r-md); }
.editor-preview[role="button"]:hover { outline: 4px solid var(--gaze); outline-offset: 4px; }

/* ---------- Handy: Knöpfe der Titelzeile in eigener Zeile -----------------
   Sieben Knöpfe passen nicht neben Logo und Titel. Unter 600 px stehen sie
   in einer zweiten Zeile, gleichmäßig verteilt, jeder mindestens 44 px. */
@media (max-width: 600px) {
  .shell { flex-wrap: wrap; row-gap: 4px; }
  .shell-context { flex: 1 1 auto; min-width: 0; }
  .shell-page { overflow: hidden; text-overflow: ellipsis; }
  .shell-status { display: none; }
  .shell-actions { order: 3; flex: 1 1 100%; justify-content: space-between; gap: 4px; margin-left: 0; }
  .shell-actions .shell-btn { flex: 1 1 0; min-width: 44px; padding: 0; justify-content: center; }
}

/* ---------- Handy: ganze Tafel sichtbar, nichts scrollt seitlich ----------
   Auf schmalen oder niedrigen Bildschirmen dürfen Felder kleiner als 64 px werden.
   Jedes Wort bleibt an seinem Platz und sichtbar – besser für die Motorplanung
   als eine Tafel, deren Hälfte außerhalb des Bildschirms liegt.
   Tipp im Assistenten: auf Handys 5 × 4 (große Felder). */
@media (max-width: 700px), (orientation: landscape) and (max-height: 520px) {
  :root { --cell-min: 0px; --frame: 3px; }
  .board {
    grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows, 7), minmax(0, 1fr));
    padding: 2px;
  }
  .card { padding: 3px 3px 0; border-radius: 9px; }
  .board .card--group {
    margin: 0 4px 4px 0;
    box-shadow: 2px 2px 0 -1px var(--layer), 2px 2px 0 1px var(--wc), 4px 4px 0 -1px var(--layer), 4px 4px 0 1px var(--wc);
  }
  .card--group::before { height: 6px; left: -3px; top: -3px; }
  .card-count { top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 4px; font-size: .7rem; }
  .cell-add .glyph { width: 20px; height: 20px; }
  /* Schnellsätze teilen sich die Breite statt aus dem Bild zu laufen */
  .quickbar .quick { flex: 1 1 0; min-width: 0; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .sentencebar { height: calc(80px * var(--font-scale)); min-height: 64px; }
  .quickbar { height: calc(80px * var(--font-scale)); min-height: 64px; }
}

/* ---------- Handy quer: wenig Höhe – Kopfzeile und Satzleiste schlanker ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .shell { min-height: 0; gap: 4px; padding-top: calc(env(safe-area-inset-top) + 3px); padding-bottom: 3px; }
  .shell-btn { min-height: 40px; }
  .shell-brand img { width: 24px; height: 24px; }
  .shell-page { font-size: 1.1rem; }
  .sentencebar { height: 60px; min-height: 52px; }
  .sentence { padding: 4px; }
  .sentence-speak, .bar-btn { gap: 2px; font-size: .8125rem; }
  .sentence-speak .glyph, .bar-btn .glyph { width: 22px; height: 22px; }
  .chip { min-width: 52px; }
  .chip-label { font-size: .85rem; }
  .app { grid-template-columns: 1fr calc(112px * var(--font-scale)); }
  .app > .quickbar { overflow: hidden; }
  .quick { min-height: 0; padding: 3px 2px 2px; }
  .quick .card-sym { max-height: 40px; }
}
