:root {
  --bg: #101218;
  --panel: #181c24;
  --panel-2: #202633;
  --border: rgba(255, 255, 255, 0.1);
  --text: #edf2f7;
  --muted: #a8b3c7;
  --accent: #ffd166;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Avenir Next", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #151922 0%, #0d1016 100%);
}

.shell {
  width: min(1800px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  gap: 20px;
}

.hero,
.panel {
  border: 1px solid var(--border);
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.05),
      rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border-radius: 20px;
}

.hero {
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.hero p {
  margin: 10px 0 0;
  max-width: 64ch;
  color: var(--muted);
  line-height: 1.5;
}

.status {
  min-width: 250px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 0.95rem;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.field select,
.field input,
.field button {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

.field button {
  cursor: pointer;
  background: linear-gradient(180deg, #ffd166, #f7b538);
  color: #241600;
  font-weight: 700;
}

.controls-panel {
  display: grid;
  gap: 18px;
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.controls-copy {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 72ch;
  line-height: 1.45;
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.param-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 10px;
}

.param-topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.param-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.param-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 0.9rem;
}

.param-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.param-input {
  width: 100%;
}

.grid {
  display: grid;
  grid-template-columns:
    minmax(280px, 420px) minmax(0, 1fr) minmax(280px, 420px);
  gap: 20px;
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

.image-wrap,
.svg-wrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #121722;
  background-size: 16px 16px;
  min-height: 320px;
  display: grid;
  place-items: center;
}

#source-image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
}

#debug-svg {
  width: 100%;
  height: min(78vh, 920px);
  display: block;
}

.summary {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: rgba(8, 12, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  max-width: 280px;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 100ms ease,
    transform 100ms ease;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.tooltip-line {
  color: var(--muted);
}

@media (max-width: 980px) {

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

  .param-grid {
    grid-template-columns: 1fr;
  }

  .controls-header {
    flex-direction: column;
  }

  .hero {
    align-items: start;
    flex-direction: column;
  }
}