:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel-2: #171b22;
  --line: #232933;
  --ink: #e8ecf1;
  --ink-dim: #8a94a3;
  --ink-faint: #5b6573;
  --accent: #6aa9ff;
  --accent-2: #9b7bff;
  --accent-ink: #0b0d10;
  --danger: #ff6a6a;
  --good: #5ed39a;
  --mask: #ff3d6a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: #0d1015;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .get-app { margin-left: 6px; }
.app-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  object-fit: cover;
  display: block;
}
.app-icon.big {
  width: 112px; height: 112px;
  border-radius: 26px;
  margin: 0 auto 20px;
  box-shadow: 0 18px 40px rgba(106,169,255,0.28), 0 8px 20px rgba(155,123,255,0.22);
}
/* Backwards-compat: keep the old gradient tile around for any leftover uses */
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
  box-shadow: var(--shadow);
}
h1 { font-size: 16px; margin: 0; letter-spacing: 0.2px; }
.subtitle { font-size: 12px; margin: 2px 0 0; color: var(--ink-dim); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.badge {
  padding: 5px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11px; color: var(--ink-dim); letter-spacing: 0.3px;
}
.badge.good { color: var(--good); border-color: rgba(94, 211, 154, 0.35); }
.badge.warn { color: #ffb86a; border-color: rgba(255, 184, 106, 0.35); }
.badge.bad { color: var(--danger); border-color: rgba(255, 106, 106, 0.35); }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 0;
}
.panel-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-section h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-dim);
  margin: 0 0 10px;
}

.file-drop {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover, .file-drop.drag {
  border-color: var(--accent);
  background: rgba(106, 169, 255, 0.06);
}

body.drag::after {
  content: attr(data-drop-text) " ";
  position: fixed;
  inset: 16px;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: rgba(106, 169, 255, 0.08);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.4px;
  pointer-events: none;
  z-index: 9999;
}
.drop-icon { font-size: 22px; margin-bottom: 6px; color: var(--ink-dim); }
.drop-inner > div { font-size: 13px; margin-top: 4px; }
.hint { color: var(--ink-faint); font-size: 11px; margin-top: 4px; }
.sample-row { display: flex; gap: 6px; margin-top: 10px; }
.btn.sample {
  flex: 1; font-size: 11px; padding: 6px 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: #1e232c; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }

.tool-row { display: flex; gap: 6px; margin-bottom: 10px; }
.tool {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
}
.tool:hover { background: #1e232c; }
.tool.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(106, 169, 255, 0.08);
}

.slider-row {
  display: grid;
  grid-template-columns: 90px 1fr 32px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-dim);
}
.slider-row .num { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--panel);
}

.select-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-dim);
}
select {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}

.status {
  margin-top: 10px;
  font-size: 11px;
  color: var(--ink-dim);
  min-height: 14px;
  line-height: 1.4;
}
.status.err { color: var(--danger); }
.status.ok { color: var(--good); }

.export-row { display: flex; flex-direction: column; gap: 8px; }

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.15);
}
.view-toggle, .zoom-row { display: flex; gap: 4px; }
.chip {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-dim);
  cursor: pointer;
}
.chip:hover:not(:disabled) { color: var(--ink); }
.chip.active { color: var(--ink); border-color: var(--accent); background: rgba(106,169,255,0.08); }
.chip.static { cursor: default; color: var(--ink); }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }

.canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #14181f;
  display: grid;
  place-items: center;
}
.canvas-stack {
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  transform-origin: center;
}
.canvas-stack canvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
  image-rendering: pixelated;
}
.canvas-stack canvas[hidden] { display: none; }
#image-canvas { position: relative !important; }
#cursor-canvas { touch-action: none; cursor: crosshair; }
#mask-canvas { pointer-events: none; }
#result-canvas { position: absolute; top: 0; left: 0; }

