:root {
  --bg-app: #eef2f8;
  --bg-panel: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-desk: #dce4f1;
  --border: #dde4ee;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-soft-border: #bfdbfe;
  --danger: #dc2626;
  --success: #10b981;
  --warn: #f59e0b;
  --radius-sm: 7px;
  --radius-md: 11px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-pop: 0 14px 34px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-paper: 0 20px 48px -12px rgba(15, 23, 42, 0.2), 0 6px 16px -4px rgba(15, 23, 42, 0.1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  min-height: 580px;
}

/* ============================================================================
 * 1. Single Compact Top Bar (Exact 50px height, 1 clean row)
 * ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 50px;
  min-height: 50px;
  max-height: 50px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 30;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 2px;
  padding: 3px 7px 3px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.brand:hover {
  background: var(--bg-subtle);
  border-color: var(--border);
}

.brand.is-has-doc:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
}

.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-weight: 800;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.28);
}

.brand-title {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

/* Base Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.08s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.is-disabled {
  pointer-events: none;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-xs {
  height: 25px;
  padding: 0 9px;
  font-size: 11.5px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: #94a3b8;
}

/* Dropdown Menu (更多 ▾) */
.dropdown {
  position: relative;
  display: inline-flex;
}

.btn-dropdown {
  gap: 5px;
  padding-right: 9px;
}

.btn-dropdown[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
  color: var(--accent);
}

.caret-icon {
  opacity: 0.7;
  transition: transform 0.14s ease;
}

.btn-dropdown[aria-expanded="true"] .caret-icon {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 60;
  min-width: 210px;
}

.more-menu {
  right: 0;
  width: 224px;
}

.menu-section-label {
  display: block;
  padding: 5px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.menu-item:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--accent);
}

.menu-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.menu-item.menu-item-danger {
  color: var(--danger);
}

.menu-item.menu-item-danger:hover:not(:disabled) {
  background: #fef2f2;
  color: #b91c1c;
}

.menu-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.menu-ext {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}

/* Subtle Inline Header Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  max-width: 340px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-sub);
  overflow: hidden;
}

.status-pill.is-loading {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.status-pill.is-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

#statusText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--success);
}

.status-dot.loading {
  background: var(--accent);
  animation: pulse 1.1s infinite;
}

.status-dot.error {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* ============================================================================
 * 2. Main Workspace (calc(100vh - 50px))
 * ========================================================================== */
.workbench {
  flex: 1;
  height: calc(100vh - 50px);
  min-height: 0;
  display: flex;
  background: var(--bg-desk);
  overflow: hidden;
}

/* Left Narrow 120px Multi-Page Thumbnail Rail */
.page-rail {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  background: #f8fafc;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
  z-index: 10;
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rail-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: #e2e8f0;
  color: #334155;
  font-size: 10.5px;
  font-weight: 700;
}

.rail-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.rail-add-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.page-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-card {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  padding: 5px;
  cursor: pointer;
  transition: border-color 0.14s, box-shadow 0.14s, background 0.14s;
}

.page-card:hover {
  border-color: #93c5fd;
}

.page-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.14);
}

.page-thumb-wrap {
  width: 100%;
  aspect-ratio: 210 / 297;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.page-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-thumb-adjust-btn {
  position: absolute;
  right: 4px;
  bottom: 4px;
  height: 19px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.page-thumb-adjust-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.page-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  gap: 2px;
}

.page-card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  padding-left: 2px;
}

.page-card.active .page-card-label {
  color: var(--accent);
}

.page-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.page-act-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 10.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-act-btn:hover:not(:disabled) {
  background: #ffffff;
  color: var(--text-main);
}

.page-act-btn.danger:hover:not(:disabled) {
  color: var(--danger);
  background: #fef2f2;
}

.page-act-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ============================================================================
 * 3. Center Hero Workspace & Empty Welcome Dropzone
 * ========================================================================== */
.stage-hero {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg-desk);
}

.stage-empty {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  background: radial-gradient(ellipse at 50% 24%, #f8fafc 0%, #e6edf7 100%);
}

.welcome-card {
  max-width: 660px;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 18px 44px -12px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
}

.welcome-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 24px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafcff 0%, #f4f8ff 100%);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.welcome-dropzone:hover {
  border-color: var(--accent);
  background: #eff6ff;
}

.welcome-icon {
  margin-bottom: 12px;
}

.welcome-dropzone h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.welcome-dropzone p {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--text-sub);
  line-height: 1.55;
}

.welcome-dropzone kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}

.welcome-cta {
  height: 36px;
  padding: 0 18px;
  font-size: 13px;
  border-radius: 8px;
}

.welcome-samples {
  margin-top: 20px;
}

.welcome-samples-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.welcome-samples-head::before,
.welcome-samples-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.empty-sample-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.empty-sample-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.empty-sample-card:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.08);
}

.empty-sample-card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.empty-sample-card-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* In-Stage Centered Processing Overlay (#stageLoading) & Error Recovery (#ocrErrorBanner) */
.stage-loading {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(226, 232, 243, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.stage-loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 280px;
  max-width: 440px;
  padding: 18px 22px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(191, 219, 254, 0.95);
  box-shadow: 0 18px 42px -10px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(37, 99, 235, 0.08);
}

.stage-loading-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid #dbeafe;
  border-top-color: var(--accent);
  flex-shrink: 0;
  animation: stageSpin 0.78s linear infinite;
}

@keyframes stageSpin {
  to {
    transform: rotate(360deg);
  }
}

.stage-loading-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.stage-loading-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.stage-loading-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ocr-error-banner {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}

.ocr-error-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  width: 100%;
  padding: 16px 20px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #fecaca;
  box-shadow: var(--shadow-pop);
}

.ocr-error-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  color: var(--danger);
  font-weight: 800;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ocr-error-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ocr-error-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #991b1b;
}

.ocr-error-msg {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.45;
  word-break: break-word;
}

.ocr-error-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================================================
 * 4. Standalone PageX (`Paper X`) Reader & Lossless In-Page Editor
 * ========================================================================== */
.kit-stage {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  flex: 1;
}

