/* ==========================================================================
   JustPrint Web Edition - Universal Responsive Stylesheet
   Pixel-Perfect Mobile APK UI + Spacious Desktop Fullscreen Experience
   ========================================================================== */

:root {
  /* Core Color Palette - SwiftFileKit Slate & Indigo Palette */
  --bg-app: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-surface: #1e293b;
  --bg-elevated: #334155;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.25);

  --primary-red: #6366f1;
  --primary-red-hover: #4f46e5;
  --primary-red-glow: rgba(99, 102, 241, 0.35);

  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-emerald: #10b981;
  --accent-blue: #3b82f6;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
body.theme-light {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-surface: #f8fafc;
  --bg-elevated: #e2e8f0;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.14);
  --border-strong: rgba(0, 0, 0, 0.24);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

button {
  font-family: inherit;
}

/* Network Banner */
.network-banner {
  background: #f59e0b;
  color: #000000;
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.network-banner.hidden {
  display: none;
}

/* ==========================================================================
   Responsive Wrapper (Fluid on Desktop, Mobile-Shell on Phone)
   ========================================================================== */
.apk-app-wrapper {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px 36px 16px;
  display: flex;
  flex-direction: column;
  transition: max-width var(--transition-normal);
}

@media (min-width: 768px) {
  .apk-app-wrapper {
    max-width: 94vw;
    padding: 0 28px 48px 28px;
  }
}

@media (min-width: 1024px) {
  .apk-app-wrapper {
    max-width: 1200px;
    padding: 0 36px 56px 36px;
  }
}

@media (min-width: 1360px) {
  .apk-app-wrapper {
    max-width: 1380px;
    padding: 0 44px 64px 44px;
  }
}

/* Universal Header */
.app-universal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  color: var(--primary-red);
  width: 28px;
  height: 28px;
}

.brand-text-group {
  display: flex;
  flex-direction: column;
}

.brand-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Desktop Stepper Navigation */
.desktop-stepper-nav {
  display: none;
}

@media (min-width: 860px) {
  .desktop-stepper-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 4px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  .step-nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .step-nav-item:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
  }

  .step-nav-item.active {
    background: var(--primary-red);
    color: #ffffff;
    box-shadow: 0 2px 10px var(--primary-red-glow);
  }

  .step-nav-item.completed {
    color: var(--text-primary);
  }

  .step-nav-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    font-weight: 800;
  }

  .step-nav-item.active .step-nav-num {
    background: rgba(0, 0, 0, 0.25);
  }

  .step-nav-arrow {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    opacity: 0.4;
  }

  .step-nav-arrow i {
    width: 14px;
    height: 14px;
  }
}