.compare-slider {
  position: absolute;
  top: 0; bottom: 0;
  width: 24px;            /* generous hit area */
  margin-left: -12px;     /* center the hit area on the seam */
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  z-index: 10;
}
.compare-slider::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: white;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
  pointer-events: none;
}
.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px; height: 32px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  pointer-events: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--ink-dim);
  pointer-events: none;
}
.empty-state[hidden] { display: none; }
[hidden] { display: none !important; }
.empty-icon { font-size: 48px; opacity: 0.5; }
.empty-title { font-size: 15px; color: var(--ink); margin-top: 10px; }
.empty-desc { font-size: 12px; margin-top: 4px; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 0;
  max-width: 520px;
  width: calc(100% - 40px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
dialog::backdrop { background: rgba(0,0,0,0.7); }
dialog article { padding: 22px 26px; }
dialog h3 { margin: 14px 0 6px; font-size: 13px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.6px; }
dialog h3:first-child { margin-top: 0; }
dialog p, dialog li { font-size: 13px; line-height: 1.5; color: var(--ink); }
dialog code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
kbd {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
}

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  .panel { max-height: 42vh; border-right: none; border-bottom: 1px solid var(--line); }
}

/* -------- Landing page -------- */
.landing {
  position: fixed;
  inset: 0;
  z-index: 200;
  background:
    radial-gradient(1000px 700px at 15% 0%, rgba(106,169,255,0.18), transparent 60%),
    radial-gradient(900px 600px at 85% 100%, rgba(155,123,255,0.18), transparent 60%),
    var(--bg);
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.landing-inner {
  max-width: 760px;
  width: 100%;
  text-align: center;
  position: relative;
}
.landing-lang {
  position: absolute;
  top: -10px;
  right: 0;
  z-index: 2;
}
.landing-lang select,
.header-lang {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  max-width: 180px;
}
.header-lang { padding: 4px 8px; font-size: 11px; }
[dir="rtl"] .landing-lang { right: auto; left: 0; }
/* app-icon.big already styled above; keep a hook for any gradient .logo.big fallback */
.landing-hero .logo.big {
  width: 112px; height: 112px;
  border-radius: 26px;
  margin: 0 auto 20px;
  font-size: 56px;
  box-shadow: 0 18px 40px rgba(106,169,255,0.28);
}
.landing-title {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 12px;
  background: linear-gradient(135deg, #ffffff 0%, #b7d0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-tag {
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-dim);
  margin: 0 0 36px;
}
.landing-cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 48px;
}
.appstore-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  border-radius: 12px;
  background: #000;
  border: 1px solid #2a2a2a;
  color: #fff;
  text-decoration: none;
  min-height: 56px;
  transition: transform 0.08s, border-color 0.12s;
}
.appstore-btn:hover { border-color: #555; transform: translateY(-1px); }
.appstore-btn:active { transform: translateY(0); }
.appstore-icon { display: grid; place-items: center; color: #fff; }
.appstore-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  text-align: left;
}
.appstore-small { font-size: 10px; letter-spacing: 0.4px; opacity: 0.85; }
.appstore-big { font-size: 20px; font-weight: 600; letter-spacing: -0.2px; }
.landing-web {
  min-height: 56px;
  padding: 0 22px;
  font-size: 15px;
}

.landing-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
  text-align: left;
}
.feature {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
}
.feature-icon { font-size: 22px; margin-bottom: 8px; }
.feature-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--ink); }
.feature ul { margin: 0; padding-left: 18px; color: var(--ink-dim); font-size: 13px; line-height: 1.7; }
.landing-foot { font-size: 12px; color: var(--ink-faint); }
.landing-foot a { color: var(--accent); text-decoration: none; }
.landing-foot a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .landing-title { font-size: 32px; }
  .landing-tag { font-size: 15px; }
  .landing-features { grid-template-columns: 1fr; }
  .landing-cta { flex-direction: column; }
  .landing-cta > * { width: 100%; justify-content: center; }
}

/* Persistent "Get iOS app" header CTA */
.btn.get-app {
  background: #000;
  color: #fff;
  border-color: #2a2a2a;
  padding: 6px 12px;
  font-size: 12px;
  text-decoration: none;
  font-weight: 500;
}
.btn.get-app:hover { background: #111; border-color: #555; }
@media (max-width: 560px) {
  .btn.get-app span, .btn.get-app { font-size: 0; padding: 6px; }
  .btn.get-app svg { display: block; }
  .btn.get-app::after { content: "Get app"; font-size: 12px; margin-left: 6px; }
}
