/* ══════════════════════════════════════════════════════════════
   app.css · Universal Data Visualizer v2.1 · imifactory.ch
   ──────────────────────────────────────────────────────────────
   Anwendungsschale (Variante B). Kopfbalken und Brotkrumen
   folgen dem imifactory-Standard, darunter arbeitet die Seite
   wie eine Anwendung.

   Gestaltungsregeln nach ISO 9241-110:
   · Selbstbeschreibungsfaehigkeit – Statusleiste nennt jederzeit
     Datei, Form und dargestellten Typ; gesperrte Schaltflaechen
     nennen ihren Grund im rechten Feld.
   · Steuerbarkeit – Abbrechen, Zuruecksetzen, Einstellungsfeld
     ein- und ausklappbar.
   · Fehlertoleranz – unpassende Typen werden gesperrt statt eine
     unbrauchbare Darstellung zu erzeugen.
   · Erwartungskonformitaet – jede Aenderung wirkt sofort, kein
     zusaetzlicher Bestaetigungsschritt.
   ══════════════════════════════════════════════════════════════ */

:root {
  --navy:      #0b3c5d;
  --navy-dk:   #082c45;
  --navy-lt:   #14567f;
  --teal:      #00bfae;
  --teal-dk:   #009e91;

  --ink:       #1c2733;
  --ink-2:     #4a5866;
  --ink-3:     #556676;   /* 5.26:1 auf --bg, WCAG AA */

  --bg:        #eef2f5;
  --surface:   #ffffff;
  --surface-2: #f7f9fb;
  --line:      #d8e0e7;
  --line-ui:   #7d8f9e;   /* Rahmen von Bedienelementen */
  --focus:     #106b7d;   /* 6.14:1 auf Weiss, WCAG 1.4.11 */
  --line-2:    #e8edf1;

  --danger:    #c0392b;
  --warn:      #e67e22;
  --good:      #27ae60;

  --r:         6px;
  --shadow:    0 1px 3px rgba(16,36,54,.08), 0 6px 18px rgba(16,36,54,.06);

  --topbar-h:  52px;
  --crumb-h:   34px;
  --tool-h:    52px;
  --status-h:  30px;

  --ui:  15px;
  --ui-s: 13px;
  --ui-xs: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--ui)/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--navy); color: #fff; padding: 10px 16px;
  border-radius: 0 0 var(--r) 0; text-decoration: none;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* Auf dunklem Grund muss der Fokus hell sein, sonst verschwindet er. */
.topbar :focus-visible,
.statusbar :focus-visible {
  outline-color: #ffffff;
}