.header-util-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn-util {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn-util:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

body.theme-dark .sun-icon { display: block; }
body.theme-dark .moon-icon { display: none; }
body.theme-light .sun-icon { display: none; }
body.theme-light .moon-icon { display: block; }

/* Screen Views */
.apk-screen-viewport {
  flex: 1;
}

.screen-view {
  display: none;
  animation: fadeIn 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen-view.active {
  display: block;
}

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

/* ==========================================================================
   APK Top Appbar
   ========================================================================== */
.apk-top-appbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0 20px 0;
  flex-wrap: wrap;
}

.apk-appbar-back {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.apk-appbar-back:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-light .apk-appbar-back:hover {
  background: rgba(0, 0, 0, 0.06);
}

.apk-appbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.apk-appbar-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.apk-doc-title-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apk-info-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.apk-info-count {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.desktop-align-right {
  margin-left: auto;
}

/* Bottom CTA Primary Button */
.apk-bottom-cta-wrap {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 0 20px 0;
  background: linear-gradient(180deg, rgba(13, 15, 18, 0) 0%, rgba(13, 15, 18, 0.95) 40%, #0d0f14 100%);
  z-index: 50;
  margin-top: 24px;
}

body.theme-light .apk-bottom-cta-wrap {
  background: linear-gradient(180deg, rgba(241, 245, 249, 0) 0%, rgba(241, 245, 249, 0.95) 40%, #f1f5f9 100%);
}

.apk-btn-primary {
  width: 100%;
  height: 54px;
  background: var(--primary-red);
  border: none;
  border-radius: var(--radius-lg);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px var(--primary-red-glow);
  transition: all var(--transition-fast);
}

.apk-btn-primary:hover {
  background: var(--primary-red-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-red-glow);
}

.apk-btn-primary:active {
  transform: translateY(1px);
}

/* ==========================================================================
   Desktop Split Layout (Steps 5, 6, 7 and Step 1 Dashboard)
   ========================================================================== */
.desktop-split-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 900px) {
  .desktop-split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 36px;
    align-items: start;
  }

  .desktop-split-left {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
  }

  .desktop-split-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
}

@media (min-width: 1280px) {
  .desktop-split-layout {
    grid-template-columns: 1.08fr 0.92fr;
    gap: 48px;
  }
}

/* ==========================================================================
   STEP 1: IMPORT & HOME SCREEN
   ========================================================================== */
.apk-home-header {
  text-align: center;
  padding: 10px 0 28px 0;
}

.apk-brand-logo-large {
  width: 68px;
  height: 68px;
  background: var(--primary-red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  margin: 0 auto 16px auto;
  box-shadow: 0 4px 20px var(--primary-red-glow);
}

.apk-home-title {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.apk-home-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 480px;
  margin: 0 auto;
}

/* Desktop Home Dashboard 2-Column Layout */
.desktop-home-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 900px) {
  .desktop-home-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 36px;
    align-items: start;
  }
}

.upload-container-outer {
  width: 100%;
}

.upload-dropzone {
  background: var(--bg-card);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  margin-bottom: 16px;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--primary-red);
  background: rgba(239, 68, 68, 0.04);
  transform: translateY(-2px);
}

.upload-icon-circle {
  width: 68px;
  height: 68px;
  background: rgba(239, 68, 68, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-red);
  margin: 0 auto 16px auto;
}

.upload-icon-circle i {
  width: 30px;
  height: 30px;
}

.upload-title {
  font-size: 1.28rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.upload-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.upload-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  font-size: 0.82rem;
  font-weight: 700;
}

.hidden-input {
  display: none;
}

.sample-action-box {
  text-align: center;
}

.btn-sample-link {
  background: transparent;
  border: none;
  color: var(--primary-red);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-sample-link:hover {
  text-decoration: underline;
}

/* Recent Files History Grid */
.my-files-section {
  margin-bottom: 20px;
}

.section-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-clear-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-clear-link:hover {
  color: var(--primary-red);
}

.recent-files-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.recent-file-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.recent-file-item:hover {
  border-color: var(--border-medium);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.recent-file-icon {
  color: var(--primary-red);
  flex-shrink: 0;
}

.recent-file-info {
  flex: 1;
  min-width: 0;
}

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

.recent-file-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Desktop Feature Highlights Card */
.desktop-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  color: var(--primary-red);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feature-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.feature-text strong {
  font-size: 0.92rem;
  color: var(--text-primary);
}

.feature-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   STEP 2 & 3: SELECTION & REARRANGE (Wide Multi-Column Grids on PC)
   ========================================================================== */
.apk-filter-chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.apk-filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.apk-filter-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.apk-pages-grid, .apk-rearrange-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 600px) {
  .apk-pages-grid, .apk-rearrange-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 18px;
  }
}

@media (min-width: 1024px) {
  .apk-pages-grid, .apk-rearrange-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 22px;
  }
}

.page-item-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px;
  position: relative;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-item-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.page-item-card.selected {
  border-color: var(--primary-red);
  background: rgba(239, 68, 68, 0.04);
}

