:root {
  --bg: #0b0f17;
  --bg-elevated: #0d121c;
  --panel: rgba(15, 21, 32, 0.86);
  --panel-border: rgba(148, 163, 184, 0.14);
  --text: #e6edf7;
  --text-dim: #8b98aa;
  --text-faint: #5b6472;
  --accent: #22d3ee;
  --accent-2: #818cf8;
  --accent-3: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --radius: 16px;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(129, 140, 248, 0.18), transparent 60%),
    radial-gradient(800px 500px at 85% 0%, rgba(34, 211, 238, 0.14), transparent 55%),
    var(--bg);
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(11, 15, 23, 0.72);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.35);
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-name span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tag {
  padding: 3px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  background: rgba(148, 163, 184, 0.06);
}

.segment {
  border: 0;
  padding: 7px 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font: 600 12px var(--sans);
  cursor: pointer;
  transition: all 160ms ease;
}

.segment:hover { color: var(--text); }

.segment.is-active {
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 14px rgba(34, 211, 238, 0.25);
}

.ghost-link {
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  padding: 7px 4px;
}

.ghost-link:hover { color: var(--text); }

/* ---------- page ---------- */

.page {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 26px 24px 30px;
  flex: 1;
}

.hero {
  text-align: center;
  margin: 6px 0 26px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: -0.035em;
  line-height: 1.05;
  background: linear-gradient(100deg, #f8fafc 20%, var(--accent) 55%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  margin: 0 auto;
  max-width: 620px;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
}

.hero p strong { color: var(--text); font-weight: 600; }

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(148, 163, 184, 0.05);
  color: var(--text-dim);
  font: 500 11px var(--mono);
}

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr);
  height: min(64vh, 680px);
  min-height: 440px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.pane + .pane { border-left: 1px solid var(--panel-border); }

.pane-head {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(148, 163, 184, 0.035);
}

.file-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dot-red { background: #f87171; box-shadow: 0 0 10px rgba(248, 113, 113, 0.6); }
.dot-green { background: var(--accent-3); box-shadow: 0 0 10px rgba(52, 211, 153, 0.6); }

.file-name {
  font: 600 12px var(--mono);
  color: var(--text-dim);
}

.lang-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(34, 211, 238, 0.09);
  color: var(--accent);
  font: 600 10px var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.spacer { flex: 1; }

.example-select {
  margin-left: 6px;
  padding: 3px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font: 500 11px var(--sans);
  outline: none;
}

.icon-button {
  border: 1px solid var(--panel-border);
  background: rgba(148, 163, 184, 0.06);
  color: var(--text-dim);
  border-radius: 7px;
  padding: 4px 9px;
  font: 600 11px var(--sans);
  cursor: pointer;
  transition: all 160ms ease;
}

.icon-button:hover {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.45);
}

/* The IR toggle is the one thing in this bar that changes what the pane
   shows, so it gets the accent treatment instead of the muted icon-button. */
.ir-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
  padding: 6px 13px;
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(129, 140, 248, 0.24));
  color: #d6fbff;
  font: 700 12px var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  animation: ir-glow 2.8s ease-in-out infinite;
  transition: color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.ir-button:hover {
  color: #ecfeff;
  border-color: rgba(34, 211, 238, 0.8);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.3);
}

.ir-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ir-button.is-active {
  color: #06121a;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 18px rgba(34, 211, 238, 0.4);
  animation: none;
}

.ir-button-icon {
  font: 700 11px var(--mono);
  opacity: 0.85;
}

@keyframes ir-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.26); }
  50% { box-shadow: 0 0 16px 2px rgba(34, 211, 238, 0.26); }
}

@media (prefers-reduced-motion: reduce) {
  .ir-button { animation: none; }
}

.editor {
  flex: 1;
  min-height: 0;
}

.divider {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--panel-border);
  border-right: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, transparent, rgba(34, 211, 238, 0.05), transparent);
}

.run-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(129, 140, 248, 0.18));
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.run-button:hover {
  transform: scale(1.08);
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.35);
}

.run-button:active { transform: scale(0.96); }

/* ---------- status ---------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.04);
  font: 500 12px var(--mono);
  color: var(--text-dim);
  min-height: 40px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.status-dot.is-loading {
  background: var(--warning);
  animation: pulse 1.1s ease-in-out infinite;
}

.status-dot.is-ok { background: var(--accent-3); box-shadow: 0 0 10px rgba(52, 211, 153, 0.6); }
.status-dot.is-error { background: var(--danger); box-shadow: 0 0 10px rgba(251, 113, 133, 0.6); }

.status-stats { margin-left: auto; color: var(--text-faint); }

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

.warnings {
  margin-top: 12px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.05);
  color: #fde68a;
  font-size: 12px;
}

.warnings summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}

.warnings ul {
  margin: 0;
  padding: 0 14px 12px 34px;
  display: grid;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #fcd34d;
}

/* ---------- footer ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 18px 24px 26px;
  color: var(--text-faint);
  font-size: 11.5px;
}

.footer code { font-family: var(--mono); color: var(--text-dim); }
.footer a { color: var(--text-dim); text-decoration: none; }
.footer a:hover { color: var(--accent); }
.footer-sep { opacity: 0.5; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .topbar { padding: 12px 16px; }
  .brand-tag { display: none; }
  .page { padding: 18px 14px 24px; }
  .workspace {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(360px, 52vh);
    height: auto;
  }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--panel-border); }
  .divider {
    display: none;
  }
  .hero { margin-top: 0; }
  .status-stats { display: none; }
}

@media (max-width: 640px) {
  /* Keep the pane header on one line: the glyph still marks the toggle. */
  #ir-button-label { display: none; }
  .ir-button { padding: 5px 9px; }
  .icon-button { padding: 4px 7px; }
}
