/**
 * LightDraw Playground — product studio shell.
 * Direction: drafting-board charcoal + amber signal (not purple / Inter).
 * Supports day / night via html[data-site-theme].
 */

:root,
:root[data-site-theme='night'] {
  --ink: #07090d;
  --panel: #0e1218;
  --panel-2: #141a24;
  --line: #243044;
  --text: #e8eef8;
  --muted: #8b97ad;
  --signal: #f0a202;
  --signal-dim: rgba(240, 162, 2, 0.14);
  --cyan: #3ecfcf;
  --cyan-dim: rgba(62, 207, 207, 0.12);
  --cyan-active-text: #a5e8e8;
  --radius: 12px;
  --font: 'Outfit', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --scroll-track: rgba(255, 255, 255, 0.04);
  --scroll-thumb: rgba(139, 156, 192, 0.45);
  --scroll-thumb-hover: rgba(62, 207, 207, 0.55);
  --hero-fade-a: rgba(62, 207, 207, 0.16);
  --hero-fade-b: rgba(240, 162, 2, 0.1);
  --stage-bar-bg: rgba(14, 18, 24, 0.85);
  --rail-hover: rgba(255, 255, 255, 0.03);
  --frame-bg: #0d1322;
}

:root[data-site-theme='day'] {
  --ink: #e8eef6;
  --panel: #f4f7fb;
  --panel-2: #ffffff;
  --line: #c5d0e0;
  --text: #152033;
  --muted: #5a6b86;
  --signal: #e09700;
  --signal-dim: rgba(224, 151, 0, 0.14);
  --cyan: #0f766e;
  --cyan-dim: rgba(15, 118, 110, 0.1);
  --cyan-active-text: #0f766e;
  --scroll-track: rgba(21, 32, 51, 0.06);
  --scroll-thumb: rgba(90, 107, 134, 0.4);
  --scroll-thumb-hover: rgba(15, 118, 110, 0.55);
  --hero-fade-a: rgba(15, 118, 110, 0.12);
  --hero-fade-b: rgba(224, 151, 0, 0.1);
  --stage-bar-bg: rgba(244, 247, 251, 0.92);
  --rail-hover: rgba(21, 32, 51, 0.04);
  --frame-bg: #dfe7f2;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

html {
  scroll-behavior: smooth;
}

body.site-body {
  margin: 0;
  font-family: var(--font);
  background: var(--ink);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Hero (first viewport = brand composition) ───────────────────────────── */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--line);
}

.hero-atmosphere {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 70% 20%, var(--hero-fade-a), transparent 55%),
    radial-gradient(ellipse 50% 40% at 15% 80%, var(--hero-fade-b), transparent 50%),
    linear-gradient(165deg, var(--panel) 0%, var(--ink) 45%, var(--panel-2) 100%);
  z-index: 0;
}

.hero-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(36, 48, 68, 0.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 48, 68, 0.55) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
}

.hero-canvas {
  position: absolute;
  inset: auto 0 0;
  width: 100%;
  height: min(48vh, 420px);
  z-index: 1;
  pointer-events: none;
  opacity: 0.9;
  overflow: hidden;
}

.hero-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.hero-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem 1.5rem 28vh;
  max-width: 40rem;
  animation: hero-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-brand {
  margin: 0 0 0.75rem;
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--text);
}

.hero-line {
  margin: 0 0 0.85rem;
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--cyan);
}

.hero-sub {
  margin: 0 auto 1.75rem;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 34ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: #0a0c10;
  background: var(--signal);
  border: 1px solid transparent;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.hero-btn:hover {
  background: #ffb62e;
  transform: translateY(-1px);
}

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

.hero-btn--ghost:hover {
  background: var(--panel-2);
  border-color: var(--cyan);
  color: var(--text);
  transform: translateY(-1px);
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-inner {
    animation: none;
  }
  .hero-btn {
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
}

/* ── Playground app shell ────────────────────────────────────────────────── */
.playground {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink);
}

.rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  min-height: 0;
}

.rail-brand {
  padding: 1.15rem 1rem 0.85rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.rail-logo {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}

.rail-logo:hover {
  color: var(--cyan);
}

.rail-ver {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rail-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.rail-group {
  margin: 0.7rem 0 0.2rem;
  padding: 0 0.7rem;
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
}

.rail-group:first-child {
  margin-top: 0.15rem;
}

.rail-item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.rail-item:hover {
  color: var(--text);
  background: var(--rail-hover);
}

.rail-item.is-active {
  color: var(--text);
  background: var(--cyan-dim);
  border-color: color-mix(in srgb, var(--cyan) 35%, transparent);
}

.rail-item small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.85;
}

.rail-item.is-active small {
  color: var(--cyan-active-text);
}

.rail-foot {
  padding: 0.85rem 1rem 1.1rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.85rem;
  font-size: 0.75rem;
}

.rail-foot a {
  color: var(--muted);
  text-decoration: none;
}

.rail-foot a:hover {
  color: var(--cyan);
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(62, 207, 207, 0.06), transparent 50%),
    var(--ink);
}

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--line);
  background: var(--stage-bar-bg);
  backdrop-filter: blur(8px);
}

.stage-titles h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stage-titles p {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 52ch;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.stage-live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #86efac;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(134, 239, 172, 0.3);
  background: rgba(34, 197, 94, 0.08);
}