/* ── Kopfbalken ─────────────────────────────────────────────── */
.topbar {
  background: var(--navy);
  color: #fff;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
}
.topbar-inner {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
/* Standardgroesse: das Logo ist Marke, nicht Bildmotiv. */
.topbar-logo {
  height: 26px;
  width: auto;
  display: block;
  flex: 0 0 auto;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-spacer { flex: 1 1 auto; }
.topbar-badge {
  font-size: var(--ui-xs);
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  padding: 2px 10px;
}

/* ── Brotkrumen ─────────────────────────────────────────────── */
.breadcrumb {
  height: var(--crumb-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  max-width: 1800px;
  margin: 0 auto;
  font-size: var(--ui-s);
  color: var(--ink-3);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.breadcrumb a { color: var(--navy-lt); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb strong { color: var(--ink-2); font-weight: 600; }

/* ══ Anwendungsschale ═══════════════════════════════════════ */
.app {
  max-width: 1800px;
  margin: 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  /* Der Arbeitsbereich fuellt die verfuegbare Hoehe.
     Vorher war er auf 880 px gedeckelt — auf grossen Bildschirmen
     wurde das Einstellungsfeld dadurch gescrollt, obwohl darunter
     Platz frei blieb. */
  height: calc(100dvh - var(--topbar-h) - var(--crumb-h));
  min-height: 520px;
  position: relative;
}

/* ── Werkzeugleiste ─────────────────────────────────────────── */
.apptoolbar {
  min-height: var(--tool-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}
.tb-group { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.tb-sep { width: 1px; height: 26px; background: var(--line); flex: 0 0 auto; }
.tb-spacer { flex: 1 1 auto; min-width: 8px; }

.tb-btn {
  font: inherit;
  font-size: var(--ui-s);
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid var(--line-ui);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.tb-btn:hover:not(:disabled) { background: #eef3f7; border-color: #c4d0da; }
.tb-btn:active:not(:disabled) { background: #e3ebf1; }
.tb-btn:disabled { opacity: .42; cursor: not-allowed; }

.tb-btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
}
.tb-btn-primary:hover:not(:disabled) { background: var(--navy-lt); border-color: var(--navy-lt); }

/* Diagrammtypen als zusammenhaengende Gruppe */
.tb-type {
  font: inherit;
  font-size: var(--ui-s);
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid var(--line-ui);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: -1px;
}
.tb-type:first-child { margin-left: 0; border-radius: var(--r) 0 0 var(--r); }
.tb-type:last-child  { border-radius: 0 var(--r) var(--r) 0; }
.tb-type .ic { font-size: 14px; line-height: 1; opacity: .8; }
.tb-type:hover:not(:disabled) { background: #eef3f7; z-index: 1; }
.tb-type[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
  z-index: 2;
}
.tb-type[aria-pressed="true"] .ic { opacity: 1; }
/* Gesperrt heisst: sichtbar, aber erkennbar nicht waehlbar.
   Der Grund steht im rechten Feld – nicht verstecken. */
.tb-type:disabled {
  opacity: .38;
  cursor: not-allowed;
  background: var(--surface-2);
}

/* ── Buehne ─────────────────────────────────────────────────── */
.stage {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 300px;
  min-height: 0;
}
.app.no-props .stage { grid-template-columns: 232px minmax(0, 1fr); }
.app.no-props .props { display: none; }

/* ── Spaltenliste links ─────────────────────────────────────── */
.palette {
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pal-head {
  padding: 10px 14px;
  font-size: var(--ui-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.pal-body { padding: 12px 14px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; }
.pal-empty { font-size: var(--ui-s); color: var(--ink-3); }
.pal-label {
  font-size: var(--ui-xs);
  font-weight: 700;
  color: var(--ink-2);
  margin: 14px 0 5px;
  display: block;
}
.pal-label:first-child { margin-top: 0; }

.ylist { display: flex; flex-direction: column; gap: 1px; }
.ycol {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 4px;
  font-size: var(--ui-s);
  cursor: pointer;
  min-height: 34px;
}
.ycol:hover { background: #e8eef3; }
.ycol input { width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; margin: 0; }
.ycol label { cursor: pointer; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ycol .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ycol.off { opacity: .45; }
.ycol.off .dot { background: var(--line) !important; }

/* ── Zeichenflaeche ─────────────────────────────────────────── */
.canvaswrap {
  position: relative;
  padding: 16px;
  min-height: 0;
  display: flex;
  background:
    linear-gradient(var(--line-2) 1px, transparent 1px) 0 0 / 100% 40px,
    var(--surface);
}
.canvaswrap canvas { flex: 1 1 auto; min-height: 0; max-width: 100%; }

.dropzone {
  position: absolute;
  inset: 16px;
  z-index: 5;
  border: 2px dashed #b9c8d4;
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  padding: 24px;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--teal); background: #f3fbfa; }
.dropzone.over { border-color: var(--teal); background: #e6f7f5; border-style: solid; }
.dz-icon { font-size: 34px; color: var(--teal); line-height: 1; }
.dz-title { font-size: 17px; font-weight: 600; }
.dz-sub { font-size: var(--ui-s); color: var(--ink-2); }
.dz-link { color: var(--navy-lt); text-decoration: underline; }
.dz-note { font-size: var(--ui-xs); color: var(--ink-3); margin-top: 8px; }

.busy {
  position: absolute;
  inset: 16px;
  z-index: 10;
  background: rgba(255,255,255,.93);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.busy-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
  width: min(360px, 90%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.busy-text { font-size: var(--ui-s); font-variant-numeric: tabular-nums; }
.busy-track { width: 100%; height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.busy-bar { height: 100%; width: 0; background: var(--teal); transition: width .1s linear; }

.alert.info {
  background: #eaf4f8;
  border-color: #b6d6e4;
  border-left-color: var(--navy-lt);
  color: #123c52;
}
.alert {
  position: absolute;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 20;
  background: #fdecea;
  border: 1px solid #f0b8b1;
  border-left: 4px solid var(--danger);
  color: #7d1d13;
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: var(--ui-s);
  box-shadow: var(--shadow);
}

/* ── Zoom ───────────────────────────────────────────────────── */
.canvaswrap.zooming { cursor: col-resize; }
.zoom-band {
  position: absolute;
  top: 16px; bottom: 44px;
  background: rgba(16, 107, 125, .14);
  border-left: 2px solid var(--focus);
  border-right: 2px solid var(--focus);
  pointer-events: none;
  z-index: 4;
}
.zoom-hint {
  position: absolute;
  left: 50%; bottom: 20px; transform: translateX(-50%);
  background: rgba(11, 60, 93, .9); color: #fff;
  font-size: var(--ui-xs); padding: 4px 10px; border-radius: 999px;
  pointer-events: none; z-index: 6; white-space: nowrap;
}

/* Betrag und Einheit nebeneinander */
.absrow { display: flex; gap: 6px; }
.absrow .ctl-input { flex: 1 1 40%; }
.absrow .ctl-select { flex: 1 1 60%; }

/* ── Einstellungen rechts ───────────────────────────────────── */
.props {
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.prop-head {
  padding: 8px 10px 8px 14px;
  font-size: var(--ui-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
/* overflow-x MUSS ausdruecklich gesetzt sein: steht nur overflow-y,
   rechnet CSS die andere Achse von "visible" auf "auto" hoch. Das
   ergab einen waagrechten Rollbalken und links abgeschnittenen Text. */
.prop-body { padding: 14px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; }

.icon-btn {
  font: inherit;
  font-size: 19px;
  line-height: 1;
  width: 30px; height: 30px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.icon-btn:hover { background: #e3ebf1; color: var(--ink); }

.prop-block { margin-bottom: 18px; }
.prop-block:last-child { margin-bottom: 0; }
.prop-label { font-size: var(--ui-xs); font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.prop-note { font-weight: 400; color: var(--ink-3); }
.prop-sub {
  display: block;
  font-size: var(--ui-xs);
  color: var(--ink-2);
  margin: 10px 0 4px;
  font-weight: 600;
}
.prop-hint { font-size: var(--ui-xs); color: var(--ink-3); margin: 4px 0 0; line-height: 1.45; }

/* Der Grund, warum etwas geht oder nicht geht. Immer sichtbar. */
.prop-why {
  overflow-wrap: anywhere;
  font-size: var(--ui-s);
  line-height: 1.45;
  color: var(--ink-2);
  background: #eaf4f8;
  border-left: 3px solid var(--navy-lt);
  border-radius: 0 4px 4px 0;
  padding: 9px 11px;
}
.prop-why.blocked {
  background: #fff6e8;
  border-left-color: var(--warn);
  color: #7a4a10;
}

.ctl-select, .ctl-input {
  font: inherit;
  font-size: var(--ui-s);
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line-ui);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
.ctl-input:focus, .ctl-select:focus { border-color: var(--focus); }

.fielderr { font-size: var(--ui-xs); color: var(--danger); line-height: 1.4; margin: 3px 0 0; }
.fielderr:empty { display: none; }

.klevels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.klev { display: flex; flex-direction: column; gap: 3px; }
.klev label { font-size: var(--ui-xs); color: var(--ink-3); font-weight: 600; }

.switchrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--ui-s);
  min-height: 34px;
}
.switch { width: 18px; height: 18px; flex: 0 0 auto; cursor: pointer; margin: 0; }

/* ── Statistik ──────────────────────────────────────────────── */
.statlist { margin: 0; font-size: var(--ui-s); }
.statlist > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-2);
}
.statlist > div:last-child { border-bottom: 0; }
.statlist dt { color: var(--ink-3); font-size: var(--ui-xs); }
.statlist dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}
.statlist dt { flex: 0 0 auto; }

.multistats { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ms-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--navy);
  border-radius: 4px;
  padding: 7px 9px;
}
.ms-name { font-size: var(--ui-xs); font-weight: 700; margin-bottom: 3px; overflow-wrap: anywhere; }
.ms-vals {
  font-size: var(--ui-xs); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; gap: 2px 10px;
}
.ms-vals span { white-space: nowrap; }

/* ── Stufenuebersicht ───────────────────────────────────────── */
.levelsum { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.lvl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--ui-xs);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
}
.lvl-swatch { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.lvl-name { flex: 1 1 auto; color: var(--ink-2); }
.lvl-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Ergebnis der Abstandspruefung ──────────────────────────── */
.gapresult { margin-top: 10px; font-size: var(--ui-xs); }
.gap-head {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--navy-lt); border-radius: 4px;
  padding: 7px 9px; margin-bottom: 6px; line-height: 1.5;
}
.gap-head strong { font-variant-numeric: tabular-nums; }
.gap-head.clean { border-left-color: var(--good); }
.gap-head.dirty { border-left-color: var(--warn); }
.gap-list { max-height: 190px; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 3px; }
.gap-item {
  display: flex; gap: 7px; align-items: baseline;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; padding: 5px 8px;
}
.gap-kind { font-weight: 700; flex: 0 0 auto; }
.gap-kind.gap { color: var(--warn); }
.gap-kind.dense { color: var(--navy-lt); }
.gap-kind.duplicate { color: #8e44ad; }
.gap-kind.backwards { color: var(--danger); }
.gap-where { color: var(--ink-3); flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap-delta { font-variant-numeric: tabular-nums; font-weight: 600; flex: 0 0 auto; }
.gap-more { color: var(--ink-3); padding: 4px 2px; }

/* ── Startfehler: sichtbar statt stumm ──────────────────────── */
.bootfail {
  margin: 16px; padding: 14px 16px;
  background: #fdecea; border: 1px solid #f0b8b1;
  border-left: 4px solid var(--danger); border-radius: var(--r);
  color: #7d1d13; font-size: var(--ui-s); line-height: 1.5;
}
.bootfail code { background: #fff; padding: 1px 5px; border-radius: 3px; }

/* ── Statusleiste ───────────────────────────────────────────── */
.statusbar {
  height: var(--status-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--navy-dk);
  color: #cfe0ec;
  font-size: var(--ui-xs);
  overflow: hidden;
  white-space: nowrap;
}
.st-item { flex: 0 0 auto; }
.st-sep { color: #5d7e97; }
.st-spacer { flex: 1 1 auto; }
.st-note {
  flex: 0 1 auto;
  color: #9fc3dc;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Info-Ueberlagerung ─────────────────────────────────────── */
.infopanel {
  position: absolute;
  inset: var(--tool-h) 0 var(--status-h) 0;
  z-index: 30;
  background: rgba(255,255,255,.97);
  overflow-y: auto;
}
.info-inner { max-width: 760px; margin: 0 auto; padding: 26px 24px 40px; position: relative; }
.info-close { position: absolute; top: 14px; right: 14px; font-size: 22px; }
.info-inner h2 { font-size: 15px; color: var(--navy); margin: 22px 0 8px; }
.info-inner h2:first-of-type { margin-top: 0; }
.steps, .typelist { margin: 0; padding-left: 20px; font-size: var(--ui-s); line-height: 1.65; }
.typelist { list-style: none; padding-left: 0; }
.typelist li { padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.typelist li:last-child { border-bottom: 0; }

/* ══ Fliesstext unterhalb der Anwendung ═════════════════════ */
.pagetext {
  max-width: 940px;
  margin: 26px auto 0;
  padding: 0 16px;
}
.tbox {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 14px;
}
.tbox h2 { font-size: 16px; color: var(--navy); margin: 0 0 8px; }
.tbox p { font-size: 14px; color: var(--ink-2); margin: 0 0 9px; }
.tbox p:last-child { margin-bottom: 0; }

.pagefoot {
  max-width: 940px;
  margin: 8px auto 0;
  padding: 18px 16px 30px;
  text-align: center;
  font-size: var(--ui-s);
  color: var(--ink-3);
}
.pagefoot a { color: var(--navy-lt); text-decoration: none; }
.pagefoot a:hover { text-decoration: underline; }

/* ══ Anpassung an kleinere Anzeigen ═════════════════════════ */
@media (min-width: 1700px) {
  .stage { grid-template-columns: 260px minmax(0, 1fr) 360px; }
  .app.no-props .stage { grid-template-columns: 260px minmax(0, 1fr); }
}

@media (max-width: 1150px) {
  .stage { grid-template-columns: 208px minmax(0, 1fr); }
  .props {
    position: absolute;
    top: var(--tool-h);
    bottom: var(--status-h);
    right: 0;
    width: 300px;
    z-index: 25;
    box-shadow: -6px 0 20px rgba(16,36,54,.14);
    border-left: 1px solid var(--line);
  }
  .app.no-props .stage { grid-template-columns: 208px minmax(0, 1fr); }
}

@media (max-width: 780px) {
  .app {
    height: auto;
    min-height: 0;
    border-left: 0;
    border-right: 0;
  }
  .stage {
    display: flex;
    flex-direction: column;
  }
  .palette { border-right: 0; border-bottom: 1px solid var(--line); }
  .pal-body { max-height: 200px; }
  .canvaswrap { height: 62vh; min-height: 340px; padding: 10px; }
  .dropzone, .busy { inset: 10px; }
  .props {
    position: static;
    width: auto;
    box-shadow: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .prop-body { max-height: none; }
  .infopanel { position: fixed; inset: 0; }
  .topbar-title { font-size: 13px; }
  .breadcrumb { font-size: var(--ui-xs); overflow-x: auto; }
}

/* ── Sehr schmale Anzeigen (Telefon hochkant) ───────────────── */
@media (max-width: 480px) {
  :root { --tool-h: 46px; --status-h: auto; }

  /* Werkzeugleiste umbrechen statt seitlich schieben: auf dem
     Telefon findet niemand einen Knopf, der rechts ausserhalb
     des Bildes liegt. */
  .apptoolbar { flex-wrap: wrap; overflow-x: visible; row-gap: 6px; }
  .tb-sep, .tb-spacer { display: none; }
  .tb-group { flex: 1 1 auto; }
  #chart-type-grid { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .tb-btn { flex: 1 1 auto; justify-content: center; padding-left: 10px; padding-right: 10px; }

  /* Nur das Sinnbild, der Text kostet zu viel Breite. */
  .tb-type { padding: 6px 10px; font-size: 0; gap: 0; }
  .tb-type .ic { font-size: 17px; }
  .tb-type[aria-pressed="true"] { font-size: 0; }

  .statusbar {
    flex-wrap: wrap;
    white-space: normal;
    padding: 5px 12px;
    row-gap: 2px;
    line-height: 1.4;
  }
  .st-spacer { display: none; }
  .st-note { flex: 1 1 100%; white-space: normal; }

  .canvaswrap { height: 54vh; min-height: 280px; padding: 8px; }
  .dropzone, .busy { inset: 8px; }
  .dz-title { font-size: 15px; }
  .dz-note { display: none; }
  .pal-body { max-height: 160px; }
  .klevels { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .breadcrumb { height: auto; padding: 6px 12px; flex-wrap: wrap; row-gap: 2px; }
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .topbar-title { font-size: 12px; }
  .tbox { padding: 14px 16px; }
  .gap-list { max-height: 150px; }
}

/* ── Beruehrungsbedienung ───────────────────────────────────── */
@media (pointer: coarse) {
  .tb-btn, .tb-type { min-height: 44px; padding-left: 14px; padding-right: 14px; }
  .ctl-select, .ctl-input { min-height: 44px; }
  .ycol { min-height: 44px; }
  .ycol input { width: 20px; height: 20px; }
  .switch { width: 22px; height: 22px; }
  .icon-btn { width: 44px; height: 44px; }
}

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

@media print {
  .apptoolbar, .palette, .props, .statusbar, .breadcrumb, .infopanel { display: none !important; }
  .app { height: auto; border: 0; }
}