.px-reader {
  --px-chrome-top: #f9fbff;
  --px-chrome-mid: #f2f6fc;
  --px-chrome-bot: #eaf0f9;
  --px-well-bg: #e1e8f3;
  --px-outline-bg: #fafcff;
  --px-desk-base: #dce4f1;
  --px-desk-dot: rgba(124, 143, 174, 0.42);
  --px-hairline: #d4deec;
  --px-hairline-strong: #c2cfe2;
  --px-ink: #0f172a;
  --px-ink-sub: #475569;
  --px-ink-muted: #64748b;
  --px-cobalt: #2563eb;
  --px-cobalt-deep: #1d4ed8;
  --px-sky-pill: #d6eafc;

  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--px-desk-base);
  color: var(--px-ink);
  position: relative;
}

.px-reader.px-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100vh;
}

/* 1 Pure Document Toolbar */
.px-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 44px;
  min-height: 44px;
  background: linear-gradient(180deg, var(--px-chrome-top) 0%, var(--px-chrome-mid) 58%, var(--px-chrome-bot) 100%);
  border-bottom: 1px solid var(--px-hairline);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 1px 2px rgba(15, 23, 42, 0.04);
  flex-shrink: 0;
  user-select: none;
  z-index: 12;
  overflow-x: auto;
  scrollbar-width: none;
}

.px-toolbar::-webkit-scrollbar {
  display: none;
}

.px-toolbar-left,
.px-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.px-toolbar-spacer {
  flex: 1 1 8px;
  min-width: 4px;
}

.px-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: linear-gradient(180deg, transparent 0%, var(--px-hairline-strong) 20%, var(--px-hairline-strong) 80%, transparent 100%);
  flex-shrink: 0;
}

.px-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid #d4deec;
  background: linear-gradient(180deg, #ffffff 0%, #f4f7fc 100%);
  color: #0f172a;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.px-btn:hover:not(:disabled) {
  border-color: #b8c7de;
  background: #ffffff;
  color: #0f172a;
}

.px-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  box-shadow: none;
}

.px-btn-text.active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 2px 5px rgba(37, 99, 235, 0.3);
}

.px-btn-text.active:hover:not(:disabled) {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
}

.px-btn-icon {
  width: 28px;
  min-width: 28px;
  padding: 0;
}

.px-btn-circle {
  border-radius: 999px;
  color: #475569;
}

.px-btn-circle.active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #1d4ed8;
  color: #ffffff;
}

.px-btn-mini {
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #475569;
}

.px-btn-mini:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(194, 207, 226, 0.7);
  color: #0f172a;
}

/* Segmented Pill Groups */
.px-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  height: 28px;
  border-radius: 999px;
  background: #e1e8f3;
  border: 1px solid #d0dceb;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.px-btn-group .px-btn {
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: #475569;
  font-size: 11px;
}

.px-btn-group .px-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.6);
  color: #0f172a;
}

.px-tool-capsule .px-btn.active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: rgba(29, 78, 216, 0.65);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.28);
}

.px-fit-capsule .px-btn.active,
.px-mode-group .px-btn.active {
  background: #ffffff;
  border-color: rgba(194, 207, 226, 0.85);
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.px-action-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Compact Zoom: - [100%] + */
.px-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 3px;
  border-radius: 999px;
  background: #e1e8f3;
  border: 1px solid #d0dceb;
}

.px-zoom-select {
  height: 22px;
  width: 54px;
  padding: 0 2px 0 5px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  cursor: pointer;
}

.px-zoom-select:hover,
.px-zoom-select:focus {
  background: #ffffff;
  border-color: #2563eb;
  outline: none;
}

/* Multi-Page Navigation Capsule (< 1 / N >) */
.px-pager {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 3px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #d4deec;
}

.px-page-input {
  width: 24px;
  height: 20px;
  padding: 0 2px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #eef3fa;
  color: #0f172a;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.px-page-input:focus {
  outline: none;
  background: #ffffff;
  border-color: #2563eb;
}

.px-page-total {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  padding: 0 3px 0 1px;
  white-space: nowrap;
}

/* Compact Live Search Box */
.px-find-box {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.px-find-input-wrap {
  display: flex;
  align-items: center;
  width: 132px;
  height: 28px;
  background: #ffffff;
  border: 1px solid #d4deec;
  border-radius: 999px;
  padding: 0 5px 0 8px;
  gap: 4px;
  transition: width 0.16s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.px-find-input-wrap:focus-within,
.px-find-box.has-query .px-find-input-wrap {
  width: 170px;
}

.px-find-input-wrap:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.px-find-icon {
  color: #64748b;
  flex-shrink: 0;
}

.px-find-input {
  flex: 1;
  min-width: 36px;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: #0f172a;
  font-family: var(--font-sans);
  font-size: 11.5px;
  padding: 0;
}

.px-find-input::placeholder {
  color: #94a3b8;
}

.px-find-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  flex-shrink: 0;
  line-height: 1.25;
}

.px-find-badge.no-match {
  background: #fee2e2;
  color: #b91c1c;
}

.px-find-clear {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  flex-shrink: 0;
}

.px-find-clear:hover {
  color: #0f172a;
}

.px-find-nav {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

/* Reader Workspace: Outline Drawer + Paper Desk Well */
.px-workspace {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

.px-outline-drawer {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  background: var(--px-outline-bg);
  border-right: 1px solid var(--px-hairline);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
  box-shadow: 4px 0 14px rgba(15, 23, 42, 0.05);
  z-index: 6;
}

.px-outline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid #e6edf7;
  flex-shrink: 0;
}

.px-outline-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.px-outline-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--px-ink);
}

.px-outline-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e8effa;
  color: var(--px-cobalt);
}

.px-outline-close,
.modal-close-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.px-outline-close:hover,
.modal-close-btn:hover:not(:disabled) {
  background: #eef2f7;
  color: #0f172a;
}

.px-outline-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 8px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.px-outline-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--px-ink-muted);
  line-height: 1.55;
}

.px-outline-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  width: calc(100% - 2px);
  border: none;
  border-radius: 0 8px 8px 0;
  background: transparent;
  padding: 6px 10px 6px 14px;
  text-align: left;
  color: var(--px-ink);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
}

.px-outline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

.px-outline-item:hover {
  background: #f1f5fb;
}

.px-outline-item.active {
  background: var(--px-sky-pill);
  color: #0b2454;
  font-weight: 600;
}

.px-outline-item.active::before {
  background: var(--px-cobalt);
}

.px-outline-item[data-kind="page"] {
  font-weight: 700;
  padding-left: 14px;
}

.px-outline-item[data-kind="h1"] {
  font-weight: 600;
  padding-left: 18px;
}

.px-outline-item[data-kind="h2"] {
  font-size: 11.5px;
  padding-left: 28px;
  color: var(--px-ink-sub);
}

