/* ============================================================
   PDFLokal - Style Guide
   ============================================================
   Design Philosophy: Handling papers on a desk
   - Clean, minimal, functional
   - Paper-like textures and shadows
   - Fast, no unnecessary animations
   ============================================================ */

/* CSS Variables */
:root {
  /* Colors */
  --bg-primary: #fafaf9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f4;
  --bg-hover: #e7e5e4;
  
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-tertiary: #a8a29e;
  --text-inverse: #ffffff;
  
  --accent-primary: #dc2626;
  --accent-secondary: #b91c1c;
  --accent-light: #fef2f2;
  
  --border-light: #e7e5e4;
  --border-medium: #d6d3d1;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-paper: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;

  /* Safe Area Insets (for notched phones) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  /* Mobile-specific spacing */
  --mobile-bottombar-height: 60px;
  --mobile-header-height: 56px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p { color: var(--text-secondary); }

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-secondary);
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.875rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--accent-secondary);
  color: var(--text-inverse);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: var(--space-3xl) 0 var(--space-2xl);
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
}

.hero-hint {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-top: var(--space-sm);
  opacity: 0.8;
}

/* Drop Zone */
.dropzone-container {
  max-width: 700px;
  margin: var(--space-xl) auto var(--space-3xl);
}

.dropzone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-secondary);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

.dropzone-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-lg);
  color: var(--text-tertiary);
}

.dropzone h3 {
  font-size: 1.125rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.dropzone p {
  font-size: 0.9375rem;
  color: var(--text-tertiary);
}

.dropzone input[type="file"] {
  display: none;
}

/* Tools Grid */
.tools-section {
  padding-bottom: var(--space-3xl);
}

.tools-row {
  display: flex;
  gap: var(--space-2xl);
  margin-bottom: var(--space-2xl);
}

.tools-row .tools-category {
  flex: 1;
  margin-bottom: 0;
}

.tools-row .tools-category:first-child {
  padding-right: var(--space-2xl);
  border-right: 1px solid var(--border-light);
}

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

@media (max-width: 900px) {
  .tools-row .tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .tools-row {
    flex-direction: column;
    gap: var(--space-xl);
  }

  .tools-row .tools-category:first-child {
    padding-right: 0;
    border-right: none;
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-light);
  }

  .tools-row .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.tools-category {
  margin-bottom: var(--space-2xl);
}

.tools-category h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
}

.tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tool-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

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

.tool-card.disabled:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-light);
}

.tool-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-sm);
  color: var(--accent-primary);
}

.tool-card.disabled .tool-icon {
  color: var(--text-tertiary);
}

.tool-card h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.tool-card p {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

/* Privacy Badge */
.privacy-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
}

.privacy-badge svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.privacy-badge p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* Footer */
.footer {
  text-align: center;
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--border-light);
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.footer a {
  color: var(--text-secondary);
}

.footer a:hover {
  color: var(--accent-primary);
}

/* ============================================================
   Workspace Styles (Tool-specific views)
   ============================================================ */

.workspace {
  display: none;
  padding: var(--space-xl) 0;
}

.workspace.active {
  display: block;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.workspace-header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9375rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.back-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* File List / Thumbnails */
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  min-height: 150px;
  padding: var(--space-lg);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.file-item {
  position: relative;
  width: 120px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-paper);
  overflow: hidden;
  cursor: grab;
  transition: all var(--transition-fast);
}

.file-item:hover {
  box-shadow: var(--shadow-md);
}

.file-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.file-item-preview {
  width: 100%;
  height: 150px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-item-preview img,
.file-item-preview canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-item-info {
  padding: var(--space-sm);
  border-top: 1px solid var(--border-light);
}

.file-item-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.file-item-remove {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.file-item:hover .file-item-remove {
  opacity: 1;
}

.file-item-remove:hover {
  background: var(--accent-primary);
}

/* Page Thumbnails for PDF */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
}

.page-item {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-paper);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-item:hover {
  box-shadow: var(--shadow-md);
}

.page-item.selected {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.page-item canvas {
  width: 100%;
  display: block;
}

.page-item-number {
  position: absolute;
  bottom: var(--space-xs);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.page-item-checkbox {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-medium);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-item.selected .page-item-checkbox {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Add File Button */
.add-file-btn {
  width: 120px;
  height: 150px;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.add-file-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-light);
}

.add-file-btn svg {
  width: 32px;
  height: 32px;
}

.add-file-btn span {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-xl);
}

.control-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.control-group label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.control-group input[type="number"],
.control-group input[type="text"],
.control-group select {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9375rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.control-group input:focus,
.control-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Range Slider */
.range-slider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  max-width: 400px;
}

.range-slider input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--border-medium);
  border-radius: 3px;
  cursor: pointer;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
}

.range-slider .range-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 50px;
  text-align: right;
}

