/* ==========================================================================
   Extrudo — "maker studio" design system
   Blueprint / workshop meets soft modern SaaS.
   One accent: electric violet. Ink stage, warm-paper UI.
   ========================================================================== */

:root {
  --paper:      #f4f3f8;   /* light UI background */
  --paper-2:    #ffffff;   /* raised surfaces / panel */
  --ink:        #16131f;   /* primary text */
  --ink-soft:   #6a6577;   /* secondary text */
  --line:       #e4e1ec;   /* hairline borders */

  --stage:      #0e1420;   /* deep blueprint ink (3D area) */
  --stage-line: rgba(120, 150, 200, 0.10); /* blueprint grid */

  --accent:     #6c4cf1;   /* electric violet */
  --accent-600: #5a3ce4;
  --accent-700: #4c30c9;
  --accent-tint:#efeaff;

  --radius:     12px;
  --radius-lg:  16px;
  --shadow:     0 1px 2px rgba(22,19,31,.04), 0 8px 28px rgba(22,19,31,.06);

  --font-ui:    'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-disp:  'Space Grotesk', var(--font-ui);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background:
    linear-gradient(135deg, var(--accent) 0%, var(--accent-700) 100%);
  position: relative; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px;
  border: 2px solid rgba(255,255,255,.9); border-radius: 2px;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.brand-name {
  font-family: var(--font-disp); font-weight: 700; font-size: 19px;
  letter-spacing: -0.02em;
}
.brand-tag {
  font-size: 12px; color: var(--ink-soft); font-weight: 500;
  padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--line);
}
.topbar-nav { display: flex; align-items: center; gap: 12px; }
.tier-badge {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent-700);
}
.tier-badge.pro { background: var(--accent); color: #fff; }
.pro-lock {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  padding: 1px 6px; margin-left: 6px; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent-700);
  vertical-align: middle;
}
.btn-ghost {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; cursor: pointer; transition: all .15s ease;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-700); background: var(--accent-tint); }

/* -------------------------------------------------------------------- tool */
.tool {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

/* ------------------------------------------------------------------- stage */
.stage {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 120% at 50% 30%, #16203150 0%, transparent 60%),
    var(--stage);
  min-height: 62vh;
}
.stage-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--stage-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--stage-line) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(120% 100% at 50% 45%, #000 40%, transparent 85%);
}
.stage-corners .c {
  position: absolute; width: 18px; height: 18px; pointer-events: none;
  border-color: rgba(150,170,210,.35); border-style: solid; border-width: 0;
}
.stage-corners .tl { top: 18px; left: 18px; border-top-width: 2px; border-left-width: 2px; }
.stage-corners .tr { top: 18px; right: 18px; border-top-width: 2px; border-right-width: 2px; }
.stage-corners .bl { bottom: 18px; left: 18px; border-bottom-width: 2px; border-left-width: 2px; }
.stage-corners .br { bottom: 18px; right: 18px; border-bottom-width: 2px; border-right-width: 2px; }

#canvas-wrap { position: absolute; inset: 0; }
#canvas-wrap canvas { display: block; width: 100%; height: 100%; }

.hud {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(14,20,32,.72); backdrop-filter: blur(8px);
  border: 1px solid rgba(150,170,210,.18);
  color: #cdd6e6; font-size: 12px; font-variant-numeric: tabular-nums;
  font-family: var(--font-disp); letter-spacing: .01em;
}
.hud-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.hud-unit { color: #7f8aa0; }
.hint {
  position: absolute; bottom: 16px; left: 0; right: 0; text-align: center;
  color: #5f6b82; font-size: 12px; margin: 0; pointer-events: none;
  letter-spacing: .02em;
}

/* ------------------------------------------------------------------- panel */
.panel {
  background: var(--paper-2); border-left: 1px solid var(--line);
  padding: 26px 24px; overflow-y: auto; display: flex; flex-direction: column;
}
.panel-head { margin-bottom: 22px; }
.panel h1 {
  font-family: var(--font-disp); font-weight: 700; font-size: 24px;
  margin: 0 0 4px; letter-spacing: -0.025em; line-height: 1.1;
}
.panel .sub { margin: 0; color: var(--ink-soft); font-size: 14px; }

.field { display: block; margin-bottom: 18px; }
.field-group {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px 16px 4px; margin-bottom: 20px;
}
.field-group .field:last-child { margin-bottom: 12px; }
.field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--ink);
}
.field-label b { font-weight: 500; color: var(--accent-700); font-variant-numeric: tabular-nums; }

.field input[type=text],
.field textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: var(--font-ui);
  color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); transition: border-color .15s, box-shadow .15s;
}
.field textarea {
  resize: vertical; min-height: 48px; line-height: 1.35;
}
.field input[type=text]:focus,
.field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint); background: #fff;
}
.field-hint {
  display: block; margin-top: 6px; font-size: 12px; color: var(--ink-soft);
}

