/* PDF-Werkzeuge – Logik in web/src/pdf/ */
.pdf-main { max-width: 1120px; }
#pdf { margin-bottom: var(--sp-7); display: flex; flex-direction: column; gap: var(--sp-4); }

/* Dialoge (aus training-gen/ui.js) */
.tg-noscroll { overflow: hidden; }
.tg-modal { position: fixed; inset: 0; background: rgba(10, 12, 25, .55); z-index: 1000; display: flex; align-items: flex-end; justify-content: center; animation: pdfFade .18s ease; }
@media (min-width: 700px) { .tg-modal { align-items: center; } }
.tg-sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 94vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 18px 22px; animation: pdfUp .28s cubic-bezier(.2, .9, .3, 1); }
.tg-modal.full .tg-sheet { max-width: 860px; }
@media (min-width: 700px) { .tg-sheet { border-radius: var(--r-l); } }
.tg-sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tg-x { border: 0; background: none; font-size: 1.2rem; padding: 4px 8px; color: var(--text); cursor: pointer; }
.tg-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 10px 16px; border-radius: var(--r-m); opacity: 0; pointer-events: none; transition: .2s; z-index: 1100; max-width: calc(100% - 32px); text-align: center; }
.tg-toast.on { opacity: 1; transform: translate(-50%, 0); }
.pdf-undo { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: #111827; color: #fff; padding: 8px 8px 8px 16px; border-radius: var(--r-m); z-index: 1100; box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6); animation: pdfUp .25s cubic-bezier(.2, .9, .3, 1); max-width: calc(100% - 32px); }
.pdf-undo .h-btn { color: #c7d2fe; min-height: 36px; }
@keyframes pdfFade { from { opacity: 0; } }
@keyframes pdfUp { from { transform: translateY(24px); opacity: 0; } }
.pdf-undo { animation-name: pdfUndoIn; }
@keyframes pdfUndoIn { from { transform: translate(-50%, 24px); opacity: 0; } }

/* Startfläche */
.pdf-hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 38px 20px 30px; border: 2px dashed color-mix(in srgb, var(--c2, var(--accent)) 45%, var(--border)); border-radius: var(--r-l);
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--c1, #fbbf24) 14%, transparent), transparent 60%), var(--surface); cursor: pointer; transition: border-color .2s, transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s; }
.pdf-hero:hover, .pdf-hero:focus-visible { border-color: var(--c2, var(--accent)); box-shadow: 0 20px 40px -26px var(--c2, var(--accent)); }
.pdf-hero > b { font-size: 1.25rem; }
.pdf-hero-sub { color: var(--muted); font-size: var(--fs-s); }
.pdf-hero-art { position: relative; height: 86px; width: 150px; margin-bottom: 4px; }
.pdf-hero-art span { position: absolute; top: 10px; left: 50%; font-size: 3.2rem; line-height: 1; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .15)); animation: pdfFloat 4s ease-in-out infinite; }
.pdf-hero-art span:nth-child(1) { transform: translateX(-110%) rotate(-12deg); animation-delay: -.6s; }
.pdf-hero-art span:nth-child(2) { transform: translateX(-50%); top: 0; font-size: 3.8rem; }
.pdf-hero-art span:nth-child(3) { transform: translateX(10%) rotate(12deg); animation-delay: -1.8s; }
@keyframes pdfFloat { 50% { margin-top: -8px; } }
.pdf-hero:hover .pdf-hero-art span:nth-child(1) { transform: translateX(-130%) rotate(-20deg); }
.pdf-hero:hover .pdf-hero-art span:nth-child(3) { transform: translateX(30%) rotate(20deg); }
.pdf-hero-art span { transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); }
.pdf-hero-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.pdf-private { margin-top: 8px; font-size: var(--fs-xs, .8rem); color: var(--muted); background: color-mix(in srgb, #22c55e 12%, transparent); padding: 5px 12px; border-radius: 999px; }
.pdf-feats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pdf-feat { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-s); }
.pdf-feat b { font-size: 1.05rem; }
body.pdf-dropping::after { content: "📥  Loslassen zum Hinzufügen"; position: fixed; inset: 10px; z-index: 900; display: flex; align-items: center; justify-content: center; border: 3px dashed var(--c2, var(--accent)); border-radius: 22px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(3px); font: 700 1.4rem/1 var(--font); color: var(--text); pointer-events: none; animation: pdfFade .15s; }

/* Leisten */
.pdf-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.pdf-bar-info b { font-size: 1.15rem; }
.pdf-bar-info small { color: var(--muted); }
.pdf-bar-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.pdf-selbar { position: sticky; top: 8px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-radius: var(--r-m); color: #fff;
  background: linear-gradient(135deg, var(--c1, #fbbf24), var(--c2, #ea580c)); box-shadow: 0 14px 30px -18px var(--c2, #ea580c); animation: pdfUp .25s cubic-bezier(.2, .9, .3, 1); }
.pdf-selbar b { margin-right: auto; }
.pdf-selbar .h-btn--quiet { color: #fff; }

/* Seiten-Raster */
.pdf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .pdf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.pdf-card { position: relative; display: flex; flex-direction: column; border-radius: 14px; background: var(--surface); border: 2px solid transparent; box-shadow: 0 1px 0 var(--border), 0 8px 20px -16px rgba(0, 0, 0, .4);
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), border-color .15s, box-shadow .2s; }
.pdf-card:hover { transform: translateY(-3px); box-shadow: 0 1px 0 var(--border), 0 16px 26px -16px rgba(0, 0, 0, .45); }
.pdf-card:focus-visible { outline: 3px solid var(--c2, var(--accent)); outline-offset: 2px; }
.pdf-card.sel { border-color: var(--c2, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c2, var(--accent)) 22%, transparent); }
.pdf-card.pdf-in { animation: pdfCardIn .45s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes pdfCardIn { from { transform: translateY(18px) scale(.85); opacity: 0; } }
.pdf-card.pdf-lift { opacity: .35; }
.pdf-card.pdf-drop-before::before, .pdf-card.pdf-drop-after::after { content: ""; position: absolute; top: 6%; bottom: 6%; width: 4px; border-radius: 4px; background: var(--c2, var(--accent)); box-shadow: 0 0 12px var(--c2, var(--accent)); }
.pdf-card.pdf-drop-before::before { left: -10px; }
.pdf-card.pdf-drop-after::after { right: -10px; }
.pdf-ghost { position: fixed; z-index: 1200; pointer-events: none; transform: rotate(-4deg) scale(1.05); box-shadow: 0 30px 50px -20px rgba(0, 0, 0, .55); opacity: .95; }
.pdf-thumb-wrap { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1.25; padding: 10px; border-radius: 12px 12px 0 0;
  background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--border) 40%, transparent) 0 6px, transparent 6px 12px); overflow: hidden; }
.pdf-thumb { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); border-radius: 2px; opacity: 0; transform: scale(.96); transition: opacity .3s, transform .4s cubic-bezier(.2, .9, .3, 1); width: auto; height: auto; }
.pdf-thumb:not(.ready) { width: 70%; aspect-ratio: 1 / 1.41; opacity: .5; background: linear-gradient(100deg, #f1f5f9 30%, #fff 50%, #f1f5f9 70%) 0 0 / 300% 100%; animation: pdfShimmer 1.2s linear infinite; }
.pdf-thumb.ready { opacity: 1; transform: none; }
@keyframes pdfShimmer { to { background-position: -300% 0; } }
.pdf-signed { position: absolute; left: 8px; top: 8px; font-size: .95rem; background: var(--surface); border-radius: 999px; padding: 2px 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.pdf-check { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; color: #fff;
  border: 2px solid #fff; background: rgba(15, 23, 42, .25); box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), background .15s; }
.pdf-card.sel .pdf-check { background: var(--c2, var(--accent)); transform: scale(1.12); }
.pdf-card-foot { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 10px; }
.pdf-card-foot b { font-size: var(--fs-s); }
.pdf-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pdf-card-acts { margin-left: auto; display: flex; gap: 2px; }
.pdf-mini { width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-size: .95rem; cursor: pointer; transition: background .15s, transform .2s cubic-bezier(.34, 1.56, .64, 1); }
.pdf-mini:hover { background: color-mix(in srgb, var(--c2, var(--accent)) 14%, transparent); transform: scale(1.12); }
.pdf-mini--x:hover { background: color-mix(in srgb, #ef4444 16%, transparent); color: #dc2626; }
.pdf-mini:active { transform: scale(.9); }
.pdf-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 180px; border: 2px dashed var(--border); border-radius: 14px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; transition: border-color .15s, color .15s, transform .2s; }
.pdf-add span { font-size: 2rem; line-height: 1; }
.pdf-add:hover { border-color: var(--c2, var(--accent)); color: var(--text); transform: translateY(-3px); }
.pdf-tip { text-align: center; margin: 0; }

/* Ausgabe */
.pdf-out { display: flex; flex-direction: column; gap: 12px; position: sticky; bottom: 10px; z-index: 15; box-shadow: 0 -10px 40px -26px rgba(0, 0, 0, .5); }
@media (max-width: 640px) { .pdf-out { position: static; } }
.pdf-out-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.pdf-name-l { flex: 1 1 260px; display: flex; flex-direction: column; gap: 4px; position: relative; min-width: 0; }
.pdf-name-l > span:first-child, .pdf-num > span { font-size: var(--fs-xs, .8rem); color: var(--muted); font-weight: 600; }
.pdf-name { padding-right: 44px; }
.pdf-ext { position: absolute; right: 12px; bottom: 11px; color: var(--muted); font-size: var(--fs-s); pointer-events: none; }
.pdf-num { display: flex; flex-direction: column; gap: 4px; }
.pdf-out-more { display: flex; flex-wrap: wrap; gap: 8px; }
.pdf-out-more .h-btn { flex: 1 1 auto; }

/* Verkleinern */
.pdf-cmp { display: flex; flex-direction: column; gap: 8px; }
.pdf-cmp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-m); animation: pdfUp .3s cubic-bezier(.2, .9, .3, 1); }
.pdf-cmp-row small { display: block; color: var(--muted); font-size: var(--fs-xs, .8rem); }
.pdf-cmp-size { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pdf-cmp-row.is-wait .pdf-cmp-size { color: var(--muted); }
.pdf-save { color: #16a34a; font-style: normal; }
.pdf-nosave { color: var(--muted); font-style: normal; font-weight: 500; }
@media (max-width: 420px) { .pdf-cmp-row { grid-template-columns: minmax(0, 1fr) auto; } .pdf-cmp-btn { grid-column: 1 / -1; } .pdf-cmp-btn .h-btn { width: 100%; } }
.pdf-pick { display: flex; flex-direction: column; gap: 10px; }

/* Arbeitsanzeige */
.pdf-busy { position: fixed; inset: 0; z-index: 1300; display: flex; align-items: center; justify-content: center; background: rgba(10, 12, 25, .35); backdrop-filter: blur(2px); animation: pdfFade .2s; }
.pdf-busy-box { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-radius: var(--r-l); background: var(--surface); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5); }
.pdf-spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--c2, var(--accent)) 25%, transparent); border-top-color: var(--c2, var(--accent)); animation: pdfRot .8s linear infinite; }
@keyframes pdfRot { to { transform: rotate(360deg); } }

/* Unterschreiben */
.pdf-sigbox, .pdf-signer { display: flex; flex-direction: column; gap: 12px; }
.pdf-pad-wrap { position: relative; border-radius: var(--r-m); background: #fff; border: 1px solid var(--border); overflow: hidden; }
.pdf-pad { display: block; width: 100%; height: auto; aspect-ratio: 900 / 320; touch-action: none; cursor: crosshair; position: relative; z-index: 1; }
.pdf-pad-line { position: absolute; left: 6%; bottom: 22%; color: #94a3b8; font-size: .9rem; letter-spacing: .1em; pointer-events: none; }
.pdf-inks { display: flex; gap: 10px; }
.pdf-ink { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--border); cursor: pointer; transition: transform .2s cubic-bezier(.34, 1.56, .64, 1); }
.pdf-ink[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--c2, var(--accent)); transform: scale(1.1); }
.pdf-sign-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.pdf-sign-stage { position: relative; align-self: center; width: 100%; max-width: 760px; line-height: 0; box-shadow: 0 6px 24px -10px rgba(0, 0, 0, .35); background: #fff; touch-action: none; }
.pdf-sign-page { display: block; width: 100%; height: auto; }
.pdf-stamp { position: absolute; outline: 2px dashed var(--c2, var(--accent)); outline-offset: 2px; cursor: move; border-radius: 3px; animation: pdfStampIn .35s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes pdfStampIn { from { transform: scale(.6); opacity: 0; } }
.pdf-stamp img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pdf-stamp-x { position: absolute; top: -14px; right: -14px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: #ef4444; color: #fff; font-size: .75rem; line-height: 1; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.pdf-stamp-rs { position: absolute; right: -10px; bottom: -10px; width: 22px; height: 22px; border-radius: 50%; background: var(--c2, var(--accent)); border: 3px solid #fff; cursor: nwse-resize; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }

/* Scanner */
.pdf-scan { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pdf-scan-stage { position: relative; line-height: 0; touch-action: none; }
.pdf-scan-view { display: block; border-radius: 8px; max-width: 100%; }
.pdf-scan-h { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: rgba(34, 211, 238, .25); border: 3px solid #22d3ee; box-shadow: 0 0 0 4px rgba(255, 255, 255, .7); cursor: grab; touch-action: none; transition: transform .15s; }
.pdf-scan-h.on { transform: scale(1.35); background: rgba(34, 211, 238, .5); }
.pdf-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .pdf-hero-art span, .pdf-card.pdf-in, .pdf-thumb:not(.ready) { animation: none; }
}
.pdf-thumb.no-fade { transition: none; }
.pdf-signer > .h-btn--block { position: sticky; bottom: 0; z-index: 3; box-shadow: 0 -12px 24px -10px var(--surface), 0 10px 24px -12px var(--c2, var(--accent)); }
button.pdf-feat { font: inherit; color: inherit; cursor: pointer; transition: border-color .15s, transform .15s; }
button.pdf-feat:hover { border-color: var(--accent); transform: translateY(-1px); }
.pdf-feats-h { margin: 0 0 8px; font-weight: 700; }
.pdf-feats + .pdf-hero { margin-top: 14px; }