.px-outline-item[data-kind="table"] {
  font-size: 11.5px;
  padding-left: 22px;
  color: #1e40af;
}

.px-outline-leaf-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #64748b;
}

.px-outline-item.active .px-outline-leaf-icon {
  color: var(--px-cobalt);
}

.px-outline-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.px-outline-pg {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
}

/* Paper Desk Well */
.px-desk-well {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: 26px 32px;
  background-color: var(--px-desk-base);
  background-image:
    radial-gradient(circle, var(--px-desk-dot) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 18%, rgba(255, 255, 255, 0.34) 0%, rgba(186, 200, 224, 0.16) 100%),
    url('./assets/paperx-desk-tile.png');
  background-size: 16px 16px, 100% 100%, 192px 192px;
  background-repeat: repeat, no-repeat, repeat;
  box-shadow: inset 0 5px 12px -8px rgba(15, 23, 42, 0.14);
  position: relative;
  outline: none;
}

.px-desk-well.tool-pan {
  cursor: grab;
  user-select: none;
}

.px-desk-well.tool-pan.is-panning {
  cursor: grabbing;
}

.px-desk-well.tool-select,
.px-desk-well.tool-edit {
  cursor: default;
}

.px-paper-stage {
  position: relative;
  margin: auto;
  flex-shrink: 0;
  width: 595px;
  height: 842px;
}

.px-paper-sheet {
  position: absolute;
  top: 0;
  left: 0;
  width: 595px;
  height: 842px;
  transform-origin: 0 0;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 3px;
  box-shadow: var(--shadow-paper);
  overflow: visible;
}

#kitCanvas {
  display: block;
  width: 595px;
  height: 842px;
  border-radius: 2px;
}

.px-highlight-layer {
  position: absolute;
  inset: 0;
  width: 595px;
  height: 842px;
  pointer-events: none;
  z-index: 4;
}

.px-find-hit {
  position: absolute;
  background: rgba(253, 224, 71, 0.54);
  border: 1px solid rgba(234, 179, 8, 0.72);
  border-radius: 3px;
  pointer-events: none;
}

.px-find-hit.active {
  background: rgba(253, 224, 71, 0.68);
  border: 1.8px solid var(--px-cobalt);
  box-shadow: 0 0 0 2.5px rgba(37, 99, 235, 0.24), 0 2px 6px rgba(15, 23, 42, 0.14);
  z-index: 2;
}

.px-outline-flash {
  position: absolute;
  background: rgba(59, 130, 246, 0.14);
  border: 2px solid var(--px-cobalt);
  border-radius: 4px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  pointer-events: none;
  animation: pxHaloFlash 1.45s ease-out forwards;
  z-index: 3;
}

@keyframes pxHaloFlash {
  0% { opacity: 0; transform: scale(1.015); }
  16% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.85; }
  100% { opacity: 0; }
}

.px-text-layer {
  position: absolute;
  inset: 0;
  width: 595px;
  height: 842px;
  z-index: 5;
  overflow: hidden;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.px-desk-well.tool-pan .px-text-layer {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.px-desk-well.tool-edit .px-text-layer {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.px-text-span {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  color: transparent;
  background: transparent;
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  cursor: text;
}

.px-text-span::selection {
  background: rgba(56, 189, 248, 0.34);
  color: transparent;
}

/* Interactive In-Page Edit Hit Layer (`tool === 'edit'`) */
.px-edit-layer {
  position: absolute;
  inset: 0;
  width: 595px;
  height: 842px;
  z-index: 8;
  pointer-events: auto;
}

.px-desk-well.tool-pan .px-edit-layer {
  pointer-events: none;
}

.px-edit-target {
  position: absolute;
  border: 1px dashed rgba(37, 99, 235, 0.32);
  border-radius: 3px;
  background: transparent;
  cursor: text;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.px-edit-target:hover {
  border: 1px dashed rgba(37, 99, 235, 0.65);
  background: rgba(37, 99, 235, 0.05);
}

.px-edit-target.is-on-dark {
  border-color: rgba(147, 197, 253, 0.42);
}

.px-edit-target.is-on-dark:hover {
  border-color: rgba(191, 219, 254, 0.85);
  background: rgba(147, 197, 253, 0.08);
}

.px-edit-target.is-editing {
  opacity: 0;
  pointer-events: none;
}

/* Lossless In-Page Inline Editor (`#pxInlineEditor`) */
.px-inline-editor {
  position: absolute;
  z-index: 20;
  margin: 0;
  border: none;
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  outline: 2px solid #2563eb;
  border-radius: 3px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.18);
}

/* ============================================================================
 * 5. Focused Upstream Scan Preprocessor Modal (`#scanModal`)
 * ========================================================================== */
.scan-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.scan-modal-dialog {
  width: min(920px, 95vw);
  max-height: min(860px, 92vh);
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28), 0 4px 16px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scan-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}

.scan-modal-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.scan-modal-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
}

.scan-modal-page-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  padding: 2px 8px;
  border-radius: 999px;
}

.scan-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #f9fbff 0%, #eff4fb 100%);
  border-bottom: 1px solid #d4deec;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.scan-modal-controls-left,
.scan-modal-controls-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.scan-modal-well {
  flex: 1;
  min-height: 280px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  background-color: #dce4f1;
  background-image: radial-gradient(circle, rgba(124, 143, 174, 0.35) 1px, transparent 1px);
  background-size: 16px 16px;
}

.scan-frame {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 4px;
  box-shadow: var(--shadow-paper);
  max-width: 100%;
  max-height: 100%;
}

.scan-img {
  display: block;
  max-width: min(820px, 100%);
  max-height: calc(92vh - 220px);
  width: auto;
  height: auto;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
}

.quad-overlay-wrap {
  position: relative;
  display: block;
  line-height: 0;
  flex-shrink: 0;
}

.quad-overlay-wrap > .scan-img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

.quad-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#quadPolygon {
  fill: rgba(37, 99, 235, 0.14);
  stroke: #2563eb;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.quad-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #2563eb;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
  cursor: grab;
  touch-action: none;
  z-index: 5;
}

.quad-handle:active {
  cursor: grabbing;
  transform: scale(1.15);
  background: #dbeafe;
}

@keyframes quadFlashStroke {
  0% {
    fill: rgba(37, 99, 235, 0.34);
    stroke: #1d4ed8;
    stroke-width: 4.5;
  }
  100% {
    fill: rgba(37, 99, 235, 0.14);
    stroke: #2563eb;
    stroke-width: 3;
  }
}

