:root {
  --bg: #040914;
  --bg-elevated: rgba(9, 17, 31, 0.74);
  --bg-soft: rgba(16, 28, 49, 0.72);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(125, 211, 252, 0.22);
  --text: #eff6ff;
  --muted: #94a3b8;
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(1, 6, 18, 0.48);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.14), transparent 32%),
    radial-gradient(circle at top right, rgba(167, 139, 250, 0.16), transparent 26%),
    linear-gradient(180deg, #060b16 0%, #040914 100%);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family:
    "JetBrains Mono",
    "SFMono-Regular",
    ui-monospace,
    monospace;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 420px) 1fr;
  height: 100vh;
}

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
  background: linear-gradient(180deg, rgba(3, 8, 20, 0.76), rgba(3, 8, 20, 0.58));
  backdrop-filter: blur(20px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-fill {
  flex: 1 1 auto;
  min-height: 320px;
}

.brand-panel {
  padding: 22px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 1.9rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.98rem;
}

.subtitle,
.muted {
  color: var(--muted);
}

.subtitle {
  line-height: 1.55;
}

.compact {
  margin-top: 14px;
  font-size: 0.92rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-header-tight {
  margin-bottom: 10px;
}

.hint {
  color: var(--muted);
  font-size: 0.84rem;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.search-form {
  position: relative;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  background: rgba(8, 14, 26, 0.88);
  color: var(--text);
  outline: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

input[type="text"]:focus,
textarea:focus {
  border-color: rgba(125, 211, 252, 0.58);
  box-shadow: 0 0 0 4px rgba(125, 211, 252, 0.12);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06111f;
}

.ghost-button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(9, 17, 31, 0.72);
  color: var(--text);
}

.primary-button:hover,
.ghost-button:hover,
.chip:hover,
.neighbor-item:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.full-width {
  width: 100%;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  min-height: 1px;
}

.chip-row,
.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.template-button {
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(10, 18, 32, 0.78);
  color: var(--text);
}

.slider-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 14px 0 16px;
}

input[type="range"] {
  accent-color: var(--accent);
}

output {
  min-width: 42px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.details-card {
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}

.details-card h3 {
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(125, 211, 252, 0.08);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.neighbors-shell {
  margin-top: 16px;
}

.neighbors-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 6px;
}

.neighbor-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: rgba(8, 14, 26, 0.76);
  color: inherit;
  text-align: left;
}

.neighbor-main {
  min-width: 0;
}

.neighbor-word {
  margin-bottom: 4px;
  font-weight: 700;
}

.neighbor-meta {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.neighbor-score {
  color: var(--accent);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.stage-shell {
  position: relative;
  overflow: hidden;
}

#scene {
  width: 100%;
  height: 100%;
}

.labels-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.floating-label {
  position: absolute;
  padding: 6px 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(3, 8, 20, 0.8);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  transform: translate(-50%, -50%);
}

.floating-label-primary {
  border-color: rgba(125, 211, 252, 0.38);
  box-shadow: 0 10px 28px rgba(125, 211, 252, 0.18);
}

.hud {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  z-index: 2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(9, 17, 31, 0.78);
  backdrop-filter: blur(14px);
  color: var(--text);
  box-shadow: var(--shadow);
}

.status-pill-subtle {
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.18);
}

.legend {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: min(360px, calc(100vw - 40px));
  max-height: min(52vh, 420px);
  overflow-y: auto;
}

.legend h3 {
  margin-bottom: 12px;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(8, 14, 26, 0.7);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.legend-label {
  color: var(--text);
  font-size: 0.9rem;
}

.legend-size {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  padding: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.16);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
  background-clip: padding-box;
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(540px, 100vh);
    height: auto;
  }

  .panel-stack {
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  }

  .stage-shell {
    min-height: 72vh;
  }

  .legend {
    width: calc(100vw - 40px);
  }
}