/* segmented toggle (e.g. backplate shape) */
.segmented {
  display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper);
}
.segmented button {
  flex: 1; padding: 8px 10px; font-size: 13px; font-weight: 600;
  font-family: var(--font-ui); color: var(--ink-soft); cursor: pointer;
  border: 0; border-radius: calc(var(--radius) - 4px); background: transparent;
  transition: background .15s, color .15s;
}
.segmented button.active { background: var(--accent); color: #fff; }
.segmented button:disabled { cursor: default; }
#plate-corners-field.na { opacity: .4; pointer-events: none; }

/* Shape picker — wrapping grid of pill buttons (basic + Pro special shapes) */
.shape-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 4px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper);
}
.shape-grid button {
  position: relative; padding: 9px 6px; font-size: 12.5px; font-weight: 600;
  font-family: var(--font-ui); color: var(--ink-soft); cursor: pointer;
  border: 0; border-radius: calc(var(--radius) - 4px); background: transparent;
  transition: background .15s, color .15s;
}
.shape-grid button.active { background: var(--accent); color: #fff; }
.shape-grid button:disabled { cursor: default; }
/* "PRO" tag on locked special shapes — hidden once the user is Pro. */
body:not(.is-pro) .shape-grid button[data-pro]::after {
  content: "PRO"; position: absolute; top: -5px; right: -3px;
  font-size: 7px; font-weight: 800; letter-spacing: .04em; line-height: 1;
  padding: 2px 4px; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent-700);
}
body.is-pro .pro-lock { display: none !important; }

/* Emoji quick-insert — wrapping grid of tap-to-insert buttons. Any pasted emoji
   also works; these are just common shortcuts. */
.emoji-grid {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px;
  padding: 5px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper);
}
.emoji-grid button {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; cursor: pointer; padding: 0;
  border: 0; border-radius: calc(var(--radius) - 6px); background: transparent;
  transition: background .12s, transform .12s;
}
.emoji-grid button:hover { background: var(--accent-tint); }
.emoji-grid button:active { transform: scale(.9); }
@media (max-width: 520px) { .emoji-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

/* custom select */
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.field select {
  width: 100%; padding: 12px 14px; font-size: 15px; font-family: var(--font-ui);
  color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); appearance: none; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* custom range sliders */
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 999px;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat,
              var(--line);
  background-size: var(--fill, 0%) 100%;
}
input[type=range]::-moz-range-track { height: 5px; border-radius: 999px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 5px; border-radius: 999px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -7px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(76,48,201,.35);
  transition: transform .1s ease, box-shadow .15s;
}
input[type=range]::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(76,48,201,.35);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.05); box-shadow: 0 0 0 6px var(--accent-tint); }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-tint); }

/* backplate toggle switch */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; cursor: pointer;
}
.toggle-row .field-label { margin-bottom: 0; }
input.switch {
  -webkit-appearance: none; appearance: none; margin: 0;
  width: 40px; height: 22px; border-radius: 999px; background: var(--line);
  position: relative; cursor: pointer; transition: background .15s ease; flex: none;
}
input.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(22,19,31,.25);
  transition: transform .15s ease;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }
input.switch:focus-visible { box-shadow: 0 0 0 3px var(--accent-tint); }

#plate-controls { transition: opacity .15s ease; }
#plate-controls.disabled { opacity: .45; pointer-events: none; }
#plate-controls .field:last-child { margin-bottom: 4px; }

