:root {
  color-scheme: dark;
  --bg: #030306;
  --ink: #f5f3ff;
  --muted: rgba(245, 243, 255, 0.64);
  --quiet: rgba(245, 243, 255, 0.44);
  --line: rgba(255, 255, 255, 0.16);
  --violet: #8d62ff;
  --blue: #58bcff;
  --shell: min(1120px, calc(100% - 44px));
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: auto;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body::selection {
  background: rgba(141, 98, 255, 0.34);
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.filter-root {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
}

.fixed-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #05050d;
  pointer-events: none;
}

.fixed-bg img,
.fixed-bg span {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.fixed-bg img {
  z-index: 0;
  object-fit: cover;
  object-position: center;
  opacity: 0.83;
  filter: brightness(0.96) contrast(1.1) saturate(1.1);
  transform: scale(1.04);
}

.fixed-bg span {
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(3, 3, 6, 0.72), rgba(3, 3, 6, 0.14) 48%, rgba(3, 3, 6, 0.56)),
    linear-gradient(180deg, rgba(3, 3, 6, 0.18), rgba(3, 3, 6, 0.08) 44%, rgba(3, 3, 6, 0.52)),
    radial-gradient(circle at 80% 18%, rgba(141, 98, 255, 0.16), transparent 27rem),
    radial-gradient(circle at 14% 72%, rgba(88, 188, 255, 0.12), transparent 25rem);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: var(--shell);
  margin: 0 auto;
  padding-bottom: 64px;
}

.liquid-surface {
  --mx: 50%;
  --my: 50%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(230, 238, 255, 0.2);
  background: rgba(255, 255, 255, 0.008);
  box-shadow:
    0 5px 10px rgba(0, 0, 0, 0.2),
    0 18px 56px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.64),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18),
    inset 0 0 22px rgba(255, 255, 255, 0.045),
    inset 18px 0 38px -34px rgba(88, 188, 255, 0.48),
    inset -18px 0 38px -34px rgba(141, 98, 255, 0.44);
  transform: translateZ(0);
}

.liquid-surface::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.006) 44%, rgba(255, 255, 255, 0.024)),
    radial-gradient(280px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.07), transparent 62%),
    rgba(6, 8, 18, 0.01);
  backdrop-filter: var(--liquid-filter, blur(0.01px)) blur(0.24px) brightness(1.08) saturate(1.16);
  -webkit-backdrop-filter: var(--liquid-filter, blur(0.01px)) blur(0.24px) brightness(1.08) saturate(1.16);
  content: "";
  pointer-events: none;
}

.liquid-surface::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), transparent 22%),
    linear-gradient(90deg, rgba(88, 188, 255, 0.3), transparent 16%, transparent 82%, rgba(141, 98, 255, 0.3)),
    radial-gradient(180px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.2), transparent 56%);
  content: "";
  opacity: 0.82;
  pointer-events: none;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  padding: 1px;
}

.liquid-surface > * {
  position: relative;
  z-index: 2;
}

.topbar {
  position: sticky;
  top: 18px;
  z-index: 20;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  border-radius: 999px;
  padding: 10px 12px;
}

.logo,
.top-nav,
.top-nav a,
.button,
.icon-button {
  display: inline-flex;
  align-items: center;
}

.logo {
  gap: 10px;
  font-weight: 760;
}

.logo-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--violet), var(--blue));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 850;
  box-shadow: 0 10px 28px rgba(88, 188, 255, 0.18);
}

.top-nav {
  gap: 4px;
}

.top-nav a {
  min-height: 36px;
  justify-content: center;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 720;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.top-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.hero {
  display: grid;
  min-height: 34svh;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 310px);
  gap: 28px;
  align-items: end;
  padding: 86px 0 34px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 22px;
  color: #8fbfff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 22px;
  font-size: clamp(4.1rem, 8.8vw, 8.5rem);
  font-weight: 850;
  line-height: 0.86;
}

.hero p:last-child {
  max-width: 34rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.55vw, 1.2rem);
  line-height: 1.5;
}

.signal-panel {
  display: flex;
  min-height: 162px;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 8px;
  padding: 22px;
}

.signal-panel span,
.panel-heading span,
.result-kicker {
  color: #9fc9ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.signal-panel strong {
  color: #fff;
  font-size: 4.1rem;
  font-weight: 840;
  line-height: 0.85;
}

