/* ═══════════════════════════════════════════════════════
   CLONYPDF EDITOR — PREMIUM SAAS UI v2.0
   Reset & Custom Properties
═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --blue:         #2563EB;
  --blue-hover:   #1D4ED8;
  --blue-light:   #EFF6FF;
  --blue-mid:     #BFDBFE;
  --blue-50:      #F0F7FF;
  --blue-glow:    rgba(37,99,235,.18);
  --orange:       #F97316;
  --orange-light: #FFF7ED;

  /* Ink */
  --ink:    #0F172A;
  --ink-2:  #1E293B;
  --ink-3:  #334155;
  --muted:  #64748B;
  --muted-2:#94A3B8;

  /* Surfaces */
  --border:   #E2E8F0;
  --border-2: #CBD5E1;
  --bg:       #F8FAFC;
  --bg-2:     #F1F5F9;
  --surface:  #FFFFFF;

  /* Status */
  --red:         #EF4444;
  --red-light:   #FEE2E2;
  --green:       #16A34A;
  --green-light: #DCFCE7;
  --yellow:      #F59E0B;

  /* Sidebar — Dark Nav */
  --sidebar-bg:        #181C27;
  --sidebar-bg-2:      #1E2334;
  --sidebar-border:    #252C3A;
  --sidebar-text:      #9299A8;
  --sidebar-text-dim:  #4E5668;
  --sidebar-icon:      #6B7585;
  --sidebar-hover-bg:  rgba(255,255,255,.055);
  --sidebar-active-bg: rgba(37,99,235,.14);
  --sidebar-active-border: #2563EB;

  /* Canvas */
  --canvas-bg:   #C4C8D2;

  /* Radii */
  --radius-sm:  5px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(15,23,42,.06);
  --shadow-sm:    0 1px 3px rgba(15,23,42,.08),0 1px 2px rgba(15,23,42,.04);
  --shadow:       0 4px 12px rgba(15,23,42,.08),0 2px 4px rgba(15,23,42,.04);
  --shadow-md:    0 8px 24px rgba(15,23,42,.10),0 2px 6px rgba(15,23,42,.06);
  --shadow-lg:    0 20px 60px rgba(15,23,42,.12),0 6px 16px rgba(15,23,42,.06);
  --shadow-page:  0 8px 32px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.10);
  --shadow-blue:  0 4px 16px rgba(37,99,235,.25);

  /* Dimensions */
  --toolbar-h:  52px;
  --sidebar-w:  196px;
  --pagenav-h:  44px;
  --mobile-rail-h: 56px;

  /* Typography */
  --font:      'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono','Courier New',monospace;

  /* Transitions */
  --tr:   140ms cubic-bezier(.4,0,.2,1);
  --tr-2: 200ms cubic-bezier(.4,0,.2,1);
  --tr-fast: 100ms cubic-bezier(.4,0,.2,1);
}

/* ═══ Base ═══ */
html, body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  overscroll-behavior: none;
}
body.upload-mode { overflow: auto; overscroll-behavior: auto; }
.hidden { display: none !important; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }

/* Focus rings — visible on both light and dark backgrounds */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}
.sidebar :focus-visible {
  outline-color: #60A5FA;
}

/* ═══════════════════════════════════════════════════════
   CSS TOOLTIP SYSTEM
═══════════════════════════════════════════════════════ */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--ink-2);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--tr-fast);
  z-index: 9999;
  letter-spacing: .1px;
  box-shadow: var(--shadow-md);
}
[data-tooltip]:hover::after { opacity: 1; }
/* Sidebar tooltip — right side */
.sidebar [data-tooltip]::after {
  bottom: auto;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
}

/* ═══════════════════════════════════════════════════════
   UPLOAD SCREEN
═══════════════════════════════════════════════════════ */
.upload-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
}
.upload-nav {
  width: 100%; padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-xs);
}
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-brand-name { font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -.4px; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  color: var(--muted); transition: background var(--tr), color var(--tr); text-decoration: none;
}
.nav-link:hover { background: var(--bg); color: var(--ink); }

