/* ═══ Fast Scan – Liquid-Glass-Sheet ═══
   Größe der Kacheln passt sich dem Bildschirm an (--fs-tile), damit alles
   ohne Scrollen sichtbar ist. Nur das Overlay hat Unschärfe (einmal), das
   Sheet selbst nicht → flüssig auch auf schwachen Geräten. */

#fast-scan-ui {
  position: fixed; inset: 0;
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(5,3,14,0.62);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: fsFade .28s ease both;
}
#fast-scan-ui.closing { animation: fsFadeOut .26s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes fsFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fsFadeOut { from { opacity: 1; } to { opacity: 0; } }

#fast-scan-ui .fast-scan-container {
  --fs-tile: clamp(118px, min(calc((100vw - 84px) / 2), calc(100dvh - 400px)), 252px);
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  margin: auto;
  box-sizing: border-box;
  display: flex; flex-direction: column;
  padding: 16px 18px 14px;
  border-radius: 32px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09) 0%, rgba(255,255,255,0.02) 22%, rgba(255,255,255,0) 45%),
    linear-gradient(160deg, rgba(58,38,102,0.78) 0%, rgba(24,17,44,0.86) 42%, rgba(14,10,28,0.92) 100%);
  border: 1px solid rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.30);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,0.22),
    inset 0 -1px 1px rgba(255,255,255,0.05),
    inset 0 -30px 60px -40px rgba(168,85,247,0.45),
    0 30px 80px -20px rgba(0,0,0,0.75),
    0 0 0 0.5px rgba(168,85,247,0.25);
  animation: fsSheetIn .42s cubic-bezier(.2,.9,.25,1.05) both;
  scrollbar-width: none;
}
#fast-scan-ui .fast-scan-container::-webkit-scrollbar { display: none; }
@keyframes fsSheetIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }

/* Kopf */
#fast-scan-ui .fs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#fast-scan-ui .fs-head-text { text-align: left; min-width: 0; }
#fast-scan-ui .fast-scan-title {
  margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15;
  color: #fff; background: none; -webkit-text-fill-color: currentColor;
}
#fast-scan-ui .fs-head-sub { display: flex; gap: 6px; align-items: center; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: rgba(245,245,247,0.55); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fast-scan-ui .fs-lang { color: #d8b4fe; }
#fast-scan-ui .fs-dot { opacity: .5; }
#fast-scan-ui .fs-done-btn {
  flex-shrink: 0;
  height: 36px; padding: 0 16px;
  border-radius: 100px;
  font: 700 14px/1 inherit; font-family: inherit;
  color: #fff; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.20), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.16);
  border-top-color: rgba(255,255,255,0.36);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.25), 0 4px 14px -4px rgba(0,0,0,0.5);
  transition: transform .15s ease, background .15s;
}
#fast-scan-ui .fs-done-btn:hover { background: linear-gradient(180deg, rgba(255,255,255,0.26), rgba(255,255,255,0.12)); }
#fast-scan-ui .fs-done-btn:active { transform: scale(.95); }

/* Fortschritt */
#fast-scan-ui .fs-progress { height: 5px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; box-shadow: inset 0 1px 1px rgba(0,0,0,0.3); }
#fast-scan-ui .progress-bar-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #a855f7, #e879f9);
  box-shadow: 0 0 12px rgba(217,70,239,0.7);
  transition: width .35s cubic-bezier(.4,0,.2,1);
  animation: none;
}
#fast-scan-ui .fast-scan-subtitle { margin: 10px 0 0; font-size: 12.5px; line-height: 1.45; color: rgba(245,245,247,0.6); text-align: left; }

#fast-scan-ui .fs-options { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 10px; min-height: 22px; font-size: 12.5px; color: rgba(245,245,247,0.72); }
#fast-scan-ui .fs-saved-badge { margin: 0; font-size: 11px; padding: 3px 9px; cursor: help; white-space: nowrap; }

/* Bühne mit den zwei Kacheln */
#fast-scan-ui .canvas-section {
  display: flex; flex-direction: row; align-items: flex-start; justify-content: center; flex-wrap: nowrap;
  gap: 14px; margin: 0 0 12px; padding: 0;
  background: none; border: none; box-shadow: none; border-radius: 0;
}
#fast-scan-ui .fs-tile-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; width: var(--fs-tile); }
#fast-scan-ui .fs-tile-label { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: rgba(216,180,254,0.8); }
#fast-scan-ui .fs-form-label { min-height: 30px; font-size: 11.5px; line-height: 1.3; color: rgba(245,245,247,0.62); text-align: center; visibility: hidden; }
#fast-scan-ui .fs-form-label b { color: #fcd34d; font-weight: 700; }
#fast-scan-ui .fs-form-label-ghost { visibility: hidden !important; }
#fast-scan-ui .fs-form-label:empty { min-height: 0; }