/* Preview Area */
.preview-area {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-xl);
  align-items: center;
  width: 100%;
  max-width: 800px;
}

.preview-box {
  text-align: center;
}

.preview-box img,
.preview-box canvas {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-paper);
}

.preview-box p {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
}

.preview-arrow {
  font-size: 1.5rem;
  color: var(--text-tertiary);
}

/* Action Bar */
.action-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
}

/* PDF Editor Canvas */
.editor-container {
  position: relative;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.editor-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.editor-tool-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.editor-tool-btn.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Hero Signature Button */
.editor-tool-group--primary {
  position: relative;
}

.editor-tool-btn--primary {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  font-weight: 600;
  padding: var(--space-sm) var(--space-lg);
}

.editor-tool-btn--primary:hover {
  background: var(--accent-dark, #1d4ed8);
  border-color: var(--accent-dark, #1d4ed8);
  color: white;
}

.editor-tool-btn--primary.active {
  background: var(--accent-dark, #1d4ed8);
  border-color: var(--accent-dark, #1d4ed8);
  color: white;
}

/* Signature Button - Subtle but distinct */
.editor-tool-btn--signature {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--text-tertiary);
  font-weight: 600;
  padding: var(--space-sm) var(--space-lg);
}

.editor-tool-btn--signature:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-light);
}

.editor-tool-btn--signature.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Secondary Tools - More subtle */
.editor-tool-btn--secondary {
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-color: var(--border-light);
}

.editor-tool-btn--secondary:hover {
  color: var(--accent-primary);
  background: var(--accent-light);
  border-color: var(--accent-primary);
}

.editor-tool-btn--secondary.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* First-use Tooltip */
.signature-hint-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: var(--space-sm);
  background: var(--text-primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.signature-hint-tooltip.show {
  opacity: 1;
  visibility: visible;
}

.signature-hint-tooltip .tooltip-arrow {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid var(--text-primary);
}

/* Signature Confirm Button */
.signature-confirm-btn {
  position: absolute;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-fast);
}

.signature-confirm-btn:hover {
  background: var(--accent-dark, #1d4ed8);
  transform: scale(1.05);
}

/* Hero Download Button */
.btn--download-hero {
  padding: var(--space-md) var(--space-xl);
  font-weight: 600;
  font-size: 1rem;
}

.btn--download-hero:not(:disabled).has-signatures {
  animation: gentle-pulse 2s infinite;
}

@keyframes gentle-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
  }
}

.editor-canvas-wrapper {
  display: flex;
  justify-content: center;
  background: #e5e5e5;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  min-height: 500px;
  height: auto;
}

.editor-canvas {
  background: white;
  box-shadow: var(--shadow-lg);
  cursor: crosshair;
}

.editor-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.editor-page-nav button {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.editor-page-nav button:hover:not(:disabled) {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.editor-page-nav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.editor-page-nav span {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* Signature Pad */
.signature-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.signature-modal.active {
  display: flex;
}

.signature-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 500px;
  width: 90%;
}

.signature-box h3 {
  margin-bottom: var(--space-lg);
}

.signature-canvas {
  width: 100%;
  height: 200px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: white;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* Signature Tabs */
.signature-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: var(--space-sm);
}

.signature-tab {
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: all var(--transition-fast);
}

.signature-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.signature-tab.active {
  color: var(--accent-primary);
  border-bottom: 2px solid var(--accent-primary);
  margin-bottom: -1px;
}

.signature-tab-content {
  display: none;
}

.signature-tab-content.active {
  display: block;
}

.signature-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 150px;
  text-align: center;
  color: var(--text-tertiary);
}

.signature-upload-area:hover {
  border-color: var(--accent-primary);
  background: var(--accent-light);
  color: var(--accent-primary);
}

.signature-upload-area p {
  margin-top: var(--space-md);
  font-weight: 500;
  color: var(--text-secondary);
}

.signature-upload-area span {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.signature-upload-area .upload-hint-secondary {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
  font-style: italic;
}

/* Signature Background Removal Preview */
.signature-bg-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  padding: var(--space-lg);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.signature-bg-preview .preview-box {
  text-align: center;
}

.signature-bg-preview .preview-box img,
.signature-bg-preview .preview-box canvas {
  display: block;
  max-width: 200px;
  max-height: 150px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.signature-bg-preview .preview-box canvas.transparent-bg {
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 10px 10px;
}

.signature-bg-preview .preview-box p {
  margin-top: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.signature-bg-preview .preview-arrow {
  font-size: 1.5rem;
  color: var(--text-tertiary);
}

@media (max-width: 600px) {
  .signature-bg-preview {
    flex-direction: column;
    gap: var(--space-md);
  }

  .signature-bg-preview .preview-arrow {
    transform: none;
  }
}

/* Progress Bar */
.progress-container {
  margin-bottom: var(--space-xl);
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: var(--space-sm);
  text-align: center;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  animation: slideIn 0.3s ease;
}

.toast.error {
  background: var(--accent-primary);
}

.toast.success {
  background: #16a34a;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Fullscreen Loading Overlay */
#fullscreen-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.fullscreen-loading-content {
  text-align: center;
}

.fullscreen-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-light);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

.fullscreen-loading-text {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin: 0;
}

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

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn-spinner {
  animation: spin 1s linear infinite;
}

/* ============================================================
   Donation Page Styles
   ============================================================ */

.donate-page {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}

.donate-page h1 {
  margin-bottom: var(--space-lg);
}

.donate-intro {
  font-size: 1.0625rem;
  line-height: 1.7;
  margin-bottom: var(--space-2xl);
}

.qris-container {
  background: var(--bg-secondary);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-2xl);
}

.qris-container img {
  max-width: 280px;
  width: 100%;
  border-radius: var(--radius-md);
}

.qris-container p {
  margin-top: var(--space-md);
  font-size: 0.9375rem;
}

.other-ways {
  text-align: left;
  margin-bottom: var(--space-2xl);
}

.other-ways h2 {
  font-size: 1.125rem;
  margin-bottom: var(--space-md);
}

.other-ways ul {
  list-style: none;
}

.other-ways li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-light);
}

.other-ways li:last-child {
  border-bottom: none;
}

.other-ways li span:first-child {
  font-size: 1.25rem;
}

.faq-section {
  text-align: left;
  margin-bottom: var(--space-2xl);
}

.faq-section h2 {
  font-size: 1.125rem;
  margin-bottom: var(--space-lg);
}

.faq-item {
  margin-bottom: var(--space-lg);
}

.faq-item h3 {
  font-size: 1rem;
  margin-bottom: var(--space-sm);
}

.faq-item p {
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 768px) {
  .hero h1 {
    font-size: 1.75rem;
  }
  
  .hero p {
    font-size: 1rem;
  }
  
  .dropzone {
    padding: var(--space-2xl) var(--space-lg);
  }
  
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-sm);
  }
  
  .tool-card {
    padding: var(--space-md);
  }
  
  .tool-icon {
    width: 32px;
    height: 32px;
  }
  
  .tool-card h3 {
    font-size: 0.8125rem;
  }
  
  .workspace-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
  
  .preview-comparison {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
  
  .preview-arrow {
    transform: rotate(90deg);
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-bar {
    flex-direction: column;
  }
  
  .action-bar .btn {
    width: 100%;
  }
  
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }
}

