/* ==========================================================================
   SEMIO – Stylesheet im Stil von IBM Carbon (Themes „g10" hell / „g100" dunkel)
   Eckig, flach, klare Linien. Schrift: Atkinson Hyperlegible (OFL, für
   Lesbarkeit entwickelt) statt IBM Plex. Wortarten nach Fitzgerald-Schlüssel,
   Farbwerte aus der Carbon-Palette. 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; }

/* ---------- Tokens: Carbon g10 ------------------------------------------ */
:root {
  --background: #f4f4f4;
  --layer: #ffffff;
  --layer-2: #f4f4f4;
  --layer-hover: #e8e8e8;
  --layer-active: #c6c6c6;
  --field: #ffffff;
  --border-subtle: #e0e0e0;
  --border-strong: #8d8d8d;
  --text: #161616;
  --text-2: #525252;
  --interactive: #0f62fe;
  --focus: #0f62fe;
  --focus-inset: #ffffff;
  --btn-primary: #0f62fe;   --btn-primary-hover: #0353e9; --btn-primary-active: #002d9c;
  --btn-secondary: #393939; --btn-secondary-hover: #4c4c4c; --btn-secondary-active: #6f6f6f;
  --btn-danger: #da1e28;    --btn-danger-hover: #b81921;
  --support-info: #0043ce; --support-success: #24a148; --support-warning: #f1c21b; --support-error: #da1e28;
  --shell: #161616; --shell-text: #f4f4f4; --shell-active: #525252; --shell-border: #393939;
  --overlay: rgb(22 22 22 / .5);
  --predict: #161616;
  --scan-bg: #d0e2ff;

  /* Fitzgerald-Schlüssel (Carbon-Farben) */
  --wc-pron: #f1c21b;   /* Gelb 30 */
  --wc-verb: #24a148;   /* Grün 50 */
  --wc-noun: #ff832b;   /* Orange 40 */
  --wc-adj: #4589ff;    /* Blau 50 */
  --wc-quest: #8a3ffc;  /* Lila 60 */
  --wc-social: #ee5396; /* Magenta 50 */
  --wc-neg: #da1e28;    /* Rot 60 */
  --wc-misc: #8d8d8d;   /* Grau 50 */
  --wc-folder: #6f6f6f; /* Grau 60 */
  --wc-nav: #161616;

  --font-scale: 1;
  --gap: 4px;
  --cell-min: 64px;     /* nie unter 60 px Touch-Ziel */
  --frame: 4px;         /* einheitlicher Kartenrahmen */
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

/* ---------- Tokens: Carbon g100 (dunkel) -------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #161616; --layer: #262626; --layer-2: #393939; --layer-hover: #333333; --layer-active: #525252;
    --field: #262626; --border-subtle: #393939; --border-strong: #6f6f6f; --text: #f4f4f4; --text-2: #c6c6c6;
    --interactive: #4589ff; --focus: #ffffff; --focus-inset: #161616;
    --btn-secondary: #6f6f6f; --btn-secondary-hover: #606060; --btn-secondary-active: #393939;
    --support-info: #4589ff; --support-success: #42be65; --support-error: #fa4d56;
    --predict: #f4f4f4; --scan-bg: #002d9c;
    --wc-pron: #f1c21b; --wc-verb: #42be65; --wc-noun: #ff832b; --wc-adj: #78a9ff; --wc-quest: #a56eff;
    --wc-social: #ff7eb6; --wc-neg: #fa4d56; --wc-misc: #a8a8a8; --wc-folder: #c6c6c6; --wc-nav: #f4f4f4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: #161616; --layer: #262626; --layer-2: #393939; --layer-hover: #333333; --layer-active: #525252;
  --field: #262626; --border-subtle: #393939; --border-strong: #6f6f6f; --text: #f4f4f4; --text-2: #c6c6c6;
  --interactive: #4589ff; --focus: #ffffff; --focus-inset: #161616;
  --btn-secondary: #6f6f6f; --btn-secondary-hover: #606060; --btn-secondary-active: #393939;
  --support-info: #4589ff; --support-success: #42be65; --support-error: #fa4d56;
  --predict: #f4f4f4; --scan-bg: #002d9c;
  --wc-pron: #f1c21b; --wc-verb: #42be65; --wc-noun: #ff832b; --wc-adj: #78a9ff; --wc-quest: #a56eff;
  --wc-social: #ff7eb6; --wc-neg: #fa4d56; --wc-misc: #a8a8a8; --wc-folder: #c6c6c6; --wc-nav: #f4f4f4;
  color-scheme: dark;
}

/* ---------- 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 { font: inherit; color: inherit; }
button { border-radius: 0; }
[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: -3px; box-shadow: inset 0 0 0 5px var(--focus-inset); }
.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(--shell); color: var(--shell-text); }
.splash-name { font-size: 2.25rem; font-weight: 700; letter-spacing: .2em; }
.splash-status { color: #c6c6c6; }

/* ---------- App-Gerüst -------------------------------------------------- */
.app { height: 100dvh; display: grid; grid-template-rows: auto auto auto auto 1fr; padding-bottom: env(safe-area-inset-bottom); }
.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); }