@keyframes quadFlashHandle {
  0% {
    transform: scale(1.22);
    background: #dbeafe;
  }
  100% {
    transform: scale(1);
    background: #fff;
  }
}

.quad-overlay-wrap.is-flash #quadPolygon {
  animation: quadFlashStroke 380ms ease-out;
}

.quad-overlay-wrap.is-flash .quad-handle {
  animation: quadFlashHandle 380ms ease-out;
}

.scan-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fafcff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.scan-modal-hint {
  font-size: 12.5px;
  color: var(--text-sub);
  line-height: 1.35;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-modal-hint.is-success {
  color: #1d4ed8;
  font-weight: 500;
}

.scan-modal-hint.is-warn {
  color: #b45309;
  font-weight: 500;
}

.scan-modal-hint.is-error {
  color: #b91c1c;
  font-weight: 500;
}

.scan-modal-footer-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ============================================================================
 * 6. Smart Single / Dual-Target Drag Overlay & Print Media
 * ========================================================================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: auto;
}

.drop-overlay-box {
  background: #ffffff;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  padding: 32px 46px;
  text-align: center;
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.drop-dual-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 290px));
  gap: 18px;
  max-width: 620px;
  width: 100%;
}

.drop-zone-card {
  background: rgba(255, 255, 255, 0.95);
  border: 2px dashed #94a3b8;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  color: var(--text-sub);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease, transform 0.12s ease, box-shadow 0.14s ease;
}

.drop-zone-card.is-active {
  background: #eff6ff;
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 20px 44px rgba(37, 99, 235, 0.22), 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.drop-zone-icon {
  margin-bottom: 4px;
  color: currentColor;
  pointer-events: none;
}

.drop-zone-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-main);
  pointer-events: none;
}

.drop-zone-card.is-active .drop-zone-title,
.drop-overlay-box .drop-zone-title {
  color: var(--accent);
}

.drop-zone-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}

.px-print-area {
  display: none;
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body > *:not(#pxPrintArea),
  .app-shell,
  .seo-below-fold,
  .pay-modal-backdrop,
  .scan-modal-backdrop {
    display: none !important;
  }

  .px-print-area {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #ffffff;
  }

  .px-print-page {
    width: 100%;
    height: 99vh;
    max-height: 99vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .px-print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .px-print-page img {
    display: block;
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
  }
}

@media (max-width: 720px) {
  .empty-sample-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- PerPay Pro Badge & Checkout Modal ---------- */
.btn-pro {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  color: #c2410c;
  border: 1px solid #fdba74;
  font-weight: 600;
}

.btn-pro:hover {
  background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
  border-color: #fb923c;
}

.btn-pro.is-unlocked {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  color: #047857;
  border-color: #6ee7b7;
}

.pay-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pay-modal-card {
  width: 100%;
  max-width: 600px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  padding: 24px;
  color: #0f172a;
}

.pay-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.pay-mode-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #1677ff;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 2px 9px;
  margin-bottom: 6px;
}

.pay-modal-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.pay-modal-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
}

.pay-close-btn {
  border: 0;
  background: #f1f5f9;
  color: #475569;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.pay-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.pay-unlocked-banner {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.pay-unlocked-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pay-license-key-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px dashed #a7f3d0;
}

.pay-license-key-label {
  font-size: 11px;
  color: #047857;
}

.pay-license-key-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pay-license-key-code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: #ffffff;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 6px 8px;
  color: #064e3b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.pay-copy-btn {
  flex-shrink: 0;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.pay-plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .pay-plans-grid {
    grid-template-columns: 1fr;
  }
}

.pay-plan-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.pay-plan-card:hover {
  border-color: #93c5fd;
  background: #ffffff;
}

.pay-plan-card.is-selected {
  border-color: #1677ff;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.pay-plan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.pay-plan-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.pay-plan-tag {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #1677ff;
  border-radius: 999px;
  padding: 1px 7px;
}

.pay-plan-price {
  font-size: 24px;
  font-weight: 800;
  color: #1677ff;
  margin-bottom: 4px;
}

.pay-plan-desc {
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
}

.pay-submit-btn {
  width: 100%;
  justify-content: center;
  height: 40px;
  font-size: 14px;
  background: #1677ff;
  border-color: #1677ff;
}

.pay-submit-btn:hover {
  background: #0958d9;
}

.pay-restore-wrap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.pay-restore-title {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.pay-restore-row {
  display: flex;
  gap: 8px;
}

.pay-restore-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #0f172a;
  background: #ffffff;
}

.pay-restore-input:focus {
  outline: none;
  border-color: #1677ff;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.14);
}

.pay-restore-btn {
  flex-shrink: 0;
  height: 34px;
  padding: 0 14px;
  font-size: 12px;
}

.pay-restore-msg {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
}

.pay-restore-msg.is-err {
  color: #dc2626;
}

.pay-restore-msg.is-ok {
  color: #059669;
  font-weight: 600;
}

.pay-wait-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}

.pay-wait-label {
  font-size: 12px;
  color: #64748b;
}

.pay-wait-amount {
  font-size: 32px;
  font-weight: 800;
  color: #1677ff;
  margin: 6px 0 4px;
}

.pay-wait-orig {
  font-size: 12px;
  color: #475569;
  margin-bottom: 10px;
}

.pay-wait-order {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 8px;
}

.pay-wait-status {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.pay-wait-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ============================================================================
 * Mobile & Tablet Responsive Support
 * ========================================================================== */
@media (max-width: 768px) {
  html,
  body,
  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .topbar {
    height: auto !important;
    min-height: 48px;
    max-height: none !important;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 10px;
    gap: 6px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar-left {
    justify-content: flex-start;
  }

  .topbar-right {
    justify-content: flex-start;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }

  .brand-title {
    font-size: 14px;
    white-space: nowrap;
  }

  .topbar .btn {
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }

  .status-pill {
    max-width: 100%;
    font-size: 11px;
  }

  .empty-welcome {
    padding: 14px 10px;
    align-items: flex-start;
  }

  .empty-welcome-card {
    padding: 20px 14px;
    border-radius: 14px;
  }

  .empty-hero-title {
    font-size: 18px;
    line-height: 1.35;
  }

  .empty-hero-sub {
    font-size: 12.5px;
  }

  .empty-sample-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .drop-dual-wrap {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0 12px;
  }

  .px-toolbar {
    height: auto;
    min-height: 40px;
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 4px;
  }

  .px-outline-drawer,
  .px-scan-drawer {
    max-width: 85vw;
  }

  .scan-modal-backdrop {
    padding: 8px;
  }

  .scan-modal-dialog {
    max-height: 94dvh;
    border-radius: 12px;
  }

  .scan-modal-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }

  .scan-modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .scan-modal-footer-actions {
    justify-content: flex-end;
  }

  .pay-modal-backdrop {
    padding: 12px;
  }

  .pay-modal-card {
    padding: 18px 14px;
  }

  .pay-plans-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .topbar-right .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .more-menu {
    right: 0;
    max-width: calc(100vw - 20px);
  }
}

/* ---------- Unified Export Modal ---------- */
.export-modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
  padding: 22px 24px;
  color: #0f172a;
}

