:root {
  --ink: #0b2f6b;
  --paper: #f6f4ee;
  --paper-line: #e4e0d4;
  --panel: #ffffff;
  --text: #1c1c1c;
  --text-muted: #6b6558;
  --accent: #b3541e;
  --accent-soft: #f2e3d5;
  --border: #ddd7c8;
  --danger: #a3311a;
  --good: #2f6b3a;
  --radius: 6px;
  --sans: 'Inter', 'Noto Sans Bengali', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', var(--sans);
  background: var(--bg-main, #f8fafc);
  color: var(--text-main, #0f172a);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Breadcrumb Sub-Header */
.studio-top-bar {
  background: var(--bg-card-subtle, #f1f5f9);
  border-bottom: 1px solid var(--border-light, #e2e8f0);
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.studio-breadcrumbs {
  font-size: 0.88rem;
  color: var(--text-muted, #64748b);
  font-weight: 600;
}
.studio-breadcrumbs a {
  color: var(--brand-primary, #2563eb);
  font-weight: 700;
  text-decoration: none;
}

/* Page Outer Wrapper */
.sff-page-wrapper {
  width: 100%;
  max-width: 100%;
  padding: 6px 14px 20px;
  flex: 1;
  box-sizing: border-box;
}

/* Home button in top bar */
.sff-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--radius);
  transition: all 0.15s ease;
  margin-right: 4px;
}
.sff-home-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
  color: #fff;
}

/* ==========================================================================
   SMART FORM FILLER APPLICATION CARD WORKSPACE
   ========================================================================== */
.sff-app-card {
  width: 100%;
  height: calc(100vh - 20px);
  min-height: 650px;
  max-height: none;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
  position: relative;
}

/* ---------- Top bar ---------- */
.sff-app-card .app-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--ink);
  color: #fff;
  flex-wrap: wrap;
  border-bottom: 3px solid var(--accent);
  z-index: 10;
}

.sff-app-card .brand { display: flex; align-items: center; gap: 10px; }
.sff-app-card .brand-mark {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Sans Bengali', sans-serif;
  font-weight: 700;
  font-size: 16px;
}
.sff-app-card .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sff-app-card .brand-text strong { font-size: 14px; }
.sff-app-card .brand-text small { color: #cdd8ee; font-size: 11px; }

.sff-app-card .modes,
.sff-app-card .zoom-group,
.sff-app-card .page-group,
.sff-app-card .actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sff-app-card .mode-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}
.sff-app-card .mode-btn:hover { background: rgba(255,255,255,.15); }
.sff-app-card .mode-btn.active { background: var(--accent); border-color: var(--accent); }

.sff-app-card .icon-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  width: 28px; height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: 0.15s;
}
.sff-app-card .icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.sff-app-card .icon-btn:disabled { opacity: .35; cursor: default; }
#zoomLabel, #pageLabel { font-size: 12px; color: #dce4f4; min-width: 62px; text-align: center; }

.sff-app-card .actions { margin-left: auto; }
.sff-app-card .btn {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: 7px 13px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}
.sff-app-card .btn:hover { background: rgba(255,255,255,.2); }
.sff-app-card .btn-accent { background: var(--accent); border-color: var(--accent); }
.sff-app-card .btn-accent:hover { background: #964214; }
.sff-app-card .btn-primary { background: #fff; color: var(--ink); font-weight: 600; border-color: #fff; }
.sff-app-card .btn-primary:hover { background: #f0f4fa; }

/* ---------- Workspace ---------- */
.sff-app-card .workspace { flex: 1; display: flex; min-height: 0; }

.sff-app-card .sidebar {
  width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sff-app-card .tabs { display: flex; border-bottom: 1px solid var(--border); }
.sff-app-card .tab-btn {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.sff-app-card .tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

.sff-app-card .tab-panel { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 12px; overflow-y: auto; }
.sff-app-card .tab-panel.active { display: flex; }

.sff-app-card .panel-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.sff-app-card .btn-sm {
  background: var(--paper);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--text);
  transition: 0.15s;
}
.sff-app-card .btn-sm:hover { background: var(--panel); }
.sff-app-card .btn-sm.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.sff-app-card .btn-sm.btn-accent:hover { background: #964214; }

.sff-app-card .scroll-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; margin: 0 0 8px; }

.settings-block { margin-bottom: 18px; }
.settings-block h4 { margin: 0 0 6px; font-size: 13px; color: var(--text); font-weight: 700; }
.settings-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.settings-row label { font-size: 12.5px; color: var(--text-muted); }

/* Google Gemini AI Config (Web Crypto AES-256 Encrypted) */
.sff-options-card {
  background: var(--paper, #fdfbfa);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 12px;
  color: var(--text);
}
.sff-options-card code {
  font-family: monospace;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.sff-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
}
.sff-status-badge.badge-default,
.sff-status-badge.badge-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.sff-status-badge.badge-gemini,
.sff-status-badge.badge-encrypted {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.sff-status-notice {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}
.sff-status-notice code {
  font-family: monospace;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.sff-status-notice.notice-default,
.sff-status-notice.notice-warning {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  color: #92400e;
}
.sff-status-notice.notice-gemini,
.sff-status-notice.notice-encrypted {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.sff-key-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.sff-key-input-wrap input {
  padding-right: 36px;
}
.sff-key-toggle-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}
.sff-key-toggle-btn:hover {
  color: var(--text);
  background: rgba(0,0,0,0.05);
}

.text-input, .num-input, .select-input {
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  background: #fff;
  color: var(--text);
}
.num-input { width: 80px; }

/* ---------- Field cards ---------- */
.field-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--paper);
}
.field-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }

.field-label-input {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 4px;
  transition: all 0.15s ease;
}
.field-label-input.locked {
  cursor: default;
  user-select: none;
  background: transparent;
  border-color: transparent;
}
.field-label-input:not(.locked) {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: text;
}

.field-rename-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.65;
  transition: all 0.15s ease;
}
.field-rename-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,0.06);
  color: var(--ink);
}

.field-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 8px; white-space: nowrap;
}
.field-tag.acroform { background: #e2f0e5; color: var(--good); }
.field-tag.gemini { background: #fdeee0; color: var(--accent); }
.field-tag.manual { background: #e7ecf6; color: var(--ink); }
.field-tag.template { background: #dcfce7; color: #15803d; }
.field-del { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 14px; }

.field-value-input, .field-value-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; font-family: var(--sans); font-size: 13px; background: #fff; color: var(--text);
}
.field-value-textarea { resize: vertical; min-height: 44px; }
.field-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }

/* Inline Floating Direct On-Form Editor */
.sff-inline-editor-wrap {
  position: absolute;
  z-index: 100;
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.28));
  animation: sffPopIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes sffPopIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.sff-inline-editor-input {
  background: #ffffff !important;
  color: #0b2f6b !important;
  border: 2px solid var(--accent, #b3541e) !important;
  border-radius: 4px !important;
  padding: 0 4px !important;
  box-sizing: border-box !important;
  outline: none !important;
  width: 100% !important;
  font-family: 'Noto Sans Bengali', 'Inter', sans-serif !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
}
textarea.sff-inline-editor-input {
  padding: 4px !important;
  line-height: 1.35 !important;
  resize: vertical;
  min-height: 50px;
}
.sff-inline-editor-badge {
  font-size: 10.5px;
  font-weight: 600;
  background: #1e293b;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 3px;
  align-self: flex-start;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  user-select: none;
}
.sff-inline-badge-title {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sff-inline-font-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 1px 4px;
  border: 1px solid rgba(255,255,255,0.22);
}
.sff-font-btn {
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  cursor: pointer;
  line-height: 1.2;
  font-family: inherit;
  transition: all 0.1s ease;
}
.sff-font-btn:hover {
  background: rgba(255,255,255,0.45);
  transform: scale(1.05);
}
.sff-font-size-label {
  font-size: 11px;
  font-weight: 800;
  color: #93c5fd;
  min-width: 26px;
  text-align: center;
}
.sff-font-autofit {
  background: #2563eb;
  border-color: #3b82f6;
  color: #fff;
}
.sff-font-autofit:hover {
  background: #1d4ed8;
}

/* Sidebar Field Card Font Size Controls */
.field-font-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  background: #fff;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.field-font-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  color: #334155;
  cursor: pointer;
  line-height: 1.2;
}
.field-font-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.field-font-val {
  font-size: 10.5px;
  color: #0f172a;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

.review-card { border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px; background: var(--accent-soft); }
.review-meta { font-size: 11px; color: var(--text-muted); margin: 3px 0 8px; }
.review-actions { display: flex; gap: 6px; }

/* Auto-Matched Template Banner */
.auto-template-banner {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #6ee7b7;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 860px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12);
  animation: sffSlideDown 0.25s ease-out;
  z-index: 10;
}
@keyframes sffSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.auto-template-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auto-template-icon {
  font-size: 22px;
  line-height: 1;
}
.auto-template-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.auto-template-text strong {
  font-size: 13.5px;
  color: #065f46;
  font-weight: 700;
}
.auto-template-text small {
  font-size: 12px;
  color: #047857;
  line-height: 1.4;
}
.auto-template-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.btn-rescan {
  background: #fff;
  border: 1.5px solid #10b981;
  color: #047857;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: 0.15s;
}
.btn-rescan:hover {
  background: #d1fae5;
  border-color: #059669;
}
.btn-close-banner {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #059669;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
}
.btn-close-banner:hover {
  color: #064e3b;
  background: rgba(0,0,0,0.05);
}

.template-active-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  margin-left: 8px;
  display: inline-block;
}

/* ---------- Stage Area ---------- */
.sff-app-card .stage-area {
  flex: 1;
  overflow: auto;
  background: #d9d4c4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 30px 40px;
  position: relative;
}
.sff-app-card .stage-inner { position: relative; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#pageCanvas { display: block; background: #fff; }
#overlay { position: absolute; top: 0; left: 0; }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 5;
}

/* Interactive Dropzone Card in Page View */
.dropzone-card {
  background: #ffffff;
  border: 2px dashed #93c5fd;
  border-radius: 16px;
  padding: 36px 28px;
  text-align: center;
  max-width: 480px;
  width: 92%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}
.dropzone-card:hover,
.dropzone-card.drag-hover {
  border-color: #2563eb;
  background: #eff6ff;
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.16);
}
.dropzone-icon-wrap {
  width: 62px;
  height: 62px;
  background: #dbeafe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.dropzone-icon {
  font-size: 32px;
}
.dropzone-title {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px 0;
  line-height: 1.35;
}
.dropzone-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 18px 0;
}
.dropzone-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 20px;
}
.dz-pill {
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  padding: 3px 9px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
}
.dropzone-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.dropzone-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

