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

/**
 * Demo playground chrome.
 * Load ../dist/lightdraw.min.css on pages that use the HTML renderer so
 * components inside #app inherit --ld-* tokens from .lightdraw-html-root.
 */
:root,
:root[data-site-theme='night'],
:root[data-demo-theme='dark'] {
  --bg: #0b1120;
  --surface: #151d2e;
  --surface-elevated: #1c2740;
  --border: #2a3654;
  --text: #e8edf7;
  --text-muted: #8b9cc0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --demo-canvas-bg: #0d1322;
  --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);
  --btn-secondary-hover: #243352;
}

:root[data-site-theme='day'],
:root[data-demo-theme='light'] {
  --bg: #e8eef6;
  --surface: #f4f7fb;
  --surface-elevated: #ffffff;
  --border: #c5d0e0;
  --text: #152033;
  --text-muted: #5a6b86;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --shadow: 0 8px 28px rgba(21, 32, 51, 0.08);
  --demo-canvas-bg: #dfe7f2;
  --scroll-track: rgba(21, 32, 51, 0.06);
  --scroll-thumb: rgba(90, 107, 134, 0.4);
  --scroll-thumb-hover: rgba(37, 99, 235, 0.55);
  --btn-secondary-hover: #e2eaf5;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Slim themed scrollbars (Firefox + WebKit) */
* {
  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;
}

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.demo-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.demo-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-elevated) 0%, var(--surface) 100%);
}

.demo-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  margin-bottom: 0.5rem;
}

.demo-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.demo-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.35rem;
  max-width: 60ch;
}

.demo-header code {
  font-size: 0.8125rem;
  color: #93c5fd;
}

.demo-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 1.25rem 1.25rem;
  gap: 0.75rem;
}

.demo-control-bar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.demo-section-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.demo-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.demo-canvas-wrap {
  flex: 1;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--demo-canvas-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 4px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.demo-canvas-wrap #app {
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.demo-canvas-wrap.light {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  /* Tall UI scenes scroll inside the frame (same as theme stage) */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
}

.demo-canvas-wrap.light #app {
  flex: 0 0 auto;
  height: auto;
  min-height: 100%;
  overflow: visible;
}

.demo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.demo-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.demo-btn:hover {
  background: var(--accent-hover);
}

.demo-btn.secondary {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.demo-btn.secondary:hover {
  background: var(--btn-secondary-hover);
}

.demo-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.demo-btn.secondary.is-active,
.demo-btn.secondary.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Split layout — canvas + aside (animation, export, a11y) */
.demo-layout-aside {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 240px);
  gap: 1rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.demo-aside-panel {
  background: linear-gradient(180deg, var(--surface-elevated) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  align-self: start;
  box-shadow: var(--shadow);
}

.demo-aside-panel h2,
.demo-aside-panel h3 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.65rem;
}

.demo-aside-panel p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 0.75rem;
}

.demo-aside-panel .demo-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.4rem;
  text-align: left;
}

.demo-aside-panel label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: block;
  margin: 0.5rem 0 0.25rem;
}

.demo-aside-panel input[type='range'],
.demo-aside-panel input[type='number'] {
  width: 100%;
}

.demo-aside-panel kbd {
  display: inline-block;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
}

.demo-aside-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.demo-aside-link {
  display: block;
  font-size: 0.75rem;
  color: #93c5fd;
  text-decoration: none;
  margin: -0.2rem 0 0.35rem 0.25rem;
}

.demo-aside-link:hover {
  text-decoration: underline;
}

.demo-json-output {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 10px;
  color: #94a3b8;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (prefers-reduced-motion: reduce) {
  .demo-btn {
    transition: none;
  }

  .cluster-status-dot.is-active {
    animation: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-demo-theme='light']) {
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: light) {
  :root:not([data-demo-theme='dark']) {
    color-scheme: light;
  }
}

/* Split layout — sidebar + canvas (diagram, animation demos) */
.demo-layout-split {
  display: grid;
  grid-template-columns: minmax(200px, 220px) 1fr;
  gap: 1rem;
  align-items: stretch;
  min-height: 0;
}

.demo-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  max-height: 100%;
}

.demo-sidebar h2 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}

.demo-sidebar .demo-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
}

