/* ============================================================================
   VECTR — black dark-mode, minimalist startup aesthetic
   (Inspired by Linear / Vercel / Notion: pure black canvas, hairline borders,
   a single restrained violet→blue accent, generous negative space.)
   ========================================================================== */

:root {
  --bg:        #000000;
  --surface:   #0a0a0c;
  --surface-2: #111114;
  --surface-3: #17171b;
  --border:    rgba(255, 255, 255, 0.09);
  --border-2:  rgba(255, 255, 255, 0.14);
  --text:      #f4f4f6;
  --text-2:    #b4b4bd;
  --muted:     #6f6f7a;
  --faint:     #45454e;
  --accent:    #7c7cf5;
  --accent-2:  #a78bfa;
  --accent-3:  #5b8bff;
  --danger:    #f2555a;
  --ok:        #34d399;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 20px 60px -20px rgba(0, 0, 0, 0.9);
  --ease:      cubic-bezier(0.22, 0.61, 0.36, 1);
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* The [hidden] attribute must win over class-level display rules
   (.hero/.workspace set display:flex/grid which would otherwise override it). */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  letter-spacing: -0.01em;
}

/* ---- ambient background --------------------------------------------------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 25%, transparent 75%);
}
.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  top: -280px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 620px;
  background: radial-gradient(ellipse at center, rgba(124,124,245,0.18), transparent 62%);
  filter: blur(30px);
}

/* ---- nav ------------------------------------------------------------------ */
.nav {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.logo { display: flex; align-items: center; gap: 9px; }
.logo-mark { display: block; }
.logo-text { font-weight: 700; font-size: 18px; letter-spacing: 0.04em; }
.logo-badge {
  font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-2); background: rgba(167,139,250,0.12);
  border: 1px solid rgba(167,139,250,0.2); padding: 2px 7px; border-radius: 20px;
  margin-top: 2px;
}
.nav-right { display: flex; align-items: center; gap: 14px; }
.nav-hint {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
}
.nav-hint .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52,211,153,0.14); }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  font-family: var(--font); font-size: 13.5px; font-weight: 550; cursor: pointer;
  border-radius: var(--radius-sm); padding: 10px 15px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.18s var(--ease); white-space: nowrap;
}
.btn-sm { padding: 8px 12px; font-size: 12.5px; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #0b0b12; font-weight: 650;
  box-shadow: 0 8px 24px -8px rgba(124,124,245,0.7), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.4); }
.btn-ghost {
  background: var(--surface-2); color: var(--text-2); border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }

/* ---- stage layout --------------------------------------------------------- */
.stage {
  position: relative; z-index: 5; flex: 1;
  width: 100%; max-width: 1320px; margin: 0 auto; padding: 34px 26px;
  display: flex; flex-direction: column;
}

/* ============================ HERO ======================================== */
.hero {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 30px; padding: 24px 0 40px;
}
.hero-copy { max-width: 620px; }
.hero-title {
  font-size: clamp(30px, 5vw, 52px); font-weight: 700; line-height: 1.05;
  letter-spacing: -0.03em;
}
.grad {
  background: linear-gradient(100deg, var(--accent-2), var(--accent-3));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub {
  margin-top: 16px; font-size: clamp(14px, 1.7vw, 17px); color: var(--text-2);
  line-height: 1.6; letter-spacing: -0.01em;
}

.dropzone {
  position: relative; width: min(620px, 100%); cursor: pointer;
  border-radius: 20px; background: var(--surface);
  border: 1.5px dashed var(--border-2);
  transition: all 0.22s var(--ease); overflow: hidden;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--surface-2); outline: none; }
.dropzone.is-drag { border-color: var(--accent-2); background: rgba(124,124,245,0.06); transform: scale(1.01); }
.dz-inner { position: relative; z-index: 2; padding: 54px 30px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dz-icon {
  width: 62px; height: 62px; border-radius: 16px; display: grid; place-items: center;
  color: var(--accent-2); background: rgba(124,124,245,0.09); border: 1px solid rgba(124,124,245,0.18);
  margin-bottom: 8px; transition: transform 0.25s var(--ease);
}
.dropzone:hover .dz-icon { transform: translateY(-3px); }
.dz-title { font-size: 18px; font-weight: 600; }
.dz-sub { font-size: 13.5px; color: var(--muted); }
.dz-sub u { color: var(--text-2); text-underline-offset: 3px; text-decoration-color: var(--faint); }
.dz-ring { position: absolute; inset: 0; z-index: 1; opacity: 0;
  background: radial-gradient(400px circle at var(--mx,50%) var(--my,50%), rgba(124,124,245,0.12), transparent 60%);
  transition: opacity 0.3s; }
.dropzone:hover .dz-ring { opacity: 1; }

.hero-samples { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.samples-label { font-size: 12.5px; color: var(--muted); }
.sample-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sample {
  width: 58px; height: 58px; border-radius: 12px; cursor: pointer; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2);
  transition: all 0.18s var(--ease); display: grid; place-items: center; padding: 0;
}
.sample:hover { border-color: var(--accent); transform: translateY(-2px); }
.sample svg { width: 100%; height: 100%; display: block; }

/* ========================== WORKSPACE ===================================== */
.workspace { display: grid; grid-template-columns: 1fr 312px; gap: 22px; align-items: start; }

/* ---- viewer --------------------------------------------------------------- */
.viewer-wrap { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.viewer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.seg-btn {
  font-family: var(--font); font-size: 12.5px; font-weight: 550; color: var(--muted);
  background: transparent; border: none; cursor: pointer; padding: 7px 14px; border-radius: 8px;
  transition: all 0.16s var(--ease);
}
.seg-btn:hover { color: var(--text-2); }
.seg-btn.is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.05); }
.viewer-meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.viewer {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); overflow: hidden;
  box-shadow: var(--shadow); user-select: none;
}
.viewer-inner { position: absolute; inset: 0; }
.layer { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.layer img, .svg-host { width: 100%; height: 100%; }
.layer img { object-fit: contain; display: block; pointer-events: none; }
.svg-host { display: grid; place-items: center; }
.svg-host svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }

