/* ═══════════════════════════════════════════════
   Document Scanner to PDF — style.css
   PDFStories — Production Ready
═══════════════════════════════════════════════ */

/* ── TOKENS ── */
:root {
  --accent: #1a6cff;
  --accent-2: #0d4fcb;
  --accent-glow: rgba(26,108,255,0.18);
  --danger: #ff3b30;
  --success: #30d158;
  --warning: #ffd60a;

  --bg: #0f1117;
  --bg-2: #181c26;
  --surface: #1e2230;
  --surface-2: #252a3a;
  --surface-3: #2d3347;
  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(26,108,255,0.5);

  --text: #f0f2f8;
  --text-2: #b0b8d0;
  --text-muted: #5a6278;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);

  --font: 'Cairo', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;

  --header-h: 60px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  direction: rtl;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input { font-family: var(--font); }
svg { flex-shrink: 0; }
img { max-width: 100%; display: block; }

/* ── LOADING SCREEN ── */
#loadingScreen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#loadingScreen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-content {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.loader-icon { width: 64px; height: 64px; animation: loaderPulse 1.4s ease infinite; }
@keyframes loaderPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.8; }
}
.loader-text {
  font-size: 18px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text);
}
.loader-bar {
  width: 160px; height: 3px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden;
}
.loader-fill {
  height: 100%; background: var(--accent);
  border-radius: 99px;
  animation: loaderBar 1.4s ease forwards;
}
@keyframes loaderBar {
  0% { width: 0%; }
  60% { width: 80%; }
  100% { width: 100%; }
}

/* ── HEADER ── */
#appHeader {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(15,17,23,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 640px; margin: 0 auto;
  height: 100%; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.brand-icon svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 15px; font-weight: 800; line-height: 1.1; }