#fast-scan-ui .letter-guide-container,
#fast-scan-ui .canvas-wrapper {
  position: relative;
  width: var(--fs-tile); height: var(--fs-tile);
  margin: 0;
  border-radius: 24px;
  overflow: hidden;
  background: #1b1430;
  border: 1px solid rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.24);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.12), 0 14px 34px -12px rgba(0,0,0,0.7);
  flex-shrink: 0;
}
#fast-scan-ui .canvas-wrapper {
  border-color: rgba(192,132,252,0.55);
  border-top-color: rgba(233,213,255,0.6);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.14), 0 0 0 4px rgba(168,85,247,0.12), 0 14px 34px -12px rgba(0,0,0,0.7), 0 0 30px -6px rgba(168,85,247,0.45);
  touch-action: none;
}
#fast-scan-ui .guide-image,
#fast-scan-ui #fastScanGuideImage { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
#fast-scan-ui #fastScanCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; cursor: crosshair; touch-action: none; background: transparent !important; }
#fast-scan-ui .fs-letter-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 1; }
#fast-scan-ui #current-fast-scan-letter {
  fill: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Naskh Arabic', 'Noto Sans Arabic', 'Noto Sans Hebrew', 'Noto Sans Armenian', 'Noto Sans Georgian', 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 500;
  paint-order: stroke; stroke: rgba(21,16,31,0.85); stroke-width: 16px; stroke-linejoin: round;
  filter: drop-shadow(0 0 22px rgba(192,132,252,0.55));
  transition: opacity .15s ease;
}
/* Verbindungs-Markierungen (Arabisch) */
#fast-scan-ui .fs-join { opacity: 0; transition: opacity .2s; }
#fast-scan-ui .fs-join.on { opacity: 1; }
#fast-scan-ui .fs-join line { stroke: #fcd34d; stroke-width: 30; stroke-linecap: round; stroke-dasharray: 34 30; }
#fast-scan-ui .fs-join circle { fill: #fcd34d; r: 36px; }

/* Pinsel · Rückgängig · Löschen */
#fast-scan-ui .fs-controls {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: 100px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.10);
  border-top-color: rgba(255,255,255,0.2);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.12);
}
#fast-scan-ui .fs-brush { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: rgba(245,245,247,0.55); }
#fast-scan-ui .fs-brush svg { flex-shrink: 0; }
#fast-scan-ui #brush-width-fastscan {
  flex: 1; min-width: 40px; height: 6px; margin: 0;
  -webkit-appearance: none; appearance: none; border: none; outline: none; cursor: pointer; border-radius: 3px;
  background: linear-gradient(to right, #a855f7 0, #c084fc var(--p, 50%), rgba(255,255,255,0.14) var(--p, 50%));
}
#fast-scan-ui #brush-width-fastscan::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #fff 0%, #f3e8ff 60%, #e9d5ff 100%);
  border: none; box-shadow: 0 2px 8px rgba(0,0,0,0.45), 0 0 0 0.5px rgba(0,0,0,0.2);
}
#fast-scan-ui #brush-width-fastscan::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: none;
  background: radial-gradient(circle at 50% 35%, #fff 0%, #f3e8ff 60%, #e9d5ff 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
#fast-scan-ui .fs-brush-val { min-width: 30px; text-align: right; font-size: 12px; font-weight: 700; color: rgba(245,245,247,0.7); font-variant-numeric: tabular-nums; }
#fast-scan-ui .fs-brush-dot { flex-shrink: 0; background: #fff; border-radius: 50%; box-shadow: 0 0 6px rgba(255,255,255,0.4); transition: width .15s, height .15s; }
#fast-scan-ui .fs-toolbar { display: flex; gap: 6px; width: auto; flex-shrink: 0; }
#fast-scan-ui .fs-icon-btn {
  position: static !important;
  width: 40px; height: 40px; padding: 0 !important; margin: 0;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  cursor: pointer;
  color: rgba(245,245,247,0.9);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.05));
  border: 1px solid rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.28);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.18), 0 3px 10px -3px rgba(0,0,0,0.5);
  transition: transform .15s ease, background .15s, opacity .15s;
  flex: none !important;
}
#fast-scan-ui .fs-icon-btn:hover:not(:disabled) { background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.08)); transform: none; }
#fast-scan-ui .fs-icon-btn:active:not(:disabled) { transform: scale(.92); }
#fast-scan-ui .fs-icon-btn:disabled { opacity: .35; cursor: default; }
#fast-scan-ui .fs-icon-btn.clear-button { color: #ff7a70; background: linear-gradient(180deg, rgba(255,69,58,0.22), rgba(255,69,58,0.08)); border-color: rgba(255,105,97,0.3); border-top-color: rgba(255,160,150,0.45); }
#fast-scan-ui .fs-icon-btn.clear-button:hover { background: linear-gradient(180deg, rgba(255,69,58,0.32), rgba(255,69,58,0.14)); }