.upload-hero-section {
  width: 100%; padding: 64px 24px 48px; text-align: center;
  background: linear-gradient(180deg,#EBF2FF 0%,var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.upload-hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; background: var(--blue-light); border: 1px solid var(--blue-mid);
  border-radius: 100px; font-size: 12px; font-weight: 600; color: var(--blue);
  margin-bottom: 18px; letter-spacing: .2px;
}
.upload-hero h1 {
  font-size: clamp(30px,5vw,52px); font-weight: 700; line-height: 1.1;
  letter-spacing: -1.5px; color: var(--ink); margin-bottom: 14px;
}
.upload-hero h1 em { font-style: normal; color: var(--blue); }
.upload-hero-sub {
  font-size: 16px; color: var(--muted); line-height: 1.65;
  max-width: 500px; margin: 0 auto 36px;
}

.drop-zone-wrap { display: flex; justify-content: center; padding: 0 24px 56px; width: 100%; }
.drop-zone {
  width: 100%; max-width: 540px; background: var(--surface);
  border: 1.5px dashed var(--border-2); border-radius: var(--radius-xl);
  padding: 48px 32px; text-align: center; cursor: pointer; position: relative;
  transition: border-color var(--tr-2), background var(--tr-2), transform var(--tr-2), box-shadow var(--tr-2);
  box-shadow: var(--shadow);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue); background: var(--blue-light);
  transform: translateY(-2px); box-shadow: var(--shadow-md),var(--shadow-blue);
}
.drop-zone.drag-over { transform: scale(1.01); }
.drop-zone-icon { margin-bottom: 14px; display: flex; justify-content: center; }
.drop-zone-icon svg { filter: drop-shadow(0 4px 10px rgba(37,99,235,.22)); }
.dz-title { font-size: 17px; font-weight: 600; color: var(--ink); margin-bottom: 4px; letter-spacing: -.2px; }
.dz-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.dz-hint { font-size: 12px; color: var(--muted-2); margin-top: 14px; }
.btn-browse-main {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 26px;
  background: var(--blue); color: white; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer; border: none;
  transition: background var(--tr), transform var(--tr), box-shadow var(--tr);
  box-shadow: var(--shadow-blue); letter-spacing: -.1px;
}
.btn-browse-main:hover { background: var(--blue-hover); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.35); }

.upload-spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.upload-progress-bar {
  width: 240px; height: 5px; background: var(--border);
  border-radius: 100px; overflow: hidden; margin: 12px auto 0;
}
.upload-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--blue), #60A5FA);
  border-radius: 100px; width: 0; transition: width .3s ease;
}
.dz-error-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--red-light); color: var(--red);
  font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.dz-upload-status { font-size: 14px; font-weight: 500; color: var(--ink); }
.upload-pills {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 18px;
}
.pill {
  padding: 5px 13px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; font-size: 12px; font-weight: 500; color: var(--muted); box-shadow: var(--shadow-xs);
}

/* ═══ Landing page sections (same as before, only minor refinements) ═══ */
.landing-content { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.section { padding: 64px 0; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: none; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--blue); margin-bottom: 10px; font-family: var(--font-mono); }
.section-title { font-size: clamp(22px,3vw,34px); font-weight: 700; color: var(--ink); letter-spacing: -.5px; margin-bottom: 10px; line-height: 1.2; }
.section-sub { font-size: 15px; color: var(--muted); line-height: 1.65; max-width: 500px; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 14px; margin-top: 36px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px;
  transition: box-shadow var(--tr-2),transform var(--tr-2),border-color var(--tr-2);
}
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--blue-mid); }
.feature-icon { width: 40px; height: 40px; border-radius: var(--radius); background: var(--blue-light); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; color: var(--blue); }
.feature-card h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.feature-card p { font-size: 13px; color: var(--muted); line-height: 1.6; }

.how-steps { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 28px; margin-top: 40px; }
.how-step { text-align: center; }
.step-num { width: 44px; height: 44px; border-radius: 50%; background: var(--blue); color: white; font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; box-shadow: var(--shadow-blue); }
.step-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.step-desc { font-size: 13px; color: var(--muted); line-height: 1.65; }