/* ---------- UI-Shell (Titelzeile) -------------------------------------- */
.shell {
  --sh-bg: var(--shell);
  display: flex; align-items: stretch; min-height: 56px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 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 16px; border-right: 1px solid var(--shell-border); }
.shell-name { font-weight: 700; letter-spacing: .2em; font-size: 1.05rem; }
.shell-context { display: flex; align-items: baseline; gap: 12px; padding: 0 16px; align-self: center; min-width: 0; }
.shell-page { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.shell-profile { color: #a8a8a8; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-status { align-self: center; margin-left: auto; padding: 0 16px; font-size: .8125rem; color: #c6c6c6; }
.shell-status[hidden] + .shell-actions { margin-left: auto; }
.shell-actions { display: flex; }
.shell-btn {
  display: inline-flex; align-items: center; gap: 10px; min-width: 64px; padding: 0 18px;
  background: transparent; color: var(--shell-text); border: 0; border-left: 1px solid var(--shell-border); 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: #a8a8a8; }
.shell-btn.is-pressed, .shell-btn.is-holding { background: var(--shell-active); }
.shell-btn.is-holding { box-shadow: inset 0 -4px 0 #4589ff; }
.shell-btn[aria-disabled="true"] { color: #6f6f6f; cursor: default; }
.shell-btn:focus-visible { outline-color: #fff; box-shadow: inset 0 0 0 5px var(--shell); }

/* ---------- Bearbeitungs-Banner (Carbon inline notification) ----------- */
.edit-banner { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; background: var(--layer); border-left: 4px solid var(--interactive); border-bottom: 1px solid var(--border-subtle); }
.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: 4px; padding: 0 0 0 8px; background: var(--layer); border: 0; border-bottom: 2px solid var(--border-strong); text-align: left; }
.sentence.is-pressed { background: var(--layer-hover); }
.sentence-words { flex: 1; min-width: 0; display: flex; gap: 4px; padding: 6px 0; overflow-x: auto; scrollbar-width: none; }
.sentence-words::-webkit-scrollbar { display: none; }
.sentence.is-empty .sentence-words::before { content: 'Wörter antippen – hier entsteht der Satz'; align-self: center; color: var(--text-2); padding-left: 8px; }
.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-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: 104px; background: var(--btn-primary); color: #fff; 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: #fff; border: 0; 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; }
.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: 6px solid var(--wc); font-weight: 700; font-size: 1.0625rem; }
.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: 2px;
}

[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: Carbon-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);
  overflow: hidden; container-type: inline-size;
}
.card.is-pressed { background: var(--layer-active); }
@media (hover: hover) { .card:hover { background: var(--layer-hover); } }
.card-sym { display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; }
/* 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); pointer-events: none;
}
.card-count {
  position: absolute; top: -4px; right: -4px; min-width: 30px; height: 30px; padding: 0 6px;
  display: grid; place-items: center; background: var(--wc); color: var(--layer);
  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: -6px; background: var(--scan-bg); }

.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); 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: -4px; background: var(--scan-bg); }

/* Verweilen: Fortschrittsbalken unten */
.card.is-dwelling::after, .quick.is-dwelling::after { content: ''; position: absolute; left: 0; bottom: 0; height: 6px; width: calc(var(--dwell, 0) * 100%); background: var(--interactive); border: 0; }

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

/* ==========================================================================
   Carbon-Komponenten (Bezugspersonen-Bereich, Dialoge)
   ========================================================================== */
.cds-btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 32px; min-height: 48px; padding: 0 16px; border: 1px solid transparent; text-align: left; font-weight: 700; cursor: pointer; }
.cds-btn--md { min-height: 40px; gap: 16px; }
.cds-btn--full { width: 100%; }
.cds-btn--primary { background: var(--btn-primary); color: #fff; }
.cds-btn--primary:hover { background: var(--btn-primary-hover); }
.cds-btn--primary:active { background: var(--btn-primary-active); }
.cds-btn--secondary { background: var(--btn-secondary); color: #fff; }
.cds-btn--secondary:hover { background: var(--btn-secondary-hover); }
.cds-btn--tertiary { background: transparent; color: var(--interactive); border-color: var(--interactive); }
.cds-btn--tertiary:hover { background: var(--interactive); color: #fff; }
.cds-btn--ghost { background: transparent; color: var(--interactive); }
.cds-btn--ghost:hover { background: var(--layer-hover); }
.cds-btn--danger { background: var(--btn-danger); color: #fff; }
.cds-btn--danger:hover { background: var(--btn-danger-hover); }
.cds-btn--danger-ghost { background: transparent; color: var(--support-error); }
.cds-btn--danger-ghost:hover { background: var(--btn-danger); color: #fff; }
.cds-btn--icon { justify-content: center; padding: 0; width: 48px; color: var(--text); }
.cds-btn:disabled { background: var(--layer-active); color: var(--text-2); cursor: not-allowed; }

.cds-field { margin: 0 0 24px; }
.cds-field[hidden] { display: none; }
.cds-label { display: block; margin-bottom: 8px; font-size: .875rem; color: var(--text-2); }
.cds-helper { margin: 6px 0 0; font-size: .8125rem; color: var(--text-2); }
.cds-input, .cds-select { width: 100%; min-height: 48px; padding: 0 16px; background: var(--field); color: var(--text); border: 0; border-bottom: 1px solid var(--border-strong); border-radius: 0; font-size: 1rem; }
.cds-modal .cds-input, .cds-modal .cds-select { background: var(--layer-2); }
.cds-input[aria-invalid="true"] { outline: 2px solid var(--support-error); outline-offset: -2px; }
.cds-select { appearance: none; padding-right: 40px; }
.cds-select-wrap { position: relative; }
.cds-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; }

.cds-toggle__label { display: block; cursor: pointer; }
.cds-toggle__label .cds-label { color: var(--text); font-size: 1rem; }
.cds-toggle__row { display: flex; align-items: center; gap: 12px; min-height: 32px; }
.cds-toggle__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cds-toggle__switch { position: relative; width: 56px; height: 28px; background: var(--border-strong); border-radius: 14px; flex: none; }
.cds-toggle__switch::before { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; }
.cds-toggle__input:checked + .cds-toggle__switch { background: var(--support-success); }
.cds-toggle__input:checked + .cds-toggle__switch::before { left: 31px; }
.cds-toggle__input:focus-visible + .cds-toggle__switch { outline: 3px solid var(--focus); outline-offset: 2px; }
.cds-toggle__text { font-size: .875rem; }

.cds-slider__row { display: flex; align-items: center; gap: 12px; }
.cds-slider { flex: 1; min-height: 40px; accent-color: var(--interactive); }
.cds-slider__range { font-size: .8125rem; color: var(--text-2); white-space: nowrap; }
.cds-slider__value { min-width: 72px; min-height: 40px; display: grid; place-items: center; background: var(--layer-2); border-bottom: 1px solid var(--border-strong); font-variant-numeric: tabular-nums; }

.cds-notification { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0 0 16px; background: var(--layer-2); border-left: 4px solid var(--support-info); }
.cds-notification--success { border-left-color: var(--support-success); }
.cds-notification--warning { border-left-color: var(--support-warning); }
.cds-notification--error { border-left-color: var(--support-error); }

.cds-switcher { display: flex; border: 1px solid var(--border-strong); margin-bottom: 16px; }
.cds-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(--border-strong); cursor: pointer; }
.cds-switcher__btn:last-child { border-right: 0; }
.cds-switcher__btn[aria-selected="true"] { background: var(--btn-secondary); color: #fff; }

/* Modal */
.cds-modal { padding: 0; border: 0; background: var(--layer); color: var(--text); max-height: calc(100dvh - 32px); flex-direction: column; }
.cds-modal[open] { display: flex; }
.cds-modal::backdrop { background: var(--overlay); }
.cds-modal--xs { width: min(420px, 100vw - 32px); }
.cds-modal--sm { width: min(560px, 100vw - 32px); }
.cds-modal--md { width: min(760px, 100vw - 32px); }
.cds-modal--lg { width: min(1040px, 100vw - 32px); }
.cds-modal--full { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
.cds-modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0 12px 16px; }
.cds-modal__label { margin: 0 0 4px; font-size: .8125rem; color: var(--text-2); }
.cds-modal__title { margin: 0; font-size: 1.5rem; font-weight: 400; }
.cds-modal__body { flex: 1; overflow: auto; padding: 8px 16px 24px; }
.cds-modal--full .cds-modal__body { padding: 0; display: flex; min-height: 0; border-top: 1px solid var(--border-subtle); }
.cds-modal__footer { display: flex; border-top: 1px solid var(--border-subtle); }
.cds-modal__footer .cds-btn { flex: 1; min-height: 64px; align-items: flex-start; padding-top: 14px; }

/* 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: 2px; }
.pin-key { min-height: 72px; font-size: 1.75rem; background: var(--layer-2); border: 0; cursor: pointer; display: grid; place-items: center; }
.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%; }
.cds-sidenav { flex: none; width: 256px; overflow-y: auto; background: var(--layer-2); border-right: 1px solid var(--border-subtle); padding: 8px 0; }
.cds-sidenav__item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 16px; background: transparent; border: 0; border-left: 4px solid transparent; text-align: left; font-weight: 700; color: var(--text-2); cursor: pointer; }
.cds-sidenav__item:hover { background: var(--layer-hover); color: var(--text); }
.cds-sidenav__item[aria-current="true"] { background: var(--layer-active); color: var(--text); border-left-color: var(--interactive); }
.cg-content { flex: 1; overflow-y: auto; padding: 24px 32px 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 { border-top: 1px solid var(--border-subtle); margin-bottom: 8px; }
.cg-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.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 .cds-field { flex: 1; margin-bottom: 0; }
.sym-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; margin-top: 12px; max-height: 360px; overflow-y: auto; }
.sym-result { display: grid; grid-template-rows: 80px auto; justify-items: center; gap: 4px; padding: 8px 4px; background: var(--layer-2); border: 2px solid transparent; cursor: pointer; font-size: .8125rem; }
.sym-result img { width: 80px; height: 80px; object-fit: contain; background: #fff; }
.sym-result[aria-selected="true"] { border-color: var(--interactive); box-shadow: inset 0 0 0 2px var(--interactive); }

/* 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(160px, 1fr)); gap: 4px; }
.forms-tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 72px; padding: 8px 16px; background: var(--layer-2); border: 0; border-left: 6px solid var(--wc); 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: 4px; padding: 8px; width: 100%; }
.kb-display { min-height: 72px; display: flex; align-items: center; padding: 0 16px; background: var(--layer-2); border-bottom: 2px solid var(--interactive); font-size: 2rem; font-weight: 700; overflow-x: auto; white-space: pre; }
.kb-suggest { display: flex; gap: 4px; min-height: 88px; overflow-x: auto; }
.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); font-weight: 700; cursor: pointer; }
.kb-row { display: flex; gap: 4px; 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-2); border: 0; 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: #fff; font-size: 1rem; }
.kb-key--space { flex: 4; font-size: 1rem; }
.kb-key--primary { flex: 2; background: var(--btn-primary); color: #fff; font-size: 1rem; }

/* ---------- Schmale Bildschirme ---------------------------------------- */
@media (max-width: 760px) {
  .shell-brand .shell-name, .shell-profile, .shell-btn small { display: none; }
  .shell-brand { padding: 0 12px; }
  .shell-context { padding: 0 10px; }
  .shell-btn { padding: 0 12px; min-width: 52px; }
  .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; }
  .cds-sidenav { width: 100%; display: flex; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  .cds-sidenav__item { width: auto; flex: none; border-left: 0; border-bottom: 4px solid transparent; }
  .cds-sidenav__item[aria-current="true"] { border-bottom-color: var(--interactive); }
  .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: 900px) {
  .app {
    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; padding: 4px 8px 4px 4px; gap: 8px; font-size: 1rem; }
  .quick .card-sym { height: 44px; width: 44px; max-height: none; }
}

/* ---------- 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: #f4f4f4; 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: #f4f4f4; height: 100%; width: auto; max-width: 100%; aspect-ratio: 1 / 1; }
}

/* ---------- Suche ------------------------------------------------------- */
.search-input { font-size: 1.5rem; min-height: 64px; border-bottom: 2px solid var(--interactive); }
.search .cds-helper { margin: 8px 0 12px; }
.search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px; }
.search-hit { display: flex; align-items: stretch; gap: 0; background: var(--layer-2); }
.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); 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 #161616; }
.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); 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; }
.cds-btn.is-active { background: var(--interactive); color: #fff; }
.cds-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 16px; background: var(--layer-2); border: 0; border-bottom: 3px solid transparent; font-weight: 700; cursor: pointer; white-space: nowrap; }
.plan-tab[aria-selected="true"] { border-bottom-color: var(--interactive); background: var(--layer); }
.plan-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.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-strong); 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: inset 0 0 0 3px var(--interactive); }
.plan-now { position: absolute; top: 0; left: 0; background: var(--interactive); color: #fff; font-weight: 700; padding: 2px 10px; font-size: .875rem; }
.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; 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 4px 0 var(--interactive); background: var(--layer); }
.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 .cds-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-2); border: 0; border-left: 4px solid var(--interactive); 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: 6px; background: var(--layer-2); flex-wrap: wrap; }
.plan-edit-fields { flex: 1; display: flex; gap: 8px; min-width: 200px; }
.plan-edit-fields .cds-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-strong); 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-2); border: 2px solid transparent; 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; }
.cds-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: #4589ff; }

