@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #06110f;
  --bg-strong: #030807;
  --surface: #0f172a;
  --surface-soft: #111c28;
  --panel: #132033;
  --line: rgba(148, 163, 184, 0.28);
  --line-strong: rgba(148, 163, 184, 0.42);
  --text: #f8fafc;
  --muted: #aab6c7;
  --green: #22c55e;
  --cyan: #38bdf8;
  --rose: #fb7185;
  --yellow: #facc15;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.38);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(125deg, rgba(34, 197, 94, 0.14), transparent 36%),
    linear-gradient(235deg, rgba(251, 113, 133, 0.13), transparent 42%),
    linear-gradient(180deg, var(--bg) 0%, #08111c 56%, var(--bg-strong) 100%);
  color: var(--text);
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  min-height: 44px;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--text);
  color: #03100c;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 8, 7, 0.86);
  backdrop-filter: blur(18px);
}

.brand,
.topbar-nav a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.brand {
  gap: 0.55rem;
  font-weight: 800;
}

.brand::before {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.45);
  content: "";
}

.topbar-nav {
  display: flex;
  gap: 0.35rem;
}

.topbar-nav a {
  padding: 0 0.8rem;
  color: #dbeafe;
}

.topbar-nav a:hover,
.topbar-nav a:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.playground-shell {
  display: grid;
  min-height: calc(100svh - 64px);
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 1rem;
  padding: 1rem;
}

.editor-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.88);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: grid;
  min-height: 720px;
  grid-template-rows: auto minmax(420px, 1fr) auto;
}

.preview-panel {
  display: grid;
  min-height: 720px;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  overflow: hidden;
}

.panel-header,
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--green);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.toolbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.preset-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.preset-select,
.button {
  min-height: 44px;
  border-radius: 8px;
}

.preset-select {
  max-width: 11rem;
  border: 1px solid var(--line);
  background: #08111c;
  color: var(--text);
  padding: 0 0.75rem;
}

.button {
  border: 1px solid var(--line);
  padding: 0 0.95rem;
  color: var(--text);
  font-weight: 700;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.button.primary {
  border-color: rgba(34, 197, 94, 0.62);
  background: var(--green);
  color: #03100c;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.05);
}

.code-editor {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 420px;
  resize: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  background: #07101a;
  color: #e2e8f0;
  padding: 1rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.94rem;
  line-height: 1.6;
  tab-size: 2;
}

.code-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.45);
}

.output-row {
  min-height: 150px;
  background: rgba(3, 8, 7, 0.32);
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
}

.status-line span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  padding: 0 0.65rem;
  background: rgba(255, 255, 255, 0.04);
}

.json-output {
  padding: 0.75rem 1rem 1rem;
}

.json-output summary {
  min-height: 44px;
  color: #dbeafe;
  cursor: pointer;
  font-weight: 700;
}

.json-output pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  color: #d1fae5;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.scene-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.scene-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #dbeafe;
  padding: 0 0.75rem;
}

.scene-tab.active,
.scene-tab:hover,
.scene-tab:focus-visible {
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(56, 189, 248, 0.16);
  color: var(--text);
}

.canvas-wrap {
  position: relative;
  min-height: 420px;
  background: #030807;
}

#preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.preview-meter {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}

.preview-meter span {
  min-height: 34px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: rgba(3, 8, 7, 0.72);
  color: #dbeafe;
  padding: 0.45rem 0.65rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
}

#beat-stat.active {
  border-color: rgba(34, 197, 94, 0.68);
  color: #dcfce7;
}

.error-output {
  min-height: 96px;
  max-height: 180px;
  overflow: auto;
  border-top: 1px solid rgba(251, 113, 133, 0.38);
  background: rgba(127, 29, 29, 0.28);
  color: #fecdd3;
  padding: 1rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .playground-shell {
    grid-template-columns: 1fr;
  }

  .editor-panel,
  .preview-panel {
    min-height: 620px;
  }
}

@media (max-width: 700px) {
  .topbar,
  .panel-header,
  .preview-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-nav {
    width: 100%;
  }

  .topbar-nav a,
  .button,
  .preset-select {
    width: 100%;
  }

  .playground-shell {
    padding: 0.75rem;
  }

  .editor-panel,
  .preview-panel {
    min-height: 560px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
