/* PDF-Tools – reines CSS, keine externen Schriften oder Frameworks. Farben wie solideumgesetzt.de. */

:root {
  --bg: #fdf9f3;
  --surface: #ffffff;
  --surface-alt: #f6f0e6;
  --ink: #1d2a3a;
  --muted: #5b6878;
  --line: #e6ddcf;
  --accent: #0b7a68;
  --accent-hover: #096656;
  --accent-ink: #ffffff;
  --accent-soft: #ddf3ea;
  --danger: #b4371a;
  --danger-soft: #fde7df;
  --warn: #9a6200;
  --warn-soft: #fff1d6;
  --stage-bg: #e9e2d6;
  --shadow: 0 1px 2px rgb(29 42 58 / 6%), 0 4px 16px rgb(29 42 58 / 6%);
  --radius: 14px;
  --radius-small: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --surface: #16212d;
    --surface-alt: #131e29;
    --ink: #edf1f5;
    --muted: #9aa8b8;
    --line: #263445;
    --accent: #3fd0a8;
    --accent-hover: #67dcbb;
    --accent-ink: #06231b;
    --accent-soft: #123128;
    --danger: #ff8a6b;
    --danger-soft: #3a1f19;
    --warn: #f2c063;
    --warn-soft: #33270f;
    --stage-bg: #0a1118;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Kein Doppeltipp-Zoom: Knöpfe reagieren sofort, auch direkt nach dem Unterschreiben. Zwei-Finger-Zoom bleibt. */
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
}

main {
  flex: 1;
}

h1,
h2 {
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.1rem);
}

h2 {
  font-size: 1.15rem;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

img,
svg {
  display: block;
}

[hidden] {
  display: none !important;
}

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

.muted {
  color: var(--muted);
}

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

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

/* ---------- Kopfzeile ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}

.brand img {
  flex: none;
  border-radius: 8px;
}

.brand span {
  white-space: nowrap;
}

/* Schmale Handys: nur das Logo, damit Installieren und Status-Badge Platz haben. */
@media (max-width: 420px) {
  .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

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

/* Status-Badge: pending (wird geladen), ready (offline bereit), offline (ohne Netz, App läuft), warn */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge[data-state="pending"] .badge__dot {
  animation: pulse 1.2s ease-in-out infinite;
}

.badge[data-state="ready"],
.badge[data-state="offline"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.badge[data-state="offline"] .badge__dot {
  background: transparent;
  box-shadow: inset 0 0 0 2px currentColor;
}

.badge[data-state="warn"] {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* ---------- Einleitung ---------- */

.intro {
  padding: 28px 0 8px;
}

.privacy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-small);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.95rem;
}

.privacy svg {
  flex: none;
  margin-top: 2px;
  color: var(--accent);
}

/* Nummerierte Schritte */
.step {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step__num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.85rem;
  font-weight: 700;
}

.step__optional {
  font-size: 0.85rem;
  font-weight: 400;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn--large {
  min-height: 52px;
  padding: 0 24px;
  font-size: 1.02rem;
}

.btn--small {
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.875rem;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--muted);
}

/* Label-Buttons um das versteckte Datei-Feld: Fokus sichtbar machen */
.btn:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-btn--bordered {
  background: var(--surface);
  border-color: var(--line);
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-alt);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---------- 1. Hinzufügen ---------- */

.add {
  padding: 18px 0 8px;
}

.add h2 {
  margin-bottom: 12px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.dropzone .btn {
  width: 100%;
  max-width: 320px;
}

.dropzone__hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.docs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
}

.docs:empty {
  display: none;
}

.doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 36px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
}

.doc__dot,
.card__dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.doc__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.doc__count {
  flex: none;
  color: var(--muted);
  white-space: nowrap;
}

.doc__remove {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.doc__remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.progress {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  background: var(--surface-alt);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* ---------- 2. Seiten ---------- */

.pages {
  padding: 26px 0 8px;
}

.pages__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pages__hint {
  margin: 6px 0 0;
  font-size: 0.875rem;
}

.count {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  text-align: center;
}

.empty {
  margin: 14px 0 0;
  padding: 28px 16px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--muted);
  text-align: center;
}

.grid {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.grid:empty {
  display: none;
}

@media (max-width: 380px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: opacity 0.15s, border-color 0.15s;
}

.card.is-dragging {
  opacity: 0.4;
}

.card.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.card__thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--surface-alt);
  cursor: pointer;
}

.card__thumb:focus-visible {
  outline-offset: -3px;
}

/* Das Bild füllt die Fläche mit object-fit: contain, der Schatten folgt per drop-shadow nur dem Bild selbst. */
.card__thumb img {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgb(0 0 0 / 22%));
  transition: opacity 0.15s;
  pointer-events: none;
}

