/* ─────────────────────────────────────────────────────────
   RST Tools | style.css
   Brand: RST Group — Orange #FF8022 · Navy #122C59
   Font:  Manrope (Google Fonts)
   ───────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* RST Brand Colors — exact values from brand guide */
  --rst-orange:      #FF8022;
  --rst-orange-dark: #E06A10;
  --rst-orange-light:#FFF4EC;
  --rst-orange-mid:  #FFE0C4;
  --rst-navy:        #122C59;
  --rst-navy-light:  #EEF2F8;

  /* Mapped to theme vars (used throughout) */
  --red:        var(--rst-orange);
  --red-dark:   var(--rst-orange-dark);
  --red-light:  var(--rst-orange-light);
  --red-mid:    var(--rst-orange-mid);

  --bg:         #f5f5f7;
  --bg2:        #EBEBF4;
  --text:       #1B3A6B;
  --text-body:  #47474f;
  --text-light: #8B8B8F;
  --border:     #D9D9E3;
  --white:      #ffffff;
  --shadow:     0 5px 30px 0 rgba(27,58,107,.12);
  --shadow-sm:  0 2px 8px 0 rgba(27,58,107,.08);
  --radius:     6px;
  --radius-lg:  12px;
  --header-h:   62px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text-body);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ────────────────────────────────────────────── */
.header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: var(--white);
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
  z-index: 200;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  line-height: 0; /* removes inline image gap */
}
.logo-img {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
}
/* Footer logo — inverted white on navy background */
.logo-img-footer {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.90;
}
/* Text fallback / legacy */
.logo-icon  { display: block; }
.logo-text  { font-size: 20px; font-weight: 800; letter-spacing: -.3px; line-height: 1; }
.logo-rst   { color: var(--rst-orange); }
.logo-tools { color: var(--rst-navy); }
.logo-red   { color: var(--rst-orange); }

/* Nav */
.nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 16px;
}
.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-body);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background .15s;
}
.nav-link:hover { background: var(--bg2); }

/* Dropdown */
.nav-dropdown { position: relative; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-body);
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}
.nav-btn:hover, .nav-dropdown:hover .nav-btn { background: var(--bg2); }

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all .18s ease;
  z-index: 300;
}
.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-body);
  font-size: 14px;
  transition: background .15s;
}
.nav-dropdown-item:hover { background: var(--bg2); }
.nav-dropdown-item.active-tool {
  font-weight: 600;
  background: var(--rst-orange-light);
  color: var(--rst-orange);
}

/* ─── Upload Section ────────────────────────────────────── */
.upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  padding: 60px 20px;
  margin-top: var(--header-h);
  background: linear-gradient(160deg, var(--rst-orange-light) 0%, var(--white) 55%);
  text-align: center;
}

.tool-header { margin-bottom: 36px; }

.tool-icon-wrap {
  width: 80px;
  height: 80px;
  background: var(--rst-orange);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 10px 28px rgba(240,90,40,.35);
}

.tool-title {
  font-size: 38px;
  font-weight: 800;
  color: var(--rst-navy);
  letter-spacing: -.5px;
  margin-bottom: 12px;
}

.tool-desc {
  font-size: 17px;
  color: var(--text-light);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Upload Zone */
.upload-zone {
  background: var(--white);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 56px 48px 40px;
  width: 100%;
  max-width: 560px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone.drag-over {
  border-color: var(--rst-orange);
  background: var(--rst-orange-light);
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--rst-orange);
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  padding: 14px 36px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(240,90,40,.40);
}
.btn-upload:hover {
  background: var(--rst-orange-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(240,90,40,.45);
}

.upload-or {
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-light);
}

.upload-cloud-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
.btn-cloud {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-cloud:hover { border-color: var(--rst-orange); background: var(--rst-orange-light); }

.upload-limit {
  margin-top: 20px;
  font-size: 12px;
  color: var(--border);
}


/* ─── Editor Section ────────────────────────────────────── */
.editor-section {
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
}

/* Top bar */
.editor-topbar {
  position: sticky;
  top: var(--header-h);
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.editor-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ef-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--rst-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.ef-badge {
  background: var(--bg2);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.ef-size {
  font-size: 13px;
  color: var(--text-light);
  white-space: nowrap;
}

.btn-add-more {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rst-orange);
  background: var(--rst-orange-light);
  border: 1px solid var(--rst-orange-mid);
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-add-more:hover { background: var(--rst-orange-mid); }

/* Editor body: pages + sidebar */
.editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Pages panel */
.pages-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}
.pages-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-content: flex-start;
}

/* Page thumbnail */
.page-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  position: relative;
  cursor: pointer;
  user-select: none;
}
.page-canvas-wrap {
  position: relative;
  background: var(--white);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: outline .1s;
  outline: 2.5px solid transparent;
}
.page-thumb.selected .page-canvas-wrap {
  outline-color: var(--rst-orange);
}
.page-canvas-wrap canvas { display: block; }

/* Check badge */
.page-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  background: var(--rst-orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(.7);
  transition: opacity .15s, transform .15s;
}
.page-thumb.selected .page-check { opacity: 1; transform: scale(1); }

/* Cut-after divider */
.page-thumb.cut-after::after {
  content: '';
  position: absolute;
  top: 0; bottom: 22px;
  right: -9px;
  width: 2px;
  background: var(--rst-orange);
  border-radius: 2px;
}
.page-thumb.cut-after::before {
  content: '✂';
  position: absolute;
  right: -20px;
  top: -14px;
  color: var(--rst-orange);
  font-size: 16px;
  rotate: 90deg;
}

/* Group color strip */
.page-group-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
}