@media (max-width: 480px) {
  .header-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .header-actions {
    gap: var(--space-sm);
  }

  .header-actions .btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
  }

  .header-actions .btn-ghost {
    padding: var(--space-xs);
  }

  .header-actions .btn-ghost svg {
    width: 18px;
    height: 18px;
  }

  .logo span {
    font-size: 0.9rem;
  }

  .logo-icon {
    width: 28px;
    height: 28px;
    font-size: 0.875rem;
  }

  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
  
  .file-item {
    width: 100px;
  }
  
  .file-item-preview {
    height: 120px;
  }
}


.page-item .page-source {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  font-size: 0.625rem;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-item .page-rotation-badge {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  font-size: 0.625rem;
  background: var(--accent-primary);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.page-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

/* Drop indicator for drag and drop */
.drop-indicator {
  width: 4px;
  height: 140px;
  background: var(--accent-primary);
  border-radius: 2px;
  margin: 0 -2px;
  box-shadow: 0 0 8px var(--accent-primary);
  animation: pulse-indicator 0.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-indicator {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.page-item .delete-btn {
  position: absolute;
  bottom: 24px;
  right: var(--space-xs);
  width: 20px;
  height: 20px;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.page-item:hover .delete-btn {
  opacity: 1;
}

/* Enhanced PDF Editor Styles */
.editor-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.editor-toolbar-line {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  overflow: visible;
}

.editor-toolbar-line--actions {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}

.editor-toolbar-spacer {
  flex: 1;
}

.editor-tool-group {
  display: flex;
  gap: var(--space-xs);
}

.editor-tool-divider {
  width: 1px;
  height: 32px;
  background: var(--border-light);
}

/* More Tools Dropdown */
.editor-more-tools {
  position: relative;
}

.more-tools-dropdown {
  display: none;
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  padding: var(--space-xs) 0;
}

.more-tools-dropdown.active {
  display: block;
}

.more-tools-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-align: left;
}

.more-tools-item:hover {
  background: var(--bg-tertiary);
}

.more-tools-item svg {
  flex-shrink: 0;
}

.modal-note {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: var(--space-sm);
}

.editor-action-group {
  display: flex;
  gap: var(--space-xs);
}

.editor-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.editor-action-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-light);
}

.editor-action-btn.danger:hover {
  border-color: #dc2626;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

.editor-zoom-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.editor-zoom-group .zoom-level {
  min-width: 48px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.editor-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.editor-status .status-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Text Input Modal */
.edit-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.edit-modal.active {
  display: flex;
}

.edit-modal-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-xl);
}

.edit-modal-box h3 {
  margin-bottom: var(--space-lg);
  font-size: 1.125rem;
}

.edit-modal-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.edit-text-input {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition-fast);
}

.edit-text-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.edit-text-options {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.edit-option-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.edit-option-group label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.edit-option-group select,
.edit-option-group input[type="color"] {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 0.875rem;
  cursor: pointer;
}

.edit-option-group input[type="color"] {
  width: 50px;
  height: 36px;
  padding: 2px;
}

.edit-text-preview {
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

#text-preview-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: var(--space-xs);
}

.text-preview-box {
  min-height: 40px;
  padding: var(--space-sm);
  background: white;
  border-radius: var(--radius-sm);
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Font Size Number Input */
.font-size-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.font-size-input-wrap input[type="number"] {
  width: 70px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 0.875rem;
  text-align: center;
}

.font-size-input-wrap input[type="number"]::-webkit-inner-spin-button,
.font-size-input-wrap input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

.font-size-unit {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Bold/Italic Toggle Buttons */
.text-style-toggles {
  display: flex;
  gap: var(--space-xs);
}

.text-style-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.text-style-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
}

.text-style-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Color Section */
.edit-text-color-section {
  margin-top: var(--space-sm);
}

.edit-text-color-section > label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.color-options-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.color-presets {
  display: flex;
  gap: var(--space-xs);
}

.color-preset-btn {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-preset-btn:hover {
  transform: scale(1.1);
}

.color-preset-btn.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
}

.color-options-row input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.edit-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* Annotation Selection Handles */
.annotation-selected {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Canvas Cursors */
.editor-canvas.tool-select { cursor: default; }
.editor-canvas.tool-whiteout { cursor: crosshair; }
.editor-canvas.tool-text { cursor: text; }
.editor-canvas.tool-signature { cursor: copy; }
.editor-canvas.dragging { cursor: grabbing; }
.editor-canvas.resizing { cursor: nwse-resize; }

/* Annotation Resize Handles (rendered via CSS overlay) */
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--accent-primary);
  border: 2px solid white;
  border-radius: 2px;
  cursor: nwse-resize;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* Mobile Responsive for Editor */
@media (max-width: 768px) {
  .editor-toolbar {
    gap: var(--space-sm);
  }

  .editor-toolbar-line {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .editor-tool-group {
    justify-content: center;
  }

  .editor-tool-divider {
    display: none;
  }

  .editor-action-group {
    justify-content: center;
  }

  .editor-zoom-group {
    display: none;
  }

  .editor-status {
    justify-content: center;
    margin-left: 0;
    margin-top: var(--space-sm);
  }

  .editor-tool-btn {
    padding: var(--space-sm);
    font-size: 0.75rem;
  }

  .editor-tool-btn svg {
    width: 14px;
    height: 14px;
  }

  .edit-modal-box {
    padding: var(--space-lg);
  }

  .edit-text-options {
    flex-direction: column;
    gap: var(--space-md);
  }

  /* Signature button on mobile */
  .editor-tool-btn--signature {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
  }

  .editor-tool-btn--signature svg {
    width: 16px;
    height: 16px;
  }

  /* Hide tooltip on mobile (touch interaction is different) */
  .signature-hint-tooltip {
    display: none !important;
  }

  /* Toolbar lines on mobile */
  .editor-toolbar-line {
    flex-wrap: wrap;
    justify-content: center;
  }

  .editor-toolbar-spacer {
    display: none;
  }

  .editor-toolbar-line--actions {
    justify-content: center;
  }

  /* Download button on mobile */
  .btn--download-hero {
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
    width: 100%;
    justify-content: center;
  }
}

/* Drop Hint Component - For file upload areas */
.drop-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  text-align: center;
  min-height: 150px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.drop-hint:hover,
.drop-hint.drag-over {
  border-color: var(--accent-primary);
  background: var(--accent-light);
  color: var(--accent-primary);
}

.drop-hint-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  color: inherit;
}

.drop-hint-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.drop-hint-subtext {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.drop-hint input[type="file"] {
  display: none;
}

/* Empty state for page-grid and file-list */
.page-grid.empty,
.file-list.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.page-grid.empty .drop-hint,
.file-list.empty .drop-hint {
  width: 100%;
  max-width: 400px;
  min-height: 200px;
  border: none;
  background: transparent;
}

.preview-area .drop-hint {
  width: 100%;
  max-width: 500px;
}

@media (max-width: 768px) {
  .drop-hint {
    padding: var(--space-lg);
    min-height: 120px;
  }

  .drop-hint-icon {
    width: 40px;
    height: 40px;
  }

  .drop-hint-text {
    font-size: 0.875rem;
  }
}

/* Workspace dropzones - use homepage dropzone style with constraints */
.preview-area .dropzone,
.page-grid.empty .dropzone,
.file-list.empty .dropzone,
.unified-empty-state .dropzone {
  max-width: 500px;
  margin: 0 auto;
}

.page-grid.empty .dropzone,
.file-list.empty .dropzone {
  max-width: 400px;
}

/* Unified Editor empty state dropzone */
.unified-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-xl);
}

.unified-empty-state .dropzone {
  width: 100%;
}

/* ============================================================
   Unified Editor Workspace Styles
   ============================================================ */

#unified-editor-workspace.workspace {
  padding: var(--space-md) 0;
}

#unified-editor-workspace.workspace.active {
  display: flex;
  flex-direction: column;
  height: auto;
}

