    :root {
      --bg: #0a0a0f;
      --surface-1: rgba(255,255,255,.05);
      --surface-2: rgba(255,255,255,.08);
      --surface-3: rgba(255,255,255,.12);
      --glass: rgba(20,20,35,.7);
      --glass-dark: rgba(20,20,35,.85);
      --text: #f0f0f5;
      --text-secondary: rgba(240,240,245,.6);
      --text-tertiary: rgba(240,240,245,.45);
      --border: rgba(255,255,255,.08);
      --border-light: rgba(255,255,255,.15);
      --grad1: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
      --radius: 16px;
      --radius-sm: 12px;
      --radius-lg: 24px;
      --transition: all 300ms cubic-bezier(.4,0,.2,1);
    }

    [data-mode="light"] {
      --bg: #f5f5f7;
      --surface-1: rgba(0,0,0,.03);
      --surface-2: rgba(0,0,0,.06);
      --surface-3: rgba(0,0,0,.1);
      --glass: rgba(255,255,255,.8);
      --glass-dark: rgba(255,255,255,.9);
      --text: #1a1a2e;
      --text-secondary: rgba(26,26,46,.6);
      --text-tertiary: rgba(26,26,46,.45);
      --border: rgba(0,0,0,.08);
      --border-light: rgba(0,0,0,.12);
    }

    [data-theme="emerald"] { --grad1: linear-gradient(135deg, #10b981, #34d399, #6ee7b7); }
    [data-theme="rose"] { --grad1: linear-gradient(135deg, #f43f5e, #fb7185, #fda4af); }
    [data-theme="amber"] { --grad1: linear-gradient(135deg, #f59e0b, #fbbf24, #fcd34d); }

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

    /* Skip to content link (accessibility) */
    .skip-link {
      position: absolute;
      top: -100%;
      left: 16px;
      z-index: 9999;
      padding: 12px 20px;
      background: var(--grad1);
      color: white;
      border-radius: var(--radius-sm);
      font-weight: 600;
      font-size: 14px;
      text-decoration: none;
      transition: top 0.2s;
    }
    .skip-link:focus {
      top: 12px;
    }

    /* Keyboard focus styles */
    :focus-visible {
      outline: 2px solid #6366f1;
      outline-offset: 2px;
    }
    button:focus:not(:focus-visible),
    input:focus:not(:focus-visible) {
      outline: none;
    }

    html, body {
      width: 100%;
      height: 100%;
      font-family: 'Inter', sans-serif;
      background: var(--bg);
      color: var(--text);
      overflow: hidden;
    }

    body {
      display: flex;
      flex-direction: column;
    }

    /* Layout */
    #app {
      display: flex;
      flex-direction: column;
      height: 100vh;
      position: relative;
    }

    /* Top bar with logo */
    .top-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: max(12px, env(safe-area-inset-top)) 16px 12px;
      background: var(--glass-dark);
      backdrop-filter: blur(20px);
      border-bottom: 1px solid var(--border);
      z-index: 100;
      flex-shrink: 0;
    }

    .top-bar-left {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .top-bar-logo {
      height: 28px;
      width: auto;
      flex-shrink: 0;
      object-fit: contain;
    }

    .top-bar-title {
      font-size: 18px;
      font-weight: 800;
      letter-spacing: -0.3px;
      background: var(--grad1);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .share-app-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 14px;
      border: 1px solid var(--border-light);
      border-radius: 20px;
      background: var(--surface-2);
      color: var(--text);
      font-size: 12px;
      font-weight: 600;
      font-family: 'Inter', sans-serif;
      cursor: pointer;
      transition: var(--transition);
    }

    .share-app-btn:hover {
      background: var(--surface-3);
      transform: translateY(-1px);
    }

    .share-app-btn:active {
      transform: scale(0.97);
    }

    /* Ambient orbs */
    .orb-container {
      position: fixed;
      inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 0;
    }

    .orb {
      position: absolute;
      border-radius: 50%;
      filter: blur(80px);
      opacity: 0.15;
    }

    .orb-1 { width: 400px; height: 400px; background: #6366f1; top: -100px; left: -100px; }
    .orb-2 { width: 300px; height: 300px; background: #a855f7; bottom: -50px; right: -50px; }

    /* Content area */
    .content-wrapper {
      flex: 1;
      overflow: hidden;
      position: relative;
      z-index: 1;
    }

    .screen {
      position: absolute;
      inset: 0;
      opacity: 0;
      pointer-events: none;
      transition: opacity 300ms ease;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    .screen.active {
      opacity: 1;
      pointer-events: auto;
    }

    .screen-content {
      padding: 16px;
      padding-bottom: 80px;
    }

    /* Navigation */
    .nav-bar {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      height: calc(64px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
      background: var(--glass-dark);
      backdrop-filter: blur(20px);
      border-top: 1px solid var(--border);
      display: flex;
      justify-content: space-around;
      align-items: center;
      z-index: 100;
    }

    .nav-item {
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      cursor: pointer;
      position: relative;
      transition: var(--transition);
      border: none;
      background: none;
      color: var(--text-secondary);
      font-size: 12px;
      font-weight: 500;
    }

    .nav-item.active {
      color: var(--text);
    }

    .nav-item.active::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 3px;
      background: var(--grad1);
    }

    .nav-icon {
      font-size: 24px;
    }

    /* FAB */
    .fab {
      position: fixed;
      bottom: 80px;
      right: 16px;
      width: 56px;
      height: 56px;
      border-radius: 50%;
      background: var(--grad1);
      border: none;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
      box-shadow: 0 8px 24px rgba(99,102,241,0.4);
      transition: var(--transition);
      z-index: 50;
      animation: pulse-glow 2s ease-in-out infinite;
    }

    .fab:hover {
      transform: scale(1.1);
      box-shadow: 0 12px 32px rgba(99,102,241,0.6);
    }

    .fab:active {
      transform: scale(0.95);
    }

    @keyframes pulse-glow {
      0%, 100% { opacity: 0.85; }
      50% { opacity: 1; }
    }

    /* Headers */
    .header {
      font-size: 28px;
      font-weight: 700;
      margin-bottom: 24px;
      background: var(--grad1);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .subheader {
      font-size: 14px;
      color: var(--text-secondary);
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .subheader-action {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      background: var(--grad1);
      border: none;
      color: white;
      font-size: 18px;
      font-weight: 700;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: var(--transition);
      line-height: 1;
    }

    .subheader-action:hover {
      transform: scale(1.1);
      box-shadow: 0 0 16px rgba(99, 102, 241, 0.5);
    }

    /* Cards */
    .card {
      background: var(--glass);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 16px;
      transition: var(--transition);
      cursor: pointer;
    }

    .card:hover {
      background: var(--glass-dark);
      border-color: var(--border-light);
    }

    .card-title {
      font-weight: 600;
      margin-bottom: 8px;
      font-size: 14px;
    }

    .card-meta {
      font-size: 12px;
      color: var(--text-tertiary);
    }

    /* Buttons */
    .btn {
      padding: 12px 20px;
      border-radius: var(--radius-sm);
      border: none;
      font-weight: 600;
      font-size: 14px;
      cursor: pointer;
      transition: var(--transition);
      font-family: 'Inter', sans-serif;
    }

    .btn-primary {
      background: var(--grad1);
      color: white;
      box-shadow: 0 4px 12px rgba(99,102,241,0.3);
    }

    .btn-primary:hover {
      box-shadow: 0 6px 20px rgba(99,102,241,0.5);
      transform: translateY(-2px);
    }

    .btn-secondary {
      background: var(--surface-2);
      color: var(--text);
      border: 1px solid var(--border);
    }

    .btn-secondary:hover {
      background: var(--surface-3);
      border-color: var(--border-light);
    }

    .btn-sm {
      padding: 8px 12px;
      font-size: 12px;
    }

    .btn-icon {
      width: 44px;
      height: 44px;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
    }

    /* Inputs */
    .input-field {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 12px;
      color: var(--text);
      font-family: 'Inter', sans-serif;
      font-size: 14px;
      transition: var(--transition);
    }

    .input-field:focus {
      outline: none;
      background: var(--surface-3);
      border-color: var(--border-light);
      box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
    }

    /* Grid */
    .grid {
      display: grid;
      gap: 12px;
    }

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

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

    /* Document grid */
    .doc-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .doc-item {
      aspect-ratio: 3/4;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: var(--transition);
      position: relative;
      overflow: hidden;
    }

    .doc-item:hover {
      background: var(--surface-3);
      transform: scale(1.02);
    }
    .doc-item.batch-selected {
      outline: 3px solid #6366f1;
      outline-offset: -3px;
    }

    .doc-item-image {
      width: 100%;
      height: 80%;
      object-fit: cover;
      background: var(--surface-3);
    }

    .doc-item-label {
      width: 100%;
      height: 20%;
      padding: 4px;
      font-size: 10px;
      color: var(--text-secondary);
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .page-badge {
      position: absolute;
      top: 4px;
      right: 4px;
      background: var(--grad1);
      color: white;
      width: 24px;
      height: 24px;
      border-radius: 50%;
      font-size: 10px;
      font-weight: 700;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Modal */
    .modal {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.7);
      display: flex;
      align-items: flex-end;
      z-index: 200;
      opacity: 0;
      pointer-events: none;
      transition: opacity 300ms ease;
    }

    .modal.active {
      opacity: 1;
      pointer-events: auto;
    }

    .modal-content {
      width: 100%;
      background: var(--glass-dark);
      backdrop-filter: blur(20px);
      border-top: 1px solid var(--border);
      border-radius: var(--radius) var(--radius) 0 0;
      padding: 20px;
      max-height: 90vh;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      animation: slide-up 300ms cubic-bezier(.4,0,.2,1);
    }

    @keyframes slide-up {
      from { transform: translateY(100%); }
      to { transform: translateY(0); }
    }

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

    .modal-title {
      font-size: 18px;
      font-weight: 700;
    }

    .modal-close {
      background: var(--surface-2);
      border: none;
      border-radius: 50%;
      width: 44px;
      height: 44px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text);
      transition: var(--transition);
      flex-shrink: 0;
    }

    .modal-close:hover {
      background: var(--surface-3);
    }

    /* Scan screen */
    .scan-container {
      position: relative;
      width: 100%;
      aspect-ratio: 3/4;
      background: black;
      border-radius: var(--radius);
      overflow: hidden;
      margin-bottom: 16px;
    }

    video {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    #canvas-preview {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Overlays */
    .scan-overlay {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .scan-frame {
      position: absolute;
      inset: 0;
      border: 2px dashed rgba(255,255,255,0.3);
      border-radius: 8px;
    }

    .scan-frame.card-mode {
      width: 85.6mm;
      height: 53.98mm;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      border: 3px solid rgba(99,102,241,0.5);
      border-radius: 12px;
      box-shadow: inset 0 0 0 1000px rgba(0,0,0,0.4);
    }

    .scan-frame.document-mode {
      margin: 10%;
      top: 10%;
      width: 80%;
      height: 80%;
    }

    .scan-corner {
      position: absolute;
      width: 30px;
      height: 30px;
      border: 2px solid #6366f1;
    }

    .scan-corner.tl { top: 20px; left: 20px; border-right: none; border-bottom: none; }
    .scan-corner.tr { top: 20px; right: 20px; border-left: none; border-bottom: none; }
    .scan-corner.bl { bottom: 20px; left: 20px; border-right: none; border-top: none; }
    .scan-corner.br { bottom: 20px; right: 20px; border-left: none; border-top: none; }

    /* Toolbar */
    .scan-toolbar {
      display: flex;
      gap: 8px;
      margin-bottom: 16px;
      flex-wrap: wrap;
    }

    .chip {
      padding: 8px 16px;
      border-radius: var(--radius-lg);
      border: none;
      background: var(--surface-2);
      color: var(--text);
      cursor: pointer;
      font-size: 12px;
      font-weight: 600;
      transition: var(--transition);
      border: 1px solid var(--border);
    }

    .chip.active {
      background: var(--grad1);
      color: white;
      border-color: transparent;
    }

    .chip:hover {
      background: var(--surface-3);
    }

    .chip.active:hover {
      background: var(--grad1);
    }

    /* Signature pad */
    #signature-canvas {
      width: 100%;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      cursor: crosshair;
      touch-action: none;
    }

    /* Receipt data */
    .receipt-data {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 16px;
      margin-bottom: 16px;
    }

    .receipt-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 0;
      border-bottom: 1px solid var(--border);
    }

    .receipt-row:last-child {
      border-bottom: none;
    }

    .receipt-label {
      color: var(--text-secondary);
      font-size: 13px;
      font-weight: 500;
    }

    .receipt-value {
      color: var(--text);
      font-weight: 600;
      font-size: 14px;
    }

    /* OCR modal */
    .ocr-text {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 16px;
      font-size: 14px;
      line-height: 1.6;
      color: var(--text);
      margin-bottom: 16px;
      max-height: 300px;
      overflow-y: auto;
      word-wrap: break-word;
    }

    /* Tools grid */
    .tools-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
    }

    .tool-card {
      background: var(--glass);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      cursor: pointer;
      transition: var(--transition);
      text-align: center;
    }

    .tool-card:hover {
      background: var(--glass-dark);
      border-color: var(--border-light);
      transform: translateY(-4px);
    }

    .tool-icon {
      font-size: 32px;
    }

    .tool-name {
      font-weight: 600;
      font-size: 14px;
    }

    .tool-desc {
      font-size: 12px;
      color: var(--text-tertiary);
    }

    /* Folders */
    .folder-list {
      display: flex;
      gap: 12px;
      margin-bottom: 16px;
      overflow-x: auto;
      padding-bottom: 8px;
    }

    .folder-item {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 10px 16px;
      cursor: pointer;
      white-space: nowrap;
      transition: var(--transition);
      display: flex;
      align-items: center;
      gap: 8px;
      position: relative;
    }

    .folder-item.active {
      background: var(--grad1);
      color: white;
      border-color: transparent;
    }

    .folder-delete {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: rgba(239, 68, 68, 0.2);
      border: 1px solid rgba(239, 68, 68, 0.4);
      color: #ef4444;
      font-size: 12px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: var(--transition);
      flex-shrink: 0;
      padding: 0;
      line-height: 1;
    }

    .folder-delete:hover {
      background: rgba(239, 68, 68, 0.4);
      transform: scale(1.15);
    }

    .folder-item.active .folder-delete {
      background: rgba(255, 255, 255, 0.2);
      border-color: rgba(255, 255, 255, 0.4);
      color: white;
    }

    /* Search */
    .search-bar {
      position: relative;
      margin-bottom: 16px;
    }

    .search-bar input {
      width: 100%;
      padding-left: 36px;
    }

    .search-icon {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-secondary);
      pointer-events: none;
    }

    /* Loading */
    .spinner {
      width: 40px;
      height: 40px;
      border: 3px solid var(--surface-2);
      border-top-color: var(--grad1);
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }

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

    .loading-center {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 300px;
    }

    /* Responsive */
    @media (max-width: 480px) {
      .tools-grid {
        grid-template-columns: repeat(2, 1fr);
      }

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

    /* Utility */
    .hidden { display: none !important; }
    .mt-1 { margin-top: 8px; }
    .mt-2 { margin-top: 16px; }
    .mb-1 { margin-bottom: 8px; }
    .mb-2 { margin-bottom: 16px; }
    .gap-1 { gap: 8px; }
    .gap-2 { gap: 16px; }

    /* File input hidden */
    input[type="file"] {
      display: none;
    }

    /* Page thumbnails */
    .page-list {
      display: flex;
      gap: 12px;
      overflow-x: auto;
      padding-bottom: 8px;
      margin-bottom: 16px;
    }

    .page-thumb {
      flex-shrink: 0;
      width: 80px;
      aspect-ratio: 3/4;
      background: var(--surface-2);
      border: 2px solid var(--border);
      border-radius: var(--radius-sm);
      cursor: grab;
      overflow: hidden;
      position: relative;
      transition: var(--transition);
    }

    .page-thumb:hover {
      border-color: var(--border-light);
    }

    .page-thumb.active {
      border-color: #6366f1;
    }

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

    .page-index {
      position: absolute;
      bottom: 4px;
      right: 4px;
      background: rgba(0,0,0,0.6);
      color: white;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      font-size: 10px;
      font-weight: 700;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Empty state */
    .empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 300px;
      gap: 12px;
      color: var(--text-secondary);
    }

    .empty-icon {
      font-size: 48px;
      opacity: 0.5;
    }

    .empty-text {
      font-size: 14px;
      text-align: center;
    }
    /* Premium Banner */
    .premium-overlay {
      position: fixed;
      inset: 0;
      background: var(--bg);
      z-index: 10000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      padding-top: max(20px, env(safe-area-inset-top));
      padding-bottom: max(20px, env(safe-area-inset-bottom));
      animation: fadeIn 0.4s ease;
    }

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

    .premium-banner {
      background: rgba(25, 25, 45, 0.98);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-lg);
      padding: 28px 24px 24px;
      max-width: 380px;
      width: 100%;
      text-align: center;
      position: relative;
      overflow: hidden;
    }

    .premium-banner::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: conic-gradient(from 0deg, transparent, rgba(99,102,241,0.1), transparent, rgba(139,92,246,0.1), transparent);
      animation: premiumRotate 6s linear infinite;
    }

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

    .premium-banner > * {
      position: relative;
      z-index: 1;
    }

    .premium-logo {
      height: 48px;
      width: auto;
      object-fit: contain;
      margin-bottom: 12px;
    }

    .premium-header {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      margin-bottom: 6px;
    }

    .premium-crown-sm {
      font-size: 28px;
      animation: crownBounce 2s ease-in-out infinite;
    }

    .premium-crown {
      font-size: 48px;
      margin-bottom: 12px;
      animation: crownBounce 2s ease-in-out infinite;
    }

    @keyframes crownBounce {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-4px); }
    }

    .premium-title {
      font-size: 24px;
      font-weight: 800;
      background: var(--grad1);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .premium-lifetime-badge {
      display: inline-block;
      font-size: 14px;
      font-weight: 700;
      color: #fbbf24;
      letter-spacing: 0.3px;
      margin-bottom: 4px;
    }

    .premium-subtitle {
      font-size: 13px;
      color: var(--text-secondary);
      margin-bottom: 14px;
      line-height: 1.4;
    }

    .premium-free-row {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      font-size: 12.5px;
      color: var(--text-secondary);
      margin-bottom: 16px;
      padding: 10px 0;
      border-top: 1px solid var(--border);
      border-bottom: 1px solid var(--border);
    }

    .premium-features-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 4px 16px;
      text-align: left;
      margin-bottom: 20px;
      padding: 12px 8px;
      background: var(--surface-2);
      border-radius: var(--radius-sm);
    }

    .premium-feat {
      display: flex;
      align-items: center;
      gap: 7px;
      padding: 6px 0;
      font-size: 13px;
      color: var(--text);
    }

    .premium-feat span:first-child {
      font-size: 15px;
      flex-shrink: 0;
    }

    .premium-features {
      text-align: left;
      margin-bottom: 20px;
    }

    .premium-feature {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 0;
      font-size: 13px;
      border-bottom: 1px solid var(--border);
    }

    .premium-feature:last-child {
      border-bottom: none;
    }

    .premium-feature-icon {
      font-size: 18px;
      flex-shrink: 0;
    }

    .premium-feature-lock {
      margin-left: auto;
      font-size: 11px;
      color: var(--text-tertiary);
    }

    .premium-price {
      font-size: 36px;
      font-weight: 800;
      background: var(--grad1);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      margin-bottom: 4px;
    }

    .premium-price-note {
      font-size: 11px;
      color: var(--text-tertiary);
      margin-bottom: 6px;
    }

    .premium-buy-btn {
      width: 100%;
      padding: 14px;
      border: none;
      border-radius: var(--radius);
      background: var(--grad1);
      color: white;
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      transition: var(--transition);
      font-family: 'Inter', sans-serif;
      margin-bottom: 6px;
    }

    .premium-buy-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
    }

    .premium-free-btn {
      background: var(--surface-3) !important;
      color: var(--text) !important;
      border: 1px solid var(--border-light) !important;
      box-shadow: none !important;
      margin-bottom: 4px !important;
      display: flex !important;
      flex-direction: column !important;
      align-items: center !important;
    }

    .premium-free-btn:hover {
      background: var(--surface-2) !important;
      box-shadow: none !important;
    }

    .premium-free-note {
      font-size: 11px;
      color: var(--text-tertiary);
    }

    .premium-free-highlight {
      display: block;
      font-size: 11px;
      font-weight: 600;
      color: #fbbf24;
      letter-spacing: 0.2px;
      margin-top: 2px;
    }

    .premium-skip-btn {
      background: none;
      border: none;
      color: var(--text-tertiary);
      font-size: 13px;
      cursor: pointer;
      font-family: 'Inter', sans-serif;
      padding: 6px 8px;
    }

    .premium-skip-btn:hover {
      color: var(--text-secondary);
    }

    .premium-skip {
      background: none;
      border: none;
      color: var(--text-tertiary);
      font-size: 13px;
      cursor: pointer;
      font-family: 'Inter', sans-serif;
      padding: 8px;
    }

    .premium-skip:hover {
      color: var(--text-secondary);
    }

    /* Lock overlay on premium tools */
    .tool-card.locked {
      position: relative;
      opacity: 0.65;
    }

    .tool-card.locked::after {
      content: '🔒';
      position: absolute;
      top: 8px;
      right: 8px;
      font-size: 14px;
    }

    .free-badge {
      display: inline-block;
      font-size: 9px;
      font-weight: 700;
      background: #22c55e;
      color: white;
      padding: 2px 6px;
      border-radius: 4px;
      margin-left: 6px;
      vertical-align: middle;
      letter-spacing: 0.5px;
    }

    .pro-badge {
      display: inline-block;
      font-size: 9px;
      font-weight: 700;
      background: var(--grad1);
      color: white;
      padding: 2px 6px;
      border-radius: 4px;
      margin-left: 6px;
      vertical-align: middle;
      letter-spacing: 0.5px;
    }

    /* Annotation styles */
    .annotate-tool-btn {
      padding: 8px 12px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--surface-2);
      color: var(--text);
      cursor: pointer;
      font-size: 12px;
      font-weight: 600;
      transition: var(--transition);
      white-space: nowrap;
    }

    .annotate-tool-btn:hover {
      background: var(--surface-3);
    }

    .annotate-tool-btn.active {
      background: var(--grad1);
      color: white;
      border-color: transparent;
    }

    #annotate-canvas {
      width: 100%;
      height: 100%;
      border-radius: var(--radius-sm);
    }

    #annotate-doc-select.hidden, #annotate-canvas-wrapper.hidden {
      display: none !important;
    }

    /* Live Edge Detection Canvas */
    #edge-detect-canvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 5;
    }

    /* Auto-capture indicator */
    .auto-capture-indicator {
      position: absolute;
      top: 12px;
      left: 50%;
      transform: translateX(-50%);
      padding: 4px 14px;
      background: rgba(16,185,129,0.85);
      color: white;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 600;
      z-index: 10;
      display: none;
      backdrop-filter: blur(8px);
    }
    .auto-capture-indicator.active { display: block; }
    .auto-capture-indicator.ready { background: rgba(99,102,241,0.9); animation: pulse-ready 0.8s infinite alternate; }
    @keyframes pulse-ready { from { opacity: 0.7; } to { opacity: 1; } }

    /* Flash toggle button */
    .flash-toggle {
      position: absolute;
      top: 12px;
      right: 12px;
      z-index: 10;
      width: 44px;
      height: 44px;
      border-radius: 50%;
      border: none;
      background: rgba(0,0,0,0.5);
      color: white;
      font-size: 18px;
      cursor: pointer;
      backdrop-filter: blur(8px);
      display: none;
    }
    .flash-toggle.visible { display: flex; align-items: center; justify-content: center; }
    .flash-toggle.flash-on { background: rgba(251,191,36,0.8); }

    /* Manual Crop Handles */
    .crop-handle-overlay {
      position: absolute;
      inset: 0;
      z-index: 15;
      display: none;
    }
    .crop-handle-overlay.active { display: block; }
    .crop-handle {
      position: absolute;
      width: 44px;
      height: 44px;
      background: rgba(99,102,241,0.9);
      border: 3px solid white;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      cursor: grab;
      touch-action: none;
      z-index: 20;
      box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    .crop-handle:active { cursor: grabbing; background: rgba(139,92,246,1); transform: translate(-50%, -50%) scale(1.15); }
    #crop-line-canvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 14;
    }

    /* Brightness/Contrast Sliders */
    .adjust-sliders {
      display: none;
      flex-direction: column;
      gap: 8px;
      margin-top: 8px;
      padding: 12px;
      background: var(--surface-1);
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
    }
    .adjust-sliders.visible { display: flex; }
    .slider-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .slider-row label {
      font-size: 11px;
      color: var(--text-secondary);
      min-width: 70px;
      font-weight: 500;
    }
    .slider-row input[type="range"] {
      flex: 1;
      height: 4px;
      -webkit-appearance: none;
      background: var(--surface-3);
      border-radius: 2px;
      outline: none;
    }
    .slider-row input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--grad1);
      cursor: pointer;
    }
    .slider-row .slider-value {
      font-size: 11px;
      color: var(--text-tertiary);
      min-width: 30px;
      text-align: right;
    }

    /* Page management (reorder/rotate) */
    .page-thumb {
      position: relative;
      cursor: grab;
    }
    .page-thumb.dragging {
      opacity: 0.4;
      transform: scale(0.95);
    }
    .page-thumb.drag-over {
      border: 2px solid #6366f1;
      border-radius: 8px;
    }
    .page-actions {
      position: absolute;
      bottom: 22px;
      right: 4px;
      display: flex;
      gap: 2px;
      z-index: 5;
    }
    .page-action-btn {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      border: none;
      background: rgba(0,0,0,0.6);
      color: white;
      font-size: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      backdrop-filter: blur(4px);
    }
    .page-action-btn:hover { background: rgba(99,102,241,0.8); }

    /* Gallery import multi */
    #gallery-input { display: none; }

    /* Color mode indicator */
    .color-mode-chip.active-color {
      background: linear-gradient(135deg, #6366f1, #a855f7) !important;
      color: white !important;
    }

    /* Toast Notifications */
    .toast-container {
      position: fixed;
      top: 16px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 99999;
      display: flex;
      flex-direction: column;
      gap: 8px;
      pointer-events: none;
      width: 90%;
      max-width: 380px;
    }
    .toast {
      pointer-events: auto;
      padding: 14px 18px;
      border-radius: var(--radius-sm);
      backdrop-filter: blur(20px);
      font-size: 13px;
      font-weight: 500;
      line-height: 1.4;
      display: flex;
      align-items: center;
      gap: 10px;
      animation: toastIn 0.35s cubic-bezier(.4,0,.2,1);
      box-shadow: 0 8px 32px rgba(0,0,0,0.3);
      word-break: break-word;
    }
    .toast.toast-exit {
      animation: toastOut 0.3s cubic-bezier(.4,0,.2,1) forwards;
    }
    .toast-success {
      background: rgba(16,185,129,0.95);
      color: white;
      border: 1px solid rgba(16,185,129,0.3);
    }
    .toast-error {
      background: rgba(239,68,68,0.95);
      color: white;
      border: 1px solid rgba(239,68,68,0.3);
    }
    .toast-info {
      background: var(--glass-dark);
      color: var(--text);
      border: 1px solid var(--border-light);
    }
    .toast-warning {
      background: rgba(245,158,11,0.95);
      color: white;
      border: 1px solid rgba(245,158,11,0.3);
    }
    .toast-icon { font-size: 18px; flex-shrink: 0; }
    .toast-text { flex: 1; }
    .toast-close {
      background: none; border: none; color: inherit; opacity: 0.7;
      cursor: pointer; font-size: 16px; padding: 0 0 0 8px; flex-shrink: 0;
    }
    .toast-close:hover { opacity: 1; }
    @keyframes toastIn {
      from { opacity: 0; transform: translateY(-20px) scale(0.95); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }
    @keyframes toastOut {
      from { opacity: 1; transform: translateY(0) scale(1); }
      to { opacity: 0; transform: translateY(-20px) scale(0.9); }
    }

    /* Custom Dialog Modal */
    .dialog-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.6);
      backdrop-filter: blur(4px);
      z-index: 50000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }
    .dialog-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }
    .dialog-box {
      background: var(--glass-dark);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border-light);
      border-radius: var(--radius);
      padding: 24px;
      max-width: 340px;
      width: 100%;
      animation: dialogIn 0.3s cubic-bezier(.4,0,.2,1);
    }
    .dialog-overlay.active .dialog-box {
      animation: dialogIn 0.3s cubic-bezier(.4,0,.2,1);
    }
    @keyframes dialogIn {
      from { transform: scale(0.9) translateY(10px); opacity: 0; }
      to { transform: scale(1) translateY(0); opacity: 1; }
    }
    .dialog-title {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 8px;
    }
    .dialog-message {
      font-size: 13px;
      color: var(--text-secondary);
      margin-bottom: 16px;
      line-height: 1.5;
    }
    .dialog-input {
      width: 100%;
      margin-bottom: 16px;
    }
    .dialog-actions {
      display: flex;
      gap: 8px;
      justify-content: flex-end;
    }
    .dialog-actions .btn { min-width: 80px; text-align: center; }

    /* Document Viewer */
    .viewer-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.92);
      z-index: 30000;
      display: flex;
      flex-direction: column;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
    }
    .viewer-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }
    .viewer-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 16px;
      background: rgba(0,0,0,0.5);
      backdrop-filter: blur(12px);
      flex-shrink: 0;
    }
    .viewer-title {
      font-size: 14px;
      font-weight: 600;
      color: white;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1;
      margin: 0 12px;
    }
    .viewer-close {
      width: 44px; height: 44px; border-radius: 50%;
      background: rgba(255,255,255,0.15); border: none;
      color: white; font-size: 18px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: var(--transition); flex-shrink: 0;
    }
    .viewer-close:hover { background: rgba(255,255,255,0.25); }
    .viewer-body {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      position: relative;
      touch-action: none;
    }
    .viewer-image {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      transform-origin: center center;
      user-select: none;
      -webkit-user-drag: none;
      will-change: transform;
    }
    .viewer-footer {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      padding: 12px 16px;
      background: rgba(0,0,0,0.5);
      backdrop-filter: blur(12px);
      flex-shrink: 0;
    }
    .viewer-nav-btn {
      width: 44px; height: 44px; border-radius: 50%;
      background: rgba(255,255,255,0.15); border: none;
      color: white; font-size: 20px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: var(--transition);
    }
    .viewer-nav-btn:hover { background: rgba(255,255,255,0.25); }
    .viewer-nav-btn:disabled { opacity: 0.3; cursor: default; }
    .viewer-page-info {
      color: rgba(255,255,255,0.7);
      font-size: 13px;
      font-weight: 500;
      min-width: 60px;
      text-align: center;
    }
    .viewer-action-btn {
      padding: 10px 16px;
      min-height: 44px;
      border-radius: 22px;
      background: rgba(255,255,255,0.15);
      border: none;
      color: white;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: var(--transition);
      font-family: 'Inter', sans-serif;
    }
    .viewer-action-btn:hover { background: rgba(255,255,255,0.25); }

    /* Accessibility: Respect reduced motion preference */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }

    /* Performance: Skip layout/paint for hidden screens */
    .screen:not(.active) { content-visibility: auto; }

    /* Compatibility: Firefox range slider styling */
    .slider-row input[type="range"]::-moz-range-thumb {
      width: 16px; height: 16px;
      border-radius: 50%;
      background: var(--grad1);
      cursor: pointer;
      border: none;
    }
    .slider-row input[type="range"]::-moz-range-track {
      background: var(--surface-3);
      border: none;
      height: 4px;
      border-radius: 2px;
    }

    /* Print styles */
    @media print {
      .nav-bar, .top-bar, .fab, .toast-container, .dialog-overlay,
      .viewer-overlay, .premium-overlay, .language-selector-overlay { display: none !important; }
      .screen { position: static !important; opacity: 1 !important; overflow: visible !important; }
      .screen:not(.active) { display: none !important; }
      img { max-width: 100% !important; page-break-inside: avoid; }
      .content-wrapper { padding: 0 !important; }
    }

    /* Custom scrollbar */
    * { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

    /* Selection color */
    ::selection { background: rgba(99,102,241,0.3); color: var(--text); }

    /* Chip min-height for touch */
    .chip { min-height: 44px; display: inline-flex; align-items: center; }

    /* Active states for interactive elements */
    .btn:active { transform: scale(0.97); }
    .chip:active { transform: scale(0.97); }
    .tool-card:active { transform: scale(0.98); }
    .nav-item:active { opacity: 0.7; }
    .btn-icon:hover { background: var(--surface-3); }

    /* Transition for flash toggle */
    .flash-toggle { transition: var(--transition); }

    /* Responsive: tablet */
    @media (min-width: 481px) and (max-width: 768px) {
      .doc-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
      .tools-grid { grid-template-columns: repeat(3, 1fr); }
      .modal-content { max-width: 520px; margin: 0 auto; }
    }

    /* Responsive: desktop */
    @media (min-width: 769px) {
      .doc-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
      .tools-grid { grid-template-columns: repeat(4, 1fr); }
      .modal-content { max-width: 600px; margin: 0 auto; }
      .screen-content { max-width: 900px; margin: 0 auto; }
    }

    /* Landscape orientation */
    @media (orientation: landscape) and (max-height: 500px) {
      .nav-bar { height: calc(48px + env(safe-area-inset-bottom)); }
      .nav-item { gap: 2px; }
      .nav-icon { font-size: 16px; }
      .screen-content { padding-bottom: 56px; }
    }