.export-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.export-name-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.export-name-input {
  flex: 1;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 11px;
  font-size: 13px;
  color: #0f172a;
  background: #f8fafc;
}

.export-name-input:focus {
  outline: none;
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.export-group-label {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  margin: 10px 0 8px;
}

.export-primary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.export-option-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.export-option-card:hover:not(:disabled) {
  border-color: #2563eb;
  background: #eff6ff;
  transform: translateY(-1px);
}

.export-option-card:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.export-opt-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  color: #ffffff;
  margin-bottom: 2px;
}

.export-opt-badge.is-word { background: #2563eb; }
.export-opt-badge.is-excel { background: #16a34a; }
.export-opt-badge.is-pdf { background: #dc2626; }
.export-opt-badge.is-ppt { background: #ea580c; }

.export-opt-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.export-opt-desc {
  font-size: 11.5px;
  color: #64748b;
}

.export-secondary-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.export-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #1e293b;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.export-list-item:hover:not(:disabled) {
  border-color: #93c5fd;
  background: #f8fafc;
}

.export-list-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .export-modal-card {
    padding: 16px 14px;
  }

  .export-primary-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
 * Below-the-Fold Multilingual SEO Guide, FAQ & Internal Tool Links
 * ========================================================================== */
.seo-below-fold {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 40px 16px 56px;
  color: #1e293b;
}

.seo-container {
  max-width: 960px;
  margin: 0 auto;
}

.seo-lang-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.seo-lang-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.seo-lang-pill:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.seo-lang-pill.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.seo-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 28px 30px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.seo-card h1 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.35;
  color: #0f172a;
}

.seo-intro {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.7;
  color: #475569;
}

.seo-card h2 {
  margin: 22px 0 10px;
  font-size: 16px;
  color: #0f172a;
}

.seo-steps,
.seo-tips {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.75;
  color: #334155;
}

.seo-steps li,
.seo-tips li {
  margin-bottom: 6px;
}

.seo-faq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.seo-faq-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
}

.seo-faq-item h3 {
  margin: 0 0 6px;
  font-size: 13.5px;
  color: #0f172a;
}

.seo-faq-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #475569;
}

.seo-tools-nav {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.seo-tools-title {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 10px;
}

.seo-tools-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seo-tool-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
}

.seo-tool-link:hover {
  border-color: #2563eb;
  color: #2563eb;
}

/* ============================================================================
 * Refined Mobile Toolbar & SEO Layout (<= 768px)
 * ========================================================================== */