#unified-editor-workspace .workspace-header {
  flex-shrink: 0;
  margin-bottom: var(--space-sm);
}

#unified-editor-workspace .action-bar {
  flex-shrink: 0;
  padding: var(--space-sm) 0;
}

.unified-editor-layout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  flex: 1;
  min-height: 1200;
  overflow: hidden;
}

/* Sidebar */
.unified-sidebar {
  width: 280px;
  min-width: 280px;
  max-height: 100vh;
  position: sticky;
  top: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, min-width 0.3s ease;
}

/* Collapsed sidebar state */
.unified-sidebar.collapsed {
  width: 48px;
  min-width: 48px;
}

.unified-sidebar.collapsed .sidebar-title,
.unified-sidebar.collapsed .unified-sidebar-header .btn,
.unified-sidebar.collapsed .unified-thumbnails,
.unified-sidebar.collapsed .unified-sidebar-footer {
  display: none;
}

.unified-sidebar.collapsed .unified-sidebar-header {
  justify-content: center;
  padding: var(--space-md) var(--space-sm);
}

.unified-sidebar.collapsed .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}

/* Sidebar toggle button */
.sidebar-toggle-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.sidebar-toggle-btn svg {
  transition: transform 0.3s ease;
}

.unified-sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.sidebar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.unified-thumbnails {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.unified-thumbnails .drop-hint {
  min-height: 140px;
  padding: var(--space-lg);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
}

.unified-sidebar-footer {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.sidebar-page-count {
  flex: 1;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Thumbnail Items */
.ue-thumbnail {
  position: relative;
  background: white;
  border: 3px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

/* Portrait PDF thumbnail */
.ue-thumbnail.portrait {
  aspect-ratio: auto;
}

/* Landscape PDF thumbnail - ensure minimum visibility */
.ue-thumbnail.landscape {
  min-height: 100px;
}

.ue-thumbnail:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.ue-thumbnail.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-md);
}

.ue-thumbnail.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.ue-sidebar-drop-indicator {
  height: 4px;
  background: var(--accent-primary);
  border-radius: 2px;
  margin: var(--space-xs) 0;
  animation: dropIndicatorPulse 0.8s ease-in-out infinite;
}

.ue-thumbnail canvas {
  max-width: 100%;
  max-height: 180px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.ue-thumbnail-number {
  position: absolute;
  bottom: var(--space-sm);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.ue-thumbnail-source {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.5rem;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ue-thumbnail-delete {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  width: 18px;
  height: 18px;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.ue-thumbnail:hover .ue-thumbnail-delete {
  opacity: 1;
}

/* Main Content Area */
.unified-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 200;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-sm);
}

.unified-main .editor-toolbar {
  margin-bottom: 0;
  flex-shrink: 0;
  overflow: visible;
}

/* Status bar above canvas */
.ue-status-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  margin-top: var(--space-sm);
}

.unified-canvas-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #e5e5e5;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-md);
  min-height: 500px;
  height: auto;
  position: relative; /* For confirm button positioning */
  overflow: auto; /* Allow scrolling when canvas is zoomed */
}

#ue-canvas {
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  /* Size is controlled by JavaScript */
}

.unified-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-2xl);
}