.trust-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 14px; margin-top: 36px; }
.trust-item { display: flex; align-items: flex-start; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.trust-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--green-light); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--green); }
.trust-item h4 { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.trust-item p { font-size: 12px; color: var(--muted); line-height: 1.55; }

.faq-list { margin-top: 36px; display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.faq-q {
  width: 100%; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  text-align: left; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; gap: 12px;
  transition: background var(--tr);
}
.faq-q:hover { background: var(--bg); }
.faq-q svg { flex-shrink: 0; transition: transform var(--tr); color: var(--muted); }
.faq-item.open .faq-q svg { transform: rotate(45deg); }
.faq-a { padding: 0 20px; max-height: 0; overflow: hidden; transition: max-height .3s ease, padding .3s ease; }
.faq-item.open .faq-a { max-height: 300px; padding: 0 20px 16px; }
.faq-a p { font-size: 13px; color: var(--muted); line-height: 1.7; }

.seo-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 36px; }
.seo-block h2 { font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 12px; letter-spacing: -.3px; }
.seo-block p { font-size: 14px; color: var(--muted); line-height: 1.75; margin-bottom: 10px; }
.seo-block p:last-child { margin-bottom: 0; }

.cta-banner {
  background: linear-gradient(135deg,#1E40AF 0%,#2563EB 55%,#3B82F6 100%);
  border-radius: var(--radius-xl); padding: 52px 40px; text-align: center; position: relative; overflow: hidden;
}
.cta-banner::before {
  content:''; position: absolute; inset:0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.cta-banner h2 { font-size: 28px; font-weight: 700; color: white; letter-spacing: -.5px; margin-bottom: 10px; position: relative; }
.cta-banner p { font-size: 15px; color: rgba(255,255,255,.8); margin-bottom: 26px; position: relative; }
.btn-cta-banner {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 30px;
  background: white; color: var(--blue); border-radius: var(--radius);
  font-size: 14px; font-weight: 700; transition: transform var(--tr), box-shadow var(--tr);
  position: relative; letter-spacing: -.1px; border: none; cursor: pointer;
}
.btn-cta-banner:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }

.upload-footer { width: 100%; padding: 28px 24px; background: var(--surface); border-top: 1px solid var(--border); text-align: center; }
.upload-footer p { font-size: 12px; color: var(--muted-2); }

/* ═══════════════════════════════════════════════════════
   EDITOR SCREEN — Full-height SaaS workspace
═══════════════════════════════════════════════════════ */
.editor-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;     /* True full-height, accounts for mobile browser chrome */
  overflow: hidden;
}

/* ── Render progress bar (top of editor, not global fixed) ── */
.render-progress {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: transparent; z-index: 400; pointer-events: none;
}
.render-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #60A5FA);
  transition: width .2s ease;
  border-radius: 0 2px 2px 0;
}

/* ══════════════════
   TOOLBAR
══════════════════ */
.toolbar {
  height: var(--toolbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 300;
  box-shadow: 0 1px 0 var(--border);
  gap: 0;
  position: relative;
}

.toolbar-left {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0;
}
.toolbar-center {
  display: flex; align-items: center; gap: 1px;
  flex-shrink: 0;
}
.toolbar-right {
  display: flex; align-items: center; gap: 4px;
  flex: 1; justify-content: flex-end;
}

/* Brand mark */
.toolbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--ink);
  letter-spacing: -.3px; padding: 0 4px; text-decoration: none;
  flex-shrink: 0;
}
.toolbar-brand span { font-weight: 700; letter-spacing: -.4px; }

/* Filename chip */
.toolbar-filename {
  font-size: 12px; font-weight: 500; color: var(--muted);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; font-family: var(--font-mono);
  flex-shrink: 1; min-width: 0;
}

/* Dividers inside toolbar */
.toolbar-divider {
  width: 1px; height: 20px; background: var(--border);
  margin: 0 8px; flex-shrink: 0;
}

/* Toolbar group wrappers */
.tb-group {
  display: flex; align-items: center; gap: 1px;
}

/* Generic toolbar button */
.tb-btn {
  width: 34px; height: 34px;
  min-width: 40px; min-height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background var(--tr-fast), color var(--tr-fast);
  position: relative; border: none; cursor: pointer; background: none;
  flex-shrink: 0;
}
.tb-btn:hover { background: var(--bg); color: var(--ink); }
.tb-btn:active { background: var(--bg-2); transform: scale(.96); }

/* Zoom percentage label */
.zoom-label {
  font-size: 12px; font-family: var(--font-mono); color: var(--muted);
  min-width: 44px; text-align: center;
  cursor: pointer; padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--tr-fast), color var(--tr-fast);
  font-weight: 600; flex-shrink: 0;
}
.zoom-label:hover { background: var(--bg); color: var(--ink); }