.card__thumb img:not([src]) {
  visibility: hidden;
}

.card.is-busy .card__thumb img {
  opacity: 0.4;
}

.card.is-busy .card__thumb::after {
  content: "";
  position: absolute;
  top: calc(50% - 14px);
  left: calc(50% - 14px);
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.card__num,
.card__tag {
  z-index: 1;
}

.card__num {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
}

.card__tag {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 700;
}

.card__src {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.card__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
}

.tool {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.tool + .tool {
  border-left: 1px solid var(--line);
}

.tool svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.tool:hover:not(:disabled) {
  background: var(--surface-alt);
}

.tool:disabled {
  color: var(--line);
  cursor: default;
}

.tool--danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- 3. Unterschrift, 4. Export ---------- */

.panel {
  margin: 28px 0 8px;
  padding: 20px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (min-width: 600px) {
  .panel {
    padding: 24px;
  }
}

.signature__body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

.signature__preview {
  display: grid;
  place-items: center;
  flex: 0 1 280px;
  min-width: 0;
  height: 96px;
  padding: 10px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-small);
  /* Immer hell: die Unterschrift ist dunkle Tinte auf Papier, auch im Dunkelmodus. */
  background: #fff;
  font-size: 0.9rem;
}

.signature__preview .muted {
  color: #5b6878;
}

.signature__preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.signature__actions {
  flex: 1 1 220px;
}

.signature__note {
  margin: 10px 0 0;
  font-size: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-top: 14px;
}

.field__label {
  font-size: 0.875rem;
  font-weight: 600;
}

.field__input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--bg);
  overflow: hidden;
}

.field__input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.field input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  /* 16px verhindert das automatische Zoomen auf iOS */
  font-size: 16px;
}

.field input:focus {
  outline: none;
}

.field__suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--surface-alt);
  color: var(--muted);
  border-left: 1px solid var(--line);
}

.export__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.export__actions .btn {
  flex: 1 1 220px;
}

.result {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  background: var(--accent-soft);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* ---------- Hinweise, Fußzeile ---------- */

.howto {
  margin: 28px 0 36px;
  color: var(--muted);
  font-size: 0.92rem;
}

.howto h2 {
  color: var(--ink);
  font-size: 1rem;
}

.howto p {
  margin: 6px 0 0;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.85rem;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
}

.noscript {
  padding: 16px;
  background: var(--warn-soft);
}

/* ---------- Dialoge ---------- */

.dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 12px 48px rgb(0 0 0 / 30%);
}

.dialog::backdrop {
  background: rgb(15 23 32 / 55%);
}

.dialog h2 {
  font-size: 1.1rem;
}

/* Zeichenfläche */
.dialog--pad {
  width: min(640px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  border-radius: var(--radius);
  overflow: auto;
}

.dialog__inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -6px -6px 0 0;
}