/* Button size modifier */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8125rem;
}

.btn-icon {
  padding: var(--space-xs);
  width: 28px;
  height: 28px;
}

/* Desktop - ensure proper canvas sizing */
@media (min-width: 901px) {
  .unified-editor-layout {
    height: auto;
  }

  .unified-main {
    height: auto;
    overflow: visible;
  }

  .unified-canvas-wrapper {
    min-height: 500px;
    height: auto;
  }
}

/* Mobile Responsive */
@media (max-width: 900px) {
  #unified-editor-workspace.workspace.active {
    height: auto;
  }

  .unified-editor-layout {
    flex-direction: column;
    flex: none;
  }

  .unified-sidebar {
    width: 100%;
    min-width: auto;
    max-height: 180px;
    transition: max-height 0.3s ease;
  }

  .unified-sidebar.collapsed {
    width: 100%;
    min-width: auto;
    max-height: 48px;
  }

  .unified-sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(90deg);
  }

  .unified-thumbnails {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--space-sm);
    padding: var(--space-sm);
  }

  .ue-thumbnail {
    width: 100px;
    min-height: 60px;
    flex-shrink: 0;
  }

  .ue-thumbnail.landscape {
    width: 140px;
    min-height: 70px;
  }

  .ue-thumbnail canvas {
    max-height: 100px;
  }

  .unified-main {
    min-height: auto;
    height: auto;
  }

  .unified-canvas-wrapper {
    min-height: 500px;
    height: auto;
  }
}

