:root {
  --bg: #1e1e2e;           /* Base */
  --bg-surface: #313244;   /* Surface 0 */
  --bg-input: #181825;     /* Mantle */
  --border: #45475a;       /* Surface 1 */
  --text: #cdd6f4;         /* Text */
  --text-dim: #6c7086;     /* Overlay 0 */
  --accent: #89b4fa;       /* Blue */
  --terminal-bg: #11111b;  /* Crust */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

h3 { color: var(--accent); margin-bottom: 0.5rem; font-size: 1rem; }
h4 { color: var(--text-dim); margin-bottom: 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

.header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.header h1 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
}
.header p { color: var(--text-dim); font-size: 0.9rem; }

/* Presets */
.presets { margin-bottom: 1.5rem; }
.preset-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.preset-bar button {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s;
}
.preset-bar button:hover { border-color: var(--accent); }
.preset-bar button.active {
  border-color: var(--accent);
  background: rgba(137, 180, 250, 0.15);
}

/* Format editor */
.format-editor { margin-bottom: 1.5rem; }
.format-editor input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}
.format-editor input:focus { outline: none; border-color: var(--accent); }

.placeholder-ref {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.placeholder-ref code {
  color: var(--accent);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
}

.note {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

/* Colors */
.colors { margin-bottom: 1.5rem; }
.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
@media (max-width: 600px) {
  .color-grid { grid-template-columns: 1fr; }
}
.color-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.color-row .label {
  font-size: 0.8rem;
  min-width: 5.5rem;
  color: var(--text);
}
.swatches {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  align-items: center;
}
.swatches input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
  display: inline-block;
}
.swatch:hover { transform: scale(1.2); }
input[type="radio"]:focus-visible + .swatch { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="radio"]:checked + .swatch { border-color: #fff; box-shadow: 0 0 0 1px #fff, inset 0 0 0 1px #1e1e2e; }
.swatch[data-ansi="0"] {
  /* Reset: checkerboard to indicate "no color" */
  background: repeating-conic-gradient(#585b70 0% 25%, #313244 0% 50%) 50% / 8px 8px; /* Surface 2 / Surface 0 */
}

/* Preview */
.preview { margin-bottom: 1.5rem; }
.terminal {
  background: var(--terminal-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.terminal-titlebar {
  background: #181825;   /* Mantle */
  padding: 0.4rem 0.8rem;
  display: flex;
  gap: 6px;
  align-items: center;
}
.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dot.r { background: #f38ba8; } /* Red */
.terminal-dot.y { background: #f9e2af; } /* Yellow */
.terminal-dot.g { background: #a6e3a1; } /* Green */
.terminal-body { padding: 0.8rem 1rem; }
.prompt-line {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  white-space: pre-wrap;
}
.prompt-line .scenario-label {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin-right: 0.5rem;
  display: inline-block;
  min-width: 7rem;
}

/* Export */
.export { margin-bottom: 1rem; }
.export-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.copy-btn {
  background: var(--accent);
  color: #1e1e2e;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.15s;
}
.copy-btn:hover { opacity: 0.85; }