.dialog__foot {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.dialog__foot .btn {
  flex: 0 1 160px;
}

.pad {
  position: relative;
  /* Papierweiß auch im Dunkelmodus, damit Schwarz und Dunkelblau so aussehen wie später im PDF. */
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  aspect-ratio: 5 / 2;
  max-height: 55dvh;
  overflow: hidden;
}

.pad canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.pad__line {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 24%;
  border-bottom: 2px dashed #d8d0c2;
  pointer-events: none;
}

.pad__hint {
  position: absolute;
  left: 6%;
  bottom: calc(24% - 24px);
  color: #8a94a2;
  font-size: 0.85rem;
  pointer-events: none;
}

.pad__tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.colors {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.color {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.color input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.color__swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 70%);
}

.color__swatch--black {
  background: #111;
}

.color__swatch--blue {
  background: #1a2b6d;
}

.color:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  font-weight: 600;
}

.color:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Große Ansicht einer Seite: füllt den Bildschirm */
.dialog--editor {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  background: var(--stage-bg);
}

.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor__head,
.editor__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}

.editor__head {
  justify-content: space-between;
  min-height: 56px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
}

.editor__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor__src {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}

.editor__viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.stage {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 12px rgb(0 0 0 / 25%);
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage canvas.is-stale {
  opacity: 0.5;
}

.stage__layer {
  position: absolute;
  inset: 0;
}

.editor__loading {
  position: absolute;
  top: 24px;
  left: 50%;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  transform: translateX(-50%);
}

.editor__hint {
  margin: 0;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  text-align: center;
}

.editor__bar {
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

/* Schmale Handys: Pfeile neben "Unterschrift einfügen", "Neu zeichnen" klein darunter. */
@media (max-width: 480px) {
  .editor__bar {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    row-gap: 6px;
  }

  #editor-redraw {
    grid-column: 1 / -1;
    justify-self: center;
  }

  #editor-prev {
    order: 1;
  }

  #editor-add {
    order: 2;
    padding: 0 12px;
    white-space: nowrap;
  }

  #editor-add svg {
    display: none;
  }

  #editor-next {
    order: 3;
  }

  #editor-redraw {
    order: 4;
    min-height: 34px;
    padding: 0 14px;
    font-size: 0.875rem;
  }
}

/* Platzierte Unterschrift */
.sig {
  position: absolute;
  touch-action: none;
  cursor: move;
  outline: 1px dashed rgb(11 122 104 / 70%);
  outline-offset: 0;
  user-select: none;
  -webkit-user-select: none;
}

.sig img {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sig.is-selected,
.sig:focus-visible {
  outline: 2px solid #0b7a68;
  background: rgb(11 122 104 / 8%);
}

.sig.is-dragging {
  cursor: grabbing;
}

.sig__delete,
.sig__handle {
  position: absolute;
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.sig.is-selected .sig__delete,
.sig.is-selected .sig__handle,
.sig:focus-within .sig__delete,
.sig:focus-within .sig__handle {
  display: grid;
}

.sig__delete {
  top: -14px;
  left: -14px;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  background: #b4371a;
  color: #fff;
  font: 700 18px/1 var(--font);
  cursor: pointer;
}

.sig__handle {
  right: -14px;
  bottom: -14px;
  border: 3px solid #fff;
  background: #0b7a68;
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
  cursor: nwse-resize;
  touch-action: none;
}

/* Größere Griffe für Finger */
@media (pointer: coarse) {
  .sig__delete,
  .sig__handle {
    width: 36px;
    height: 36px;
  }

  .sig__delete {
    top: -18px;
    left: -18px;
  }

  .sig__handle {
    right: -18px;
    bottom: -18px;
  }
}

/* ---------- Drag-Overlay und Toast ---------- */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 4px dashed var(--accent);
  pointer-events: none;
}

.drop-overlay span {
  padding: 14px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 16px;
  border-radius: var(--radius-small);
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
  font-size: 0.92rem;
  transform: translateX(-50%);
}

.toast__action,
.toast__close {
  flex: none;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.toast__action {
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-ink);
}

.toast__close {
  width: 36px;
  font-size: 1.3rem;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