/* ============================================================
   Page Manager Modal for Unified Editor
   ============================================================ */

/* Kelola button in sidebar - slightly more prominent */
.ue-manage-btn {
  flex-shrink: 0;
}

/* Modal box - larger size for page management */
.ue-pm-modal-box {
  max-width: 900px;
  width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.ue-pm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.ue-pm-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.ue-pm-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.ue-pm-close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Toolbar */
.ue-pm-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

/* Make toolbar buttons more prominent */
.ue-pm-toolbar > .btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: var(--space-sm) var(--space-lg);
}

.ue-pm-toolbar > .btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-primary);
}

.ue-pm-extract-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

.ue-pm-selection-count {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding: 0 var(--space-sm);
}

/* Pages container - scrollable area */
.ue-pm-pages-container {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  min-height: 250px;
  max-height: 50vh;
}

/* Page grid */
.ue-pm-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-md);
  align-items: start;
}

/* Individual page item */
.ue-pm-page-item {
  position: relative;
  background: white;
  border: 3px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  cursor: grab;
  transition: all var(--transition-fast);
  aspect-ratio: auto;
}

.ue-pm-page-item:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.ue-pm-page-item.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.ue-pm-page-item.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.ue-pm-page-item canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

/* Page number badge */
.ue-pm-page-number {
  position: absolute;
  bottom: var(--space-sm);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* Source file badge */
.ue-pm-source-badge {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(59, 130, 246, 0.9);
  color: white;
  font-size: 0.5625rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rotation badge */
.ue-pm-rotation-badge {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  background: var(--accent-primary);
  color: white;
  font-size: 0.5625rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Action buttons overlay - always visible */
.ue-pm-page-actions {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  display: flex;
  gap: 3px;
}

.ue-pm-page-action-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  padding: 0;
}

.ue-pm-page-action-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.ue-pm-page-action-btn.delete:hover {
  background: var(--accent-primary);
}

.ue-pm-page-action-btn svg {
  width: 12px;
  height: 12px;
}

/* Extract mode checkbox */
.ue-pm-page-checkbox {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  width: 22px;
  height: 22px;
  background: white;
  border: 2px solid var(--border-medium);
  border-radius: 4px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.ue-pm-pages.extract-mode .ue-pm-page-checkbox {
  display: flex;
}

.ue-pm-pages.extract-mode .ue-pm-page-actions {
  display: none;
}

.ue-pm-pages.extract-mode .ue-pm-rotation-badge {
  left: calc(var(--space-sm) + 26px);
}

.ue-pm-pages.extract-mode .ue-pm-page-item {
  cursor: pointer;
}

.ue-pm-page-item.selected .ue-pm-page-checkbox {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Drop indicator for drag-drop */
.ue-pm-drop-indicator {
  width: 4px;
  min-height: 100px;
  background: var(--accent-primary);
  border-radius: 2px;
  animation: dropIndicatorPulse 0.8s ease-in-out infinite;
  align-self: stretch;
}

@keyframes dropIndicatorPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Footer */
.ue-pm-page-count {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-right: auto;
}

/* Extract mode button active state */
#ue-pm-extract-mode-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .ue-pm-modal-box {
    max-height: 90vh;
    padding: var(--space-md);
  }

  .ue-pm-pages {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: var(--space-sm);
  }

  .ue-pm-toolbar {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .ue-pm-extract-actions {
    width: 100%;
    margin-left: 0;
    margin-top: var(--space-sm);
  }

  .ue-pm-page-action-btn {
    width: 22px;
    height: 22px;
  }

  .ue-pm-page-action-btn svg {
    width: 10px;
    height: 10px;
  }
}

/* Utility Classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ============================================================
   MOBILE OPTIMIZATION STYLES
   ============================================================ */

/* Mobile body adjustments */
body.is-mobile {
  overscroll-behavior: none;
}

body.is-touch button:active,
body.is-touch .btn:active {
  transform: scale(0.97);
  transition: transform 0.1s;
}

/* ============================================================
   Mobile Bottom Bar
   ============================================================ */

.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-bottombar-height);
  padding-bottom: var(--sab);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  z-index: 100;
  align-items: center;
  justify-content: space-between;
  padding-left: max(var(--space-sm), var(--sal));
  padding-right: max(var(--space-sm), var(--sar));
  gap: var(--space-xs);
}

.mobile-page-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.mobile-nav-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast);
}

