:root {
  --bg: #0f1014;
  --panel: #181c24;
  --panel-2: #1f2530;
  --border: #2a3140;
  --fg: #e6ecf2;
  --muted: #8b95a3;
  --accent: #7cc4ff;
  --accent-dim: #4a7aa8;
  --error: #ff7c8a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

code {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
}

header {
  max-width: 1080px;
  margin: 28px auto 16px;
  padding: 0 20px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 76ch;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.preview-panel { grid-column: 1; }
.config-panel  { grid-column: 2; grid-row: 1 / span 2; }
.presets-panel { grid-column: 1; }
.output-panel  { grid-column: 1 / -1; }

/* ── Preview ── */

.preview-stage {
  background:
    linear-gradient(45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(-45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1d24 75%),
    linear-gradient(-45deg, transparent 75%, #1a1d24 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: #14171d;
  border-radius: 6px;
  padding: 14px;
  min-height: 300px;
}

.preview-grid {
  /* tracks injected at runtime via <style id="live-grid"> */
  min-height: 270px;
}

.preview-cell {
  background: hsl(var(--hue, 200) 70% 60% / 0.85);
  color: #061018;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 36px;
  min-width: 36px;
}

/* ── Track lists ── */

.track-section { margin-bottom: 16px; }

.track-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.track-head .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.mini {
  background: var(--panel-2);
  color: var(--accent);
  border: 1px dashed var(--accent-dim);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}

.mini:hover { border-style: solid; }

.track-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-row {
  display: flex;
  gap: 6px;
}

.track-input {
  flex: 1;
  background: #0c0e13;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.85rem;
  outline: none;
}

.track-input:focus { border-color: var(--accent); }
.track-input.invalid { border-color: var(--error); color: var(--error); }

.track-del {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.track-del:hover { color: var(--error); border-color: var(--error); }

/* ── Gap + alignment ── */

.gap-section, .align-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inline-field .label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.inline-field input, .inline-field select {
  background: #0c0e13;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.85rem;
  outline: none;
}

.inline-field input:focus, .inline-field select:focus { border-color: var(--accent); }

/* ── Presets ── */

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Output ── */

.output {
  background: #0c0e13;
  color: #c6d4e6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  margin: 0;
}

.copy {
  margin-top: 10px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
}

.copy:hover { border-color: var(--accent); }

footer {
  grid-column: 1 / -1;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.6;
}

footer code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.8rem;
}

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
  .preview-panel, .config-panel, .presets-panel, .output-panel { grid-column: 1; grid-row: auto; }
}