.page-thumb-container {
  width: 100%;
  aspect-ratio: 1 / 1.414;
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.page-thumb-container canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

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

.page-num-tag {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.page-select-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.page-item-card.selected .page-select-checkbox {
  background: var(--primary-red);
  border-color: var(--primary-red);
  color: #ffffff;
}

.btn-rotate-card {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-rotate-card:hover {
  color: var(--primary-red);
  background: rgba(239, 68, 68, 0.1);
}

/* Rearrange Drag & Drop Card Styles */
.rearrange-card {
  user-select: none;
  cursor: grab;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.rearrange-card:active {
  cursor: grabbing;
}

.rearrange-card.is-dragging {
  opacity: 0.45;
  transform: scale(0.96);
  border: 2px dashed var(--primary-red);
  box-shadow: 0 8px 24px var(--primary-red-glow);
}

.rearrange-card.drag-over-target {
  border: 2px solid var(--primary-red);
  transform: translateY(-4px);
  box-shadow: 0 0 16px var(--primary-red-glow);
}

.rearrange-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 0 2px;
}

.drag-grip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: grab;
}

.drag-grip i {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
}

.page-order-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary-red);
}

.rearrange-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}

.rearrange-nav-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-move-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-move-card:hover:not(:disabled) {
  background: var(--primary-red);
  color: #ffffff;
  border-color: var(--primary-red);
}

.btn-move-card:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-move-card i {
  width: 14px;
  height: 14px;
}

.page-orig-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ==========================================================================
   STEP 4: SELECT LAYOUT SCREEN
   ========================================================================== */
.apk-tabs-header {
  display: flex;
  border-bottom: 1.5px solid var(--border-subtle);
  margin-bottom: 20px;
  max-width: 480px;
}

.apk-tab-btn {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
  text-align: center;
}

.apk-tab-btn.active {
  color: var(--primary-red);
}

.apk-tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1.5px;
  left: 0;
  right: 0;
  height: 2.5px;
  background: var(--primary-red);
  border-radius: 3px 3px 0 0;
}

.apk-tab-pane {
  display: none;
}

.apk-tab-pane.active {
  display: block;
}

.apk-format-toggle-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
  max-width: 480px;
}

.apk-format-pill {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all var(--transition-fast);
}

.apk-format-pill.active {
  border-color: var(--primary-red);
  background: rgba(239, 68, 68, 0.06);
}

.pill-main {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.apk-format-pill.active .pill-main {
  color: var(--primary-red);
}

.pill-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Presets Grid: 2 Columns on Mobile, 3 Columns on Medium, 4 Columns on Wide PC */
.apk-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (min-width: 768px) {
  .apk-presets-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1200px) {
  .apk-presets-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
  }
}

.apk-presets-grid.hidden {
  display: none;
}

.app-layout-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px 14px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.app-layout-card:hover {
  border-color: rgba(239, 68, 68, 0.5);
  transform: translateY(-2px);
}

.app-layout-card.active {
  border: 2px solid var(--primary-red);
  background: rgba(239, 68, 68, 0.05);
  box-shadow: 0 0 16px var(--primary-red-glow);
}