/* checkerboard to reveal transparency in vector output */
.checker {
  background-color: #0d0d10;
  background-image:
    linear-gradient(45deg, #17171b 25%, transparent 25%),
    linear-gradient(-45deg, #17171b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #17171b 75%),
    linear-gradient(-45deg, transparent 75%, #17171b 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

/* slider clip */
.viewer[data-view="slider"] .layer-vector { clip-path: inset(0 0 0 var(--split, 50%)); }
.viewer[data-view="slider"] .slider-handle { display: flex; }
.viewer[data-view="split"] .layer-original { clip-path: inset(0 50% 0 0); }
.viewer[data-view="split"] .layer-vector   { clip-path: inset(0 0 0 50%); }
.viewer[data-view="split"] .split-divider { display: block; }
.viewer[data-view="vector"] .layer-original { opacity: 0; }
.viewer[data-view="vector"] .layer-vector   { clip-path: none; }
.viewer[data-view="original"] .layer-vector { opacity: 0; }
.viewer[data-view="original"] .layer-original { clip-path: none; }
.viewer:not([data-view="slider"]) .slider-handle { display: none; }

.slider-handle {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%);
  transform: translateX(-50%); width: 40px; cursor: ew-resize; z-index: 6;
  display: flex; align-items: center; justify-content: center;
}
.sh-line { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, var(--accent-2), var(--accent), transparent);
  opacity: 0.9; }
.sh-grip {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(20,20,26,0.9); border: 1px solid var(--border-2); color: var(--text);
  display: grid; place-items: center; backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
.corner-tag {
  position: absolute; bottom: 12px; z-index: 4; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2);
  background: rgba(10,10,12,0.72); border: 1px solid var(--border); padding: 4px 9px; border-radius: 7px;
  backdrop-filter: blur(6px); pointer-events: none;
}
.tag-a { left: 12px; }
.tag-b { right: 12px; }
.viewer[data-view="vector"] .tag-a, .viewer[data-view="original"] .tag-b { display: none; }

/* processing overlay */
.proc { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  background: rgba(5,5,7,0.55); backdrop-filter: blur(3px); }
.proc-card { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 220px; }
.spinner { width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.12); border-top-color: var(--accent-2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.proc-stage { font-size: 13px; color: var(--text-2); font-weight: 500; }
.proc-bar { width: 100%; height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.proc-fill { height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s var(--ease); }

/* ---- controls panel ------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: sticky; top: 22px; display: flex; flex-direction: column; gap: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.reset-link { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; font-family: var(--font); }
.reset-link:hover { color: var(--text-2); }

.ctrl-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; cursor: pointer; transition: all 0.16s var(--ease); font-family: var(--font);
}
.mode-btn:hover { border-color: var(--border-2); }
.mode-btn.is-active { border-color: var(--accent); background: rgba(124,124,245,0.08); }
.mode-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.mode-desc { font-size: 11px; color: var(--muted); }

.ctrl { display: flex; flex-direction: column; gap: 9px; }
.ctrl-row { display: flex; align-items: center; justify-content: space-between; }
.ctrl-row label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.ctrl-row output { font-family: var(--mono); font-size: 12px; color: var(--text); background: var(--surface-2);
  padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); }
.ctrl-hint { font-size: 11px; color: var(--faint); line-height: 1.4; }

/* range input */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: var(--surface-3); border-radius: 4px; outline: none; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5); transition: transform 0.12s var(--ease); }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: pointer; }

.ctrl-switch { flex-direction: row; align-items: center; justify-content: space-between; }
.ctrl-switch label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.switch { width: 40px; height: 23px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--border);
  position: relative; cursor: pointer; transition: all 0.18s var(--ease); padding: 0; }
.switch span { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--muted); transition: all 0.18s var(--ease); }
.switch[aria-checked="true"] { background: rgba(124,124,245,0.25); border-color: var(--accent); }
.switch[aria-checked="true"] span { left: 19px; background: var(--accent-2); }

/* palette */
.palette { display: flex; flex-direction: column; gap: 8px; }
.palette-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.14); }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding-top: 16px; border-top: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-k { font-size: 11px; color: var(--muted); }
.stat-v { font-family: var(--mono); font-size: 13.5px; color: var(--text); font-weight: 500; }

.panel-actions { display: flex; flex-direction: column; gap: 8px; }
.panel-actions .btn { width: 100%; }

/* ---- footer --------------------------------------------------------------- */
.foot { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); gap: 12px; flex-wrap: wrap; }
.foot-dim { color: var(--faint); font-family: var(--mono); font-size: 11px; }

/* ---- toast ---------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 13px; z-index: 100;
  opacity: 0; pointer-events: none; transition: all 0.25s var(--ease); box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { position: static; }
  .viewer { aspect-ratio: 3 / 2; }
}
@media (max-width: 560px) {
  .nav-hint { display: none; }
  .stage { padding: 20px 16px; }
  .seg-btn { padding: 7px 10px; }
}