.mobile-nav-btn:active {
  background: var(--bg-hover);
}

.mobile-nav-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.mobile-page-indicator {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.mobile-page-indicator:active {
  background: var(--bg-tertiary);
}

.mobile-page-indicator strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Mobile Tools Dropdown */
.mobile-tools-wrapper {
  position: relative;
}

.mobile-more-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-more-btn:active {
  background: var(--bg-hover);
}

.mobile-tools-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + var(--space-sm));
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  z-index: 150;
  overflow: hidden;
}

.mobile-tools-dropdown.active {
  display: block;
  animation: fadeInUp 0.15s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-tool-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.mobile-tool-item:active {
  background: var(--bg-tertiary);
}

.mobile-tool-item svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Mobile Sign Button */
.mobile-sign-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent-primary);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 40px;
  white-space: nowrap;
}

.mobile-sign-btn:active {
  background: var(--accent-secondary);
}

.mobile-sign-btn.has-signature {
  background: #16a34a;
}

.mobile-sign-btn svg {
  flex-shrink: 0;
}

/* ============================================================
   Mobile Page Picker
   ============================================================ */

.mobile-page-picker {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
}

.mobile-page-picker.active {
  display: block;
}

.mobile-page-picker-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mobile-page-picker-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  padding-bottom: var(--sab);
  animation: slideUp 0.25s ease;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-page-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.mobile-page-picker-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
}

.mobile-page-picker-close:active {
  background: var(--bg-hover);
}

.mobile-page-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  padding: var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.mobile-page-thumb {
  aspect-ratio: 3/4;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--bg-tertiary);
  -webkit-tap-highlight-color: transparent;
}

.mobile-page-thumb.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.mobile-page-thumb:active {
  transform: scale(0.97);
}

.mobile-page-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.mobile-page-thumb-number {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Mobile Editor Layout Overrides
   ============================================================ */

@media (max-width: 767px) {
  /* Show mobile bottom bar */
  #unified-editor-workspace .mobile-bottom-bar {
    display: flex;
  }

  /* Hide desktop sidebar completely */
  #unified-editor-workspace .unified-sidebar {
    display: none !important;
  }

  /* Hide desktop toolbar first line (tools) */
  #unified-editor-workspace .editor-toolbar-line:first-child {
    display: none !important;
  }

  /* Simplify toolbar line 2 - zoom left, download right */
  #unified-editor-workspace .editor-toolbar-line--actions {
    justify-content: space-between;
    padding: var(--space-sm) max(var(--space-md), var(--sar)) var(--space-sm) max(var(--space-md), var(--sal));
    border-top: none;
  }

  #unified-editor-workspace .editor-action-group,
  #unified-editor-workspace .editor-tool-divider {
    display: none !important;
  }

  #unified-editor-workspace .editor-toolbar-spacer {
    display: none;
  }

  /* Show zoom controls on mobile */
  #unified-editor-workspace .editor-zoom-group {
    display: flex !important;
    gap: var(--space-xs);
  }

  #unified-editor-workspace .editor-zoom-group .zoom-level {
    min-width: 45px;
    font-size: 0.75rem;
  }

  /* Keep download button visible */
  #unified-editor-workspace .btn--download-hero {
    width: auto;
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
  }

  /* Adjust main content for bottom bar */
  #unified-editor-workspace .unified-main {
    padding-bottom: calc(var(--mobile-bottombar-height) + var(--sab) + var(--space-md));
  }

  /* Canvas wrapper optimization - full width with safe area padding */
  #unified-editor-workspace .unified-canvas-wrapper {
    min-height: auto;
    height: auto;
    padding: 0 var(--sar) 0 var(--sal);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Status bar mobile styling - respect safe areas */
  #unified-editor-workspace .ue-status-bar {
    font-size: 0.75rem;
    padding: var(--space-xs) max(var(--space-sm), var(--sar)) var(--space-xs) max(var(--space-sm), var(--sal));
  }

  /* Editor toolbar adjustments */
  #unified-editor-workspace .editor-toolbar {
    padding: 0;
    gap: 0;
  }

  /* Unified editor layout goes full width */
  #unified-editor-workspace .unified-editor-layout {
    flex-direction: column;
  }

  /* Remove workspace padding on mobile for full-width canvas */
  #unified-editor-workspace.workspace {
    padding: 0;
  }

  /* Remove unified-main padding on mobile - canvas goes full width */
  #unified-editor-workspace .unified-main {
    padding: 0;
  }

  /* Workspace header adjustments - keep padding for usability */
  #unified-editor-workspace .workspace-header {
    padding: var(--space-sm) max(var(--space-md), var(--sar)) var(--space-sm) max(var(--space-md), var(--sal));
  }

  #unified-editor-workspace .workspace-header h2 {
    font-size: 1rem;
  }

  #unified-editor-workspace .back-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8125rem;
  }

  #unified-editor-workspace .back-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ============================================================
   Mobile Signature Modal Optimization
   ============================================================ */