.demo-sidebar .demo-sidebar-actions {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Diagram studio — view-only showcase sidebar */
.demo-diagram-sidebar {
  gap: 0.65rem;
}

.demo-diagram-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.demo-diagram-group + .demo-diagram-group {
  padding-top: 0.15rem;
}

.demo-diagram-info {
  margin-top: auto;
  padding: 0.75rem 0.8rem;
  background: linear-gradient(145deg, rgba(28, 39, 64, 0.95) 0%, rgba(21, 29, 46, 0.98) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.demo-diagram-info__eyebrow {
  display: block;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 0.35rem;
}

.demo-diagram-info__title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.demo-diagram-info__desc {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0;
}

.demo-canvas-wrap.demo-canvas-diagram {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(59, 130, 246, 0.07) 0%, transparent 55%),
    #0d1322;
}

.demo-log {
  padding: 0.65rem 0.85rem;
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 11px;
  color: #94a3b8;
  max-height: 88px;
  overflow: auto;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .demo-header {
    padding: 1rem;
  }

  .demo-main {
    padding: 0.75rem;
  }

  .demo-layout-split {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .demo-layout-aside {
    grid-template-columns: 1fr;
  }

  .demo-aside-panel .demo-btn {
    text-align: center;
  }

  .demo-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    padding: 0.65rem;
  }

  .demo-sidebar h2 {
    width: 100%;
  }

  .demo-sidebar .demo-btn {
    width: auto;
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 7rem;
    text-align: center;
  }

  .demo-sidebar .demo-sidebar-actions {
    width: 100%;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .demo-options .demo-btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
  }
}

/* Embedded in website playground iframe */
html.demo-embed,
html.demo-embed body {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

html.demo-embed .demo-shell {
  height: 100%;
  min-height: 0;
}

html.demo-embed .demo-header {
  display: none;
}

html.demo-embed .demo-main {
  height: 100%;
  padding: 0.5rem;
  gap: 0.5rem;
  overflow: hidden;
}

html.demo-embed .demo-main.pg-has-live-dock {
  overflow: hidden;
}

html.demo-embed #view-cluster .demo-canvas-wrap {
  height: auto;
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
}

html.demo-embed .demo-options {
  display: none;
}

html.demo-embed .demo-log {
  display: none;
}

html.demo-embed .demo-layout-aside {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.45rem;
  flex: 1;
  min-height: 0;
  height: 100%;
}

html.demo-embed .demo-layout-aside > .demo-aside-panel {
  order: -1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  max-height: none;
  overflow: visible;
  padding: 0.45rem 0.5rem;
}

html.demo-embed .demo-layout-aside > .demo-aside-panel h2,
html.demo-embed .demo-layout-aside > .demo-aside-panel .demo-aside-hint,
html.demo-embed .demo-layout-aside > .demo-aside-panel .demo-btn[onclick*='stopAll'] {
  display: none;
}

html.demo-embed .demo-aside-panel .demo-btn {
  width: auto;
  flex: 0 0 auto;
  font-size: 0.72rem;
  padding: 0.32rem 0.55rem;
  margin: 0;
}

html.demo-embed .demo-layout-split {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.45rem;
  flex: 1;
  min-height: 0;
  height: 100%;
}

html.demo-embed .demo-diagram-sidebar,
html.demo-embed .demo-layout-split > .demo-sidebar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  max-height: none;
  overflow: visible;
  padding: 0.45rem 0.5rem;
}

html.demo-embed .demo-diagram-group {
  display: contents;
}

html.demo-embed .demo-diagram-group h2,
html.demo-embed .demo-diagram-info,
html.demo-embed .demo-sidebar h2 {
  display: none;
}

html.demo-embed .demo-sidebar .demo-btn,
html.demo-embed .demo-diagram-sidebar .demo-btn {
  width: auto;
  flex: 0 0 auto;
  font-size: 0.72rem;
  padding: 0.32rem 0.55rem;
  margin: 0;
}

/* Help host already shows type tabs — drop the duplicate in-iframe picker */
html.demo-embed-no-picker .demo-diagram-sidebar,
html.demo-embed-no-picker .demo-layout-split > .demo-sidebar,
html.demo-embed-no-picker .demo-layout-aside > .demo-aside-panel {
  display: none !important;
}

html.demo-embed-no-picker .demo-layout-split,
html.demo-embed-no-picker .demo-layout-aside {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

/* Keep JSON/API dock visible under the stage in help embeds */
html.demo-embed .demo-main.pg-has-live-dock > .demo-layout-split,
html.demo-embed .demo-main.pg-has-live-dock > .demo-layout-aside {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

html.demo-embed .demo-main.pg-has-live-dock > #live-dock-host {
  flex: 0 0 auto;
  min-height: 200px;
}

html.demo-embed .demo-main.pg-has-live-dock > #live-dock-host .pg-code-dock {
  height: min(260px, 34vh);
  min-height: 200px;
}

html.demo-embed .demo-canvas-wrap {
  min-height: 0;
  flex: 1;
  height: auto;
  max-height: none;
  border-radius: 8px;
  box-shadow: none;
  padding: 0;
}

html.demo-embed .demo-toolbar {
  display: none;
}

html.demo-embed .cluster-status {
  display: none;
}

#view-dashboard,
#view-cluster {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

#view-cluster .demo-canvas-wrap {
  flex: 0 0 auto;
  width: 100%;
  height: clamp(360px, calc(100vh - 280px), 640px);
  min-height: 360px;
  max-height: 640px;
}