/* Drag overlay when document already open */
.stage-drag-overlay {
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  pointer-events: none;
  animation: sffFadeIn 0.15s ease-out;
}
@keyframes sffFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.stage-drag-content {
  background: #fff;
  padding: 26px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  animation: sffPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.stage-drag-icon { font-size: 42px; display: block; margin-bottom: 8px; }
.stage-drag-content h3 { margin: 0; font-size: 18px; color: #1e3a8a; font-weight: 800; }

/* Quick Stamp Side Toolbar */
.quick-stamp-toolbar {
  position: sticky;
  top: 6px;
  z-index: 30;
  align-self: center;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 30px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  user-select: none;
}
.quick-stamp-header {
  padding-right: 6px;
  border-right: 1px solid #e2e8f0;
  margin-right: 2px;
}
.quick-stamp-title {
  font-size: 11px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.quick-stamp-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stamp-tool-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 5px 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.stamp-tool-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}
.stamp-tool-btn.is-active {
  background: #2563eb !important;
  border-color: #1d4ed8 !important;
  color: #fff !important;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
}
.stamp-tool-btn.is-active .stamp-icon {
  transform: scale(1.15);
}
.stamp-icon { font-size: 13px; line-height: 1; }
.stamp-text { line-height: 1; }

.field-box {
  position: absolute;
  border: 1.5px dashed rgba(11,47,107,.55);
  background: rgba(11,47,107,.04);
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-sizing: border-box;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex;
  align-items: center;
  padding: 0 4px;
  overflow: visible;
}
.field-box.textarea-type {
  align-items: flex-start;
  padding-top: 4px;
}
.field-box.checkbox-type {
  border-style: solid;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: visible !important;
  padding: 0;
}
.field-box.needs-review { border-color: var(--accent); background: rgba(179,84,30,.08); }
.field-box.is-selected {
  border-color: var(--accent) !important;
  border-style: solid !important;
  border-width: 2px !important;
  box-shadow: 0 0 0 2px rgba(179,84,30,.25);
  z-index: 10;
}

.field-box.is-hovered {
  background: rgba(11,47,107,.14);
  border-color: var(--ink) !important;
  border-width: 2px;
  border-style: dashed;
  box-shadow: 0 0 0 2px rgba(11,47,107,.18);
  z-index: 5;
}
.field-box.fill-mode {
  cursor: text;
  border-style: dashed;
  border-color: rgba(11,47,107,.35);
  background: rgba(11,47,107,.02);
}
.field-box.fill-mode.checkbox-type {
  cursor: pointer;
}
.field-box.fill-mode:hover {
  background: rgba(11,47,107,.10);
  border-color: var(--ink) !important;
}
.field-box.fill-mode.is-hovered { border-style: dashed; }
.field-box.search-matched {
  border-color: #2563eb !important;
  border-style: solid !important;
  background: rgba(37, 99, 235, 0.12) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35) !important;
  z-index: 12 !important;
}

/* Active Dragging State */
.field-box.is-dragging {
  cursor: grabbing !important;
  opacity: 0.95;
  border-color: #2563eb !important;
  border-style: solid !important;
  border-width: 2.5px !important;
  background: rgba(37, 99, 235, 0.18) !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35), 0 0 0 3px rgba(37, 99, 235, 0.3) !important;
  z-index: 100 !important;
}