/* Toast */
.cds-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));
  padding: 14px 20px; background: #393939; color: #f4f4f4; border-left: 4px solid #4589ff; box-shadow: 0 2px 6px rgb(0 0 0 / .3);
}

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

/* ---------- Bezugspersonen-Startseite: Kacheln ------------------------- */
.cg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px; margin-bottom: 24px; }
.cg-tile { display: grid; gap: 6px; justify-items: start; align-content: start; min-height: 132px; padding: 20px; background: var(--layer-2); border: 0; text-align: left; cursor: pointer; }
.cg-tile:hover { background: var(--layer-hover); }
.cg-tile .glyph { width: 28px; height: 28px; color: var(--interactive); }
.cg-tile strong { font-size: 1.125rem; }
.cg-tile span { color: var(--text-2); font-size: .875rem; }
.cg-tile--primary { background: var(--btn-primary); color: #fff; }
.cg-tile--primary:hover { background: var(--btn-primary-hover); }
.cg-tile--primary .glyph, .cg-tile--primary span { color: #fff; }

/* ---------- Assistent ---------------------------------------------------- */
.wizard { display: flex; flex-direction: column; min-height: 420px; }
.wizard-h { margin: 0 0 8px; font-size: 1.5rem; font-weight: 400; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px; }
.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-2); border: 2px solid transparent; text-align: left; cursor: pointer; }
.choice:hover { background: var(--layer-hover); }
.choice.is-selected { border-color: var(--interactive); box-shadow: inset 0 0 0 2px var(--interactive); 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; width: 100%; aspect-ratio: 4 / 3; margin-bottom: 4px; }
.grid-preview span { background: var(--border-strong); }
.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%; }
.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); margin-bottom: 16px; flex-wrap: wrap; }
.howto-btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; background: #161616; color: #f4f4f4; font-weight: 700; position: relative; }
.howto-btn::after { content: ''; position: absolute; left: 0; bottom: 0; height: 4px; width: 60%; background: #4589ff; }
.howto-btn small { display: block; font-weight: 400; font-size: .6875rem; color: #a8a8a8; }
.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 > .cds-field { margin: 0; }
.lib-toolbar > .cds-field:first-child { flex: 1; min-width: 220px; }
.lib-toolbar > .cds-field:nth-child(2) { width: 170px; }
.lib-toolbar .cds-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 14px; background: var(--layer-2); border: 1px solid var(--border-subtle); cursor: pointer; font-weight: 700; }
.lib-cat:hover { background: var(--layer-hover); }
.lib-cat[aria-pressed="true"] { background: var(--btn-secondary); color: #fff; border-color: var(--btn-secondary); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 4px; margin: 8px 0 16px; }
.lib-item { display: grid; grid-template-rows: 92px auto; justify-items: center; gap: 4px; padding: 8px 4px; background: #fff; color: #161616; border: 2px solid var(--border-subtle); 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[aria-selected="true"] { border-color: var(--interactive); box-shadow: inset 0 0 0 2px var(--interactive); }
.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 .cds-field { margin-bottom: 8px; }
.lib-preview { width: 180px; 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 */
.cds-btn--icon { width: 48px; min-height: 48px; }
.cds-btn--icon:disabled { background: transparent; color: var(--border-strong); }
.cds-btn--danger-ghost.cds-btn--icon { color: var(--support-error); }
.cds-btn--danger-ghost.cds-btn--icon:hover { color: #fff; }
.cds-btn--icon[aria-pressed="true"] { background: var(--layer-active); }

.cds-switcher__btn { white-space: nowrap; padding: 0 16px; }

/* ---------- 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; padding: 8px 4px; background: transparent; border: 0; 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-strong); touch-action: none; cursor: grab; box-shadow: 0 2px 8px rgb(0 0 0 / .12); }
.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 .cds-field { margin-bottom: 12px; }
.studio-sec .cds-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); 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; }
}