/* Navigation */
#fast-scan-ui .nav-buttons { display: flex; gap: 10px; margin-top: 12px; flex-wrap: nowrap; justify-content: stretch; }
#fast-scan-ui .nav-button {
  flex: 1; min-width: 0;
  height: 50px; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 100px;
  font: 700 15px/1 inherit; font-family: inherit; letter-spacing: 0.005em;
  color: #fff; cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.04) 50%, rgba(255,255,255,0) 100%),
    linear-gradient(135deg, #a855f7 0%, #c026d3 100%);
  border: 1px solid rgba(233,213,255,0.35);
  border-top-color: rgba(255,255,255,0.55);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), inset 0 -2px 6px rgba(88,28,135,0.45), 0 10px 26px -10px rgba(192,38,211,0.8);
  transition: transform .15s ease, filter .15s, opacity .15s;
  overflow: hidden;
}
#fast-scan-ui .nav-button::after { display: none; }
#fast-scan-ui .nav-button:hover { transform: none; filter: brightness(1.08); background:
    linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.04) 50%, rgba(255,255,255,0) 100%),
    linear-gradient(135deg, #a855f7 0%, #c026d3 100%); box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), inset 0 -2px 6px rgba(88,28,135,0.45), 0 12px 28px -10px rgba(192,38,211,0.9); }
#fast-scan-ui .nav-button:active { transform: scale(.97); }
#fast-scan-ui #fs-next-btn { flex: 1.6; }
#fast-scan-ui .nav-button.secondary {
  color: rgba(245,245,247,0.92);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.05));
  border-color: rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.28);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.18), 0 6px 18px -8px rgba(0,0,0,0.6);
}
#fast-scan-ui .nav-button.secondary:hover { filter: none; background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.08)); box-shadow: inset 0 1px 1px rgba(255,255,255,0.18), 0 6px 18px -8px rgba(0,0,0,0.6); }
#fast-scan-ui .nav-button:disabled { opacity: .35; cursor: default; filter: none; transform: none; }

#fast-scan-ui .fs-hint { margin-top: 10px; font-size: 11px; color: rgba(245,245,247,0.38); text-align: center; }
#fast-scan-ui .fs-hint kbd { font-family: inherit; font-size: 10px; padding: 1px 5px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.06); }

/* RTL-Sprachen: Tafeln in Leserichtung (Vorlage rechts) */
#fast-scan-ui .fs-rtl .canvas-section { flex-direction: row-reverse; }

@media (max-width: 560px) {
  #fast-scan-ui { padding: 8px; }
  #fast-scan-ui .fast-scan-container { --fs-tile: clamp(118px, min(calc((100vw - 56px) / 2), calc(100dvh - 380px)), 240px); padding: 14px 12px 12px; border-radius: 28px; }
  #fast-scan-ui .canvas-section { gap: 10px; }
  #fast-scan-ui .fast-scan-title { font-size: 19px; }
  #fast-scan-ui .fs-hint { display: none; }
  #fast-scan-ui .fs-controls { padding-left: 12px; }
  #fast-scan-ui .fs-icon-btn { width: 38px; height: 38px; }
  #fast-scan-ui .fs-form-label { font-size: 10.5px; }
}
@media (max-height: 760px) {
  #fast-scan-ui .fast-scan-subtitle { display: none; }
  #fast-scan-ui .fs-hint { display: none; }
}
@media (hover: none) { #fast-scan-ui .fs-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { #fast-scan-ui, #fast-scan-ui .fast-scan-container { animation: none; } }