body.sff-is-dragging,
body.sff-is-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

/* Move handle badge attached to top of field */
.field-move-handle {
  position: absolute;
  top: -19px;
  left: -1px;
  background: var(--ink, #0b2f6b);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px 3px 0 0;
  pointer-events: none;
  display: none;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.15);
  z-index: 20;
}
.field-box:hover .field-move-handle,
.field-box.is-selected .field-move-handle,
.field-box.is-dragging .field-move-handle {
  display: flex;
}
.field-box.is-dragging .field-move-handle {
  background: #2563eb;
}

/* Floating Drag Position Indicator */
.sff-drag-indicator {
  position: fixed;
  z-index: 3000;
  background: #0f172a;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.15);
}

.overlay-text {
  font-family: var(--sans);
  font-weight: 600;
  white-space: pre;
  pointer-events: none;
  line-height: 1.2;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.field-box.textarea-type .overlay-text {
  white-space: pre-wrap;
  line-height: 1.35;
  overflow-wrap: break-word;
}
.overlay-check {
  pointer-events: none;
  font-family: 'Noto Sans Bengali', Arial, sans-serif;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
  transform: translateY(-3%);
  filter: drop-shadow(0 0 0.5px currentColor);
}
.overlay-hint { font-size: 10px; color: rgba(11,47,107,.55); pointer-events: none; padding: 2px; }

/* Resize handles (মাউস দিয়ে টেনে লম্বা বা খাটো করার হ্যান্ডেল) */
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--accent, #b3541e);
  border: 1.5px solid #fff;
  border-radius: 50%;
  z-index: 30;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transition: transform 0.1s ease, background 0.1s ease;
  touch-action: none;
  user-select: none;
  display: none;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
}