/* Download / primary action button */
.btn-save {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 36px;
  background: linear-gradient(135deg, #1D4ED8 0%, #2563EB 100%);
  color: white; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; letter-spacing: -.1px;
  transition: filter var(--tr), transform var(--tr), box-shadow var(--tr);
  box-shadow: var(--shadow-blue);
  white-space: nowrap; min-height: 40px; border: none; cursor: pointer;
  flex-shrink: 0;
}
.btn-save:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.4); }
.btn-save:active { transform: translateY(0); filter: brightness(.96); }
.btn-save:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

/* Loading state for download */
.btn-save.loading {
  pointer-events: none;
}
.btn-save.loading .btn-save-text { display: none; }
.btn-save.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ══════════════════
   EDITOR BODY
══════════════════ */
.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden; /* Children handle their own scroll */
  position: relative;
}

/* ══════════════════
   SIDEBAR — Dark premium rail
══════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 100;
  overscroll-behavior: contain;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }

/* Tool nav section */
.tool-nav { padding: 10px 6px 6px; flex-shrink: 0; }
.tool-group { margin-bottom: 2px; }
.tool-group-label {
  display: block;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--sidebar-text-dim);
  padding: 10px 10px 4px;
  font-family: var(--font-mono);
}

/* Tool buttons */
.tool-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 12.5px; font-weight: 450;
  transition: background var(--tr-fast), color var(--tr-fast), border-color var(--tr-fast);
  text-align: left; min-height: 38px;
  border: none; cursor: pointer; background: none;
  border-left: 2px solid transparent;
  position: relative;
}
.tool-btn:hover {
  background: var(--sidebar-hover-bg);
  color: rgba(255,255,255,.85);
}
.tool-btn.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--sidebar-active-border);
}
.tool-btn svg { flex-shrink: 0; color: var(--sidebar-icon); transition: color var(--tr-fast); }
.tool-btn:hover svg { color: rgba(255,255,255,.7); }
.tool-btn.active svg { color: #60A5FA; }

/* ── Tool options panel inside sidebar ── */
.tool-options {
  border-top: 1px solid var(--sidebar-border);
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sidebar-bg-2);
}
.tool-options-inner { padding: 12px 10px; }

/* Options inside sidebar — dark theme */
.opt-section { margin-bottom: 14px; }
.opt-label {
  display: block; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--sidebar-text-dim); margin-bottom: 6px;
  font-family: var(--font-mono);
}
.opt-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.opt-input {
  width: 100%; padding: 6px 8px;
  background: #1A2030; border: 1px solid #2E374A;
  border-radius: var(--radius); font-size: 12px; color: #E0E5EE;
  outline: none; transition: border-color var(--tr);
}
.opt-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.opt-select {
  width: 100%; padding: 6px 8px;
  background: #1A2030; border: 1px solid #2E374A;
  border-radius: var(--radius); font-size: 12px; color: #E0E5EE;
  outline: none;
}
.opt-color {
  width: 30px; height: 30px; border: 1.5px solid #3A4255;
  border-radius: var(--radius); padding: 2px; cursor: pointer; background: none; flex-shrink: 0;
}
.opt-range { width: 100%; accent-color: var(--blue); }
.opt-btn {
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500;
  border: 1px solid #2E374A; color: var(--sidebar-text);
  background: #1A2030; cursor: pointer; transition: background var(--tr), color var(--tr);
  min-height: 28px;
}
.opt-btn:hover { background: #222C3D; color: #E0E5EE; }
.opt-btn.primary { background: var(--blue); color: white; border-color: var(--blue); }
.opt-btn.primary:hover { background: var(--blue-hover); }
.opt-btn.danger { color: #FC8181; border-color: #553030; }
.opt-btn.danger:hover { background: #3D1A1A; }

/* Color swatches */
.color-swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 5px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--tr-fast), border-color var(--tr-fast);
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}
.swatch:hover { transform: scale(1.2); }
.swatch.selected { border-color: white; box-shadow: 0 0 0 2px var(--blue); }

/* Size swatches */
.size-swatches { display: flex; gap: 8px; align-items: center; }
.size-dot {
  border-radius: 50%; background: rgba(255,255,255,.7); cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--tr-fast);
  flex-shrink: 0;
}
.size-dot.selected { border-color: var(--blue); background: white; }