@media (max-width: 768px) {
  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .topbar-right {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .topbar-right #btnOpenExportModal {
    flex: 2 1 0;
    justify-content: center;
  }

  .topbar-right #btnClearDoc {
    flex: 1 1 0;
    justify-content: center;
  }

  .px-toolbar {
    height: auto !important;
    min-height: 40px;
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
    padding: 6px 8px;
    gap: 5px;
  }

  .px-toolbar-left,
  .px-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    gap: 4px;
    flex-shrink: 1;
  }

  .px-toolbar-right {
    padding-top: 4px;
    border-top: 1px solid var(--px-hairline, #e2e8f0);
  }

  .px-toolbar-spacer,
  .px-divider {
    display: none !important;
  }

  .px-btn {
    height: 28px;
    padding: 0 7px;
    font-size: 11.5px;
  }

  .px-zoom-select {
    height: 28px;
    font-size: 11.5px;
  }

  .seo-below-fold {
    padding: 24px 12px 40px;
  }

  .seo-card {
    padding: 18px 14px;
  }

  .seo-card h1 {
    font-size: 18px;
  }

  .seo-faq-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Topbar Language Switcher & Mobile Zoom Select Fix ---------- */
.topbar-lang-select {
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.topbar-lang-select:hover {
  border-color: var(--accent);
}

@media (max-width: 768px) {
  .topbar-right .topbar-lang-select {
    flex: 0 0 auto;
    height: 30px;
  }
}

/* ============================================================================
 * Unified Tidy Topbar, Crisp Toolbar Alignment & Viewport-Fitted ScanModal
 * ========================================================================== */
.brand {
  height: 32px;
  flex-shrink: 0;
}

.topbar .btn {
  height: 32px;
  line-height: 1;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.lang-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.lang-picker-btn {
  gap: 5px;
  padding: 0 8px 0 9px;
  pointer-events: none;
}

.lang-flag {
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.lang-picker-wrap:hover .lang-picker-btn {
  background: var(--bg-subtle);
  border-color: #94a3b8;
}

.lang-picker-wrap:focus-within .lang-picker-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.lang-picker-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 16px;
}

/* Fit Scan Adjust Modal cleanly inside ANY desktop or mobile viewport (zero cutoff!) */
.scan-modal-backdrop {
  padding: 16px;
}

.scan-modal-dialog {
  width: min(880px, calc(100vw - 32px));
  height: min(720px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
}

.scan-modal-header {
  padding: 10px 16px;
}

.scan-modal-toolbar {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 14px;
  gap: 8px;
}

.scan-modal-toolbar::-webkit-scrollbar {
  display: none;
}

.scan-modal-controls-left,
.scan-modal-controls-right {
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 5px;
}

.scan-modal-well {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px;
}

.scan-frame {
  width: 100%;
  height: 100%;
  box-shadow: none;
}

.scan-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: var(--shadow-paper);
}

.scan-modal-footer {
  padding: 10px 16px;
  flex-shrink: 0;
}

/* Crisp alignment for desktop & mobile editor toolbar */
.px-toolbar {
  height: 44px;
  min-height: 44px;
  align-items: center;
}

.px-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 3px;
}

.px-zoom-select {
  height: 22px;
  line-height: 20px;
  min-width: 54px;
  padding: 0 2px 0 6px;
  margin: 0;
  border-radius: 999px;
  vertical-align: middle;
}

.px-btn-mini {
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
}

.px-btn-icon {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
}

.px-btn-group .px-btn {
  height: 22px;
  padding: 0 8px;
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 10px;
    gap: 6px;
  }

  /* Row 1: Brand + Flag Language Picker */
  .topbar-left {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 8px;
  }

  .brand {
    height: 30px;
    gap: 6px;
    padding: 2px 4px 2px 1px;
    margin-right: 0;
  }

  .brand-logo-img {
    width: 20px;
    height: 20px;
  }

  .brand-title {
    font-size: 13.5px;
    letter-spacing: -0.01em;
  }

  /* Row 2: Upload / + Add / Scan Adjust / Export merged into one clean aligned row */
  .topbar-actions-shell {
    width: 100%;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }

  .topbar-right {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    gap: 6px;
    padding-top: 0;
    border-top: 0;
  }

  .topbar-right::-webkit-scrollbar {
    display: none;
  }

  .topbar-right #btnUpload,
  .topbar-right #btnAddPage,
  .topbar-right #btnOpenScanAdjust {
    flex: 0 0 auto;
    justify-content: center;
  }

  .topbar-right #btnOpenExportModal {
    flex: 1 1 auto;
    justify-content: center;
  }

  .topbar .btn {
    height: 30px;
    padding: 0 8px;
    gap: 4px;
    font-size: 12px;
  }

  .lang-picker-btn {
    height: 28px;
    padding: 0 7px 0 8px;
    gap: 4px;
  }

  .lang-flag {
    font-size: 15px;
  }

  /* Single clean 42px touch-scrollable editor toolbar on mobile (hide Pan, Zoom %, Fit Width/Page) */
  #btnPxPan,
  .px-zoom-controls,
  .px-fit-capsule {
    display: none !important;
  }

  .px-toolbar {
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 8px !important;
    gap: 6px !important;
  }

  .px-toolbar::-webkit-scrollbar {
    display: none;
  }

  .px-toolbar-left,
  .px-toolbar-right {
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    flex-shrink: 0 !important;
    border-top: 0 !important;
    padding-top: 0 !important;
    gap: 5px !important;
  }

  .px-toolbar-right {
    border-left: 1px solid var(--px-hairline-strong);
    padding-left: 6px !important;
  }

  .px-toolbar-spacer {
    display: none !important;
  }

  .px-divider {
    display: inline-block !important;
  }

  .px-btn:not(.px-btn-mini):not(.px-btn-icon) {
    height: 28px;
    padding: 0 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  .px-btn-group .px-btn {
    height: 22px;
    padding: 0 7px;
    font-size: 11px;
  }

  .px-btn-mini {
    width: 22px;
    min-width: 22px;
    height: 22px;
    padding: 0;
  }

  .px-btn-icon {
    width: 28px;
    min-width: 28px;
    height: 28px;
    padding: 0;
  }

  .px-zoom-select {
    height: 22px;
    font-size: 11px;
  }

  /* Scan Adjust Modal on mobile: 100% fits viewport, single-row scrollable toolbar */
  .scan-modal-backdrop {
    padding: 8px;
  }

  .scan-modal-dialog {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }

  .scan-modal-header {
    padding: 9px 12px;
  }

  .scan-modal-toolbar {
    padding: 6px 10px;
    gap: 6px;
  }

  .scan-modal-well {
    padding: 10px;
  }

  .scan-modal-footer {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 6px;
  }

  .scan-modal-hint {
    flex: 1 1 100%;
    font-size: 11.5px;
    white-space: normal;
    line-height: 1.3;
  }

  .scan-modal-footer-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }
}

/* ============================================================================
 * Page Zoom Lock (Doc-Only Pinch Zoom) & Non-Selectable Menus / Toolbars
 * ========================================================================== */