.page-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
}

/* ─── Options sidebar ────────────────────────────────────── */
.options-sidebar {
  width: 290px;
  flex-shrink: 0;
  background: var(--white);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--header-h) + 52px);
  height: calc(100vh - var(--header-h) - 52px);
}
.options-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}
.options-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  color: var(--text-light);
  margin-bottom: 14px;
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 20px;
  gap: 2px;
}
.mode-tab {
  flex: 1;
  padding: 7px 4px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all .15s;
}
.mode-tab.active {
  background: var(--white);
  color: var(--rst-navy);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* Mode panels */
.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* Split all */
.mode-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 10px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.5;
}

/* Ranges */
.ranges-hint {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
  line-height: 1.5;
}
.ranges-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range-num {
  width: 22px;
  height: 22px;
  background: var(--rst-orange);
  color: var(--white);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.range-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-body);
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.range-input:focus { border-color: var(--rst-orange); }
.range-input::placeholder { color: var(--border); }

.btn-del-range {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
.btn-del-range:hover { border-color: var(--rst-orange); color: var(--rst-orange); }

.btn-add-range {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn-add-range:hover { border-color: var(--rst-orange); color: var(--rst-orange); }

/* Merge toggle */
.merge-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--bg2); }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-switch { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 21px;
  transition: background .2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  left: 3px; top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--rst-orange); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(17px); }
.toggle-text { font-size: 13px; color: var(--text-body); line-height: 1.4; }

/* Fixed pages */
.fixed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-body);
  padding: 14px 0;
}
.fixed-input {
  width: 68px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--text-body);
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.fixed-input:focus { border-color: var(--rst-orange); }
.fixed-hint { font-size: 13px; color: var(--text-light); line-height: 1.5; }

/* Sidebar footer */
.options-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.split-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
}
.btn-split {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 13px;
  background: var(--rst-orange);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(240,90,40,.30);
  font-family: inherit;
}
.btn-split:hover {
  background: var(--rst-orange-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(240,90,40,.40);
}
.btn-split:disabled {
  background: var(--border);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}


/* ─── Status sections (processing + download) ────────────── */
.status-section {
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(160deg, var(--rst-orange-light) 0%, var(--white) 55%);
}
.status-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 52px 56px;
  text-align: center;
  max-width: 440px;
  width: 100%;
}

/* Spinner */
.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--bg2);
  border-top-color: var(--rst-orange);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress bar */
.progress-bar-wrap {
  width: 100%;
  height: 5px;
  background: var(--bg2);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 20px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--rst-orange);
  border-radius: 5px;
  transition: width .3s ease;
}

.status-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--rst-navy);
  margin-bottom: 8px;
}
.status-sub {
  font-size: 14px;
  color: var(--text-light);
}

/* Success icon */
.success-icon {
  width: 72px;
  height: 72px;
  background: #34C759;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(52,199,89,.30);
}

/* Download button */
.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 40px;
  background: var(--rst-orange);
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(240,90,40,.40);
  margin: 16px auto 0;
  font-family: inherit;
}
.btn-download:hover {
  background: var(--rst-orange-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(240,90,40,.45);
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 12px auto 0;
  padding: 9px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text-light);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  font-family: inherit;
}
.btn-secondary:hover { border-color: var(--text-light); color: var(--text-body); }


/* ─── Footer ────────────────────────────────────────────── */
.footer {
  background: var(--rst-navy);
  border-top: 1px solid var(--border);
  padding: 36px 24px;
}
.footer-inner { max-width: 1000px; margin: 0 auto; text-align: center; }
.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 18px;
}
.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-bottom: 16px;
}
.footer-links a {
  font-size: 13px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: color .15s;
}
.footer-links a:hover { color: var(--white); }
.footer-copy { font-size: 12px; color: rgba(255,255,255,.4); }


