:root {
  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-elevated: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text-primary: #ededed;
  --text-secondary: #888;
  --text-tertiary: #555;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99,102,241,0.15);
  --success: #10b981;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text-primary); font-family: var(--font); min-height: 100vh; }

/* ── Nav ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.logo { font-weight: 600; font-size: 16px; letter-spacing: -0.3px; }
.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--text-secondary); text-decoration: none; font-size: 14px; transition: color 0.15s; }
.nav-links a:hover { color: var(--text-primary); }

/* ── Hero ── */
.hero {
  max-width: 680px;
  margin: 80px auto 60px;
  padding: 0 24px;
  text-align: center;
}
.hero-badge {
  display: inline-block;
  background: var(--accent-muted);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(99,102,241,0.3);
  margin-bottom: 24px;
  letter-spacing: 0.3px;
}
h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fff 0%, #999 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Input section ── */
.input-section {
  max-width: 720px;
  margin: 0 auto 60px;
  padding: 0 24px;
}
.input-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
#prompt-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font);
}
#prompt-input:focus { border-color: var(--accent); }
#prompt-input::placeholder { color: var(--text-tertiary); }

#generate-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
#generate-btn:hover { background: var(--accent-hover); }
#generate-btn:active { transform: scale(0.98); }
#generate-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── Chips ── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ── Status bar ── */
#status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 0;
}
.status-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Error banner ── */
#error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: #fca5a5;
  margin-top: 12px;
}

/* ── Results grid ── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto 16px;
  padding: 0 24px;
}
/* (mobile override consolidated below) */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.card-body {
  padding: 16px;
  min-height: 280px;
}
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }

#schematic-container {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
#schematic-container svg {
  max-width: 100%;
  height: auto;
}

/* ── Netlist toggle ── */
.netlist-toggle {
  max-width: 1100px;
  margin: 0 auto 8px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s;
  background: none;
  font-family: var(--font);
}
.netlist-toggle:hover { border-color: var(--border-hover); }
.netlist-toggle.open #toggle-chevron { transform: rotate(180deg); }
#toggle-chevron { transition: transform 0.2s; }

#netlist-content {
  max-width: 1100px;
  margin: 0 auto 16px;
  padding: 0 24px;
}
#netlist-pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre;
}

/* ── Feedback row ── */
.feedback-row {
  max-width: 1100px;
  margin: 0 auto 16px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}
.feedback-label { white-space: nowrap; }
.feedback-btn {
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.feedback-btn.positive:hover { border-color: var(--success); color: var(--success); background: rgba(16,185,129,0.08); }
.feedback-btn.negative:hover { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.08); }
.feedback-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Refine row ── */
.refine-row {
  max-width: 1100px;
  margin: 0 auto 60px;
  padding: 0 24px;
  display: flex;
  gap: 10px;
}
#refine-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font);
}
#refine-input:focus { border-color: var(--accent); }
#refine-input::placeholder { color: var(--text-tertiary); }
#refine-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: var(--font);
}
#refine-btn:hover { border-color: var(--border-hover); }
#refine-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Examples section ── */
.examples-section {
  max-width: 1100px;
  margin: 0 auto 80px;
  padding: 0 24px;
}
.examples-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}
.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
/* (mobile override consolidated below) */
.example-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.example-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.example-prompt {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 14px;
  font-style: italic;
}
.example-preview {
  height: 60px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.preview-line {
  height: 2px;
  width: var(--w);
  background: var(--c);
  border-radius: 1px;
  opacity: 0.8;
}
.preview-tran { padding: 8px; }
.preview-tran svg { display: block; }
.example-tag {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

/* ── Metrics panel (stats) ── */
#metrics-panel {
  max-width: 1100px;
  margin: 0 auto 24px;
  padding: 0 24px;
}
.metrics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.metrics-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.stats-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table td:last-child { color: var(--text-primary); font-weight: 500; text-align: right; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  margin-top: 40px;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
}
.footer-sep { opacity: 0.4; }

/* ── Mobile ── */
@media (max-width: 768px) {
  /* Nav: stack logo above links */
  nav {
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
    text-align: center;
  }
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 20px;
  }
  .nav-links a { font-size: 13px; }

  /* Hero: tighten spacing */
  .hero {
    margin: 48px auto 40px;
    padding: 0 16px;
  }
  .hero-badge { margin-bottom: 18px; }
  h1 { letter-spacing: -1px; margin-bottom: 16px; }
  .hero-sub { font-size: 15px; line-height: 1.6; }

  /* Input: stack button below input */
  .input-section {
    padding: 0 16px;
    margin-bottom: 40px;
  }
  .input-wrapper {
    flex-direction: column;
  }
  #prompt-input {
    padding: 12px 14px;
    font-size: 16px; /* prevents iOS zoom */
  }
  #generate-btn {
    justify-content: center;
    padding: 12px 20px;
  }

  /* Chips: allow scroll if needed */
  .chips { gap: 6px; }
  .chip {
    padding: 5px 12px;
    font-size: 12px;
  }

  /* Results */
  .results-grid {
    grid-template-columns: 1fr;
    padding: 0 16px;
    gap: 12px;
  }
  .card-body {
    padding: 12px;
    min-height: 200px;
  }

  /* Netlist */
  .netlist-toggle {
    margin-left: 16px;
    margin-right: 16px;
    max-width: calc(100% - 32px);
  }
  #netlist-content { padding: 0 16px; }
  #netlist-pre {
    padding: 12px 14px;
    font-size: 12px;
  }

  /* Feedback */
  .feedback-row {
    padding: 0 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Refine */
  .refine-row {
    padding: 0 16px;
    flex-direction: column;
    margin-bottom: 40px;
  }
  #refine-btn { text-align: center; }

  /* Examples */
  .examples-section { padding: 0 16px; margin-bottom: 48px; }
  .examples-grid { grid-template-columns: 1fr; }

  /* Metrics */
  #metrics-panel { padding: 0 16px; }

  /* Footer */
  .footer-inner {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }
  .footer-sep { display: none; }
}

/* ── Small phones ── */
@media (max-width: 380px) {
  nav { padding: 12px 14px; }
  .hero { margin: 36px auto 32px; padding: 0 12px; }
  .input-section { padding: 0 12px; }
  .results-grid { padding: 0 12px; }
  .netlist-toggle { margin-left: 12px; margin-right: 12px; max-width: calc(100% - 24px); }
  #netlist-content { padding: 0 12px; }
  .feedback-row { padding: 0 12px; }
  .refine-row { padding: 0 12px; }
  .examples-section { padding: 0 12px; }
  #metrics-panel { padding: 0 12px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