.app-wireframe-box {
  width: 100%;
  height: 114px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.app-mini-sheet {
  background: #252a34;
  border: 1.5px solid #3b4252;
  border-radius: 8px;
  padding: 5px;
  display: grid;
  gap: 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
}

body.theme-light .app-mini-sheet {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.app-mini-sheet.landscape {
  width: 92px;
  height: 65px;
  padding: 5px;
  gap: 4px;
}

.app-mini-sheet.portrait {
  width: 65px;
  height: 92px;
  padding: 5px;
  gap: 4px;
}

.app-red-cell {
  background: var(--primary-red);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

/* Individual Cell Formats */
.cell-1-1-landscape { width: 78px; height: 51px; }
.cell-1-1-portrait { width: 51px; height: 78px; }
.cell-2-1-portrait { width: 51px; height: 36px; }
.cell-3-1-portrait { width: 51px; height: 23px; }

.app-mini-sheet.landscape.grid-2x2-mini { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.app-mini-sheet.landscape.grid-2x2-mini .app-red-cell { width: 37px; height: 24px; }

.app-mini-sheet.portrait.grid-2x2-mini { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.app-mini-sheet.portrait.grid-2x2-mini .app-red-cell { width: 24px; height: 36px; }

.grid-3x2-mini { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
.grid-3x2-mini .app-red-cell { width: 24px; height: 23px; }

.grid-4x2-mini { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr 1fr; }
.grid-4x2-mini .app-red-cell { width: 24px; height: 16px; }

.grid-1x2-mini { grid-template-columns: 1fr 1fr; }
.grid-1x2-mini .app-red-cell { width: 37px; height: 51px; }

.grid-1x3-mini { grid-template-columns: 1fr 1fr 1fr; }
.grid-1x3-mini .app-red-cell { width: 23px; height: 51px; }

.grid-2x3-mini { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.grid-2x3-mini .app-red-cell { width: 23px; height: 24px; }

.grid-2x4-mini { grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.grid-2x4-mini .app-red-cell { width: 17px; height: 24px; }

.app-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.app-layout-card.active .app-card-title {
  color: var(--primary-red);
}

.app-card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-card-check {
  margin-top: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}

.app-layout-card.active .app-card-check {
  color: var(--primary-red);
}

/* Custom Layout Stage */
.custom-layout-stage {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

@media (min-width: 680px) {
  .custom-layout-stage {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 32px;
    align-items: center;
  }
}

.custom-card-preview {
  width: 150px;
  height: 190px;
  background: var(--bg-surface);
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  margin: 0 auto 16px auto;
}

.custom-summary-text {
  font-weight: 800;
  color: var(--primary-red);
  font-size: 1.05rem;
  margin-bottom: 16px;
  display: block;
}

.custom-controls-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ctrl-row label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.apk-slider-range {
  flex: 1;
  accent-color: var(--primary-red);
}

/* ==========================================================================
   STEP 5: PAGE SETUP SCREEN
   ========================================================================== */
.apk-preview-meta-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.apk-sheet-preview-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px 20px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  margin-bottom: 18px;
}

.sheet-preview-viewport {
  width: 100%;
  min-height: 280px;
  max-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 900px) {
  .sheet-preview-viewport {
    min-height: 380px;
    max-height: 480px;
  }
}

.virtual-sheet-real {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  display: grid;
  gap: 4px;
  padding: 8px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.virtual-sheet-real.portrait {
  width: 220px;
  height: 310px;
}

.virtual-sheet-real.landscape {
  width: 310px;
  height: 220px;
}

.sheet-page-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  overflow: hidden;
  border-radius: 2px;
  height: 100%;
  width: 100%;
  transition: all var(--transition-fast);
}

.sheet-page-cell.has-border {
  border: 1.5px solid #000000;
}

.sheet-page-cell.has-cutlines {
  outline: 1px dashed rgba(239, 68, 68, 0.55);
  outline-offset: -2px;
}

.sheet-page-cell canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.virtual-sheet-real.inverted .sheet-page-cell canvas {
  filter: invert(1) hue-rotate(180deg);
}

.virtual-sheet-real.clear-bg .sheet-page-cell canvas {
  filter: contrast(135%) brightness(108%);
}

.sheet-page-num-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  z-index: 5;
  pointer-events: none;
}

.apk-preview-hint {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 14px;
  text-align: center;
}

/* Page Options 2x2 Grid */
.apk-section-header {
  margin-bottom: 12px;
}

.apk-section-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.apk-options-2x2-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.app-option-toggle-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.app-option-toggle-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.app-option-toggle-card.active {
  border-color: var(--primary-red);
  background: rgba(239, 68, 68, 0.04);
}

.option-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.option-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.option-icon.red-icon {
  color: var(--primary-red);
}

.option-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

/* APK Switch Toggle */
.apk-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  pointer-events: none; /* Let parent card handle click event seamlessly */
}

.apk-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.apk-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2e3440;
  transition: .22s;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-light .apk-slider {
  background-color: #cbd5e1;
}

.apk-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: .22s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.apk-switch input:checked + .apk-slider {
  background-color: var(--primary-red);
  border-color: var(--primary-red);
}

.apk-switch input:checked + .apk-slider:before {
  transform: translateX(20px);
}

/* Accordion */
.setup-advanced-accordion {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 10px;
}

.accordion-header {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-secondary);
  user-select: none;
  list-style: none;
}

.accordion-header::-webkit-details-marker {
  display: none;
}

.accordion-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.accordion-title-wrap i {
  color: var(--primary-red);
}

.accordion-arrow {
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.setup-advanced-accordion[open] .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 18px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.adv-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 14px;
}

.adv-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.adv-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toggle-pills {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.pill-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.pill-btn.active {
  background: var(--primary-red) !important;
  color: #ffffff !important;
  box-shadow: 0 1px 6px var(--primary-red-glow);
}

.toggle-switch-sm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.toggle-switch-sm input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-switch-sm .switch-slider {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  background-color: #2e3440;
  border-radius: 22px;
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toggle-switch-sm .switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle-switch-sm input:checked + .switch-slider {
  background-color: var(--primary-red);
  border-color: var(--primary-red);
}

.toggle-switch-sm input:checked + .switch-slider:before {
  transform: translateX(16px);
}

.toggle-switch-sm .label-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==========================================================================
   STEP 6: COLOR MODE SCREEN
   ========================================================================== */
.apk-colormode-meta-header {
  margin-bottom: 12px;
}

.apk-preview-meta-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

#colormode-live-preview-canvas {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

@media (min-width: 900px) {
  #colormode-live-preview-canvas {
    max-height: 420px;
  }
}

.apk-sim-pager-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: -6px 0 16px 0;
}

.apk-pager-arrow-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.apk-pager-arrow-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.apk-pager-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.apk-colormodes-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.apk-colormode-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.apk-colormode-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.apk-colormode-card.active {
  border: 2px solid var(--primary-red);
  background: rgba(239, 68, 68, 0.05);
  box-shadow: 0 0 16px var(--primary-red-glow);
}

.apk-colormode-card.full-width {
  width: 100%;
}

.mode-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.apk-colormode-card.active .mode-card-title {
  color: var(--primary-red);
}

.mode-card-sub {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ==========================================================================
   STEP 7: PRINTABLE PDF SCREEN
   ========================================================================== */
.desktop-printable-view {
  display: none;
}

@media (min-width: 900px) {
  .desktop-printable-view {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 22px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  .desktop-stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
  }

  .stage-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .stage-sheet-pager {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .stage-page-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
  }

  .desktop-stage-canvas-box {
    width: 100%;
    min-height: 440px;
    max-height: 540px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    padding: 16px;
  }

  #output-sheet-canvas {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
  }
}

.apk-ready-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 8px 0 24px 0;
}

.apk-ready-icon-circle {
  width: 68px;
  height: 68px;
  background: var(--primary-red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  margin-bottom: 14px;
  box-shadow: 0 4px 20px var(--primary-red-glow);
}

.apk-ready-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.apk-ready-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* File Card */
.apk-ready-file-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.ready-file-thumb {
  width: 58px;
  height: 82px;
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ready-file-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ready-file-info {
  flex: 1;
  min-width: 0;
}

.ready-file-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ready-file-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.ready-file-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ready-file-open-btn {
  background: transparent;
  border: none;
  color: var(--primary-red);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ready-file-open-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Action Cards Stack */
.apk-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.apk-action-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.apk-action-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.apk-action-card:active {
  transform: scale(0.99);
}

.action-card-icon-squircle {
  width: 48px;
  height: 48px;
  background: var(--primary-red);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-red-glow);
}

.action-card-body {
  flex: 1;
  min-width: 0;
}

.action-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.action-sub {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin: 0;
}

.action-card-arrow {
  color: var(--text-muted);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.apk-action-card:hover .action-card-arrow {
  color: var(--text-primary);
  transform: translateX(3px);
}

.apk-bottom-restart {
  text-align: center;
  margin-top: 12px;
}

.btn-restart-session {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 10px 22px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-restart-session:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.loading-dialog-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--primary-red);
  border-radius: 50%;
  margin: 0 auto 16px auto;
  animation: spin 0.8s linear infinite;
}

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

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 16px 0 8px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-red);
  border-radius: var(--radius-full);
  transition: width 0.2s ease;
}

.progress-percentage-text {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-red);
}

/* Fullscreen Preview Modal */
.preview-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.preview-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
}

.preview-modal-canvas-box {
  flex: 1;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #000000;
}

.preview-modal-canvas-box canvas {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.preview-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-page-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-page-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   ALL-IN-ONE PDF TOOLS HUB & WORKSPACE STYLES (#E5322D THEME)
   ========================================================================== */

.hub-hero-section {
  padding: 32px 20px 24px;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.hub-main-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hub-main-title span {
  color: var(--primary-red);
}

.hub-main-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Hub Search & Filter Bar */
.hub-controls-bar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  margin-bottom: 32px;
}

.hub-search-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.hub-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.hub-search-input {
  width: 100%;
  padding: 12px 16px 12px 46px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.hub-search-input:focus {
  outline: none;
  border-color: var(--primary-red);
  box-shadow: 0 0 0 3px var(--primary-red-glow);
}

.hub-category-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.hub-pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hub-pill-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.hub-pill-btn.active {
  background: var(--primary-red);
  color: #ffffff;
  border-color: var(--primary-red);
  box-shadow: 0 2px 8px var(--primary-red-glow);
}

/* Tools Grid Layout */
.tools-grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  padding: 0 20px 48px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.tool-hub-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
  text-align: left;
}

.tool-hub-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-red);
  box-shadow: 0 10px 24px rgba(229, 50, 45, 0.12);
  background: var(--bg-card-hover);
}

.tool-card-icon-box {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: rgba(229, 50, 45, 0.12);
  color: var(--primary-red);
  border: 1px solid rgba(229, 50, 45, 0.2);
}

.tool-hub-card:hover .tool-card-icon-box {
  background: var(--primary-red);
  color: #ffffff;
}

.tool-card-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tool-card-badge.popular {
  background: rgba(229, 50, 45, 0.15);
  color: var(--primary-red);
  border-color: rgba(229, 50, 45, 0.3);
}

.tool-card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.tool-card-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.45;
  flex: 1;
  margin-bottom: 16px;
}

.tool-card-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-red);
}

/* Dedicated Tool Workspace */
.tool-workspace-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  width: 100%;
}

.tool-ws-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.tool-ws-breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-ws-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ws-back:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-red);
}

.tool-ws-title-group h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.tool-ws-title-group p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.tool-ws-body-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

@media (max-width: 860px) {
  .tool-ws-body-grid {
    grid-template-columns: 1fr;
  }
}

.ws-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.ws-options-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ws-option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-option-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ws-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.ws-input:focus {
  outline: none;
  border-color: var(--primary-red);
}

.ws-btn-primary {
  width: 100%;
  background: var(--primary-red);
  color: #ffffff;
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px var(--primary-red-glow);
  transition: all var(--transition-fast);
}

.ws-btn-primary:hover {
  background: var(--primary-red-hover);
  transform: translateY(-1px);
}

.ws-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ws-file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  max-height: 280px;
  overflow-y: auto;
}

.ws-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.ws-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-mini-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.75rem;
}

.ws-mini-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.ws-mini-btn.danger:hover {
  background: rgba(229, 50, 45, 0.2);
  color: var(--primary-red);
  border-color: var(--primary-red);
}

.sig-pad-canvas {
  width: 100%;
  height: 180px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border-medium);
  cursor: crosshair;
  touch-action: none;
}