/* ─── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--rst-navy);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 22px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 860px) {
  .editor-body { flex-direction: column; }
  .options-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .options-scroll { padding: 16px; }
  .nav { display: none; }
  .tool-title { font-size: 28px; }
  .status-card { padding: 40px 28px; }
  .upload-zone { padding: 40px 24px 32px; }
}

@media (max-width: 480px) {
  .ef-name { max-width: 120px; }
  .ef-size { display: none; }
}

/* ─────────────────────────────────────────────────────────
   Scan Document — Cyan theme (#00BCD4)
   ───────────────────────────────────────────────────────── */

.tool-icon-wrap.cyan {
  background: #00BCD4;
  box-shadow: 0 10px 28px rgba(0,188,212,.35);
}
.btn-download.cyan {
  background: #00BCD4;
  box-shadow: 0 4px 16px rgba(0,188,212,.40);
}
.btn-download.cyan:hover {
  background: #00ACC1;
  box-shadow: 0 8px 24px rgba(0,188,212,.50);
}
.btn-merge.scan-export-btn {
  background: #00BCD4;
  box-shadow: 0 4px 14px rgba(0,188,212,.30);
}
.btn-merge.scan-export-btn:hover {
  background: #00ACC1;
  box-shadow: 0 6px 20px rgba(0,188,212,.40);
}

/* ── Intro zone overrides ───────────────────────────────── */
.scan-intro-zone {
  border-color: #B2EBF2;
}
.scan-intro-zone.drag-over {
  border-color: #00BCD4;
  background: #E0F7FA;
}
.scan-start-btn {
  background: #00BCD4 !important;
  box-shadow: 0 4px 16px rgba(0,188,212,.40) !important;
}
.scan-start-btn:hover:not(:disabled) {
  background: #00ACC1 !important;
}
.scan-start-btn:disabled {
  background: var(--border) !important;
  box-shadow: none !important;
  cursor: progress;
}
.scan-upload-btn {
  margin-top: 4px;
}

/* ── Camera section — full-bleed ─────────────────────────── */
.scan-camera-section {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  display: flex;
  flex-direction: column;
}
.scan-camera-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.scan-overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
}

/* Top bar in camera */
.scan-cam-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 12px) 16px 12px;
  z-index: 5;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 100%);
}
.scan-cam-iconbtn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.scan-cam-iconbtn:hover { background: rgba(0,0,0,.65); }
.scan-cam-pagecount {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  background: rgba(0,0,0,.45);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15);
  font-family: inherit;
}

/* Detection hint */
.scan-cam-hint {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  background: rgba(0,0,0,.55);
  border-radius: 999px;
  z-index: 5;
  letter-spacing: .2px;
  transition: background .2s;
}
.scan-cam-hint.locked {
  background: rgba(0,188,212,.85);
}

/* Bottom bar — shutter, thumbs, done */
.scan-cam-bottombar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 18px 20px calc(env(safe-area-inset-bottom, 14px) + 14px);
  background: linear-gradient(0deg, rgba(0,0,0,.65) 0%, rgba(0,0,0,0) 100%);
  z-index: 5;
}
.scan-cam-thumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scan-cam-thumbs::-webkit-scrollbar { display: none; }
.scan-cam-thumb {
  width: 40px; height: 54px;
  object-fit: cover;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,.6);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* Shutter button */
.scan-shutter {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s;
}
.scan-shutter:active { transform: scale(.94); }
.scan-shutter-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid #fff;
  box-sizing: border-box;
}
.scan-shutter-dot {
  width: 58px; height: 58px;
  background: #fff;
  border-radius: 50%;
  transition: background .15s;
}
.scan-shutter:hover .scan-shutter-dot { background: #00BCD4; }

/* Done button */
.scan-cam-done {
  padding: 10px 18px;
  background: rgba(255,255,255,.95);
  color: #00BCD4;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: end;
  font-family: inherit;
  transition: background .15s, transform .1s;
}
.scan-cam-done:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
}
.scan-cam-done:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Review pages grid ───────────────────────────────────── */
.scan-pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}
.scan-page-tile {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.scan-page-tile:hover {
  box-shadow: var(--shadow-sm);
  border-color: #00BCD4;
}
.scan-page-tile-img {
  aspect-ratio: 1240/1754;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.scan-page-tile-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-page-tile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--white);
}
.scan-page-num {
  font-size: 12px;
  font-weight: 700;
  color: #00BCD4;
  background: #E0F7FA;
  padding: 2px 9px;
  border-radius: 999px;
}
.scan-page-tile-actions {
  display: flex;
  gap: 4px;
}

/* ── Filter & size tabs ──────────────────────────────────── */
.scan-filter-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.scan-filter-tab {
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all .15s;
}
.scan-filter-tab:hover {
  border-color: #00BCD4;
  color: #00BCD4;
}
.scan-filter-tab.active {
  background: #00BCD4;
  border-color: #00BCD4;
  color: #fff;
}