.stage-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  animation: live-pulse 1.6s ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(134, 239, 172, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(134, 239, 172, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(134, 239, 172, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-live-dot {
    animation: none;
  }
}

.stage-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.775rem;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
  color: #0a0c10;
  background: var(--signal);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.stage-btn:hover {
  background: #ffb62e;
}

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

.stage-btn--ghost:hover {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

.stage-frame-wrap {
  flex: 1;
  min-height: 0;
  padding: 0.75rem;
  display: flex;
}

.stage-frame {
  flex: 1;
  width: 100%;
  min-height: min(78vh, 860px);
  height: calc(100vh - 5.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--frame-bg);
  display: block;
}

.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--cyan);
}

.theme-toggle .theme-toggle-icon {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  background: var(--signal);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--panel-2) 40%, transparent);
}

.theme-toggle[data-theme='day'] .theme-toggle-icon {
  background: var(--cyan);
}

.rail-brand-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Help center ─────────────────────────────────────────────────────────── */
.help-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  background: var(--ink);
}

.help-nav {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  padding: 1rem 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.help-nav a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
}

.help-nav a:hover,
.help-nav a.is-active,
.help-nav a[aria-current='true'] {
  color: var(--text);
  background: var(--cyan-dim);
}

.help-nav .help-nav-group {
  margin: 0.95rem 0 0.3rem;
  padding: 0 0.65rem;
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
  background: transparent;
}

.help-main {
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 3rem;
  max-width: 920px;
}

.help-hero {
  margin-bottom: 2rem;
}

.help-hero h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
}

.help-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 48ch;
}

.help-section {
  margin-bottom: 2.25rem;
  scroll-margin-top: 1rem;
}

.help-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.help-section > p {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

.help-example {
  display: grid;
  gap: 0.75rem;
  margin: 0.85rem 0 1.25rem;
}

.help-code {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}

.help-live {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--frame-bg);
  min-height: 360px;
}

.help-live iframe {
  width: 100%;
  height: 480px;
  border: 0;
  display: block;
  background: var(--frame-bg);
}

.help-live--tall iframe {
  height: 560px;
}

.help-live--code iframe {
  height: 620px;
}

.help-live-block {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.help-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.help-type-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

.help-type-tab:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--cyan) 40%, var(--line));
}

.help-type-tab.is-active {
  color: var(--text);
  background: var(--cyan-dim);
  border-color: color-mix(in srgb, var(--cyan) 45%, transparent);
}

.help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

@media (max-width: 860px) {
  .playground {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.5rem;
    gap: 0.35rem;
  }

  .rail-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .rail-item small {
    display: none;
  }

  .rail-foot {
    display: none;
  }

  .stage-frame {
    height: calc(100vh - 11rem);
    min-height: 520px;
  }

  .hero-inner {
    padding-bottom: 22vh;
  }

  .help-shell {
    grid-template-columns: 1fr;
  }

  .help-nav {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .help-nav .help-nav-group {
    width: 100%;
  }
}

/* ── Markdown doc viewer (doc.html) ─────────────────────────────────────── */
.doc-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  background: var(--ink);
}

.doc-nav {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  padding: 1rem 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.doc-nav a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
}

.doc-nav a:hover,
.doc-nav a.is-active,
.doc-nav a[aria-current='true'] {
  color: var(--text);
  background: var(--cyan-dim);
}

.doc-main {
  padding: 0 clamp(1rem, 3vw, 2.5rem) 3rem;
  max-width: 920px;
  width: 100%;
  justify-self: center;
}

.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(8px);
}

.doc-crumb {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.doc-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.doc-loading,
.doc-error {
  color: var(--muted);
  font-size: 0.9375rem;
}

.doc-error {
  color: #fda4af;
}

.doc-prose {
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.65;
}

.doc-prose > *:first-child {
  margin-top: 0;
}

.doc-prose h1,
.doc-prose h2,
.doc-prose h3,
.doc-prose h4 {
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 1.75rem 0 0.65rem;
}

.doc-prose h1 {
  font-size: 1.85rem;
}

.doc-prose h2 {
  font-size: 1.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.doc-prose h3 {
  font-size: 1.1rem;
}

.doc-prose p,
.doc-prose ul,
.doc-prose ol,
.doc-prose blockquote,
.doc-prose table {
  margin: 0 0 1rem;
}

.doc-prose ul,
.doc-prose ol {
  padding-left: 1.35rem;
}

.doc-prose li + li {
  margin-top: 0.25rem;
}

.doc-prose a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.doc-prose a:hover {
  color: var(--signal);
}

.doc-prose code {
  font-family: var(--mono);
  font-size: 0.84em;
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.doc-prose pre {
  margin: 0 0 1.15rem;
  padding: 0.95rem 1.05rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a0f18;
  overflow-x: auto;
}

:root[data-site-theme='day'] .doc-prose pre {
  background: #1e2430;
}

.doc-prose pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.8rem;
  line-height: 1.55;
  color: #e8eef8;
}

.doc-prose blockquote {
  margin-left: 0;
  padding: 0.35rem 0 0.35rem 1rem;
  border-left: 3px solid var(--cyan);
  color: var(--muted);
}

.doc-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  display: block;
  overflow-x: auto;
}

.doc-prose th,
.doc-prose td {
  border: 1px solid var(--line);
  padding: 0.5rem 0.7rem;
  text-align: left;
}

.doc-prose th {
  background: var(--panel);
  font-weight: 600;
}

.doc-prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.75rem 0;
}

.doc-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

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

  .doc-nav {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .doc-nav .help-nav-group {
    width: 100%;
  }
}