@media (max-width: 767px) {
  .signature-modal .signature-box {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: var(--space-md);
    padding-top: calc(var(--space-md) + var(--sat));
    padding-bottom: calc(var(--space-md) + var(--sab));
    display: flex;
    flex-direction: column;
  }

  .signature-modal .signature-canvas {
    flex: 1;
    min-height: 180px;
    max-height: none;
    touch-action: none;
  }

  .signature-modal .signature-tabs {
    margin-bottom: var(--space-sm);
  }

  .signature-modal .signature-tab {
    flex: 1;
    padding: var(--space-md);
    font-size: 0.9375rem;
    min-height: 44px;
  }

  .signature-modal .signature-actions {
    margin-top: auto;
    padding-top: var(--space-md);
    gap: var(--space-sm);
    flex-wrap: wrap;
  }

  .signature-modal .signature-actions .btn {
    flex: 1;
    min-height: 48px;
    min-width: 100px;
  }

  /* Upload area mobile */
  .signature-upload-area {
    min-height: 160px;
    padding: var(--space-xl);
    flex: 1;
  }

  /* Signature background removal modal */
  #signature-bg-modal .edit-modal-box {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    padding-top: calc(var(--space-md) + var(--sat));
    padding-bottom: calc(var(--space-md) + var(--sab));
  }

  #signature-bg-modal .edit-modal-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #signature-bg-modal .edit-modal-actions {
    margin-top: auto;
    padding-top: var(--space-md);
    flex-shrink: 0;
  }

  .signature-bg-preview {
    flex-direction: column;
    gap: var(--space-md);
  }

  .signature-bg-preview .preview-box {
    width: 100%;
  }

  .signature-bg-preview .preview-box img,
  .signature-bg-preview .preview-box canvas {
    margin: 0 auto;
    max-width: 100%;
    max-height: 120px;
  }
}

/* ============================================================
   Mobile Touch Enhancements
   ============================================================ */

/* Larger touch targets for signature resize handles */
body.is-touch .resize-handle {
  width: 20px;
  height: 20px;
}

body.is-touch .resize-handle.nw { top: -10px; left: -10px; }
body.is-touch .resize-handle.ne { top: -10px; right: -10px; }
body.is-touch .resize-handle.sw { bottom: -10px; left: -10px; }
body.is-touch .resize-handle.se { bottom: -10px; right: -10px; }

/* Signature confirm button on mobile */
@media (max-width: 767px) {
  .signature-confirm-btn {
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
    min-height: 44px;
    min-width: 100px;
  }
}

/* ============================================================
   Mobile Homepage Adjustments
   ============================================================ */

@media (max-width: 767px) {
  /* Adjust dropzone for easier touch */
  .dropzone {
    padding: var(--space-xl);
    min-height: 150px;
  }

  .dropzone-icon {
    width: 48px;
    height: 48px;
  }

  /* Tool cards touch-friendly */
  .tool-card {
    min-height: 80px;
    padding: var(--space-md);
  }
}

/* ============================================================
   Keyboard Shortcuts Modal & Help Button
   ============================================================ */

.shortcuts-help-btn {
  position: fixed;
  bottom: calc(var(--space-lg) + var(--sab));
  right: var(--space-lg);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.shortcuts-help-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
  transform: scale(1.05);
}

.shortcuts-help-btn svg {
  width: 22px;
  height: 22px;
}

.shortcuts-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.shortcuts-modal.active {
  display: flex;
}

.shortcuts-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.shortcuts-modal-box {
  position: relative;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 500px;
  width: calc(100% - var(--space-xl) * 2);
  max-height: calc(100vh - var(--space-xl) * 2);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.shortcuts-modal-box h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.shortcuts-modal-content {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.shortcut-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.shortcut-group h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.shortcut-item span {
  flex: 1;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.shortcuts-modal-actions {
  margin-top: var(--space-xl);
  display: flex;
  justify-content: center;
}

@media (max-width: 767px) {
  .shortcuts-help-btn {
    bottom: calc(80px + var(--sab));
    right: var(--space-md);
    width: 40px;
    height: 40px;
  }

  .shortcuts-help-btn svg {
    width: 20px;
    height: 20px;
  }

  .shortcuts-modal-box {
    padding: var(--space-lg);
  }

  .shortcuts-modal-content {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}