/* primary CTA */
.btn-primary {
  width: 100%; padding: 14px; margin-top: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-size: 15px; font-weight: 600; color: #fff;
  background: var(--accent); border: none; border-radius: var(--radius);
  cursor: pointer; box-shadow: 0 4px 14px rgba(76,48,201,.28);
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn-primary:hover { background: var(--accent-600); box-shadow: 0 6px 20px rgba(76,48,201,.36); }
.btn-primary:active { transform: translateY(1px); }
.btn-ico { font-size: 17px; line-height: 1; }
.note { text-align: center; font-size: 12px; color: var(--ink-soft); margin: 12px 0 0; }

/* -------------------------------------------------------------- site footer */
.site-foot {
  background: var(--paper-2); border-top: 1px solid var(--line);
  padding: 18px 24px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.site-foot-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; }
.site-foot-links span { color: var(--ink-soft); font-weight: 600; }
.site-foot-links a { color: var(--ink-soft); text-decoration: none; }
.site-foot-links a:hover { color: var(--accent-700); }
.site-foot p { margin: 0; font-size: 12px; color: var(--ink-soft); }

/* ------------------------------------------------------------- embed mode */
/* Used when the tool is iframed into a landing page (?embed=1). */
body.embed .topbar,
body.embed .site-foot { display: none; }
body.embed { min-height: 0; height: 100%; }
body.embed .stage { min-height: 0; }

/* ----------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  .tool { grid-template-columns: 1fr; }
  .stage { min-height: 46vh; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
  .brand-tag { display: none; }
}

/* ==========================================================================
   PREMIUM UPGRADE LAYER — matches the landing pages (overrides base above)
   ========================================================================== */
:root{
  --grad-accent:linear-gradient(135deg,#6c4cf1 0%,#8b5cf6 45%,#a855f7 100%);
  --grad-accent-hot:linear-gradient(135deg,#6c4cf1 0%,#9333ea 50%,#ec4899 100%);
  --glow:rgba(108,76,241,.45);
}

/* brand mark gets the hot gradient */
.brand-mark{ background:var(--grad-accent-hot); }

/* "Unlock Pro" becomes a gradient button to pull the eye (it's the money CTA) */
.btn-ghost{
  background:var(--grad-accent); color:#fff; border-color:transparent;
  box-shadow:0 4px 14px var(--glow);
}
.btn-ghost:hover{
  background:var(--grad-accent); color:#fff; filter:brightness(1.07);
  border-color:transparent; box-shadow:0 8px 22px var(--glow);
}
.tier-badge.pro{ background:var(--grad-accent-hot); color:#fff; }

/* primary download button — gradient + stronger glow */
.btn-primary{ background:var(--grad-accent); box-shadow:0 8px 24px var(--glow); }
.btn-primary:hover{
  background:var(--grad-accent); filter:brightness(1.07);
  box-shadow:0 12px 34px var(--glow); transform:translateY(-1px);
}

/* segmented + switch active states use the hot gradient for consistency */
.segmented button.active{ background:var(--grad-accent); }
input.switch:checked{ background:var(--accent-600); }

/* slightly larger, tighter panel title */
.panel h1{ font-size:26px; letter-spacing:-.03em; }

/* Colour swatches (Text / Backplate) + the secondary export link */
.color-swatch{
  -webkit-appearance:none; appearance:none;
  width:100%; height:40px; padding:0; cursor:pointer;
  background:var(--paper-2);
  border:1px solid var(--line); border-radius:var(--radius);
}
.color-swatch::-webkit-color-swatch-wrapper{ padding:4px; }
.color-swatch::-webkit-color-swatch{ border:1px solid var(--line); border-radius:calc(var(--radius) - 5px); }
.color-swatch::-moz-color-swatch{ border:1px solid var(--line); border-radius:calc(var(--radius) - 5px); }
.note a{ color:var(--accent-700); text-decoration:underline; text-underline-offset:2px; }
.note a:hover{ color:var(--accent); }

/* Download section: two labelled file options + short explanations */
.download-group{ margin-top:auto; padding-top:6px; display:flex; flex-direction:column; }
.download-group .btn-primary{ margin-top:0; }
.download-title{
  font-size:13px; font-weight:600; color:var(--ink); margin-bottom:8px;
}
.btn-outline{
  width:100%; padding:12px; margin-top:10px;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  font-family:var(--font-ui); font-size:14px; font-weight:600;
  color:var(--accent-700); background:var(--paper-2);
  border:1px solid var(--line); border-radius:var(--radius); cursor:pointer;
  transition:border-color .15s ease, background .15s ease, transform .08s ease;
}
.btn-outline:hover{ border-color:var(--accent); background:var(--accent-tint); }
.btn-outline:active{ transform:translateY(1px); }
.download-explain{
  margin:7px 2px 0; font-size:12px; line-height:1.45; color:var(--ink-soft);
}
.download-explain b{ color:var(--ink); font-weight:600; }

/* ------------------------------------------------------------ image relief */
/* Text / Image-relief mode switch (segmented pill at the top of the panel). */
.mode-switch{
  display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:4px;
  margin-bottom:18px; padding:4px;
  border:1px solid var(--line); border-radius:var(--radius); background:var(--paper);
}
.mode-btn{
  padding:9px 6px; font-family:var(--font-ui); font-size:13.5px; font-weight:600;
  color:var(--ink-soft); cursor:pointer; border:0;
  border-radius:calc(var(--radius) - 4px); background:transparent;
  transition:background .15s, color .15s;
}
.mode-btn.active{ background:var(--accent); color:#fff; }

/* Two-up variant of the shape grid, used by the relief Style picker. */
.shape-grid.two{ grid-template-columns:repeat(2, minmax(0,1fr)); }

/* Image source row: upload (file label) + "try a sample". */
.relief-source{ display:flex; gap:8px; }
.relief-source .file-btn,
.relief-source .btn-ghost{ flex:1 1 0; margin-top:0; }
.file-btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  cursor:pointer;
}
.file-btn input{ position:absolute; width:0; height:0; opacity:0; }

/* AI prompt row (revealed only when the /api/generate backend is configured). */
.ai-row{ display:flex; gap:8px; align-items:stretch; }
#ai-prompt{
  flex:1 1 auto; min-width:0; padding:11px 12px;
  font-family:var(--font-ui); font-size:14px; color:var(--ink);
  background:var(--paper-2); border:1px solid var(--line);
  border-radius:var(--radius); outline:none; transition:border-color .15s ease;
}
#ai-prompt:focus{ border-color:var(--accent); }
.ai-row #ai-generate{ flex:0 0 auto; width:auto; margin-top:0; padding:11px 16px; white-space:nowrap; }