.signal-panel small {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.builder-panel {
  grid-column: span 2;
}

.tool-panel,
.output-panel {
  border-radius: 8px;
  padding: 22px;
}

.tool-panel {
  min-height: 420px;
}

.builder-panel,
.preset-panel {
  min-height: 0;
}

.panel-heading {
  margin-bottom: 26px;
}

.panel-heading span {
  display: block;
  margin-bottom: 16px;
}

h2 {
  margin-bottom: 0;
  color: #fff;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  font-weight: 800;
  line-height: 1;
}

form {
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  outline: 0;
  background: rgba(1, 2, 9, 0.54);
  color: #fff;
  padding: 0 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 12px 28px rgba(0, 0, 0, 0.16);
}

select {
  cursor: pointer;
}

input:focus,
select:focus {
  border-color: rgba(143, 191, 255, 0.55);
  box-shadow:
    0 0 0 3px rgba(88, 188, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

input[readonly] {
  cursor: default;
  color: rgba(245, 243, 255, 0.72);
}

.button {
  min-height: 50px;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  margin-top: 10px;
  padding: 0 22px;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 780;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled):not(.is-disabled) {
  transform: translateY(-2px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.56;
}

.builder-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(230px, 0.7fr);
  gap: 14px;
}

.builder-main,
.node-editor {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.node-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-chip,
.small-button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(245, 243, 255, 0.78);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 760;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.builder-chip {
  flex: 0 1 auto;
  padding: 0 12px;
}

.builder-chip:hover,
.small-button:hover:not(:disabled) {
  border-color: rgba(143, 191, 255, 0.48);
  background: rgba(255, 255, 255, 0.095);
  color: #fff;
  transform: translateY(-1px);
}

.node-builder {
  display: flex;
  min-height: 104px;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(1, 2, 9, 0.34);
  padding: 12px;
}

.format-node {
  display: grid;
  min-width: 92px;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  cursor: grab;
  padding: 11px 12px;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.format-node:active {
  cursor: grabbing;
}

.format-node:hover,
.format-node.is-active {
  border-color: rgba(143, 191, 255, 0.58);
  background: rgba(255, 255, 255, 0.105);
}

.format-node.is-active {
  box-shadow:
    0 0 0 3px rgba(88, 188, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.format-node.is-copied {
  border-color: rgba(255, 255, 255, 0.78);
  box-shadow:
    0 0 0 3px rgba(141, 98, 255, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.format-node.is-dragging {
  opacity: 0.48;
  transform: scale(0.98);
}

.format-node span {
  color: #9fc9ff;
  font-size: 0.66rem;
  font-weight: 840;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.format-node strong {
  overflow: hidden;
  max-width: 12rem;
  color: #fff;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pattern-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.62fr);
  gap: 12px;
  align-items: end;
}

.pattern-grid > div {
  display: grid;
  gap: 8px;
}

.builder-example {
  display: flex;
  min-height: 48px;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(1, 2, 9, 0.54);
  color: rgba(245, 243, 255, 0.78);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
  padding: 0 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-editor {
  align-content: start;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(1, 2, 9, 0.28);
  padding: 12px;
}

.node-control {
  display: grid;
  gap: 8px;
}

.node-editor.is-text-mode .node-length-control,
.node-editor:not(.is-text-mode) .node-text-control {
  display: none;
}

.node-editor-actions {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}

.small-button {
  display: grid;
  width: 42px;
  height: 36px;
  place-items: center;
  padding: 0;
}

.small-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.small-button.danger {
  color: rgba(255, 190, 210, 0.92);
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.output-panel {
  grid-column: 1 / -1;
  min-height: 280px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.result-header strong {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 800;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  width: 42px;
  height: 42px;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button:disabled,
.icon-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

pre {
  max-height: 320px;
  margin: 0;
  overflow: auto;
  border-radius: 6px;
  background: rgba(1, 2, 9, 0.44);
  color: rgba(245, 243, 255, 0.84);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.72;
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(1, 2, 9, 0.5);
}

.loading-card {
  display: flex;
  min-width: 260px;
  min-height: 86px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 999px;
  padding: 18px 26px;
}

.loading-card strong {
  color: #fff;
  font-size: 1rem;
}

.loading-orbit {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: #8fbfff;
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@media (max-width: 940px) {
  :root {
    --shell: min(720px, calc(100% - 30px));
  }

  .app-shell {
    width: calc(100vw - 30px);
    max-width: 720px;
    padding-right: 0;
    padding-left: 0;
  }

  .hero,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .builder-panel {
    grid-column: 1;
  }

  .builder-workspace,
  .pattern-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 64px;
  }

  .tool-panel {
    min-height: 0;
  }
}

@media (max-width: 580px) {
  .topbar {
    min-height: 54px;
    margin-top: 12px;
  }

  .logo span:last-child {
    display: none;
  }

  .top-nav a {
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .top-nav a:last-child {
    display: none;
  }

  h1 {
    font-size: clamp(2.85rem, 14vw, 3.6rem);
  }

  .hero-copy,
  .hero p:last-child {
    max-width: 100%;
  }

  .tool-panel,
  .output-panel {
    padding: 18px;
  }

  .node-add-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-chip {
    width: 100%;
    padding: 0 8px;
  }

  .result-header {
    align-items: flex-start;
  }
}

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