/* ══════════════════
   CANVAS AREA
══════════════════ */
.canvas-area {
  flex: 1;
  background: var(--canvas-bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 36px 40px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  touch-action: pan-x pan-y;
}
.canvas-area.draw-mode { touch-action: none; }

.pdf-viewport {
  display: flex; flex-direction: column; gap: 32px; align-items: center;
  padding-bottom: 40px; /* breathing room at bottom */
}

/* PDF page card */
.pdf-page-wrapper {
  position: relative;
  box-shadow: var(--shadow-page);
  border-radius: 2px;
  overflow: visible;
  background: white;
  will-change: transform;
  flex-shrink: 0;
  /* Subtle ring to separate from canvas bg */
  outline: 1px solid rgba(0,0,0,.06);
}
.page-placeholder {
  background: #E8EBF1; display: flex; align-items: center; justify-content: center;
  border-radius: 2px; position: relative; min-height: 200px; min-width: 100px;
}
.page-placeholder::after {
  content:''; width: 28px; height: 28px;
  border: 2.5px solid rgba(255,255,255,.3); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite;
}
.pdf-page-wrapper canvas.pdf-canvas { display: block; border-radius: 1px; }

/* Draw overlay */
.draw-canvas {
  position: absolute; top: 0; left: 0; pointer-events: none;
  touch-action: none; border-radius: 2px;
}
.draw-canvas.active        { pointer-events: all; cursor: crosshair; }
.draw-canvas.eraser-active { cursor: cell; }

/* ══ Placed elements (text, image, signature, etc.) ══ */
.placed-element {
  position: absolute; cursor: move;
  user-select: none; touch-action: none;
}
.element-border {
  width: 100%; height: 100%;
  outline: 1.5px dashed transparent;
  border-radius: 2px;
  transition: outline-color var(--tr-fast);
}
.placed-element:hover .element-border {
  outline-color: rgba(37,99,235,.4);
}
.placed-element.selected .element-border {
  outline: 2px solid var(--blue);
  border-radius: 2px;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Text edit active state */
.placed-element[data-type="text"].text-edit-active {
  outline: 2px dashed var(--blue);
  outline-offset: 3px;
  border-radius: 3px;
  cursor: text;
}

/* Resize handle */
.resize-handle {
  position: absolute; bottom: -6px; right: -6px;
  width: 12px; height: 12px;
  background: var(--blue); border-radius: 3px;
  cursor: se-resize; display: none;
  touch-action: none; border: 2px solid white;
  box-shadow: var(--shadow-sm);
}
.placed-element.selected .resize-handle { display: block; }

/* Delete handle */
.delete-handle {
  position: absolute; top: -10px; right: -10px;
  width: 24px; height: 24px;
  background: var(--red); border-radius: 50%; color: white;
  font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; z-index: 10;
  border: 2px solid white; box-shadow: var(--shadow-sm);
  transition: transform var(--tr-fast), background var(--tr-fast);
}
.placed-element.selected .delete-handle {
  display: flex;
  animation: popIn 150ms cubic-bezier(.34,1.56,.64,1);
}
.delete-handle:hover { transform: scale(1.15); background: #DC2626; }

/* Whiteout */
.whiteout-element {
  background: white;
  border: 1.5px solid #E2E8F0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.04);
}
.whiteout-preview {
  position: absolute; background: rgba(255,255,255,.88);
  border: 2px dashed #2563EB; pointer-events: none; z-index: 50;
}

/* Annotations */
.anno-highlight { position: absolute; pointer-events: none; border-radius: 2px; }
.anno-underline { position: absolute; border-bottom: 2px solid rgba(37,99,235,.8); pointer-events: none; }
.anno-strikeout { position: absolute; border-top: 2px solid rgba(239,68,68,.8); pointer-events: none; }

/* ══════════════════
   INLINE TEXT EDITOR
══════════════════ */
.inline-text-editor {
  position: absolute;
  background: rgba(255,255,255,.96);
  border: 2px dashed var(--blue);
  outline: none;
  min-width: 90px;
  min-height: 28px;
  padding: 3px 6px;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  z-index: 30;
  border-radius: 3px;
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  -webkit-text-size-adjust: 100%;
  touch-action: auto;
}

/* Mobile keyboard proxy — must stay on-screen (1×1px) for iOS */
.mobile-keyboard-proxy {
  position: fixed;
  top: 0; left: 0;
  width: 1px; height: 1px;
  opacity: 0; border: none; outline: none;
  background: transparent; color: transparent;
  font-size: 16px; /* ≥16px prevents iOS auto-zoom */
  resize: none;
  pointer-events: none;
  z-index: 1;
  padding: 0;
}

/* ══════════════════
   PAGE NAVIGATION
══════════════════ */
.page-nav {
  height: var(--pagenav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 -1px 3px rgba(15,23,42,.04);
  position: relative; z-index: 50;
}
.page-nav-btn {
  width: 36px; height: 36px; min-width: 40px; min-height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background var(--tr-fast), color var(--tr-fast);
  border: none; cursor: pointer; background: none;
}
.page-nav-btn:hover { background: var(--bg); color: var(--ink); }
.page-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-nav-info {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.page-input {
  width: 44px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; font-weight: 600; font-family: var(--font-mono);
  text-align: center; color: var(--ink); outline: none;
  -moz-appearance: textfield;
  transition: border-color var(--tr-fast);
}
.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.page-input:focus { border-color: var(--blue); }
#page-total { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }

/* ══════════════════
   MODALS
══════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 140ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 180ms cubic-bezier(.4,0,.2,1);
  overflow: hidden; max-height: 92vh; display: flex; flex-direction: column;
}
.modal-wide { max-width: 760px; }
@keyframes slideUp { from { transform: translateY(14px); opacity:0; } to { transform:none; opacity:1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -.3px; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
  transition: background var(--tr-fast); border: none; cursor: pointer; background: none;
}
.modal-close:hover { background: var(--bg); color: var(--ink); }

.modal-tabs { display: flex; padding: 0 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  transition: color var(--tr), border-color var(--tr);
  background: none; border-left:none; border-right:none; border-top:none; cursor: pointer;
}
.modal-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.modal-tab:hover { color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.tab-pane.hidden { display: none; }

#signature-canvas {
  width: 100%; height: 180px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: crosshair; background: #FAFAFA; display: block; touch-action: none;
}
.sig-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.sig-upload-area {
  border: 2px dashed var(--border-2); border-radius: var(--radius); padding: 28px;
  text-align: center; color: var(--muted); font-size: 13px;
  transition: border-color var(--tr);
}
.sig-upload-area:hover { border-color: var(--blue); }
.sig-upload-area p { margin-bottom: 10px; }

.form-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 5px; font-family: var(--font-mono); }
.form-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; color: var(--ink); outline: none; background: var(--surface); transition: border-color var(--tr); margin-bottom: 14px; }
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-color { width: 44px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; padding: 2px; background: none; margin-bottom: 14px; }
.form-select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; color: var(--ink); background: var(--surface); outline: none; margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(100px,1fr)); gap: 12px; }

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
}
.btn-ghost {
  padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
  color: var(--muted); border: 1.5px solid var(--border); background: var(--surface);
  transition: background var(--tr), color var(--tr); min-height: 38px; cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-primary {
  padding: 8px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
  background: var(--blue); color: white; border: none;
  transition: background var(--tr), transform var(--tr); min-height: 38px; cursor: pointer;
}
.btn-primary:hover { background: var(--blue-hover); transform: translateY(-1px); }

/* ── Pages Modal Grid ── */
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(116px,1fr)); gap: 12px; }
.page-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius-lg); cursor: pointer;
  transition: border-color var(--tr), background var(--tr); position: relative;
}
.page-thumb:hover { border-color: var(--blue-mid); background: var(--blue-50); }
.page-thumb.selected { border-color: var(--blue); }
.page-thumb canvas { max-width: 100%; border-radius: 2px; box-shadow: var(--shadow-sm); }
.page-thumb-label { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.page-thumb-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.page-thumb-btn {
  padding: 3px 7px; border-radius: 4px; font-size: 10px;
  border: 1px solid var(--border); color: var(--muted);
  background: var(--surface); cursor: pointer; transition: background var(--tr); min-height: 24px;
}
.page-thumb-btn:hover { background: var(--bg); color: var(--ink); }
.page-thumb-btn.danger { color: var(--red); border-color: #FCA5A5; }
.page-thumb-btn.danger:hover { background: var(--red-light); }
.page-deleted { opacity: .4; }
.page-deleted::after {
  content:'DELETED'; position: absolute; inset:0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: var(--red);
  background: rgba(255,255,255,.7); border-radius: var(--radius);
}

/* ══════════════════
   LOADING OVERLAY
══════════════════ */
.loading-overlay {
  position: fixed; inset:0; background: rgba(255,255,255,.92);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.loading-overlay .spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite;
}
.loading-overlay p { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ══════════════════
   TOASTS
══════════════════ */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  background: var(--ink-2); color: white;
  border-radius: var(--radius-lg); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 220ms cubic-bezier(.4,0,.2,1);
  max-width: 300px; pointer-events: all; letter-spacing: -.1px;
}
.toast.success { background: #14532D; }
.toast.error   { background: #7F1D1D; }
@keyframes toastIn  { from { transform: translateX(100%); opacity:0; } to { transform:none; opacity:1; } }
@keyframes toastOut { to   { transform: translateX(110%); opacity:0; } }

/* ══════════════════
   DOWNLOAD SUCCESS MODAL
══════════════════ */
#modal-download-success .modal { max-width: 480px; }
.dl-success-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 24px 16px; text-align: center;
}
.dl-success-icon {
  width: 60px; height: 60px; border-radius: 50%; background: var(--green-light);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
  animation: popIn 380ms cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes popIn { from { transform:scale(0); opacity:0; } to { transform:scale(1); opacity:1; } }
.dl-success-title { font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: -.4px; margin-bottom: 5px; }
.dl-success-msg { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
.dl-file-info {
  display: flex; align-items: center; gap: 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 11px 14px;
  width: 100%; margin-bottom: 8px; text-align: left;
}
.dl-file-icon {
  width: 34px; height: 34px; border-radius: var(--radius); background: var(--red-light);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--red);
}
.dl-file-name { font-size: 12px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dl-file-size { font-size: 11px; color: var(--muted-2); font-family: var(--font-mono); flex-shrink: 0; }
.dl-main-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 13px 20px;
  background: linear-gradient(135deg,#1D4ED8,#2563EB);
  color: white; border-radius: var(--radius); font-size: 14px; font-weight: 700;
  border: none; cursor: pointer;
  transition: filter var(--tr), transform var(--tr), box-shadow var(--tr);
  box-shadow: var(--shadow-blue); letter-spacing: -.1px; margin-bottom: 8px;
}
.dl-main-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.4); }
.dl-secondary-actions { display: flex; gap: 8px; width: 100%; margin-bottom: 4px; }
.dl-sec-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border); color: var(--ink-3);
  background: var(--surface); cursor: pointer;
  transition: background var(--tr), border-color var(--tr); min-height: 40px;
}
.dl-sec-btn:hover { background: var(--bg); border-color: var(--border-2); }
.dl-tools-section { width: 100%; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 4px; }
.dl-tools-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted-2); margin-bottom: 8px; font-family: var(--font-mono); text-align: left; }
.dl-tools-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.dl-tool-link {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 10px; font-weight: 600; color: var(--ink-3);
  text-decoration: none; transition: background var(--tr), color var(--tr);
  cursor: pointer; text-align: center;
}
.dl-tool-link:hover { background: var(--blue-light); color: var(--blue); }
.dl-tool-icon {
  width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--blue);
  box-shadow: var(--shadow-xs); border: 1px solid var(--border);
}

