  :root {
    --bg: #000000;
    --panel: #131316;
    --panel-raised: #1C1C21;
    --text: #F2F2F5;
    --text-dim: #8B8B95;
    --border: #2E2E35;
    --accent: #FF2E93;
    --accent-dim: #CC1F73;
    --accent-secondary: #8B5CF6;
    --accent-tertiary: #22D3EE;
    --danger: #E5716C;
    --success: #22D3EE;
  }

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

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

  #app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
  }

  /* Top bar */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    min-height: 56px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
  }

  .logo-mark {
    flex-shrink: 0;
    display: block;
    border-radius: 7px;
    object-fit: contain;
  }

  .topbar-actions {
    display: flex;
    gap: 8px;
  }

  button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
  }

  .btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    background: var(--panel-raised);
    color: var(--text);
    border: 1px solid var(--border);
    transition: background 0.15s ease, border-color 0.15s ease;
  }

  .btn:hover { background: #2A2A2E; border-color: #4A4A50; }

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

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

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

  /* Main layout */
  .main {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  /* Left control panel */
  .panel {
    width: 300px;
    min-width: 300px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px;
  }

  .panel::-webkit-scrollbar { width: 8px; }
  .panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .section {
    margin-bottom: 28px;
  }

  .section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 12px;
    letter-spacing: 0.01em;
  }

  .upload-zone {
    border: 1.5px dashed var(--border);
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
  }

  .upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(108, 108, 229, 0.06);
  }

  .upload-zone svg { margin-bottom: 8px; opacity: 0.6; }

  .upload-zone-text {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
  }

  .upload-zone-text strong { color: var(--text); font-weight: 600; }

  #fileInput { display: none; }

  .screenshot-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
  }

  .screenshot-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    background: var(--panel-raised);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 12px;
  }

  .screenshot-item.active { border-color: var(--accent); }

  .screenshot-item img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
  }

  .screenshot-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
  }

  .screenshot-item .remove-btn {
    background: none;
    color: var(--text-dim);
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
  }
  .screenshot-item .remove-btn:hover { color: var(--danger); background: rgba(229,113,108,0.1); }

  .field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 8px;
    display: block;
  }

  .swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }

  .swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s ease, border-color 0.1s ease;
  }

  .swatch:hover { transform: scale(1.06); }
  .swatch.active { border-color: white; }

  .select-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }

  .frame-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .color-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    align-items: stretch;
  }

  .color-row input[type="color"] {
    width: 42px;
    height: 36px;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-raised);
    cursor: pointer;
    flex-shrink: 0;
  }

  .zoom-pan-hint {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-top: 6px;
  }

  .mode-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mode-btn {
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    transition: border-color 0.15s ease, background 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .mode-btn strong {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
  }

  .mode-btn span {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
  }

  .mode-btn.active {
    border-color: var(--accent);
    background: rgba(108, 108, 229, 0.1);
  }

  .mode-btn:hover:not(.active) { border-color: #4A4A50; }

  .option-btn {
    padding: 9px 6px;
    border-radius: 8px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
  }

  .option-btn.active {
    background: rgba(108, 108, 229, 0.15);
    border-color: var(--accent);
    color: var(--text);
  }

  .option-btn:hover:not(.active) { border-color: #4A4A50; }

  input[type="text"], textarea {
    width: 100%;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    resize: none;
    margin-bottom: 10px;
  }

  input[type="text"]:focus, textarea:focus {
    border-color: var(--accent);
    outline: none;
  }

  input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    margin-bottom: 4px;
  }

  .range-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 12px;
  }

  .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .toggle {
    width: 36px;
    height: 20px;
    border-radius: 20px;
    background: var(--border);
    position: relative;
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
  }

  .toggle.on { background: var(--accent); }

  .toggle::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.15s ease;
  }

  .toggle.on::after { transform: translateX(16px); }

  /* Canvas area */
  .canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      linear-gradient(45deg, #1A1A1D 25%, transparent 25%),
      linear-gradient(-45deg, #1A1A1D 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #1A1A1D 75%),
      linear-gradient(-45deg, transparent 75%, #1A1A1D 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #101012;
    position: relative;
    overflow: auto;
    padding: 40px;
  }

  #previewCanvas {
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border-radius: 4px;
    max-width: 100%;
    max-height: 100%;
  }

  .empty-state {
    text-align: center;
    color: var(--text-dim);
    max-width: 280px;
  }

  .empty-state svg { margin-bottom: 16px; opacity: 0.3; }
  .empty-state h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; font-weight: 600; }
  .empty-state p { font-size: 13px; line-height: 1.5; }

  .canvas-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 500;
  }

  /* Export panel */
  .export-panel {
    width: 260px;
    min-width: 260px;
    background: var(--panel);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
  }

  .preset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease;
  }

  .preset-item:hover { border-color: #4A4A50; }
  .preset-item.checked { border-color: var(--accent); }

  .preset-item-info { display: flex; flex-direction: column; }
  .preset-item-name { font-size: 12px; font-weight: 600; }
  .preset-item-dims { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

  .checkbox {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .preset-item.checked .checkbox {
    background: var(--accent);
    border-color: var(--accent);
  }

  .progress-bar {
    height: 4px;
    background: var(--panel-raised);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 12px;
  }

  .progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s ease;
  }

  .hint {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-top: 6px;
  }

  /* Draggable caption hint on canvas */
  .drag-hint {
    position: absolute;
    border: 1.5px dashed var(--accent);
    border-radius: 6px;
    pointer-events: none;
    display: none;
  }

  .canvas-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #previewCanvas.draggable-active { cursor: grab; }
  #previewCanvas.dragging { cursor: grabbing; }

  /* Settings file controls */
  .icon-btn-row {
    display: flex;
    gap: 8px;
  }

  .icon-btn-row .btn {
    flex: 1;
    justify-content: center;
    padding: 8px;
  }

  /* Perspective slider group */
  .persp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 4px;
  }

  .persp-col label {
    font-size: 11px;
    color: var(--text-dim);
    display: block;
    margin-bottom: 4px;
  }

  /* License lock screen */
  .license-lock {
    display: none; /* toggled to flex by license.js */
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    background: var(--bg);
  }

  .license-card {
    width: 100%;
    max-width: 380px;
    padding: 32px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    text-align: center;
  }

  .license-card h2 {
    font-size: 18px;
    margin-bottom: 8px;
  }

  .license-sub {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 20px;
  }

  #licenseKeyInput {
    width: 100%;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-align: center;
    letter-spacing: 0.05em;
  }

  #licenseKeyInput:focus {
    border-color: var(--accent);
    outline: none;
  }

  .license-error {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(229, 113, 108, 0.1);
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: var(--danger);
    font-size: 12.5px;
    text-align: left;
    line-height: 1.5;
  }

  .license-footnote {
    margin-top: 18px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
  }

  /* ---------- Demo-mode additions ---------- */

  .demo-banner {
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
  }

  .demo-banner a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .demo-locked {
    position: relative;
    opacity: 0.55;
    cursor: pointer;
  }

  .pro-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 2px 5px;
    border-radius: 5px;
    line-height: 1;
  }

  .demo-upgrade-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }

  .demo-upgrade-overlay.visible { display: flex; }

  .demo-upgrade-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
  }

  .demo-upgrade-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
  }

  .demo-upgrade-close:hover { color: var(--text); }

  .demo-upgrade-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
  }

  .demo-upgrade-hero::before {
    content: '';
    position: absolute;
    width: 110px;
    height: 110px;
    background: radial-gradient(circle, rgba(255,46,147,0.28) 0%, rgba(34,211,238,0.16) 50%, transparent 75%);
    filter: blur(2px);
    z-index: 0;
  }

  .demo-upgrade-hero img {
    position: relative;
    z-index: 1;
    border-radius: 14px;
    filter: drop-shadow(0 6px 18px rgba(255, 46, 147, 0.25));
  }

  .demo-upgrade-badge {
    display: inline-block;
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 14px;
  }

  .demo-upgrade-card h3 {
    font-size: 19px;
    margin-bottom: 8px;
  }

  .demo-upgrade-card p {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 16px;
  }

  .demo-upgrade-perks {
    list-style: none;
    text-align: left;
    margin-bottom: 20px;
  }

  .demo-upgrade-perks li {
    font-size: 13px;
    color: var(--text);
    padding: 6px 0 6px 22px;
    position: relative;
    border-bottom: 1px solid var(--border);
  }

  .demo-upgrade-perks li:last-child { border-bottom: none; }

  .demo-upgrade-perks li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-tertiary);
    font-weight: 700;
  }

  .demo-upgrade-cta {
    width: 100%;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    padding: 12px;
    margin-bottom: 10px;
  }

  .demo-upgrade-dismiss {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .demo-upgrade-dismiss:hover { color: var(--text); }