/* With a live code dock, canvas must flex into remaining space — not 100vh clamps */
.demo-main.pg-has-live-dock #view-dashboard,
.demo-main.pg-has-live-dock #view-cluster,
.demo-main.pg-has-live-dock .chart-catalog-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.demo-main.pg-has-live-dock #view-cluster .demo-canvas-wrap,
.demo-main.pg-has-live-dock #view-dashboard .demo-canvas-wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
}

.cluster-toolbar {
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cluster-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cluster-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(28, 39, 64, 0.9) 0%, rgba(21, 29, 46, 0.95) 100%);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.cluster-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.cluster-status-dot.is-active {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  animation: cluster-pulse 2s ease-in-out infinite;
}

@keyframes cluster-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.cluster-canvas-wrap {
  border: 1px solid #1f2a44;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 55%),
    #06080f;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 10px;
}

.cluster-canvas-wrap #app {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
}

#view-dashboard[hidden],
#view-cluster[hidden] {
  display: none !important;
}

html.demo-embed .demo-view-tabs,
html.demo-embed .chart-catalog-wrap {
  display: none;
}

.chart-catalog-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.chart-catalog-wrap[hidden] {
  display: none !important;
}

.demo-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.demo-view-tabs .demo-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#chart-search,
#widget-search {
  width: 100%;
  max-width: 360px;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
}

.chart-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.chart-card h3 {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-family: ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.chart-card-actions button {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-muted);
  border-radius: 6px;
  width: 26px;
  height: 22px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
}

.chart-card-actions button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.chart-card .mini-canvas {
  width: 100%;
  min-height: 120px;
  height: clamp(120px, 22vw, 168px);
  overflow: hidden;
  border-radius: 8px;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-card .mini-canvas > * {
  max-width: 100%;
  max-height: 100%;
}

.chart-maximize-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 17, 32, 0.92);
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.chart-maximize-overlay[hidden] {
  display: none !important;
}

.chart-maximize-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chart-maximize-toolbar h2 {
  font-size: 1rem;
  font-weight: 600;
}

.chart-maximize-stage {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0f172a;
}

.chart-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

html.demo-embed .demo-section-pills .demo-btn {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
}

/* UI catalog — Storybook-style variant grid (demo-ui-catalog.html) */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 2px;
  -webkit-overflow-scrolling: touch;
}

.catalog-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.catalog-tile h3 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  text-transform: lowercase;
}

.catalog-stage {
  min-height: 88px;
  border-radius: 8px;
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.catalog-stage > * {
  flex: 1;
  width: 100%;
  min-height: 88px;
}

.catalog-variant-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

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

/* ── Live code playground (theme lab, etc.) ─────────────────────────────── */
.pg-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
  gap: 0.65rem;
}

.pg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  justify-content: space-between;
}

.pg-toolbar-left,
.pg-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.pg-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.pg-live-pill[data-state='on'] {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.pg-live-pill[data-state='err'] {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.1);
}

.pg-live-toggle {
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.pg-live-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.pg-live-toggle-ui {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.pg-live-toggle[data-state='on'] .pg-live-toggle-ui,
.pg-live-toggle:has(input:checked) .pg-live-toggle-ui {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.pg-live-toggle[data-state='off'] .pg-live-toggle-ui,
.pg-live-toggle:not(:has(input:checked)) .pg-live-toggle-ui {
  color: var(--text-muted);
}

.pg-live-toggle[data-state='err'] .pg-live-toggle-ui {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.1);
}

.pg-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pg-pulse 1.6s ease-out infinite;
}

.pg-live-toggle[data-state='off'] .pg-live-dot,
.pg-live-toggle:not(:has(input:checked)) .pg-live-dot,
.pg-live-toggle[data-state='err'] .pg-live-dot,
.pg-live-pill[data-state='off'] .pg-live-dot,
.pg-live-pill[data-state='err'] .pg-live-dot {
  animation: none;
}

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

.pg-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 0.75rem;
  min-height: 0;
  align-items: stretch;
}

.pg-stage .demo-canvas-wrap {
  min-height: 280px;
  overflow: auto;
}

.pg-code-dock {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #10182a 0%, #0a0f1a 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* Tall enough to read ~14–18 lines of JSON without feeling full-height */
  height: min(340px, 40vh);
  transition: height 0.2s ease;
}

.pg-code-dock.is-collapsed {
  height: 42px;
}

.pg-code-dock.is-collapsed .pg-code-body {
  display: none;
}

.pg-code-chrome {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.pg-code-tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.pg-code-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.pg-code-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.pg-code-tab.is-active {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
}

.pg-code-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.pg-code-actions .demo-btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
}