.brand-sub { font-size: 10px; color: var(--text-muted); line-height: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.btn-lang {
  padding: 5px 12px;
  background: var(--surface-2);
  border-radius: 99px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  transition: var(--transition);
  border: 1px solid var(--border);
}
.btn-lang:hover { background: var(--surface-3); color: var(--text); }
.btn-icon {
  width: 36px; height: 36px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: var(--transition);
  border: 1px solid var(--border);
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { background: var(--surface-3); color: var(--text); }

/* ── MAIN ── */
#appMain {
  max-width: 640px; margin: 0 auto;
  padding: 0 0 100px;
}

/* ── STEPS ── */
.step { display: none; }
.step.active { display: block; animation: stepIn 0.3s ease; }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── STEP HEADER ── */
.step-header {
  position: sticky; top: var(--header-h); z-index: 90;
  background: rgba(15,17,23,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.btn-back {
  width: 38px; height: 38px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-back:hover { background: var(--surface-3); }
.btn-back svg { width: 18px; height: 18px; }
.step-title { flex: 1; }
.step-title h2 { font-size: 16px; font-weight: 700; }
.step-counter { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.btn-primary-sm {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border-radius: 99px;
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-primary-sm:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-primary-sm:active { transform: translateY(0); }

/* ── LANDING ── */
.landing-hero {
  padding: 40px 24px 28px;
  text-align: center;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(26,108,255,0.3);
  border-radius: 99px;
  font-size: 12px; font-weight: 600;
  margin-bottom: 20px;
  animation: badgePop 0.5s 0.3s ease both;
}
@keyframes badgePop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
.hero-title {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 14px;
  animation: heroSlide 0.5s 0.1s ease both;
}
@keyframes heroSlide {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero-title span {
  background: linear-gradient(135deg, #1a6cff, #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subtitle {
  font-size: 14px; color: var(--text-2); line-height: 1.6;
  animation: heroSlide 0.5s 0.2s ease both;
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  margin: 0 16px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  animation: heroSlide 0.5s 0.25s ease both;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-inner {
  padding: 32px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.upload-icon { width: 72px; height: 72px; }
.upload-title { font-size: 15px; font-weight: 600; }
.upload-sub { font-size: 13px; color: var(--text-muted); }
.upload-drop-overlay {
  position: absolute; inset: 0;
  background: rgba(26,108,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: var(--accent);
  opacity: 0; pointer-events: none;
  transition: var(--transition);
}
.upload-zone.drag-over .upload-drop-overlay { opacity: 1; }

/* ── ACTION CARDS ── */
.action-cards {
  padding: 0 16px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 24px;
  animation: heroSlide 0.5s 0.3s ease both;
}
.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.action-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent, rgba(26,108,255,0.05));
  opacity: 0; transition: var(--transition);
}
.action-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(26,108,255,0.15); }
.action-card:hover::before { opacity: 1; }
.action-card:active { transform: translateY(0); }
.card-icon {
  width: 44px; height: 44px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.camera-card .card-icon { background: rgba(26,108,255,0.1); color: var(--accent); }
.gallery-card .card-icon { background: rgba(48,209,88,0.1); color: var(--success); }
.card-icon svg { width: 22px; height: 22px; }
.card-body { flex: 1; }
.card-body h3 { font-size: 14px; font-weight: 700; }
.card-body p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.card-arrow {
  color: var(--text-muted); font-size: 16px;
  transition: var(--transition);
}
.action-card:hover .card-arrow { color: var(--accent); transform: translateX(-4px); }

/* ── FEATURES STRIP ── */
.features-strip {
  padding: 0 16px 24px;
  display: flex; gap: 8px; overflow-x: auto;
  scrollbar-width: none;
  animation: heroSlide 0.5s 0.35s ease both;
}
.features-strip::-webkit-scrollbar { display: none; }
.feat {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 12px; color: var(--text-2);
}
.feat-icon { font-size: 14px; }

/* ── CROP WORKSPACE ── */
.crop-workspace {
  padding: 16px;
  min-height: calc(100vh - var(--header-h) - 120px - 80px);
  display: flex; align-items: center; justify-content: center;
}
.crop-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}
#cropCanvas { display: block; width: 100%; height: auto; }
.crop-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.crop-poly {
  fill: rgba(26,108,255,0.08);
  stroke: var(--accent);
  stroke-width: 2;
}
.crop-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}
.crop-handle {
  fill: var(--accent);
  stroke: white;
  stroke-width: 2;
  cursor: grab;
  filter: drop-shadow(0 2px 6px rgba(26,108,255,0.5));
  transition: r 0.15s ease;
}
.crop-handle:active { cursor: grabbing; }

.crop-tools {
  padding: 12px 16px;
  display: flex; gap: 8px; justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 11px;
  transition: var(--transition);
  flex: 1;
}
.tool-btn svg { width: 20px; height: 20px; }
.tool-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--accent); }
.tool-btn:active { transform: scale(0.97); }

/* ── ENHANCE ── */
.enhance-preview-wrap {
  padding: 16px;
  position: relative;
}
.enhance-canvas {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.enhance-badge {
  position: absolute;
  top: 24px; right: 24px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  color: white;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px; font-weight: 600;
  pointer-events: none;
}

.filter-scroll {
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
}
.filter-options {
  display: flex; gap: 10px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-options::-webkit-scrollbar { display: none; }
.filter-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; flex-shrink: 0;
}
.filter-thumb {
  width: 60px; height: 72px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}
.filter-item.active .filter-thumb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.filter-item span { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.filter-item.active span { color: var(--accent); font-weight: 600; }

.adjust-sliders {
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.slider-row {
  display: flex; align-items: center; gap: 12px;
}
.slider-row label {
  font-size: 13px; color: var(--text-2); flex-shrink: 0; width: 55px;
}
.slider-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  outline: none;
}
.slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent-glow);
  cursor: pointer;
  transition: transform 0.15s;
}
.slider-row input[type=range]::-webkit-slider-thumb:active { transform: scale(1.2); }
.slider-row input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.slider-row span {
  font-size: 12px; color: var(--text-muted);
  font-family: var(--font-mono);
  width: 28px; text-align: center; flex-shrink: 0;
}

/* ── PAGES MANAGER ── */
.pages-toolbar {
  padding: 10px 16px;
  display: flex; gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.pages-tool-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  transition: var(--transition);
}
.pages-tool-btn svg { width: 16px; height: 16px; }
.pages-tool-btn:hover { background: var(--surface-3); color: var(--text); }
.pages-tool-btn.danger { color: var(--danger); }
.pages-tool-btn.danger:hover { background: rgba(255,59,48,0.1); border-color: var(--danger); }
.pages-tool-btn:disabled { opacity: 0.4; pointer-events: none; }

.pages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}
@media (min-width: 480px) {
  .pages-grid { grid-template-columns: repeat(3, 1fr); }
}

.page-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  user-select: none;
}
.page-card:hover { border-color: var(--accent); }
.page-card.selected { border-color: var(--accent); }
.page-card.selected::after {
  content: '✓';
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: var(--accent);
  color: white; font-size: 12px; font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.page-thumb {
  width: 100%; aspect-ratio: 3/4;
  background: var(--surface-2);
  object-fit: cover;
  display: block;
}
.page-foot {
  padding: 6px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-num {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
}
.page-more {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  border-radius: 4px;
  transition: var(--transition);
}
.page-more:hover { background: var(--surface-3); color: var(--text); }
.page-more svg { width: 14px; height: 14px; }

.pages-empty {
  padding: 60px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px; line-height: 1.6;
}

/* Sortable */
.sortable-ghost { opacity: 0.4; }
.sortable-drag {
  opacity: 1 !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  transform: rotate(2deg) scale(1.04);
}

/* ── EXPORT ── */
.export-settings {
  padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
}
.settings-group {}
.settings-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.seg-control {
  display: flex; gap: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.seg-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.seg-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(26,108,255,0.4);
}
.seg-btn:hover:not(.active) { background: var(--surface-3); color: var(--text); }

.text-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  direction: ltr;
  text-align: right;
}
.text-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.text-input::placeholder { color: var(--text-muted); }

.pdf-preview-strip {
  display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.pdf-preview-strip::-webkit-scrollbar { display: none; }
.pdf-preview-strip img {
  height: 80px; width: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.pdf-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  background: var(--surface-2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.meta-sep { color: var(--border); }

/* ── EXPORT ACTIONS ── */
.export-actions {
  padding: 0 16px 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.btn-export {
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius);
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: var(--transition);
  position: relative; overflow: hidden;
}
.btn-export.pdf {
  background: linear-gradient(135deg, #1a6cff, #0d4fcb);
  color: white;
  box-shadow: 0 4px 24px rgba(26,108,255,0.4);
}
.btn-export.pdf:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(26,108,255,0.5); }
.btn-export.pdf:active { transform: translateY(0); }
.btn-export.pdf::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}
.export-secondary { display: flex; gap: 10px; }
.btn-export-sm {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--transition);
}
.btn-export-sm:hover { background: var(--surface-2); border-color: var(--text-muted); }

/* ── CAMERA MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open {
  display: flex;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-container {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 640px;
  max-height: 96vh;
  overflow: hidden;
  animation: modalUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  padding: 16px 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.camera-header-actions { display: flex; gap: 8px; }

.camera-modal { border-radius: var(--radius) var(--radius) 0 0; }
.camera-viewfinder {
  position: relative;
  background: #000;
  aspect-ratio: 4/3;
  overflow: hidden;
}
#cameraVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder-overlay {
  position: absolute; inset: 20px;
  pointer-events: none;
}
.vf-corner {
  position: absolute;
  width: 24px; height: 24px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}
.vf-corner.tl { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; }
.vf-corner.tr { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; }
.vf-corner.bl { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; }
.vf-corner.br { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; }
.camera-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 12px;
  white-space: nowrap;
}
.camera-controls {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.camera-count {
  font-size: 13px; color: var(--text-2);
  font-family: var(--font-mono);
  min-width: 60px;
}
.btn-capture {
  width: 68px; height: 68px;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s;
}
.btn-capture:active { transform: scale(0.94); }
.capture-ring {
  position: absolute; inset: 0;
  border: 3px solid var(--accent);
  border-radius: 50%;
}
.capture-dot {
  position: absolute; inset: 7px;
  background: white;
  border-radius: 50%;
  transition: background 0.15s;
}
.btn-capture:active .capture-dot { background: var(--accent); }
.camera-done {
  background: var(--accent);
  color: white;
  border-color: transparent;
  min-width: 60px;
}
.camera-done:hover { background: var(--accent-2); }
.camera-done:disabled { opacity: 0.4; pointer-events: none; }

/* ── CONTEXT MENU ── */
.context-menu {
  position: fixed; z-index: 2000;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 180px;
  overflow: hidden;
  display: none;
  animation: menuPop 0.15s ease;
}
@keyframes menuPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.context-menu.open { display: block; }
.context-menu button {
  width: 100%;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--text);
  text-align: right;
  transition: background 0.15s;
}
.context-menu button:hover { background: var(--surface-3); }
.context-menu button.danger { color: var(--danger); }
.menu-separator { height: 1px; background: var(--border); margin: 2px 0; }

/* ── PROGRESS ── */
.progress-overlay { align-items: center; justify-content: center; }
.progress-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-width: 200px;
  animation: modalUp 0.3s ease;
  box-shadow: var(--shadow);
}
.progress-icon { position: relative; }
#progressCircle { transition: stroke-dashoffset 0.3s ease; transform-origin: center; transform: rotate(-90deg); }
.progress-label { font-size: 14px; font-weight: 600; }
.progress-pct { font-size: 24px; font-weight: 800; color: var(--accent); font-family: var(--font-mono); }

/* ── TOAST ── */
#toastContainer {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9000;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: 90%; max-width: 360px;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--accent); color: var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.9); }
}

/* ── HELP MODAL ── */
.help-modal { border-radius: var(--radius) var(--radius) 0 0; padding-bottom: 24px; }
.help-content { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.help-step {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.help-step:hover { background: var(--surface-2); }
.help-num {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  margin-top: 1px;
}
.help-step h4 { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.help-step p { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.btn-primary {
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-2); }
.full-w { width: calc(100% - 32px); margin: 0 16px; }

/* ── ENGLISH LTR ── */
body.ltr {
  direction: ltr;
}
body.ltr .step-header,
body.ltr .header-inner { direction: ltr; }
body.ltr .card-arrow { transform: none; }
body.ltr .action-card:hover .card-arrow { transform: translateX(4px); }

/* ── UTILITIES ── */
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── RESPONSIVE ── */
@media (max-width: 360px) {
  .action-cards { grid-template-columns: 1fr; }
  .seg-btn { font-size: 11px; padding: 7px 4px; }
}
@media (min-width: 640px) {
  .modal-container { border-radius: var(--radius); max-height: 88vh; }
  .camera-modal { border-radius: var(--radius); }
  .help-modal { border-radius: var(--radius); }
  .modal-overlay { align-items: center; }
}

/* ── PRINT ── */
@media print { #appHeader, .step-header { display: none; } }
