:root {
  --bg: #07110f;
  --bg-elev: #0d1c18;
  --panel: #10241f;
  --ink: #e8f5f0;
  --muted: #8aa99c;
  --line: rgba(232, 245, 240, 0.1);
  --accent: #b6f34d;
  --accent-ink: #0a160f;
  --warm: #f0c27a;
  --danger: #ff7b72;
  --browser: #b6f34d;
  --local: #7ec8ff;
  --planned: #c4a0ff;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Syne", sans-serif;
  --radius: 10px;
  --max: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(182, 243, 77, 0.16), transparent 55%),
    radial-gradient(700px 420px at 100% 10%, rgba(126, 200, 255, 0.1), transparent 50%),
    linear-gradient(180deg, #0a1612 0%, var(--bg) 40%, #050c0a 100%);
}

.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(1.75rem, 4vw, 3rem) clamp(1.25rem, 4vw, 2rem) 1.25rem;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3rem, 8vw, 5.2rem);
  letter-spacing: -0.05em;
  line-height: 0.9;
  color: var(--ink);
}

.tagline {
  margin: 0.85rem 0 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lang-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.lang-select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
}

.headline {
  margin: 1.75rem 0 0.75rem;
  max-width: 22ch;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--accent);
}

.lede {
  margin: 0;
  max-width: 46rem;
  color: var(--muted);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.4rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  transition: transform 120ms ease, background 120ms ease;
}

.pill:hover {
  transform: translateY(-1px);
}

.pill.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.pill.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.api-section,
.examples-section,
.workspace,
.foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2rem) 2rem;
}

.examples-section {
  padding-top: 0.25rem;
}

.examples-tickers {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.examples-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.example-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(16, 36, 31, 0.9);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.example-chip:hover {
  border-color: rgba(182, 243, 77, 0.45);
  color: var(--accent);
}

.example-chip.is-active {
  border-color: var(--accent);
  background: rgba(182, 243, 77, 0.12);
  color: var(--accent);
}

.example-chip .check {
  color: var(--accent);
  margin-right: 0.35rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.section-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 40rem;
}

.legend {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.badge.browser {
  color: var(--browser);
}

.badge.local {
  color: var(--local);
}

.badge.planned {
  color: var(--planned);
}

.api-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(182, 243, 77, 0.035), transparent 35%), var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.api-table th,
.api-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.api-table th {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}

.api-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

.api-table tbody tr:hover,
.api-table tbody tr.is-active {
  background: rgba(182, 243, 77, 0.06);
}

.api-table tbody tr.is-active td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.api-table tbody tr:last-child td {
  border-bottom: 0;
}

.api-table code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  word-break: break-word;
}

.api-table td:nth-child(4) {
  color: var(--muted);
  font-size: 0.78rem;
  max-width: 22rem;
}

.doc-link {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.doc-link a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(182, 243, 77, 0.35);
}

.docs-page .hero-compact {
  padding-bottom: 0.5rem;
}

.docs-page .brand-sm {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}

.docs-page .brand-sm a {
  color: inherit;
  text-decoration: none;
}

.docs-h2 {
  margin: 2rem 0 0.75rem;
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.docs-callout {
  margin-top: 2rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid rgba(182, 243, 77, 0.28);
  border-radius: var(--radius);
  background: rgba(182, 243, 77, 0.05);
}

.docs-callout h3 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 1.05rem;
}

.docs-pre {
  margin: 0 0 1rem;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 8px;
  background: #06110e;
  color: #d7f0e4;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
}

.api-list {
  display: grid;
  gap: 0.65rem;
}

.api-row {
  display: grid;
  grid-template-columns: 1.15fr 1.15fr auto auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.95rem 1.05rem;
  background: linear-gradient(180deg, rgba(182, 243, 77, 0.04), transparent 40%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 140ms ease, transform 140ms ease;
}

.api-row:hover,
.api-row.is-active {
  border-color: rgba(182, 243, 77, 0.45);
}

.api-row:hover {
  transform: translateY(-1px);
}

.api-row.is-active {
  box-shadow: inset 0 0 0 1px rgba(182, 243, 77, 0.25);
}

.api-col label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.api-col code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  word-break: break-word;
}

.api-note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.api-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

