:root {
  --bg: #171415;
  --panel: rgba(23, 20, 21, 0.82);
  --paper: #f1ece7;
  --muted: rgba(241, 236, 231, 0.66);
  --line: rgba(241, 236, 231, 0.14);
  --line-strong: rgba(241, 236, 231, 0.26);
  --signal: #55d88a;
  --signal-2: #64a7ff;
  --warm: #f4b860;
  --violet: #a78bfa;
  --font-sans: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background:
    linear-gradient(rgba(241, 236, 231, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(241, 236, 231, 0.026) 1px, transparent 1px),
    radial-gradient(780px 480px at 18% 0%, rgba(100, 167, 255, 0.14), transparent 64%),
    radial-gradient(760px 480px at 82% 4%, rgba(85, 216, 138, 0.12), transparent 62%),
    radial-gradient(620px 420px at 56% 100%, rgba(244, 184, 96, 0.08), transparent 65%),
    linear-gradient(180deg, #211f22 0%, #1b191b 48%, var(--bg) 100%);
  background-size: 34px 34px, 34px 34px, auto, auto;
  color: var(--paper);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; padding: clamp(16px, 2.2vw, 28px); }

.topbar {
  max-width: 1480px;
  margin: 0 auto 12px;
  display: grid;
  grid-template-columns: minmax(250px, auto) 1fr auto;
  align-items: center;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(241, 236, 231, 0.045);
}
.brand-mark::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--signal);
  transform: rotate(45deg);
}
.brand strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 0.96;
  letter-spacing: 0;
}
.kicker, .field-label, .property small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.pass-tabs { justify-self: end; display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.pass-tab, .property, .btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--paper);
  background: rgba(241, 236, 231, 0.04);
  transition: background 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease), opacity 180ms var(--ease);
}
.pass-tab { min-width: 142px; padding: 9px 12px; text-align: left; }
.pass-tab span { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.pass-tab strong { display: block; margin-top: 3px; font-size: 14px; font-weight: 700; }
.pass-tab[data-active="true"], .property[data-active="true"] { border-color: rgba(85, 216, 138, 0.58); background: rgba(85, 216, 138, 0.09); }
.pass-tab[data-done="true"] { box-shadow: inset 0 -2px 0 rgba(110, 231, 183, 0.82); }
.btn { min-height: 42px; padding: 0 14px; }
.btn:hover { transform: translateY(-1px); border-color: rgba(241, 236, 231, 0.34); }
.btn.primary { background: rgba(85, 216, 138, 0.18); border-color: rgba(85, 216, 138, 0.55); }
.btn.reset { border-color: rgba(241, 236, 231, 0.28); }

.layout {
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(560px, 1.35fr) minmax(330px, 0.72fr);
  gap: 16px;
  min-height: calc(100vh - 106px);
}
.instrument-panel, .readout {
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    radial-gradient(520px 340px at 50% 8%, rgba(241, 236, 231, 0.052), transparent 66%),
    linear-gradient(135deg, rgba(100, 167, 255, 0.04), rgba(85, 216, 138, 0.025) 54%, rgba(167, 139, 250, 0.035)),
    var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}
.instrument-panel { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.stage-copy {
  padding: 16px 22px 8px;
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr;
  align-items: end;
  gap: 14px;
  border-bottom: 1px solid rgba(241, 236, 231, 0.08);
}
.stage-copy .kicker { grid-column: 1 / -1; }
.stage-copy h1 { margin: 0; font-size: clamp(26px, 3.3vw, 44px); line-height: 0.96; letter-spacing: 0; max-width: 520px; }
.stage-copy p, .readout p { margin: 0; color: var(--muted); line-height: 1.45; }
.stage-copy p { align-self: center; max-width: 560px; }

.instrument {
  width: 100%;
  min-height: min(720px, calc(100vh - 180px));
  touch-action: none;
  user-select: none;
  overflow: visible;
}
.mesh line { stroke: rgba(241, 236, 231, 0.055); stroke-width: 0.8; }
.axis-guides line {
  stroke: rgba(241, 236, 231, 0.14);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-dasharray: 1 8;
}
.axis-guides circle { fill: rgba(241, 236, 231, 0.36); }
.layer-ring circle {
  fill: none;
  stroke: rgba(241, 236, 231, 0.13);
  stroke-width: 1.1;
  transition: stroke 260ms var(--ease), stroke-width 260ms var(--ease), opacity 260ms var(--ease);
}
.layer-ring[data-active="true"] circle { stroke: rgba(241, 236, 231, 0.36); stroke-width: 1.6; }
.layer-ring[data-filled="true"] circle { stroke-dasharray: 2 7; stroke-linecap: round; }
.layer-ring text {
  fill: rgba(241, 236, 231, 0.34);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.layer-ring[data-active="true"] text,
.layer-ring[data-filled="true"] text { fill: rgba(241, 236, 231, 0.7); }
.trail circle {
  fill: var(--paper);
  stroke: rgba(23, 20, 21, 0.72);
  stroke-width: 1.4;
  filter: drop-shadow(0 0 10px rgba(241, 236, 231, 0.16));
  transform-box: fill-box;
  transform-origin: center;
  animation: commit-pop 280ms var(--ease) both;
}
.drag-probe { pointer-events: none; }
.drag-probe circle:first-child { fill: var(--paper); stroke: rgba(23, 20, 21, 0.52); stroke-width: 1; }
.drag-probe circle:last-child { fill: none; stroke: rgba(241, 236, 231, 0.34); stroke-width: 1; animation: breathe-ring 900ms var(--ease) infinite alternate; }

.source text {
  fill: var(--bg);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
}
.source-hit { fill: transparent; stroke: rgba(241, 236, 231, 0.2); stroke-width: 1; }
.option {
  cursor: grab;
  opacity: 0.18;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.option[data-available="false"] {
  opacity: 0;
  pointer-events: none;
}
.option[data-current="true"],
.option[data-committed="true"],
.option[data-preview="true"] { opacity: 1; }
.option-hit { fill: rgba(241, 236, 231, 0.01); }
.option[data-active="true"] .color-node,
.option[data-active="true"] .shape-node,
.option[data-active="true"] .texture-node rect,
.option[data-preview="true"] .color-node,
.option[data-preview="true"] .shape-node,
.option[data-preview="true"] .texture-node rect,
.option[data-committed="true"] .color-node,
.option[data-committed="true"] .shape-node,
.option[data-committed="true"] .texture-node rect {
  stroke: var(--paper);
  stroke-width: 2.6;
  filter: drop-shadow(0 0 18px rgba(241, 236, 231, 0.28));
}
.color-node { fill: var(--node-color); stroke: rgba(241, 236, 231, 0.62); stroke-width: 1.5; }
.shape-node { fill: rgba(241, 236, 231, 0.76); stroke: rgba(241, 236, 231, 0.8); stroke-width: 1.4; }
.texture-node rect { fill: rgba(241, 236, 231, 0.08); stroke: rgba(241, 236, 231, 0.58); stroke-width: 1.3; }
.color-node,
.shape-node,
.texture-node rect,
.texture-node line,
.texture-node path,
.texture-node circle {
  transition: stroke 200ms var(--ease), stroke-width 200ms var(--ease), filter 200ms var(--ease), opacity 200ms var(--ease);
}
.texture-node line, .texture-node path { fill: none; stroke: rgba(241, 236, 231, 0.86); stroke-width: 2.3; stroke-linecap: round; }
.texture-node circle { fill: rgba(241, 236, 231, 0.86); }
.option-label {
  fill: rgba(241, 236, 231, 0.42);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: fill 220ms var(--ease), opacity 220ms var(--ease);
}
.option-label[data-current="true"] { fill: rgba(241, 236, 231, 0.78); opacity: 1; }
.option-label[data-available="false"] { opacity: 0; }

.readout { padding: 20px; display: grid; align-content: start; gap: 15px; }
.readout h2 { margin: 4px 0 0; font-size: clamp(32px, 4vw, 56px); line-height: 0.94; text-transform: lowercase; }
.mark.large { width: 100%; min-height: 250px; border: 1px solid rgba(241, 236, 231, 0.09); border-radius: 10px; background: rgba(0, 0, 0, 0.14); }
.mark.small { width: 68px; height: 68px; overflow: visible; }
.placeholder { fill: none; stroke: rgba(241, 236, 231, 0.22); stroke-width: 1.5; stroke-dasharray: 4 8; }
.mark-fill { fill: color-mix(in srgb, var(--mark-color), transparent 16%); filter: url(#soft-shadow); }
.mark-outline { fill: none; stroke: rgba(241, 236, 231, 0.86); stroke-width: 3; }
.mark-texture { opacity: 0.58; }
.mark-texture line, .mark-texture path { fill: none; stroke: rgba(20, 18, 19, 0.78); stroke-width: 5; stroke-linecap: round; }
.mark-texture circle { fill: rgba(20, 18, 19, 0.74); }
.mark-texture rect { fill: rgba(20, 18, 19, 0.16); }
.mark-texture .split-a { fill: rgba(20, 18, 19, 0.05); }
.mark-texture .split-b { fill: rgba(241, 236, 231, 0.18); }
.mark-core { fill: var(--paper); stroke: rgba(23, 20, 21, 0.6); stroke-width: 2; }

.property-list { display: grid; gap: 8px; }
.property { width: 100%; min-height: 62px; padding: 10px; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; text-align: left; }
.property[data-empty="true"] { opacity: 0.58; }
.property strong { display: block; margin-top: 3px; font-size: 16px; }
.property-swatch, .mini { width: 26px; height: 26px; display: block; }
.mini.color { border-radius: 50%; background: var(--node-color); }
.mini.shape { background: rgba(241, 236, 231, 0.76); }
.mini.texture { border: 1px solid rgba(241, 236, 231, 0.48); border-radius: 5px; background: rgba(241, 236, 231, 0.66); }
.texture-hatch { background: repeating-linear-gradient(135deg, rgba(241, 236, 231, 0.85) 0 3px, transparent 3px 8px); }
.texture-dots { background: radial-gradient(circle, rgba(241, 236, 231, 0.92) 0 2px, transparent 2.8px) 0 0 / 9px 9px, rgba(241, 236, 231, 0.12); }
.texture-split { background: linear-gradient(135deg, rgba(241, 236, 231, 0.82) 0 48%, rgba(241, 236, 231, 0.24) 48% 52%, rgba(241, 236, 231, 0.46) 52%); }
.shape-circle { border-radius: 50%; }
.shape-triangle { clip-path: polygon(50% 3%, 97% 96%, 3% 96%); }
.shape-diamond { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.shape-square { border-radius: 4px; }
.shape-pentagon { clip-path: polygon(50% 0, 98% 37%, 80% 100%, 20% 100%, 2% 37%); }
.shape-hex { clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%); }

.profile-combine {
  border: 1px solid rgba(241, 236, 231, 0.1);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background:
    radial-gradient(280px 150px at 20% 0%, rgba(100, 167, 255, 0.09), transparent 64%),
    rgba(0, 0, 0, 0.14);
}
.profile-combine[data-locked="true"] {
  opacity: 0.62;
}
.profile-combine p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}
.profile-evidence {
  border-left: 2px solid rgba(85, 216, 138, 0.48);
  padding-left: 10px;
  display: grid;
  gap: 3px;
}
.profile-evidence strong {
  font-size: 14px;
  line-height: 1.2;
}
.profile-evidence span,
.combined-sentence {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.profile-suggestion {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.profile-suggestion span {
  border: 1px solid rgba(241, 236, 231, 0.14);
  border-radius: 999px;
  padding: 4px 8px;
  color: rgba(241, 236, 231, 0.78);
  background: rgba(241, 236, 231, 0.04);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
label { display: grid; gap: 6px; }
input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(241, 236, 231, 0.13);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--paper);
  padding: 9px 10px;
}
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.schema { border: 1px solid rgba(241, 236, 231, 0.09); border-radius: 8px; overflow: hidden; }
.schema summary { padding: 12px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.schema pre {
  max-height: 250px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid rgba(241, 236, 231, 0.08);
  padding: 12px;
  color: rgba(241, 236, 231, 0.76);
  background: rgba(0, 0, 0, 0.22);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(23, 20, 21, 0.96);
  padding: 11px 14px;
}

@keyframes breathe-ring {
  from { opacity: 0.32; transform: scale(0.86); }
  to { opacity: 0.82; transform: scale(1.08); }
}

@keyframes commit-pop {
  from { opacity: 0; transform: scale(0.45); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1120px) {
  .topbar, .layout { grid-template-columns: 1fr; }
  .pass-tabs { justify-self: stretch; justify-content: start; }
  .btn.reset { justify-self: start; }
  .instrument { min-height: 520px; }
}
@media (max-width: 720px) {
  .app-shell { padding: 14px; }
  .pass-tabs { display: grid; grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stage-copy { grid-template-columns: 1fr; }
  .stage-copy h1 { font-size: clamp(28px, 11vw, 46px); }
  .instrument { min-height: 460px; }
}