.pg-code-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.pg-code-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.pg-code-pane.is-active {
  display: flex;
}

.pg-code-editor {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  resize: none;
  padding: 0.75rem 0.9rem;
  background: transparent;
  color: #bfdbfe;
  font: 0.78rem/1.55 ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, monospace;
  tab-size: 2;
  outline: none;
}

.pg-code-editor[readonly] {
  color: #94a3b8;
}

.pg-code-status {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.6875rem;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  white-space: pre-wrap;
  max-height: 7.5rem;
  overflow-y: auto;
  line-height: 1.35;
}

.pg-code-status[data-tone='ok'] {
  color: #86efac;
}

.pg-code-status[data-tone='err'] {
  color: #fda4af;
}

.pg-code-status[data-tone='warn'] {
  color: #fde68a;
}

html.demo-embed .pg-workspace {
  height: 100%;
}

html.demo-embed .pg-stage {
  grid-template-columns: minmax(0, 1fr) minmax(168px, 210px);
  gap: 0.5rem;
}

html.demo-embed .pg-workspace {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

html.demo-embed .pg-toolbar-right .pg-live-pill,
html.demo-embed .pg-toolbar-right .theme-check {
  display: none;
}

html.demo-embed .pg-code-dock {
  /* Readable JSON in help/hub iframes — not full viewport, not a one-line strip */
  height: min(280px, 36vh);
  min-height: 240px;
}

html.demo-embed .pg-code-dock.is-collapsed {
  height: 40px;
}

html.demo-embed .pg-code-dock.is-collapsed .pg-code-body {
  display: none;
}

html.demo-embed .pg-btn-secondary {
  display: none;
}

html.demo-embed .pg-code-status {
  display: block;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
}

html.demo-embed .pg-code-chrome {
  flex-wrap: nowrap;
  gap: 0.25rem;
  overflow-x: auto;
}

html.demo-embed .demo-main.pg-has-live-dock {
  height: 100%;
}

html.demo-embed .demo-main.pg-has-live-dock > .demo-layout-aside {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

html.demo-embed .demo-aside-panel {
  max-height: none;
}

html.demo-embed .demo-main.pg-has-live-dock > .demo-layout-aside > .demo-aside-panel {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}

/* Prefer canvas over aside chrome in tight embeds with a live dock */
html.demo-embed .demo-main.pg-has-live-dock .demo-aside-panel h3,
html.demo-embed .demo-main.pg-has-live-dock .demo-aside-panel p {
  display: none;
}

@media (max-width: 900px) {
  .pg-stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 1fr) auto;
  }

  .pg-code-dock {
    height: min(300px, 38vh);
  }
}

/* When LivePlayground injects a dock into a classic demo-main */
.demo-main.pg-has-live-dock {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Grow the canvas / stage — not the control bar / pills row */
.demo-main.pg-has-live-dock > .demo-canvas-wrap,
.demo-main.pg-has-live-dock > .demo-layout-aside,
.demo-main.pg-has-live-dock > .demo-layout-split,
.demo-main.pg-has-live-dock > .pg-stage {
  flex: 1;
  min-height: 0;
}

.demo-main.pg-has-live-dock > .demo-control-bar,
.demo-main.pg-has-live-dock > .demo-view-tabs {
  flex: 0 0 auto;
}

.demo-main.pg-has-live-dock #live-dock-host {
  flex: 0 0 auto;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background: var(--bg);
}

.demo-main.pg-has-live-dock #live-dock-host .pg-code-dock {
  position: relative;
  z-index: 2;
}

.pg-live-check {
  color: var(--text-muted);
  gap: 0.3rem;
  cursor: pointer;
}

html.demo-embed .theme-aside .theme-cat:not([open]) {
  /* keep collapsed cats compact */
}

html.demo-embed .theme-aside .theme-tokens {
  font-size: 0.65rem;
}

html.demo-embed .theme-aside {
  max-height: 100%;
  overflow-y: auto;
}

html.demo-embed .pg-stage {
  min-height: 0;
}

html.demo-embed .pg-stage .demo-canvas-wrap {
  min-height: 0;
}

html.demo-embed .demo-main.pg-has-live-dock > .demo-canvas-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  min-height: 160px;
}

html.demo-embed .demo-main.pg-has-live-dock > .demo-canvas-wrap #app {
  flex: 0 0 auto;
  height: auto;
  min-height: 100%;
  overflow: visible;
}

html.demo-embed .pg-code-dock.is-collapsed .pg-code-tabs {
  display: none;
}

html.demo-embed .pg-code-dock.is-collapsed .pg-live-toggle,
html.demo-embed .pg-code-dock.is-collapsed #pg-btn-run,
html.demo-embed .pg-code-dock.is-collapsed .pg-btn-secondary {
  display: none;
}