html,
body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.px-desk-well {
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.topbar,
.topbar *,
.px-toolbar,
.px-toolbar *,
.page-rail,
.page-rail *,
.px-outline-drawer,
.px-outline-drawer *,
.scan-modal-header,
.scan-modal-header *,
.scan-modal-toolbar,
.scan-modal-toolbar *,
.scan-modal-footer,
.scan-modal-footer *,
.export-modal-card,
.export-modal-card *,
.pay-modal-card,
.pay-modal-card *,
.btn,
.px-btn,
.lang-picker-wrap,
.lang-picker-btn {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Keep form inputs explicitly selectable & editable */
.px-find-input,
.px-page-input,
.export-name-input,
.px-inline-editor {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

/* ============================================================================
 * Scrollable Toolbar Right / Left Indicator Buttons
 * ========================================================================== */
.toolbar-scroll-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
}

.topbar-actions-shell {
  flex: 0 1 auto;
  min-width: 0;
}

.px-toolbar-shell,
.scan-toolbar-shell {
  width: 100%;
}

.px-toolbar-shell > .px-toolbar,
.scan-toolbar-shell > .scan-modal-toolbar {
  width: 100%;
}

.toolbar-scroll-btn {
  position: absolute;
  top: 0;
  bottom: 1px;
  z-index: 20;
  width: 34px;
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.toolbar-scroll-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.toolbar-scroll-btn.is-right {
  right: 0;
  justify-content: flex-end;
  padding-right: 4px;
  background: linear-gradient(90deg, rgba(238, 243, 250, 0) 0%, rgba(238, 243, 250, 0.94) 44%, #eef3fa 100%);
}

.toolbar-scroll-btn.is-left {
  left: 0;
  justify-content: flex-start;
  padding-left: 4px;
  background: linear-gradient(270deg, rgba(238, 243, 250, 0) 0%, rgba(238, 243, 250, 0.94) 44%, #eef3fa 100%);
}

.topbar-actions-shell .toolbar-scroll-btn {
  top: 6px;
  bottom: 0;
}

.topbar-actions-shell .toolbar-scroll-btn.is-right {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 44%, #ffffff 100%);
}

.topbar-actions-shell .toolbar-scroll-btn.is-left {
  background: linear-gradient(270deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 44%, #ffffff 100%);
}

.toolbar-scroll-pill {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #2563eb;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
  transition: transform 0.12s ease, border-color 0.14s ease, background 0.14s ease;
}

.toolbar-scroll-btn:hover .toolbar-scroll-pill {
  border-color: #2563eb;
  background: #eff6ff;
}

.toolbar-scroll-btn:active .toolbar-scroll-pill {
  transform: scale(0.92);
}

@media (min-width: 769px) {
  .topbar-actions-shell .toolbar-scroll-btn {
    top: 0;
  }
}

/* ============================================================================
 * First-Screen Viewport Lock (Dedicated 1-Finger Doc Panning + Hard Pull to SEO)
 * ========================================================================== */
.app-shell {
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.workbench {
  flex: 1 1 0 !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.px-desk-well {
  overscroll-behavior: contain;
}

@media (max-width: 768px) {
  .px-desk-well {
    padding: 14px 12px;
  }
}

@media screen {
  html.is-doc-locked,
  body.is-doc-locked {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }
}

.doc-pull-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translate(-50%, 10px);
  z-index: 40;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
}

.doc-pull-hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.doc-pull-hint.is-ready {
  background: var(--accent);
}

.seo-back-doc-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.seo-back-doc-btn {
  border-radius: 999px;
  padding: 0 18px;
  height: 34px;
}

.topbar,
.topbar-left,
.scan-modal-header,
.scan-modal-footer {
  touch-action: none;
  overscroll-behavior: none;
  overflow-y: hidden;
}

.topbar-right,
.px-toolbar,
.scan-modal-toolbar {
  touch-action: pan-x;
  overscroll-behavior: none;
  overflow-y: hidden;
}

/* ============================================================================
 * Live 3-Stage Scan Pipeline Visualizer (Quad Lock -> Color Enhance -> OCR)
 * ========================================================================== */
.scan-anim-stage {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px 20px;
  background-color: #dce4f1;
  background-image: radial-gradient(circle, rgba(124, 143, 174, 0.42) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 1;
  transition: opacity 0.18s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.scan-anim-stage.is-fading-out {
  opacity: 0;
  pointer-events: none;
}

.scan-anim-frame {
  position: relative;
  border-radius: 5px;
  overflow: hidden;
  background: #1e293b;
  box-shadow: 0 22px 54px -12px rgba(15, 23, 42, 0.28), 0 6px 18px rgba(15, 23, 42, 0.12);
  transition: width 0.24s cubic-bezier(0.22, 1, 0.36, 1), height 0.24s cubic-bezier(0.22, 1, 0.36, 1), transform 0.24s ease;
}

.scan-anim-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
}

.scan-anim-orig {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.22s ease, transform 0.26s ease;
}

.scan-anim-quad-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.2s ease;
}

#scanAnimQuadMask {
  fill: rgba(15, 23, 42, 0.44);
  transition: fill 0.18s ease;
}

.scan-anim-stage.quad-locked #scanAnimQuadMask {
  fill: rgba(15, 23, 42, 0.56);
}

#scanAnimQuadPoly {
  fill: rgba(59, 130, 246, 0.08);
  stroke: #3b82f6;
  stroke-width: 3.5;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.65));
}

.scan-anim-grid {
  position: absolute;
  inset: 0;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(37, 99, 235, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
  transition: opacity 0.25s ease;
}

.scan-anim-stage.phase-ocr .scan-anim-grid {
  opacity: 1;
}

.scan-anim-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #2563eb;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25), 0 2px 8px rgba(15, 23, 42, 0.3);
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.18s ease;
}

.scan-anim-stage.quad-locked #scanAnimQuadPoly {
  fill: rgba(59, 130, 246, 0.28);
  stroke: #60a5fa;
  stroke-width: 5;
}

.scan-anim-stage.quad-locked .scan-anim-corner {
  transform: scale(1.22);
  border-color: #60a5fa;
  box-shadow: 0 0 0 8px rgba(96, 165, 250, 0.36);
}

.scan-anim-warped {
  z-index: 2;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.24s ease, transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.scan-anim-enhanced-wrap {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  clip-path: inset(0 0 100% 0);
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.scan-anim-wipe-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  margin-top: -1.5px;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.25), #60a5fa 20%, #ffffff 50%, #60a5fa 80%, rgba(59, 130, 246, 0.25));
  box-shadow: 0 0 18px 4px rgba(59, 130, 246, 0.72), 0 -10px 24px 6px rgba(96, 165, 250, 0.34);
}

.scan-anim-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 7;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.1), #3b82f6 18%, #e0f2fe 50%, #3b82f6 82%, rgba(37, 99, 235, 0.1));
  box-shadow: 0 0 14px 3px rgba(59, 130, 246, 0.72);
  transition: opacity 0.22s ease;
}

.scan-anim-laser::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 44px;
  bottom: 0;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0) 0%, rgba(59, 130, 246, 0.22) 100%);
  pointer-events: none;
}

.scan-anim-laser[data-dir="up"]::after {
  bottom: auto;
  top: 0;
  background: linear-gradient(0deg, rgba(59, 130, 246, 0) 0%, rgba(59, 130, 246, 0.22) 100%);
}

.scan-anim-stage.phase-enhance .scan-anim-orig,
.scan-anim-stage.phase-enhance .scan-anim-quad-svg,
.scan-anim-stage.phase-enhance .scan-anim-corner,
.scan-anim-stage.phase-ocr .scan-anim-orig,
.scan-anim-stage.phase-ocr .scan-anim-quad-svg,
.scan-anim-stage.phase-ocr .scan-anim-corner {
  opacity: 0;
}

.scan-anim-stage.phase-enhance .scan-anim-warped,
.scan-anim-stage.phase-ocr .scan-anim-warped {
  opacity: 1;
  transform: scale(1);
}

.scan-anim-stage.phase-enhance .scan-anim-enhanced-wrap,
.scan-anim-stage.phase-ocr .scan-anim-enhanced-wrap {
  opacity: 1;
}

.scan-anim-stage.phase-ocr .scan-anim-laser {
  opacity: 1;
}

.scan-anim-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  pointer-events: none;
  opacity: 0;
}

.scan-anim-result {
  z-index: 8;
  background: #ffffff;
}

.scan-anim-dissolve {
  z-index: 9;
}

.scan-anim-stage.phase-dissolve .scan-anim-orig,
.scan-anim-stage.phase-dissolve .scan-anim-quad-svg,
.scan-anim-stage.phase-dissolve .scan-anim-corner,
.scan-anim-stage.phase-dissolve .scan-anim-warped,
.scan-anim-stage.phase-dissolve .scan-anim-enhanced-wrap,
.scan-anim-stage.phase-dissolve .scan-anim-grid,
.scan-anim-stage.phase-dissolve .scan-anim-wipe-bar,
.scan-anim-stage.phase-dissolve .scan-anim-laser {
  opacity: 0;
}