@media (max-width: 860px) {
  .hero-top {
    flex-direction: column;
  }

  .api-row {
    grid-template-columns: 1fr;
  }

  .api-actions {
    align-items: stretch;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

.ios-banner,
.data-source-banner {
  max-width: var(--max);
  margin: 0 auto 0.75rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(240, 194, 122, 0.45);
  border-radius: var(--radius);
  background: rgba(240, 194, 122, 0.08);
  color: var(--warm);
  font-size: 0.8rem;
}

.data-source-banner {
  border-color: rgba(255, 123, 114, 0.45);
  background: rgba(255, 123, 114, 0.08);
  color: var(--danger);
}

.runtime-limits {
  margin: 0.3rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  max-width: 28rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(320px, auto) minmax(420px, 1fr);
  gap: 0.85rem;
  padding-bottom: 2.5rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.llm-pane,
.input-pane {
  min-height: 320px;
}

.input-pane .code,
.llm-pane .llm-prompt {
  min-height: 180px;
  flex: 1;
}

.workspace-out-left {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.85rem;
  min-height: 420px;
}

.result-pane,
.error-pane,
.chart-pane {
  min-height: 0;
}

.result-pane .output,
.error-pane .output {
  min-height: 120px;
}

.chart-pane {
  background: #06110e;
}

.error-log {
  color: var(--danger);
}

.pane-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.pane-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
}

.sample-label {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: var(--accent);
}

.pane-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.tiny {
  font-size: 0.72rem;
  padding: 0.4rem 0.7rem;
}

.btn.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 999px;
}

.btn.btn-icon .icon-copy {
  display: block;
}

.btn.btn-icon.is-copied {
  border-color: var(--accent);
  color: var(--accent);
}

.code {
  flex: 1;
  width: 100%;
  min-height: 280px;
  margin: 0;
  padding: 1rem 1.05rem;
  border: 0;
  resize: vertical;
  background: #06110e;
  color: #d7f0e4;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  outline: none;
}

.llm-prompt-block {
  background:
    linear-gradient(180deg, rgba(126, 200, 255, 0.07), transparent 42%),
    var(--panel);
}

.llm-prompt-chips {
  margin: 0;
  padding: 0.65rem 1rem 0;
}

.llm-prompt {
  max-height: none;
}

.llm-status {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.llm-status.is-ok {
  color: var(--accent);
}

.llm-status.is-bad {
  color: var(--danger);
}

.llm-progress {
  margin: 0.75rem 1rem 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(182, 243, 77, 0.28);
  border-radius: var(--radius);
  background: rgba(182, 243, 77, 0.06);
}

.llm-progress-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.llm-progress-label {
  font-size: 0.78rem;
  color: var(--accent);
}

.llm-progress-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(232, 245, 240, 0.08);
  overflow: hidden;
}

.llm-progress-bar {
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: llm-slide 1.1s ease-in-out infinite;
}

.llm-spinner,
.btn-spinner {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(182, 243, 77, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: llm-spin 0.7s linear infinite;
}

.btn .btn-spinner {
  display: none;
}

.btn.is-loading .btn-spinner {
  display: inline-block;
}

.btn.is-loading .btn-label {
  opacity: 0.92;
}

.llm-prompt-block.is-running {
  outline: 1px solid rgba(182, 243, 77, 0.35);
  box-shadow: inset 0 0 0 1px rgba(182, 243, 77, 0.08);
}

.result-busy {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.78rem;
  background: rgba(182, 243, 77, 0.05);
}

.result-busy[hidden] {
  display: none !important;
}

@keyframes llm-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes llm-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .llm-spinner,
  .btn-spinner,
  .llm-progress-bar {
    animation: none;
  }
}

.llm-model-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.llm-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hint {
  margin: 0;
  padding: 0.7rem 1rem;
  font-size: 0.74rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.status {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.status.ready {
  color: var(--accent);
}

.status.error {
  color: var(--danger);
}

.status.running {
  color: var(--warm);
}

.chart-wrap {
  padding: 0.75rem 1rem 0.25rem;
  border-bottom: 1px solid var(--line);
  background: #06110e;
}

.chart-wrap-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 0;
  padding: 1rem;
  min-height: 100%;
  position: relative;
}

.chart-wrap-fill .chart-canvas-box {
  flex: 1;
  height: auto;
  min-height: 240px;
}

.chart-wrap.is-empty .chart-canvas-box {
  opacity: 0.25;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  pointer-events: none;
}

.chart-wrap.is-empty .chart-empty {
  display: flex;
}

.chart-title {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.chart-canvas-box {
  position: relative;
  height: 220px;
  width: 100%;
}

.output {
  flex: 1;
  margin: 0;
  padding: 1rem 1.05rem;
  min-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #081612;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.84rem;
}

.output.is-error {
  color: var(--danger);
}

.foot {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.25rem;
  padding-top: 0.5rem;
  padding-bottom: 2.75rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .foot {
    grid-template-columns: 1fr;
  }
}

.repo-title {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-weight: 700;
}

.repo-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(182, 243, 77, 0.35);
}

.repo-sub {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.repo-sub code {
  color: var(--ink);
  background: rgba(182, 243, 77, 0.08);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.disclaimer {
  border-left: 3px solid var(--warm);
  padding-left: 0.9rem;
}

.disclaimer p {
  margin: 0;
  color: var(--warm);
  font-size: 0.8rem;
  line-height: 1.65;
}