/* ══════════════════
   LANDING GUIDE SECTION
══════════════════ */
.pdf-support-section { padding: 60px 20px; background-color: var(--bg); }
.support-container { max-width: 1100px; margin: 0 auto; }
.support-header { text-align: center; margin-bottom: 36px; }
.support-header h2 { font-size: 26px; color: var(--ink); margin-bottom: 8px; font-weight: 700; letter-spacing: -.3px; }
.support-header p { font-size: 15px; color: var(--muted); max-width: 580px; margin: 0 auto; }
.support-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.support-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 22px;
  text-decoration: none; display: flex; flex-direction: column; align-items: flex-start;
  border: 1px solid var(--border); transition: all var(--tr-2);
  box-shadow: var(--shadow-xs);
}
.support-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--blue-mid);
}
.card-icon {
  background-color: var(--blue-light); color: var(--blue);
  width: 44px; height: 44px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.card-icon svg { width: 22px; height: 22px; }
.support-card h3 { font-size: 15px; color: var(--ink); margin: 0 0 6px; font-weight: 600; }
.support-card:hover h3 { color: var(--blue); }
.support-card p { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0; }

/* ══════════════════
   SCROLLBARS (global)
══════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }
.canvas-area::-webkit-scrollbar { width: 8px; height: 8px; }
.canvas-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,.22); border-radius: 4px; }

/* ══════════════════
   ANIMATIONS
══════════════════ */
@keyframes mobileCursorBlink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   Strategy: Bottom tool rail + bottom sheet for options
════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --toolbar-h: 50px;
    --pagenav-h: 40px;
    --sidebar-w: 100%; /* Full width when shown as bottom rail */
  }

  /* Toolbar: compact */
  .toolbar { padding: 0 8px; gap: 2px; }
  .toolbar-brand span,
  .toolbar-filename,
  .zoom-label { display: none; }
  .toolbar-divider { margin: 0 4px; }
  .btn-save { padding: 0 12px; gap: 5px; }
  .btn-save .btn-save-text { display: none; } /* icon only on mobile */

  /* Editor body: stack vertically so sidebar goes below */
  .editor-body {
    flex-direction: column-reverse; /* canvas on top, rail at bottom */
  }

  /* Sidebar: transforms into bottom horizontal rail */
  .sidebar {
    width: 100%;
    height: var(--mobile-rail-h);
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    /* Snap scroll for tool groups */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .tool-nav {
    display: flex; flex-direction: row;
    padding: 0 6px; gap: 0;
    align-items: center; min-width: max-content;
  }
  .tool-group {
    display: flex; flex-direction: row;
    align-items: center; margin-bottom: 0;
    margin-right: 2px;
  }
  /* Separator between groups on mobile rail */
  .tool-group + .tool-group {
    border-left: 1px solid var(--sidebar-border);
    padding-left: 4px; margin-left: 4px;
  }
  .tool-group-label { display: none; }
  .tool-btn {
    width: 52px; height: var(--mobile-rail-h);
    justify-content: center;
    padding: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    flex-direction: column; gap: 3px;
    border-radius: 0;
    scroll-snap-align: start;
    flex-shrink: 0;
    font-size: 9px;
  }
  .tool-btn.active {
    border-left: none;
    border-bottom-color: var(--sidebar-active-border);
    background: var(--sidebar-active-bg);
  }
  .tool-btn span { display: none; } /* hide label — icon only on rail */

  /* Tool options: bottom sheet */
  .tool-options {
    display: none; /* hidden by default, shown via JS .sheet-visible */
    position: fixed;
    bottom: var(--mobile-rail-h);
    left: 0; right: 0;
    max-height: 50vh;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--sidebar-border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 200;
    overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(0,0,0,.32);
    /* Sheet handle */
  }
  .tool-options::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 2px;
    margin: 10px auto 2px;
  }
  .tool-options.sheet-visible {
    display: block;
    animation: slideUpSheet 200ms cubic-bezier(.4,0,.2,1);
  }
  @keyframes slideUpSheet {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }
  .tool-options-inner { padding: 10px 16px 20px; }

  /* Canvas: proper height accounting for toolbar + rail + page nav */
  .canvas-area {
    flex: 1;
    padding: 12px 8px;
    min-height: 0;
  }

  /* Modals: bottom sheet style */
  .modal {
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 88vh;
  }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-wide { max-width: 100%; }

  /* Download modal stays centered */
  #modal-download-success { align-items: center; padding: 20px; }
  #modal-download-success .modal { border-radius: var(--radius-xl); max-height: 92vh; }

  .toast-container { bottom: calc(var(--mobile-rail-h) + 12px); right: 12px; left: 12px; }
  .toast { max-width: 100%; }

  .dl-tools-grid { grid-template-columns: repeat(2,1fr); }

  .nav-links { display: none; }
  .how-steps { grid-template-columns: 1fr; gap: 20px; }
  .features-grid { grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); }
}

@media (max-width: 480px) {
  .upload-hero-section { padding: 44px 16px 36px; }
  .drop-zone { padding: 32px 16px; }
  .cta-banner { padding: 36px 20px; }
  .cta-banner h2 { font-size: 22px; }
  .upload-pills { overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; padding: 0 4px; }
}

@media (min-width: 1024px) {
  .support-grid { grid-template-columns: repeat(3, 1fr); }
}