.scan-anim-stage.phase-dissolve .scan-anim-result,
.scan-anim-stage.phase-dissolve .scan-anim-dissolve {
  opacity: 1;
}

.scan-anim-hud {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
  max-width: calc(100vw - 24px);
}

.scan-anim-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.scan-anim-step-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.scan-anim-step.is-active {
  color: #2563eb;
}

.scan-anim-step.is-active .scan-anim-step-dot {
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.scan-anim-step.is-done {
  color: #059669;
}

.scan-anim-step.is-done .scan-anim-step-dot {
  background: #10b981;
}

.scan-anim-sep {
  font-size: 12px;
  color: #cbd5e1;
}

@media (max-width: 768px) {
  .scan-anim-stage {
    padding: 12px 12px 16px;
    gap: 10px;
  }

  .scan-anim-hud {
    gap: 6px;
    padding: 6px 11px;
  }

  .scan-anim-step {
    font-size: 11px;
    gap: 4px;
  }
}

/* ============================================================================
 * Compact Pages Sidebar, Press-and-Hold Drag Reorder, Continuous Multi-Page Stage & Multi-Page Scan Strip
 * ========================================================================== */
.px-btn-count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 16px;
  background: #dbeafe;
  color: #1d4ed8;
}

.px-btn.active .px-btn-count {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.px-outline-drawer,
.px-pages-drawer {
  width: 136px;
  min-width: 136px;
  max-width: 136px;
}

.px-outline-header {
  padding: 7px 7px 7px 10px;
  gap: 4px;
}

.px-outline-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.px-drawer-tab-label {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}

.px-pages-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.px-pages-head-actions .rail-add-btn {
  width: 22px;
  height: 22px;
  font-size: 14px;
  border-radius: 5px;
}

.px-pages-head-actions .px-outline-close {
  width: 22px;
  height: 22px;
  font-size: 15px;
}

.px-pages-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.px-pages-hint {
  padding: 5px 10px 2px;
  font-size: 10.5px;
  color: #64748b;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.px-pages-pane .page-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 14px;
  gap: 8px;
  overscroll-behavior: contain;
}

.px-pages-pane .page-list.is-reordering {
  touch-action: none;
  overflow-x: hidden;
}

.px-pages-pane .page-card {
  padding: 4px;
  border-radius: 7px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, transform 0.14s ease;
}

.px-pages-pane .page-thumb-wrap {
  border-radius: 3px;
}

.px-pages-pane .page-thumb-adjust-btn {
  height: 17px;
  padding: 0 5px;
  font-size: 10px;
  right: 3px;
  bottom: 3px;
}

.px-pages-pane .page-card-footer {
  margin-top: 3px;
  padding: 0 2px;
}

.px-pages-pane .page-card-label {
  font-size: 11px;
}

.px-pages-pane .page-act-btn {
  width: 18px;
  height: 18px;
  font-size: 12px;
}

.px-pages-pane .page-card.is-sortable {
  cursor: grab;
}

.px-pages-pane .page-card.is-sortable:active {
  cursor: grabbing;
}

.page-card-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #64748b;
}

.page-drag-grip {
  display: inline-flex;
  align-items: center;
  color: #94a3b8;
  opacity: 0.85;
}

.page-card.active .page-drag-grip {
  color: #2563eb;
}

.page-card.is-drag-placeholder {
  opacity: 0.34;
  border: 2px dashed #3b82f6 !important;
  background: rgba(219, 234, 254, 0.55) !important;
  box-shadow: none !important;
}

.page-card.is-drag-placeholder > * {
  opacity: 0.25;
}

.page-card-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  margin: 0;
  border: 2px solid #2563eb !important;
  border-radius: 8px;
  background: #ffffff !important;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.26), 0 0 0 3px rgba(59, 130, 246, 0.22) !important;
  transform: scale(1.04) rotate(0.8deg);
  transition: transform 0.12s ease;
  opacity: 0.96;
}

/* Continuous Multi-Page Document Stream */
.px-paper-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: auto !important;
  height: auto !important;
  margin: 0 auto;
  padding-bottom: 12px;
}

.px-page-slot {
  position: relative;
  flex-shrink: 0;
}

.px-kit-canvas {
  display: block;
  border-radius: 2px;
}

@media (max-width: 768px) {
  .px-outline-drawer,
  .px-pages-drawer {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 132px;
    min-width: 132px;
    max-width: 48vw;
    z-index: 25;
    box-shadow: 10px 0 32px rgba(15, 23, 42, 0.22);
  }

  .px-paper-stage {
    gap: 14px;
  }
}

/* Multi-Page Scan Pipeline Queue Filmstrip & Batch Badge */
@keyframes scanPageEnter {
  0% {
    opacity: 0.35;
    transform: translateX(22px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.scan-anim-frame.is-page-enter {
  animation: scanPageEnter 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.scan-anim-strip {
  display: flex;
  align-items: center;
  justify-content: safe center;
  gap: 8px;
  max-width: min(560px, calc(100vw - 28px));
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #cbd5e1;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(8px);
  overflow-x: auto;
  scrollbar-width: none;
}

.scan-anim-strip::-webkit-scrollbar {
  display: none;
}

.scan-anim-thumb {
  position: relative;
  width: 38px;
  height: 52px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #cbd5e1;
  background: #1e293b;
  opacity: 0.54;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.scan-anim-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-anim-thumb.is-active {
  opacity: 1;
  transform: scale(1.06);
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.24), 0 4px 10px rgba(37, 99, 235, 0.25);
}

.scan-anim-thumb.is-done {
  opacity: 1;
  transform: scale(1);
  border-color: #10b981;
}

.scan-anim-thumb-num {
  position: absolute;
  left: 2px;
  bottom: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}

.scan-anim-thumb.is-active .scan-anim-thumb-num {
  background: #2563eb;
}

.scan-anim-thumb-check {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
}

.scan-anim-thumb.is-done .scan-anim-thumb-check {
  opacity: 1;
  transform: scale(1);
}

.scan-anim-batch-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .scan-anim-strip {
    gap: 6px;
    padding: 5px 8px;
  }

  .scan-anim-thumb {
    width: 32px;
    height: 44px;
  }
}