/* ── Mobile camera bottom-bar tweak ───────────────────────── */
@media (max-width: 480px) {
  .scan-cam-bottombar {
    grid-template-columns: 1fr auto 1fr;
    padding: 14px 14px calc(env(safe-area-inset-bottom, 12px) + 10px);
  }
  .scan-shutter { width: 70px; height: 70px; }
  .scan-shutter-dot { width: 54px; height: 54px; }
  .scan-cam-thumb { width: 34px; height: 46px; }
  .scan-cam-done { padding: 8px 14px; font-size: 13px; }
}

/* ─────────────────────────────────────────────────────────
   Save-to-Drive button (shared across all tools)
   ───────────────────────────────────────────────────────── */
.btn-save-drive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 12px 20px;
  background: var(--white);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.btn-save-drive:hover {
  border-color: #4CAF50;
  box-shadow: 0 4px 12px rgba(76,175,80,.18);
  transform: translateY(-1px);
}
.btn-save-drive:active { transform: translateY(0); }
.btn-save-drive svg { flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────
   Mobile hamburger menu + slide-out sheet
   Injected by cloud.js on every page.
   ───────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  margin-left: auto;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
.nav-hamburger:hover { background: var(--bg2); }
.nav-hamburger:active { background: var(--border); }

.mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
}
.mobile-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18,44,89,0);
  transition: background .25s ease;
  pointer-events: none;
}
.mobile-sheet-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(86%, 360px);
  background: var(--white);
  box-shadow: -10px 0 40px rgba(18,44,89,.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
}
body.mobile-nav-open .mobile-sheet { pointer-events: auto; }
body.mobile-nav-open .mobile-sheet-overlay {
  background: rgba(18,44,89,.55);
  pointer-events: auto;
}
body.mobile-nav-open .mobile-sheet-panel {
  transform: translateX(0);
  pointer-events: auto;
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.mobile-sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
}
.mobile-sheet-close {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.mobile-sheet-close:hover { background: var(--bg2); color: var(--text); }

.mobile-sheet-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-sheet-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  transition: background .12s;
}
.mobile-sheet-link:hover { background: var(--bg2); }
.mobile-sheet-link .mobile-sheet-check { margin-left: auto; }
.mobile-sheet-link span { flex: 1; }

.mobile-sheet-footer {
  padding: 14px 18px calc(env(safe-area-inset-bottom, 12px) + 14px);
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.45;
}

/* Mobile breakpoint — show hamburger, hide desktop nav */
@media (max-width: 860px) {
  .nav-hamburger { display: flex; }
  /* Existing .nav { display: none; } rule above stays — both rules apply */
}

/* Lock scroll while sheet is open */
body.mobile-nav-open { overflow: hidden; }

/* Disable double-tap zoom on touch devices (pinch-zoom is also disabled
   via viewport meta tag on each page). */
html, body { touch-action: manipulation; }
input, textarea, button, select { touch-action: manipulation; }

/* ─────────────────────────────────────────────────────────
   Scan review — sticky Export action bar on mobile.
   On phones the merge-sidebar stacks below the page grid; the export
   button would otherwise be hidden under scrolled-out pages.
   ───────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .scan-review-section .merge-sidebar-footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    background: var(--white);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(18,44,89,.10);
    padding: 12px 16px calc(env(safe-area-inset-bottom, 12px) + 12px);
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  /* Hide the small "Will export N-page A4 PDF" hint when space is tight */
  .scan-review-section .merge-preview { display: none; }
  /* Make the Export PDF button fill remaining space — clearer CTA */
  .scan-review-section .merge-sidebar-footer .btn-merge {
    flex: 1;
  }
  /* Add bottom padding so the last page isn't hidden behind the fixed bar */
  .scan-review-section .files-panel { padding-bottom: 100px; }
}

/* ─────────────────────────────────────────────────────────
   Scan Export PDF button — match the scan-options pill aesthetic.
   Bigger, full-width, rounded, deliberate CTA.
   ───────────────────────────────────────────────────────── */
.scan-export-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 999px;     /* full pill, like the filter tabs but more emphasis */
  background: #00BCD4;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .15px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,188,212,.30);
  transition: background .15s, transform .1s, box-shadow .15s;
}
.scan-export-btn:hover:not(:disabled) {
  background: #00ACC1;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,188,212,.40);
}
.scan-export-btn:active:not(:disabled) { transform: translateY(0); }
.scan-export-btn:disabled {
  background: var(--border);
  color: var(--text-light);
  box-shadow: none;
  cursor: not-allowed;
}

/* Sticky footer needs explicit display:flex (the base styles for
   .merge-sidebar-footer live inside the merge tool's inline <style>, not in
   style.css — they don't apply on the scan page). */
.scan-review-section .merge-sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
