/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a28;
  --surface: #1e1e2e;
  --border: #2a2a3a;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --accent: #7c6ff7;
  --accent2: #a78bfa;
  --accent-glow: rgba(124, 111, 247, 0.15);
  --orange: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
}

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ─── Header ─── */
header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 1.8rem;
  color: var(--accent);
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.description {
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 600px;
  margin: 0 auto;
}

.learn-more {
  color: var(--accent2);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent2);
}

.learn-more:hover { border-bottom-style: solid; }

/* ─── Input ─── */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

textarea::placeholder { color: var(--text-dim); }

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.mode-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-family: inherit;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.mode-btn:hover:not(.active) {
  color: var(--text);
}

button#submit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

button#submit:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
button#submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-icon { font-size: 1.1rem; }

/* ─── Example Chips ─── */
.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

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

.chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-glow);
}

/* ─── Progress ─── */
.progress {
  margin-bottom: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.progress-bar {
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}

.status-text {
  font-size: 0.85rem;
  color: var(--accent2);
  margin-bottom: 0.75rem;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  transition: color 0.3s;
}

.step-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.step.active .step-dot { background: var(--orange); animation: pulse 1s infinite; }
.step.done .step-dot { background: var(--green); }
.step.done { color: var(--text); }

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

/* ─── Results (Circuit Only) ─── */
.results {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.result-group h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-icon { font-size: 1.2rem; }

/* ─── Compare Results (Side by Side) ─── */
.compare-results {
  margin-bottom: 2rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.compare-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compare-header {
  padding: 1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  text-align: center;
}

.compare-header h2 {
  font-size: 1.1rem;
  margin: 0.25rem 0;
}

.compare-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.compare-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg3);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.accent-badge {
  background: var(--accent-glow);
  color: var(--accent2);
  border-color: var(--accent);
}

.single-header {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom: none;
}

.circuit-header {
  background: linear-gradient(135deg, rgba(124, 111, 247, 0.08), rgba(167, 139, 250, 0.08));
  border: 1px solid var(--accent);
  border-bottom: none;
}

.single-card {
  border-color: var(--border);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Perspective cards */
.perspectives-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.perspectives-mini {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.perspectives-mini .card {
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg3);
  cursor: pointer;
  user-select: none;
}

.card-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.card-toggle {
  color: var(--text-dim);
  font-size: 0.8rem;
  transition: transform 0.2s;
}

.card-header.open .card-toggle { transform: rotate(180deg); }

.card-body {
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.card-body.collapsed { display: none; }

/* Interference card */
.interference-card {
  border-color: var(--orange);
  border-left: 3px solid var(--orange);
}

/* Meta card */
.meta-card {
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--surface), var(--bg3));
}

.meta-card .card-body {
  font-size: 0.95rem;
}

/* ─── How It Works ─── */
.how-section {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.how-section h2 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 2rem;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.how-step {
  text-align: center;
}

.how-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 2px solid var(--accent);
  color: var(--accent2);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
}

.how-step h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.how-step p {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.how-footer {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.how-footer p {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.credits {
  margin-top: 1rem;
  font-size: 0.8rem !important;
}

.credits a { color: var(--accent2); text-decoration: none; }
.credits a:hover { text-decoration: underline; }

/* ─── Download Button ─── */
.download-bar {
  text-align: center;
  margin-bottom: 1.5rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  background: var(--bg3);
  color: var(--accent2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.download-btn:hover {
  background: var(--accent-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* ─── Utilities ─── */
.hidden { display: none !important; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .compare-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

@media (max-width: 640px) {
  .container { padding: 1.5rem 1rem 3rem; }
  h1 { font-size: 1.4rem; }
  .how-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .steps { gap: 0.4rem 1rem; }
  .input-actions { flex-wrap: wrap; }
}
