:root {
      --primary: #0284c7;
      --primary-hover: #0369a1;
      --surface: #ffffff;
      --bg: #f8fafc;
      --text: #0f172a;
      --text-muted: #64748b;
      --border: #e2e8f0;
      --radius-lg: 16px;
      --radius-md: 10px;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.5;
    }
    header {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      position: sticky;
      top: 0;
      z-index: 100;
      padding: 0.75rem 1.5rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      text-decoration: none;
      color: inherit;
    }
    .brand-icon {
      width: 36px;
      height: 36px;
      background: #ea580c;
      color: white;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 800;
      font-size: 1.1rem;
    }
    .brand-title { font-weight: 800; font-size: 1.15rem; color: #0f172a; }
    .brand-badge {
      font-size: 0.75rem;
      background: #f0f9ff;
      color: #0284c7;
      font-weight: 700;
      padding: 2px 8px;
      border-radius: 6px;
      border: 1px solid #bae6fd;
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }
    .nav-links { display: flex; align-items: center; gap: 0.85rem; }
    .nav-btn {
      text-decoration: none;
      color: var(--text-muted);
      font-size: 0.88rem;
      font-weight: 600;
      padding: 0.45rem 0.85rem;
      border-radius: 6px;
      transition: all 0.15s ease;
    }
    .nav-btn:hover { color: #0284c7; background: #f0f9ff; }
    .nav-btn.primary { background: #ea580c; color: white; font-weight: 700; }

    .hero-sec {
      max-width: 960px;
      margin: 2.2rem auto 1.25rem auto;
      padding: 0 1.25rem;
      text-align: center;
    }
    .hero-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 0.82rem;
      font-weight: 700;
      color: #0369a1;
      background: #e0f2fe;
      padding: 4px 12px;
      border-radius: 20px;
      margin-bottom: 0.75rem;
      border: 1px solid #bae6fd;
    }
    .hero-title {
      font-size: 2.2rem;
      font-weight: 800;
      color: #0f172a;
      line-height: 1.25;
      margin-bottom: 0.5rem;
    }
    .hero-sub {
      font-size: 0.98rem;
      color: var(--text-muted);
      max-width: 680px;
      margin: 0 auto;
    }

    .app-box {
      max-width: 980px;
      margin: 1.5rem auto 3rem auto;
      background: var(--surface);
      border-radius: var(--radius-lg);
      border: 1px solid var(--border);
      box-shadow: 0 12px 30px -8px rgba(0,0,0,0.07);
      padding: 2rem;
    }

    /* Dropzone */
    .dropzone {
      border: 2px dashed #cbd5e1;
      border-radius: var(--radius-md);
      padding: 3.2rem 1.5rem;
      text-align: center;
      cursor: pointer;
      background: #f8fafc;
      transition: all 0.2s ease;
      position: relative;
    }
    .dropzone:hover { border-color: var(--primary); background: #f0f9ff; }
    .dropzone input {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
      width: 100%;
      height: 100%;
    }

    /* Top Upload CTA Banner */
    .top-upload-banner {
      background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #eff6ff 100%);
      border: 2px dashed #0284c7;
      border-radius: var(--radius-md);
      padding: 1.15rem 1.6rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1.25rem;
      cursor: pointer;
      margin-bottom: 1.25rem;
      transition: all 0.2s ease;
      box-shadow: 0 4px 15px -3px rgba(2, 132, 199, 0.12);
    }
    .top-upload-banner:hover {
      border-color: #0369a1;
      background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 50%, #e0f2fe 100%);
      transform: translateY(-1px);
      box-shadow: 0 6px 18px -4px rgba(2, 132, 199, 0.2);
    }
    .top-upload-banner.dragover {
      border-color: #2563eb;
      background: #eff6ff;
    }
    .top-upload-left {
      display: flex;
      align-items: center;
      gap: 1rem;
    }
    .top-upload-icon-wrap {
      width: 48px;
      height: 48px;
      border-radius: 12px;
      background: #0284c7;
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
    }
    .top-upload-icon {
      width: 24px;
      height: 24px;
    }
    .top-upload-title {
      font-size: 1.1rem;
      font-weight: 800;
      color: #0369a1;
      margin-bottom: 0.15rem;
    }
    .top-upload-subtitle {
      font-size: 0.85rem;
      color: #0284c7;
      font-weight: 500;
    }
    .btn-primary-upload {
      background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
      color: #ffffff;
      border: none;
      padding: 0.7rem 1.5rem;
      border-radius: 10px;
      font-size: 0.95rem;
      font-weight: 800;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
      transition: all 0.2s ease;
      flex-shrink: 0;
    }
    .btn-primary-upload:hover {
      background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
      transform: scale(1.02);
    }
    @media (max-width: 640px) {
      .top-upload-banner {
        flex-direction: column;
        text-align: center;
        padding: 1.15rem 1rem;
      }
      .top-upload-left {
        flex-direction: column;
        gap: 0.6rem;
      }
    }

    .sample-btn {
      padding: 0.4rem 0.9rem;
      font-size: 0.82rem;
      font-weight: 600;
      border: 1px solid #cbd5e1;
      background: #ffffff;
      border-radius: 6px;
      color: #475569;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      transition: all 0.15s ease;
    }
    .sample-btn:hover {
      border-color: #0284c7;
      color: #0284c7;
      background: #f0f9ff;
    }

    /* Common Buttons */
    .btn-lg {
      padding: 0.8rem 1.6rem;
      font-size: 0.95rem;
      font-weight: 700;
      border-radius: var(--radius-md);
      cursor: pointer;
      border: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      transition: all 0.15s ease;
    }
    .btn-download {
      background: linear-gradient(135deg, #0284c7, #0369a1);
      color: white;
      box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
    }
    .btn-download:hover {
      opacity: 0.95;
      transform: translateY(-1px);
    }
    .btn-copy {
      background: #0f172a;
      color: white;
      box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
    }
    .btn-copy:hover {
      background: #1e293b;
      transform: translateY(-1px);
    }
    .btn-subtle {
      padding: 0.5rem 1rem;
      font-size: 0.85rem;
      font-weight: 600;
      color: #475569;
      background: #f1f5f9;
      border: 1px solid #cbd5e1;
      border-radius: 6px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s ease;
    }
    .btn-subtle:hover {
      background: #e2e8f0;
      color: #0f172a;
    }

    /* Step indicator pill */
    .step-badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      background: #e0f2fe;
      color: #0284c7;
      font-size: 0.75rem;
      font-weight: 800;
      padding: 2px 8px;
      border-radius: 4px;
      border: 1px solid #bae6fd;
    }

    /* Preset pills */
    .preset-pill {
      padding: 0.38rem 0.85rem;
      font-size: 0.82rem;
      font-weight: 600;
      border-radius: 6px;
      border: 1px solid #cbd5e1;
      background: #ffffff;
      color: #334155;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      transition: all 0.15s ease;
    }
    .preset-pill:hover {
      background: #f8fafc;
      border-color: #94a3b8;
    }
    .preset-pill.active {
      background: #0284c7;
      color: #ffffff;
      border-color: #0284c7;
      font-weight: 700;
    }
    .eraser-btn.active {
      background: #fef2f2 !important;
      color: #dc2626 !important;
      border-color: #ef4444 !important;
      box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
    }

    /* Cropper Modal Dialog & Viewport */
    .crop-modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.75);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      z-index: 99999;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1.25rem;
      animation: fadeIn 0.2s ease;
    }
    .crop-modal-dialog {
      background: #ffffff;
      border-radius: 16px;
      box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
      max-width: 860px;
      width: 100%;
      max-height: 90vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      border: 1px solid rgba(255, 255, 255, 0.2);
      animation: modalSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .crop-modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.9rem 1.25rem;
      border-bottom: 1px solid var(--border);
      gap: 0.75rem;
      flex-wrap: wrap;
      background: #ffffff;
    }
    .crop-modal-title-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .crop-modal-title {
      font-weight: 800;
      font-size: 1.1rem;
      color: #0f172a;
    }
    .crop-preset-group {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      flex-wrap: wrap;
    }
    .crop-modal-close-btn {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      border: 1px solid #cbd5e1;
      background: #f8fafc;
      color: #64748b;
      font-size: 1.25rem;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .crop-modal-close-btn:hover {
      background: #fee2e2;
      color: #dc2626;
      border-color: #fca5a5;
    }
    .crop-modal-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.9rem 1.25rem;
      border-top: 1px solid var(--border);
      background: #f8fafc;
      gap: 0.75rem;
      flex-wrap: wrap;
    }
    @keyframes modalSlideUp {
      from { opacity: 0; transform: translateY(16px) scale(0.98); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }
    .crop-wrap {
      display: flex;
      flex-direction: column;
      gap: 1.25rem;
      animation: fadeIn 0.2s ease;
    }
    .crop-viewport {
      display: flex;
      justify-content: center;
      align-items: center;
      background: #0f172a;
      padding: 1.25rem;
      overflow: hidden;
      min-height: 360px;
      max-height: 500px;
      position: relative;
      user-select: none;
      -webkit-user-select: none;
      touch-action: none;
    }
    .crop-media-wrap {
      position: relative;
      display: inline-block;
      overflow: hidden;
      max-width: 100%;
      max-height: 480px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.5);
      cursor: crosshair;
      user-select: none;
      -webkit-user-select: none;
    }
    #cropImg {
      display: block;
      max-width: 100%;
      max-height: 480px;
      object-fit: contain;
      pointer-events: none;
      user-select: none;
      -webkit-user-select: none;
    }
    .crop-selection {
      position: absolute;
      /* Box shadow mask to dim entire surrounding area */
      box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
      border: 2px dashed #38bdf8;
      cursor: move;
      box-sizing: border-box;
      touch-action: none;
    }
    /* Grid lines */
    .crop-grid-h, .crop-grid-v {
      position: absolute;
      pointer-events: none;
      opacity: 0.35;
    }
    .crop-grid-h { left: 0; right: 0; height: 1px; border-top: 1px dashed #ffffff; }
    .crop-grid-h.line1 { top: 33.333%; }
    .crop-grid-h.line2 { top: 66.666%; }
    .crop-grid-v { top: 0; bottom: 0; width: 1px; border-left: 1px dashed #ffffff; }
    .crop-grid-v.line1 { left: 33.333%; }
    .crop-grid-v.line2 { left: 66.666%; }

    /* Handles */
    .crop-handle {
      position: absolute;
      width: 12px;
      height: 12px;
      background: #ffffff;
      border: 2.5px solid #0284c7;
      border-radius: 2px;
      box-shadow: 0 2px 6px rgba(0,0,0,0.4);
      z-index: 20;
      box-sizing: border-box;
    }
    .crop-handle::after {
      content: '';
      position: absolute;
      inset: -8px;
    }
    .handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
    .handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
    .handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
    .handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
    .handle-n  { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
    .handle-s  { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
    .handle-w  { top: 50%; left: -6px; transform: translateY(-50%); cursor: ew-resize; }
    .handle-e  { top: 50%; right: -6px; transform: translateY(-50%); cursor: ew-resize; }

    .crop-badge {
      position: absolute;
      bottom: 6px;
      right: 6px;
      background: rgba(15, 23, 42, 0.88);
      color: #f8fafc;
      font-size: 0.72rem;
      font-weight: 700;
      padding: 3px 8px;
      border-radius: 4px;
      pointer-events: none;
      border: 1px solid rgba(255,255,255,0.25);
      white-space: nowrap;
    }

    .btn-primary-crop {
      background: linear-gradient(135deg, #0284c7, #0369a1);
      color: white;
      padding: 0.8rem 1.6rem;
      font-size: 0.95rem;
      font-weight: 700;
      border-radius: var(--radius-md);
      cursor: pointer;
      border: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
      transition: all 0.15s ease;
    }
    .btn-primary-crop:hover {
      opacity: 0.95;
      transform: translateY(-1px);
    }
    .btn-secondary {
      background: #f1f5f9;
      color: #334155;
      border: 1px solid #cbd5e1;
      padding: 0.8rem 1.25rem;
      font-size: 0.9rem;
      font-weight: 700;
      border-radius: var(--radius-md);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s ease;
    }
    .btn-secondary:hover {
      background: #e2e8f0;
      color: #0f172a;
    }

    /* Workspace Stage */
    .workspace-wrap {
      display: flex;
      flex-direction: column;
      gap: 1.5rem;
      animation: fadeIn 0.2s ease;
    }
    .preview-board-wrap {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
    }
    .preview-board {
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 220px;
      max-height: 360px;
      background: repeating-conic-gradient(#cbd5e1 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
      border-radius: var(--radius-md);
      padding: 1.25rem;
      border: 1px solid var(--border);
      position: relative;
      overflow: hidden;
      transition: background 0.2s ease;
    }
    #signatureCanvas {
      max-width: 100%;
      max-height: 310px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.12);
      border-radius: 4px;
      object-fit: contain;
    }
    .canvas-floating-upload-btn {
      position: absolute;
      right: 18px;
      bottom: 18px;
      z-index: 30;
      background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
      color: #ffffff;
      border: 1px solid rgba(255, 255, 255, 0.3);
      border-radius: 10px;
      padding: 0.65rem 1.25rem;
      font-size: 0.92rem;
      font-weight: 700;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1);
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .canvas-floating-upload-btn:hover {
      background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(2, 132, 199, 0.52), 0 3px 8px rgba(0, 0, 0, 0.15);
    }
    .canvas-floating-upload-btn:active {
      transform: translateY(0);
    }
    .preview-footer-bar {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.75rem;
      padding: 0.1rem 0.25rem;
    }

    /* Controls Panel */
    .control-panel {
      background: #f8fafc;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 1.25rem 1.5rem;
      display: flex;
      flex-direction: column;
      gap: 1.1rem;
    }
    .control-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
    }
    .control-label {
      font-size: 0.88rem;
      font-weight: 700;
      color: #334155;
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 160px;
    }
    .slider-box {
      flex: 1;
      display: flex;
      align-items: center;
      gap: 0.85rem;
      max-width: 480px;
    }
    .slider-box input[type="range"] {
      flex: 1;
      accent-color: #0284c7;
      cursor: pointer;
    }
    .val-badge {
      font-size: 0.78rem;
      font-weight: 700;
      background: #e2e8f0;
      color: #1e293b;
      padding: 2px 7px;
      border-radius: 4px;
      min-width: 44px;
      text-align: center;
    }

    .color-swatch-row {
      display: flex;
      gap: 0.6rem;
      align-items: center;
      flex-wrap: wrap;
    }
    .color-btn {
      padding: 0.4rem 0.9rem;
      border-radius: 6px;
      border: 1px solid #cbd5e1;
      background: white;
      font-size: 0.82rem;
      font-weight: 700;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      transition: all 0.15s ease;
    }
    .color-btn.active {
      border-color: #0284c7;
      background: #e0f2fe;
      color: #0369a1;
    }

    .bg-mode-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    .bg-mode-btn {
      padding: 0.32rem 0.7rem;
      font-size: 0.78rem;
      font-weight: 600;
      border-radius: 5px;
      border: 1px solid #cbd5e1;
      background: #ffffff;
      color: #475569;
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .bg-mode-btn.active {
      border-color: #0284c7;
      background: #e0f2fe;
      color: #0369a1;
      font-weight: 700;
    }

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

    @media (max-width: 768px) {
      .app-box { padding: 1.25rem; }
      .control-row { flex-direction: column; align-items: flex-start; }
      .slider-box { width: 100%; max-width: 100%; }
      .hero-title { font-size: 1.7rem; }
      .crop-viewport { min-height: 280px; padding: 0.5rem; }
    }
  
    /* Header Actions & Country Selector */
    .header-actions {
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }
    .select-pill {
      padding: 0.42rem 0.75rem;
      border: 1px solid var(--border, #cbd5e1);
      border-radius: 9999px;
      background: var(--surface, #ffffff);
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text, #0f172a);
      outline: none;
      cursor: pointer;
      box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    }
    .country-selector {
      min-width: 82px;
    }