/* ═══════════════════════════════════════════════════════ */
/* SEMANTIC COMPUTER v2 — Pipeline Builder                */
/* ═══════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-input: #1a1a28;
  --border: #2a2a3a;
  --text: #e0e0e8;
  --text-dim: #8888aa;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --proven: #10b981;
  --experimental: #f59e0b;
  --type-m-strong: #8b5cf6;
  --type-d: #ef4444;
  --type-m-mod: #06b6d4;

  --superpose: #8b5cf6;
  --interfere: #ef4444;
  --reframe: #f59e0b;
  --synthesize: #10b981;
  --validate: #06b6d4;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ─── Header ─── */
header { text-align: center; margin-bottom: 2rem; }
header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; }
.subtitle { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }

/* ─── Pipeline Builder ─── */
.pipeline-builder {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reset-btn {
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}
.reset-btn:hover { border-color: var(--accent); color: var(--accent); }

.pipeline {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem;
  background: var(--bg-input);
  border-radius: 8px;
  border: 2px dashed transparent;
  transition: border-color 0.2s;
  flex-wrap: wrap;
}

.pipeline.drag-over { border-color: var(--accent); }

.pipeline-bank {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  min-height: 0;
  flex-wrap: wrap;
}

.pipeline-bank:empty { display: none; }

.primitive-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: grab;
  user-select: none;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primitive-chip:active { cursor: grabbing; }

.primitive-chip .remove-btn {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 2px;
  line-height: 1;
}
.primitive-chip .remove-btn:hover { opacity: 1; }

.primitive-chip .add-btn {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 2px;
  line-height: 1;
}
.primitive-chip .add-btn:hover { opacity: 1; }

.primitive-chip.in-pipeline { border-color: rgba(255,255,255,0.15); }
.primitive-chip.in-bank { opacity: 0.4; border: 1px dashed rgba(255,255,255,0.2); }

.primitive-chip.dragging { opacity: 0.4; transform: scale(0.95); }

.chip-superpose  { background: rgba(139, 92, 246, 0.2); color: var(--superpose); }
.chip-interfere  { background: rgba(239, 68, 68, 0.2);  color: var(--interfere); }
.chip-reframe    { background: rgba(245, 158, 11, 0.2); color: var(--reframe); }
.chip-synthesize { background: rgba(16, 185, 129, 0.2); color: var(--synthesize); }
.chip-validate   { background: rgba(6, 182, 212, 0.2);  color: var(--validate); }

.arrow {
  color: var(--text-dim);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.pipeline-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.pipeline-hint .proven-tag {
  color: var(--proven);
  font-weight: 600;
}

/* ─── Input Section ─── */
.input-section {
  margin-bottom: 1rem;
}

.input-section label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  margin-top: 0.6rem;
}
.input-section label:first-child { margin-top: 0; }

.input-section textarea,
.input-section input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.input-section textarea:focus,
.input-section input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.examples {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.examples span { font-size: 0.7rem; color: var(--text-dim); }

.example-btn {
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}
.example-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── API Keys ─── */
.api-keys {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.api-keys summary {
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

.hint { color: var(--text-dim); font-weight: 400; font-size: 0.75rem; }

.key-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.key-row label {
  min-width: 110px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.key-row input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: monospace;
  font-size: 0.75rem;
}

.key-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.type-badge {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.type-m-strong { background: rgba(139, 92, 246, 0.2); color: var(--type-m-strong); }
.type-d { background: rgba(239, 68, 68, 0.2); color: var(--type-d); }
.type-m-mod { background: rgba(6, 182, 212, 0.2); color: var(--type-m-mod); }

.routing-info {
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--accent);
  display: none;
}
.routing-info.visible { display: block; }

/* ─── Compute Button ─── */
.compute-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1.5rem;
}

.compute-btn:hover { background: #5558e6; box-shadow: 0 4px 20px var(--accent-glow); }
.compute-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.compute-btn.running { background: #4445a0; animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

/* ─── Results ─── */
.results { margin-bottom: 2rem; }
.hidden { display: none !important; }

.steps-progress {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.step-indicator {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: all 0.3s;
}

.step-indicator.running {
  border-color: var(--accent);
  color: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.step-indicator.done {
  border-color: var(--proven);
  color: var(--proven);
  background: rgba(16, 185, 129, 0.1);
}

.step-indicator .model-tag {
  font-size: 0.6rem;
  opacity: 0.7;
  margin-left: 2px;
}

.result-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.7;
  min-height: 100px;
}

.result-step {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.result-step:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.result-step-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-step-body {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.model-insight {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-dim);
  display: none;
}
.model-insight.visible { display: block; }

.export-buttons {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.export-btn {
  padding: 0.4rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.export-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* ─── Footer ─── */
footer { text-align: center; padding: 2rem 1rem; color: var(--text-dim); font-size: 0.7rem; }
footer a { color: var(--accent); text-decoration: none; }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .key-row { flex-direction: column; align-items: stretch; }
  .key-row label { min-width: unset; }
  header h1 { font-size: 1.4rem; }
  .container { padding: 1rem 0.75rem; }
}
