:root {
  --bg-deep: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-panel-strong: #ffffff;
  --line-soft: rgba(29, 50, 84, 0.12);
  --line-strong: rgba(29, 50, 84, 0.28);
  --text-main: #1d2a3a;
  --text-muted: #617086;
  --accent: #1a8f73;
  --accent-hot: #c47a21;
  --danger: #ff7d7d;
  --shadow: 0 20px 60px rgba(31, 44, 66, 0.08);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --font-ui: "Avenir Next", "Trebuchet MS", sans-serif;
  --font-title: "Iowan Old Style", "Palatino Linotype", serif;
  --font-mono: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(26, 143, 115, 0.08), transparent 34%),
    radial-gradient(circle at top right, rgba(196, 122, 33, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
  color: var(--text-main);
  font-family: var(--font-ui);
}

body {
  position: relative;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(29, 50, 84, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 50, 84, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.9), transparent 88%);
}

.shell {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1,
.panel-head h2 {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.94;
  max-width: 10ch;
}

.subcopy {
  max-width: 42rem;
  margin: 14px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 14px;
  width: min(420px, 100%);
}

.stat-card,
.panel {
  border: 1px solid var(--line-soft);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.stat-card {
  padding: 16px 18px;
  border-radius: 18px;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 1.3rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.9fr);
  gap: 22px;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.panel-head,
.controls,
.toolbar,
.actions,
.preview-meta,
.legend,
.log-head {
  display: flex;
  align-items: center;
}

.panel-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar,
.controls,
.actions,
.preview-meta,
.legend,
.log-head {
  gap: 12px;
}

.controls {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 140px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.field.compact {
  min-width: 180px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid rgba(29, 50, 84, 0.14);
  border-radius: 14px;
  background: var(--bg-panel-strong);
  color: var(--text-main);
}

input[type="number"],
select {
  padding: 12px 14px;
}

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

textarea {
  min-height: 540px;
  resize: vertical;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #7eb7ff 100%);
  color: #04111a;
  font-weight: 700;
}

button.ghost {
  background: rgba(29, 50, 84, 0.04);
  color: var(--text-main);
  border: 1px solid rgba(29, 50, 84, 0.1);
}

button.tiny {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.script-footnote {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 16px;
}

.preview-meta {
  color: var(--text-muted);
  flex-wrap: wrap;
}

.canvas-wrap {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(29, 50, 84, 0.08);
  background: #ffffff;
}

#stripCanvas {
  display: block;
  width: 100%;
}

.legend {
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.legend-chip {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-block;
}

.legend-chip.rgb {
  border-radius: 6px;
  background: #2e82ff;
}

.legend-chip.white {
  border-radius: 6px;
  background: #fff4df;
}

.log-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-height: 220px;
}

#logOutput {
  margin: 0;
  min-height: 200px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fbfcfe;
  border: 1px solid rgba(29, 50, 84, 0.08);
  color: #425065;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  overflow: auto;
}

#stateLabel[data-running="true"] {
  color: var(--accent);
}

#stateLabel[data-running="false"] {
  color: var(--accent-hot);
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .hero-stats {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .shell {
    padding-inline: 16px;
  }

  .panel {
    padding: 18px;
  }

  .controls,
  .panel-head,
  .toolbar {
    align-items: start;
    flex-direction: column;
  }

  input[type="range"] {
    width: 100%;
  }

  textarea {
    min-height: 420px;
  }
}
