/* ============================================================
   PDF STUDIO — Kit-System (Trikot-Nummern-Welt, hell)
   Grund: Kit-Weiß · Tinte: Fast-Schwarz · Akzent: #FF4D00 (nur anfassbar/aktiv)
   Display: Anton · Kit-Stimme: Barlow Condensed · UI-Text: System-Sans
   ============================================================ */

@font-face {
  font-family: "Anton";
  src: url("../vendor/fonts/anton-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../vendor/fonts/barlow-condensed-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../vendor/fonts/barlow-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../vendor/fonts/barlow-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --court: #f5f5f2;
  --court-2: #ecece7;
  --ink: #111111;
  --ink-2: #63635e;
  --line: #e3e3de;
  --line-ink: #111111;
  --accent: #ff4d00;
  --accent-ink: #c53500; /* Akzent als KLEINER Text auf hellem Grund (AA 4.5:1, auch auf accent-soft) */
  --accent-soft: #fff0e9;
  --ok: #0a7a3d;
  --err: #c81e1e;

  --display: "Anton", "Arial Narrow", sans-serif;
  --kit: "Barlow Condensed", "Arial Narrow", sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --t-fast: 150ms;
  --t-med: 220ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --topbar-h: 56px;
  --shadow-pop: 0 12px 32px rgba(17, 17, 17, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

::selection { background: var(--accent); color: #fff; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Browser-Flächen tragen das Kit mit */
* { scrollbar-width: thin; scrollbar-color: #c9c9c2 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c9c9c2; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #a8a8a0; }
*::-webkit-scrollbar-track { background: transparent; }
input, [contenteditable] { caret-color: var(--accent); }

img, canvas { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }

/* ---------- Typo-Stimmen ---------- */
.display {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 0.92;
  letter-spacing: 0.005em;
}
.kit-label {
  font-family: var(--kit);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 13px;
  line-height: 1.2;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--paper);
  border-bottom: 2px solid var(--line-ink);
}
.brand {
  font-family: var(--display);
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  padding: 6px 2px;
}
.brand .dot { color: var(--accent); }
.topbar-file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--kit);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--ink-2);
}
.topbar-spacer { flex: 1; }
.chip-local {
  font-family: var(--kit);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px 4px;
  border: 2px solid var(--line-ink);
  white-space: nowrap;
  cursor: help;
}

/* ---------- Buttons (Kit-Vokabular) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--kit);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 14px;
  line-height: 1;
  min-height: 44px;
  padding: 12px 20px 11px;
  border: 2px solid var(--line-ink);
  background: var(--paper);
  color: var(--ink);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { border-color: var(--line-ink); background: var(--paper); color: var(--ink); }
.btn-big { font-size: 17px; padding: 16px 28px 15px; }
.btn-icon {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  justify-content: center;
}
.btn-danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Screens ---------- */
main { min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; animation: screen-in var(--t-med) var(--ease); }
@keyframes screen-in {
  from { opacity: 0.01; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Home ---------- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: clamp(48px, 8vh, 96px) 24px clamp(40px, 6vh, 72px);
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  cursor: pointer;
}
.hero-line {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(64px, 11.5vw, 176px);
  line-height: 0.9;
  letter-spacing: 0.002em;
}
.hero-line .dot { color: var(--accent); }
.hero-sub {
  font-size: 17px;
  color: var(--ink-2);
  max-width: 52ch;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero.dragover .hero-line { color: var(--accent); }

.roster {
  border-top: 2px solid var(--line-ink);
  border-bottom: 2px solid var(--line-ink);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.roster-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 24px 30px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast) var(--ease);
  min-height: 190px;
}
.roster-tile:nth-child(4n) { border-right: 0; }
.roster-tile:nth-child(n + 5) { border-bottom: 0; }
.roster-tile:hover { background: var(--court); }
.roster-tile:hover .num { color: var(--accent); }
.roster-tile .num {
  font-family: var(--display);
  font-size: 64px;
  line-height: 0.9;
  transition: color var(--t-fast) var(--ease);
}
.roster-name {
  font-family: var(--kit);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 19px;
  line-height: 1.1;
}
.roster-desc { font-size: 14px; color: var(--ink-2); max-width: 34ch; }

.foot {
  margin-top: auto;
  padding: 40px 24px 56px;
  max-width: 1280px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
}
.foot p.foot-statement {
  font-family: var(--display);
  text-transform: uppercase;
  font-size: clamp(28px, 3.6vw, 46px);
  line-height: 0.95;
  color: var(--ink);
}
.foot-statement em { font-style: normal; color: var(--ink); }
.foot h2 {
  font-family: var(--kit);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.foot p, .foot li { font-size: 13.5px; color: var(--ink-2); }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.foot-legal {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.foot-legal a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.foot-legal a:hover { color: var(--ink); }

/* ---------- Werkzeug-Kopf (Merge/Compress/…) ---------- */
.tool-wrap { max-width: 980px; width: 100%; margin: 0 auto; padding: 32px 24px 80px; display: flex; flex-direction: column; gap: 28px; }
.tool-head { display: flex; align-items: flex-end; gap: 18px; border-bottom: 2px solid var(--line-ink); padding-bottom: 18px; }
.tool-head .num { font-family: var(--display); font-size: 56px; line-height: 0.85; color: var(--accent); }
.tool-head h2 { font-family: var(--display); text-transform: uppercase; font-size: 40px; line-height: 0.9; font-weight: 400; }
.tool-head .tool-back { margin-left: auto; }
.tool-sub { color: var(--ink-2); font-size: 15px; margin-top: -14px; max-width: 62ch; }

/* ---------- Dateizeilen (Merge / Bilder) ---------- */
.filelist { display: flex; flex-direction: column; border: 2px solid var(--line-ink); }
.filerow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.filerow:last-child { border-bottom: 0; }
.filerow.sortable-ghost { opacity: 0.3; }
.filerow.sortable-drag { box-shadow: var(--shadow-pop); }
.filerow .grip { color: var(--ink-2); cursor: grab; padding: 8px 2px; flex: none; display: grid; place-items: center; }
.filerow .grip svg { width: 18px; height: 18px; }
.filerow .grip:active { cursor: grabbing; }
.filerow .mini {
  width: 44px;
  height: 58px;
  border: 1px solid var(--line);
  background: var(--court) center/cover no-repeat;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.filerow .mini canvas, .filerow .mini img { width: 100%; height: 100%; object-fit: cover; }
.filerow .fname { flex: 1; min-width: 0; }
.filerow .fname strong { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filerow .fname span { font-size: 12.5px; color: var(--ink-2); }
.filerow .idx { font-family: var(--display); font-size: 22px; color: var(--ink-2); min-width: 34px; text-align: right; }

.dropline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  border: 2px dashed #b9b9b2;
  color: var(--ink-2);
  font-family: var(--kit);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.dropline:hover, .dropline.dragover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

.tool-cta { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.tool-total { font-family: var(--kit); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 15px; color: var(--ink-2); }

/* ---------- Level-Wahl (Komprimieren) ---------- */
.levels { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--line-ink); }
.level {
  padding: 20px 18px 22px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  position: relative;
}
.level:last-child { border-right: 0; }
.level:hover { background: var(--court); }
.level[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 3px var(--accent); }
.level[aria-pressed="true"] .lv-name { color: var(--accent-ink); }
.lv-name { font-family: var(--display); text-transform: uppercase; font-size: 26px; line-height: 1; }
.lv-tech { font-family: var(--kit); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 12.5px; color: var(--ink-2); }
.lv-desc { font-size: 13.5px; color: var(--ink-2); }

.file-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 2px solid var(--line-ink);
  padding: 14px 18px;
}
.file-summary .fname { flex: 1; min-width: 0; }
.file-summary .fname strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-summary .fname span { color: var(--ink-2); font-size: 13px; }

/* Test-Streifen (Vorher/Nachher) */
.strip {
  position: relative;
  border: 2px solid var(--line-ink);
  overflow: hidden;
  touch-action: none;
  background: var(--court);
  user-select: none;
}
.strip canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.strip .after-wrap { position: absolute; inset: 0; overflow: hidden; }
.strip .divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 3px solid var(--accent);
  cursor: ew-resize;
}
.strip .divider-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  color: #111;
  display: grid;
  place-items: center;
  width: 34px;
  height: 28px;
}
.strip .divider-grip svg { width: 22px; height: 14px; }
.strip .tag {
  position: absolute;
  top: 10px;
  font-family: var(--kit);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  padding: 4px 8px 3px;
  pointer-events: none;
}
.strip .tag-before { left: 10px; }
.strip .tag-after { right: 10px; background: var(--accent); color: #111; }

/* Ergebnis */
.result { border: 2px solid var(--line-ink); padding: 28px 24px 30px; display: flex; flex-direction: column; gap: 14px; }
.result .headline { font-family: var(--display); text-transform: uppercase; font-size: clamp(48px, 7vw, 88px); line-height: 0.9; }
.result .headline em { font-style: normal; color: var(--ink); }
.result .detail { font-size: 15px; color: var(--ink-2); }
.result .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Fortschritt ---------- */
#progressTop {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 100;
  transition: width 180ms linear, opacity var(--t-med);
  opacity: 0;
}
#progressTop.on { opacity: 1; }
.progress-line { display: flex; align-items: center; gap: 12px; font-family: var(--kit); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 14px; }
.progress-line .bar { flex: 1; height: 10px; border: 2px solid var(--line-ink); position: relative; }
.progress-line .bar i { position: absolute; inset: 0; width: 0; background: var(--accent); transition: width 120ms linear; }

/* ---------- Editor ---------- */
#screen-editor {
  /* Feste Flex-Basis: nur die Bühne scrollt, Kopf/Werkzeuge/Rail bleiben stehen */
  flex: 0 0 calc(100vh - var(--topbar-h));
  flex-basis: calc(100dvh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  max-height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}
.ed-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-wrap: wrap;
}
.ed-title { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 10px; }
.ed-title strong { font-family: var(--kit); font-weight: 600; font-size: 16px; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-title .meta { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.ed-actions { display: flex; gap: 8px; align-items: center; }

.ed-search { display: flex; align-items: center; border: 2px solid var(--line-ink); height: 40px; }
.ed-search input {
  border: 0;
  font: inherit;
  font-size: 14px;
  padding: 0 10px;
  width: 170px;
  background: transparent;
  color: var(--ink);
}
.ed-search input::placeholder { color: var(--ink-2); }
.ed-search .hits { font-size: 12px; color: var(--ink-2); padding: 0 8px; white-space: nowrap; }
.ed-search button { min-width: 34px; min-height: 36px; display: grid; place-items: center; }
.ed-search button:hover { background: var(--court); }
.ed-search svg { width: 16px; height: 16px; }

.ed-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 2px solid var(--line-ink);
  background: var(--court);
  flex-wrap: wrap;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--kit);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
  padding: 9px 12px 8px;
  border: 2px solid transparent;
  min-height: 40px;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.tool-btn svg { width: 17px; height: 17px; }
.tool-btn:hover { background: var(--paper); border-color: var(--line-ink); }
.tool-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.tool-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }

.tool-opts { display: flex; align-items: center; gap: 10px; margin-left: 4px; }
.swatch {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line-ink);
  padding: 0;
  transition: transform var(--t-fast);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.opt-label { font-family: var(--kit); font-weight: 600; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.size-btns { display: flex; border: 2px solid var(--line-ink); }
.size-btns button { padding: 6px 10px; font-family: var(--kit); font-weight: 600; font-size: 12px; min-height: 34px; }
.size-btns button + button { border-left: 1px solid var(--line); }
.size-btns button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.zoom-cluster { margin-left: auto; display: flex; align-items: center; gap: 2px; border: 2px solid var(--line-ink); background: var(--paper); }
.zoom-cluster button { min-width: 38px; min-height: 38px; display: grid; place-items: center; font-family: var(--kit); font-weight: 700; font-size: 15px; }
.zoom-cluster button:hover { background: var(--court); }
.zoom-cluster .zoom-val { font-family: var(--kit); font-weight: 600; font-size: 13px; min-width: 52px; text-align: center; letter-spacing: 0.04em; }

.ed-body { flex: 1; display: flex; min-height: 0; }

.rail {
  width: 208px;
  flex: none;
  border-right: 2px solid var(--line-ink);
  background: var(--court);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.rail-head .kit-label { color: var(--ink-2); }
.rail-scroll { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.thumb {
  position: relative;
  border: 2px solid var(--line-ink);
  background: var(--paper);
  cursor: pointer;
  transition: box-shadow var(--t-fast);
}
.thumb.current { box-shadow: 0 0 0 3px var(--accent); }
.thumb.selected { box-shadow: 0 0 0 3px var(--accent); background: var(--accent-soft); }
.thumb.sortable-ghost { opacity: 0.3; }
.thumb canvas { width: 100%; height: auto; pointer-events: none; }
.thumb .t-skel { width: 100%; aspect-ratio: 0.707; background: linear-gradient(100deg, var(--court) 40%, #fff 50%, var(--court) 60%); background-size: 200% 100%; animation: skel 1.1s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.thumb .t-num {
  position: absolute;
  left: -2px;
  bottom: -2px;
  font-family: var(--display);
  font-size: 15px;
  background: var(--ink);
  color: #fff;
  padding: 3px 7px 2px;
  line-height: 1;
  pointer-events: none;
}
.thumb .t-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-ink);
  background: var(--paper);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.thumb:hover .t-check, .thumb.selected .t-check, .rail.has-selection .t-check { opacity: 1; }
.thumb.selected .t-check { background: var(--accent); border-color: var(--accent); }
.thumb .t-check svg { width: 14px; height: 14px; opacity: 0; }
.thumb.selected .t-check svg { opacity: 1; }
.thumb .t-badges { position: absolute; right: 4px; top: 4px; display: flex; gap: 3px; pointer-events: none; }
.thumb .t-badges span { background: var(--accent); color: #111; font-family: var(--kit); font-weight: 700; font-size: 10px; letter-spacing: 0.05em; padding: 2px 5px 1px; text-transform: uppercase; }

.rail-sel {
  border-top: 2px solid var(--line-ink);
  background: var(--paper);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail-sel .kit-label { color: var(--accent-ink); }
.rail-sel .row { display: flex; gap: 6px; flex-wrap: wrap; }
.rail-sel .btn { flex: 1; min-height: 38px; padding: 8px 10px 7px; font-size: 12.5px; justify-content: center; }
.rail-add { border-top: 1px solid var(--line); }
.rail-add .dropline { border: 0; padding: 14px 12px; font-size: 13px; }

.stage {
  flex: 1;
  overflow: auto;
  background: var(--court);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  min-width: 0;
}
.pagebox { position: relative; flex: none; background: #fff; border: 1px solid #d8d8d2; box-shadow: 0 10px 28px rgba(17, 17, 17, 0.08); }
.pagebox canvas.pg { display: block; }
.pagebox .anno-canvas { position: absolute; inset: 0; }
.pagebox .anno-dom { position: absolute; inset: 0; overflow: hidden; }
.pagebox[data-cursor="text"] .anno-dom, .pagebox[data-cursor="text"] { cursor: text; }
.pagebox[data-cursor="draw"] { cursor: crosshair; }
.pagebox[data-cursor="place"] { cursor: copy; }
.pagebox .searchlight { position: absolute; background: rgba(255, 77, 0, 0.32); pointer-events: none; }

.ta {
  position: absolute;
  min-width: 12px;
  padding: 2px 4px;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.18;
  white-space: pre-wrap;
  outline: none;
  border: 1.5px dashed transparent;
  transform-origin: top left;
}
.ta:hover { border-color: #b9b9b2; }
.ta.active { border-color: var(--accent); background: rgba(255, 255, 255, 0.55); }
.ta-edit { outline: none; min-width: 8px; min-height: 1em; white-space: pre-wrap; cursor: text; }

/* Text ändern: Inline-Eingabe exakt über der Originalzeile */
.edit-wrap { position: absolute; z-index: 6; }
.edit-input {
  display: block;
  border: 1.5px dashed var(--accent);
  outline: none;
  margin: 0;
  padding: 2px 3px 1px;
  line-height: 1.1;
  box-shadow: 0 8px 22px rgba(17, 17, 17, 0.16);
}
.edit-wrap .ta-del { top: -13px; right: -13px; }
.ta-del {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 26px;
  height: 26px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ta-del svg { width: 12px; height: 12px; }
.ta-del:hover { background: var(--err); }
.sig-box { position: absolute; border: 1.5px dashed transparent; touch-action: none; }
.sig-box:hover, .sig-box.active { border-color: var(--accent); }
.sig-box img { width: 100%; height: 100%; pointer-events: none; }
.sig-resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  cursor: nwse-resize;
  display: none;
}
.sig-box.active .sig-resize { display: block; }

/* ---------- Drop-Veil ---------- */
.dropveil {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.94);
  display: grid;
  place-items: center;
  border: 6px solid var(--accent);
}
.dropveil .display { font-size: clamp(64px, 12vw, 200px); color: var(--accent); }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  font-size: 14.5px;
  max-width: min(92vw, 560px);
  box-shadow: var(--shadow-pop);
  animation: toast-in var(--t-med) var(--ease);
}
.toast.err { background: var(--err); }
.toast button {
  color: var(--accent);
  font-family: var(--kit);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 13px;
  white-space: nowrap;
}
.toast.err button { color: #fff; text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Dialoge ---------- */
dialog {
  border: 2px solid var(--line-ink);
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  max-width: min(94vw, 680px);
  box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(17, 17, 17, 0.35); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 2px solid var(--line-ink); }
.dlg-head h3 { font-family: var(--display); text-transform: uppercase; font-weight: 400; font-size: 26px; line-height: 1; }
.dlg-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 20px; flex-wrap: wrap; }
.dlg-body p { color: var(--ink-2); font-size: 14.5px; }
.stamp-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.stamp-section:last-child { margin-bottom: 0; }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stamp-grid > .hint { grid-column: 1 / -1; }
.stamp-cell { position: relative; }
.stamp-card {
  width: 100%;
  border: 2px solid var(--line-ink);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  transition: background var(--t-fast), box-shadow var(--t-fast);
  background: var(--paper);
}
.stamp-card:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.stamp-card img { max-height: 56px; width: auto; max-width: 100%; object-fit: contain; }
.stamp-card span { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stamp-del {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 24px;
  height: 24px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
}
.stamp-del:hover { background: var(--err); }
.stamp-del svg { width: 11px; height: 11px; }
.stamp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stamp-chip {
  font-family: var(--kit);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 14px;
  padding: 8px 12px 7px;
  border: 2.5px solid currentColor;
  background: var(--paper);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.stamp-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(17,17,17,0.15); }
#dlgStamps { width: min(94vw, 680px); }
#dlgStamps input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.em-options { display: grid; gap: 10px; }
.em-opt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 2px solid var(--line-ink);
  padding: 14px 16px;
  text-align: left;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.em-opt:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.em-opt strong { font-family: var(--kit); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 15px; }
.em-opt span { font-size: 13.5px; color: var(--ink-2); }

.sig-canvas { border: 2px solid var(--line-ink); touch-action: none; width: 100%; background: #fff; cursor: crosshair; }
.field input {
  width: 100%;
  border: 2px solid var(--line-ink);
  padding: 12px 12px;
  font: inherit;
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
}
.field input::placeholder { color: var(--ink-2); }
.field label { display: block; font-family: var(--kit); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; font-size: 12.5px; margin-bottom: 6px; color: var(--ink-2); }

/* Select im Kit */
.kit-select { position: relative; display: inline-flex; border: 2px solid var(--line-ink); background: var(--paper); }
.kit-select select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--kit);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 13.5px;
  padding: 10px 34px 9px 12px;
  color: var(--ink);
  cursor: pointer;
}
.kit-select::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.seg { display: inline-flex; border: 2px solid var(--line-ink); }
.seg button {
  font-family: var(--kit);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13.5px;
  padding: 10px 16px 9px;
  min-height: 40px;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.hint { font-size: 13px; color: var(--ink-2); }
.hint strong { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .roster { grid-template-columns: repeat(2, 1fr); }
  .roster-tile:nth-child(4n) { border-right: 1px solid var(--line); }
  .roster-tile:nth-child(2n) { border-right: 0; }
  .roster-tile:nth-child(n + 5) { border-bottom: 1px solid var(--line); }
  .roster-tile:nth-child(n + 7) { border-bottom: 0; }
  .foot { grid-template-columns: 1fr; gap: 24px; }
  .rail { width: 168px; }
}
@media (max-width: 680px) {
  .topbar { padding: 0 14px; }
  .ed-head { padding: 8px 10px; }
  .ed-actions { flex-wrap: wrap; row-gap: 8px; width: 100%; }
  .ed-search { order: 9; flex: 1 1 100%; }
  .ed-search input { width: 100%; flex: 1; }
  /* (alte 110px-Regel entfernt — 100% gilt) */
  .roster { grid-template-columns: 1fr; }
  .roster-tile { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; min-height: 0; }
  .roster-tile:last-child { border-bottom: 0 !important; }
  .ed-body { flex-direction: column-reverse; }
  .rail { width: 100%; border-right: 0; border-top: 2px solid var(--line-ink); max-height: 32vh; }
  .rail-scroll { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .thumb { width: 96px; flex: none; }
  .stage { padding: 14px; }
  .levels { grid-template-columns: 1fr; }
  .level { border-right: 0; border-bottom: 1px solid var(--line); }
  .level:last-child { border-bottom: 0; }
  .hero { padding-top: 40px; }
}