.field-box:hover .resize-handle,
.field-box.is-selected .resize-handle,
.field-box.edit-mode .resize-handle {
  display: block;
}

.field-box.is-dragging .resize-handle {
  display: none !important;
}

.resize-handle:hover {
  transform: scale(1.35);
  background: #2563eb;
  z-index: 35;
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }

/* East handle: prominent stretch bar for dragging field longer or shorter */
.handle-e  {
  top: calc(50% - 11px);
  right: -5px;
  height: 22px;
  width: 8px;
  border-radius: 4px;
  cursor: ew-resize;
  background: #2563eb;
}
.handle-e:hover {
  background: #1d4ed8;
  transform: scaleX(1.35) scaleY(1.1);
}

.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }

/* West handle: stretch bar on left */
.handle-w  {
  top: calc(50% - 11px);
  left: -5px;
  height: 22px;
  width: 8px;
  border-radius: 4px;
  cursor: ew-resize;
  background: #2563eb;
}
.handle-w:hover {
  background: #1d4ed8;
  transform: scaleX(1.35) scaleY(1.1);
}

body.sff-is-resizing,
body.sff-is-resizing * {
  user-select: none !important;
  cursor: ew-resize !important;
}

.drawing-box {
  position: absolute; border: 1.5px dashed var(--accent); background: rgba(179,84,30,.08);
}

/* ---------- Hover Tooltip ---------- */
.hover-tip {
  position: fixed;
  z-index: 80;
  background: #1c1c1c;
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.35;
  max-width: 280px;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* ---------- Toast / Busy ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1c1c1c; color: #fff; padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; z-index: 2500; box-shadow: 0 6px 20px rgba(0,0,0,0.3); font-weight: 600;
}
.busy-banner {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 16px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); z-index: 2600; font-size: 12.5px; font-weight: 600;
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Supported File Types Grid */
.supported-types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.supported-type-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}
.supported-type-badge {
  display: inline-block;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--brand-primary);
  color: #fff;
  margin-bottom: 0.5rem;
}

/* Steps 4-Col Grid */
.steps-grid-4col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}
.step-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.4rem;
  position: relative;
}
.step-num-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .sff-app-card {
    height: 920px;
    max-height: none;
  }
  .sff-app-card .workspace {
    flex-direction: column-reverse;
  }
  .sff-app-card .sidebar {
    width: 100%;
    height: 390px;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .sff-app-card .stage-area {
    flex: 1;
    min-height: 400px;
    padding: 15px;
  }
  .sff-app-card .app-bar {
    gap: 8px;
    padding: 8px 12px;
  }
}

@media (max-width: 580px) {
  .sff-app-card {
    height: 980px;
    border-radius: 12px;
  }
  .sff-app-card .app-bar {
    gap: 6px;
    padding: 8px 10px;
  }
  .sff-app-card .modes,
  .sff-app-card .zoom-group,
  .sff-app-card .page-group {
    gap: 4px;
  }
  .sff-app-card .mode-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .sff-app-card .btn {
    padding: 5px 9px;
    font-size: 11.5px;
  }
  .sff-app-card .actions {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    margin-top: 4px;
  }
  .sff-app-card .sidebar {
    height: 440px;
  }
  .tool-hero-title {
    font-size: 1.8rem;
  }
}
