/*
 * The gallery's look, after uni-harness: a dark teal icon rail, soft teal light over a dot grid,
 * glass cards, and the brand gradient. Colors build on uni-ui's --uni-* variables, so the light and
 * dark themes switch together. uni-ui.css sits in the `uni` layer, so these unlayered rules win.
 */

:root {
  --g-glow: #08bdcb;
  --g-silver: #b7b9b4;
  --g-rail: #e7eff1;
  --g-rail-fg: #5b7176;
  --g-primary-1: #2e7685;
  --g-primary-2: #3c99ad;
  --g-aurora-1: rgb(60 153 173 / 0.2);
  --g-aurora-2: rgb(8 189 203 / 0.12);
  --g-aurora-3: rgb(183 185 180 / 0.25);
  --g-card-shadow: 0 24px 60px -32px rgb(6 17 20 / 0.35);
  --g-code-bg: #f6fafb;
  --tok-kw: #8b3dd6;
  --tok-type: #0b7a75;
  --tok-str: #a35200;
  --tok-num: #0a58ca;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --g-rail: #050f12;
    --g-rail-fg: #6f9097;
    --g-primary-1: #176877;
    --g-primary-2: #1f93ab;
    --g-aurora-1: rgb(37 167 193 / 0.18);
    --g-aurora-2: rgb(8 189 203 / 0.1);
    --g-aurora-3: rgb(110 123 117 / 0.16);
    --g-card-shadow: 0 24px 60px -28px rgb(0 0 0 / 0.7);
    --g-code-bg: #071417;
    --tok-kw: #c792ea;
    --tok-type: #7fdbca;
    --tok-str: #ecc48d;
    --tok-num: #82aaff;
  }
}

:root[data-theme='dark'] {
  --g-rail: #050f12;
  --g-rail-fg: #6f9097;
  --g-primary-1: #176877;
  --g-primary-2: #1f93ab;
  --g-aurora-1: rgb(37 167 193 / 0.18);
  --g-aurora-2: rgb(8 189 203 / 0.1);
  --g-aurora-3: rgb(110 123 117 / 0.16);
  --g-card-shadow: 0 24px 60px -28px rgb(0 0 0 / 0.7);
  --g-code-bg: #071417;
  --tok-kw: #c792ea;
  --tok-type: #7fdbca;
  --tok-str: #ecc48d;
  --tok-num: #82aaff;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  background: var(--uni-canvas);
  color: var(--uni-fg);
  font-family: var(--uni-font-sans);
  font-size: var(--uni-font-size);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgb(8 189 203 / 0.28);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--uni-line) transparent;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Shell: rail | sidebar | main */
.gallery {
  position: relative;
  display: flex;
  height: 100%;
  overflow: hidden;
}

.gallery-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 56px;
  flex-shrink: 0;
  padding: 12px 0;
  box-sizing: border-box;
  background: var(--g-rail);
  border-right: 1px solid var(--uni-line);
}

.rail-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 10px;
}

.gallery-logo {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 0 10px rgb(8 189 203 / 0.35));
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rail-spacer {
  flex: 1;
}

.rail-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--g-rail-fg);
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s,
    transform 0.1s;
}

.rail-button:hover {
  background: var(--uni-hover);
  color: var(--uni-fg);
}

.rail-button:active {
  transform: scale(0.95);
}

.rail-button.is-active {
  background: var(--uni-accent-soft);
  color: var(--uni-accent);
  box-shadow: inset 0 0 0 1px var(--uni-line);
}

.rail-button.is-active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--uni-accent);
  box-shadow: 0 0 12px var(--g-glow);
}

.gallery-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  padding: 16px 12px 12px;
  gap: 10px;
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 4px;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
}

.sidebar-sub {
  margin-top: 2px;
  color: var(--uni-muted);
  font-size: var(--uni-font-size-sm);
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--uni-line);
  border-radius: 10px;
  background: var(--uni-raised);
  color: var(--uni-muted);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.sidebar-search span {
  flex: 1;
  text-align: left;
}

.sidebar-search:hover {
  border-color: var(--uni-accent);
  box-shadow: 0 0 0 3px var(--uni-accent-soft);
}

.sidebar-overline {
  margin-top: 6px;
  padding: 0 6px;
  color: var(--uni-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-tree {
  flex: 1;
  min-height: 0;
}

.sidebar-tree .uni-list__row {
  border-radius: 8px;
}

.sidebar-tree .uni-list__row[aria-selected='true'] {
  background: var(--uni-accent-soft);
  box-shadow: inset 2px 0 0 var(--uni-accent);
}

.sidebar-tree .uni-list__row[aria-selected='true'] .nav-story {
  color: var(--uni-accent);
  font-weight: 600;
}

.nav-section {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.nav-section .icon {
  width: 16px;
  height: 16px;
  color: var(--uni-muted);
}

.nav-story {
  color: var(--uni-fg);
}

/* Main: soft teal light from the corners over a faint dot grid */
.gallery-main {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.aurora {
  background:
    radial-gradient(60rem 30rem at 85% -10%, var(--g-aurora-1), transparent 60%),
    radial-gradient(40rem 26rem at -10% 110%, var(--g-aurora-2), transparent 60%),
    radial-gradient(30rem 20rem at 50% 120%, var(--g-aurora-3), transparent 70%),
    var(--uni-surface);
}

.aurora::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--uni-line) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at 50% 30%, black, transparent 75%);
}

.story {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  padding: 24px 28px 20px;
  gap: 18px;
}

.gallery--embed {
  display: block;
}

.gallery--embed .story {
  padding: 0;
}

.story-hero__inner {
  animation: rise 0.28s ease-out both;
}

.story-overline {
  display: flex;
  gap: 6px;
  color: var(--uni-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.story-overline__sep {
  opacity: 0.6;
}

.story-title {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(120deg, var(--uni-accent) 20%, var(--g-glow) 60%, var(--g-silver));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
}

.story-summary {
  margin: 6px 0 0;
  color: var(--uni-muted);
  font-size: 14px;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.story-meta__spacer {
  flex: 1;
}

.story-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--uni-line);
  border-radius: 999px;
  background: var(--uni-raised);
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
  font-size: 12px;
  cursor: default;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    color 0.15s;
}

.chip:hover,
.chip.is-active {
  border-color: var(--uni-accent);
  color: var(--uni-accent);
  box-shadow: 0 0 0 3px var(--uni-accent-soft);
}

.story-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--uni-line);
  border-radius: 8px;
  background: var(--uni-raised);
  color: var(--uni-fg);
  font-size: var(--uni-font-size-sm);
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s;
}

.story-link:hover {
  border-color: var(--uni-accent);
}

.story-link .icon {
  width: 15px;
  height: 15px;
}

/* The card: a glass panel with a toolbar, the preview, and the code */
.story-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--uni-line);
  border-radius: 14px;
  background: var(--uni-panel);
  backdrop-filter: blur(24px);
  box-shadow: var(--g-card-shadow);
}

.gallery--embed .story-card {
  height: 100vh;
  box-sizing: border-box;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.story-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--uni-line);
}

.story-toolbar__title {
  font-weight: 600;
}

.story-toolbar__spacer {
  flex: 1;
}

.view-switch {
  flex: none;
}

.view-switch .uni-tab {
  padding: 5px 12px;
}

.view-switch .uni-tab .icon {
  width: 15px;
  height: 15px;
}

.view-switch .uni-tab[aria-pressed='true'] {
  background: var(--uni-raised);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.06),
    0 0 0 1px var(--uni-line);
}

.view-switch .uni-tab[aria-pressed='true'] {
  color: var(--uni-accent);
}

.story-body {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

.story-preview {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
  background:
    radial-gradient(circle, var(--uni-line) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--uni-canvas);
}

.story-body[data-view='code'] .story-preview {
  display: none;
}

.story-stage {
  position: relative;
  box-sizing: border-box;
  min-height: 100%;
  padding: 40px 32px;
  animation: rise 0.28s ease-out both;
}

.story-code-full {
  flex: 1;
  min-width: 0;
}

.story-body > .uni-pane {
  background: var(--g-code-bg);
}

/* Code panel */
.code-view,
.code-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.code-view {
  background: var(--g-code-bg);
}

.code-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--uni-line);
}

.code-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
  font-size: 12px;
}

.code-file .icon {
  width: 15px;
  height: 15px;
  color: var(--uni-accent);
}

.code-lines {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--uni-hover);
  color: var(--uni-muted);
  font-family: var(--uni-font-mono);
  font-size: 11px;
}

.code-toolbar__spacer {
  flex: 1;
}

.code-github {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--uni-radius);
  color: var(--uni-muted);
}

.code-github:hover {
  background: var(--uni-hover);
  color: var(--uni-fg);
}

.code-block {
  flex: 1;
  margin: 0;
  overflow: auto;
  padding: 10px 0 16px;
  font-family: var(--uni-font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.code-line {
  display: block;
  padding-right: 16px;
  border-left: 2px solid transparent;
  transition: background-color 0.15s;
}

.code-line:hover {
  background: var(--uni-hover);
}

.code-line.is-lit {
  border-left-color: var(--g-glow);
  background: rgb(8 189 203 / 0.14);
}

.code-line.is-changed {
  animation: changed 1.2s ease-out;
}

@keyframes changed {
  from {
    background: rgb(8 189 203 / 0.35);
  }
  to {
    background: transparent;
  }
}

.code-ln {
  display: inline-block;
  width: 3.2em;
  padding-right: 1.2em;
  text-align: right;
  color: var(--uni-faint);
  user-select: none;
}

.code-missing {
  padding: 16px;
  color: var(--uni-danger);
}

.tok-kw {
  color: var(--tok-kw);
}

.tok-type {
  color: var(--tok-type);
}

.tok-str {
  color: var(--tok-str);
}

.tok-num {
  color: var(--tok-num);
}

.tok-com {
  color: var(--uni-faint);
  font-style: italic;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-hero__inner,
  .story-stage {
    animation: none;
  }
}

/* Inspector: outlines drawn over the preview, linked to the code */
.inspect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.inspect-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--g-glow);
  border-radius: 6px;
  background: rgb(8 189 203 / 0.08);
  box-shadow:
    0 0 0 4px rgb(8 189 203 / 0.15),
    0 0 24px rgb(8 189 203 / 0.3);
  animation: rise 0.12s ease-out both;
}

.inspect-label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: -2px;
  display: inline-flex;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--g-glow);
  color: #031417;
  font-family: var(--uni-font-mono);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.inspect-detail {
  font-weight: 400;
  opacity: 0.75;
}

.story-preview.is-inspecting,
.story-preview.is-inspecting * {
  cursor: crosshair;
}

.inspect-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--uni-line);
  border-radius: 8px;
  background: transparent;
  color: var(--uni-muted);
  font: inherit;
  font-size: var(--uni-font-size-sm);
  cursor: pointer;
}

.inspect-toggle .icon {
  width: 15px;
  height: 15px;
}

.inspect-toggle:hover {
  color: var(--uni-fg);
}

.inspect-toggle.is-on {
  border-color: var(--g-glow);
  background: rgb(8 189 203 / 0.12);
  color: var(--uni-accent);
  box-shadow: 0 0 0 3px var(--uni-accent-soft);
}

.story-badge {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--uni-accent-soft);
  color: var(--uni-accent);
  letter-spacing: 0.06em;
}

.story-body[data-layout='stacked'] {
  flex-direction: column;
}

.story-body[data-layout='stacked'] .story-preview {
  min-height: 200px;
}

/* Stacked, the side view goes below the preview (.story-side--stacked), so the pane stays out of the
   column instead of taking its height */
.story-body[data-layout='stacked'] > .uni-pane {
  display: none;
}

.story-side--stacked {
  flex: 0 0 55%;
  min-height: 0;
  border-top: 1px solid var(--uni-line);
}

.story-side {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.story-side > * {
  flex: 1;
  min-height: 0;
}

/* Playground props: a bar of controls above the preview */
.props-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--uni-line);
  background: linear-gradient(90deg, rgb(8 189 203 / 0.06), transparent 60%);
}

.props-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  color: var(--uni-accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.props-title .icon {
  width: 15px;
  height: 15px;
}

.props-control {
  min-width: 140px;
}

.props-spacer {
  flex: 1;
}

.playground-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.prop-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  cursor: pointer;
  user-select: none;
}

.prop-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.prop-toggle__track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--uni-line);
  transition: background-color 0.15s;
}

.prop-toggle__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--uni-raised);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform 0.15s;
}

.prop-toggle input:checked + .prop-toggle__track {
  background: linear-gradient(135deg, var(--g-primary-1), var(--g-primary-2));
}

.prop-toggle input:checked + .prop-toggle__track::after {
  transform: translateX(14px);
}

.prop-toggle input:focus-visible + .prop-toggle__track {
  box-shadow: 0 0 0 3px var(--uni-accent-soft);
}

.prop-toggle__label {
  font-family: var(--uni-font-mono);
  font-size: 12px;
}

/* Agent view */
.agent-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--g-code-bg);
}

.agent-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--uni-line);
}

.agent-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
}

.agent-title .icon {
  width: 15px;
  height: 15px;
  color: var(--uni-accent);
}

.agent-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
}

.agent-node {
  margin: 0 0 8px calc(var(--depth, 0) * 14px);
  padding: 8px 10px;
  border: 1px solid var(--uni-line);
  border-radius: 10px;
  background: var(--uni-raised);
  animation: rise 0.2s ease-out both;
}

.agent-node .agent-node {
  margin-top: 8px;
  margin-bottom: 0;
}

.agent-node__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.agent-kind {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--uni-accent-soft);
  color: var(--uni-accent);
  font-family: var(--uni-font-mono);
  font-size: 11px;
  font-weight: 600;
}

.agent-label {
  font-weight: 600;
}

.agent-value {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--uni-hover);
  font-family: var(--uni-font-mono);
  font-size: 12px;
}

.agent-flag {
  color: var(--uni-faint);
  font-size: 11px;
}

.agent-ref {
  margin-top: 3px;
  color: var(--uni-faint);
  font-family: var(--uni-font-mono);
  font-size: 11px;
}

.agent-items,
.agent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.agent-item {
  padding: 1px 7px;
  border: 1px dashed var(--uni-line);
  border-radius: 6px;
  color: var(--uni-muted);
  font-size: 12px;
}

.agent-item.is-selected {
  border-style: solid;
  border-color: var(--uni-accent);
  color: var(--uni-accent);
}

.agent-action {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.agent-action__name {
  color: var(--uni-muted);
  font-family: var(--uni-font-mono);
  font-size: 11px;
}

.agent-chip {
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--uni-line);
  border-radius: 999px;
  background: transparent;
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
  font-size: 11px;
  cursor: pointer;
}

.agent-chip:hover {
  border-color: var(--g-glow);
  color: var(--uni-accent);
  box-shadow: 0 0 0 3px var(--uni-accent-soft);
}

.agent-chip--action {
  border-color: var(--uni-accent);
  color: var(--uni-accent);
}

.agent-input {
  width: 120px;
}

.agent-json {
  margin: 0;
  font-family: var(--uni-font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-empty {
  color: var(--uni-muted);
}

.agent-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--uni-line);
  color: var(--uni-muted);
  font-family: var(--uni-font-mono);
  font-size: 11.5px;
}

/* A component page: header, example cards, then Parts, API, and Accessibility */
.page {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 28px 72px;
}

.page-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.page-toc__link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--uni-line);
  border-radius: 999px;
  background: var(--uni-raised);
  color: var(--uni-fg);
  font-size: 12.5px;
  text-decoration: none;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.page-toc__link:hover {
  border-color: var(--uni-accent);
  color: var(--uni-accent);
}

.page-toc__link--ref {
  border-style: dashed;
  color: var(--uni-muted);
}

.example-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-margin-top: 16px;
}

.example-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.example-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}

.example-hint {
  margin: 0;
  color: var(--uni-muted);
  font-size: 13.5px;
}

.example .story-card {
  height: 440px;
}

.example .story-card:has(.props-panel) {
  height: 500px;
}

.story-card .event-log {
  flex-shrink: 0;
}

/* Event log */
.event-log {
  border-top: 1px solid var(--uni-line);
  background: var(--g-code-bg);
  font-size: 12px;
}

.event-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
}

.event-toggle,
.event-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--uni-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.event-toggle:hover,
.event-clear:hover {
  color: var(--uni-fg);
}

.event-chevron {
  display: inline-block;
  transition: transform 0.15s;
}

.event-chevron.is-open {
  transform: rotate(90deg);
}

.event-count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--uni-accent-soft);
  color: var(--uni-accent);
  font-size: 11px;
}

.event-spacer {
  flex: 1;
}

.event-list {
  max-height: 92px;
  overflow: auto;
  padding: 0 10px 8px;
  font-family: var(--uni-font-mono);
  font-size: 11.5px;
}

.event-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--uni-line);
  animation: rise 0.18s ease-out both;
}

.event-time,
.event-reason {
  color: var(--uni-faint);
}

.event-ref {
  color: var(--uni-muted);
}

.event-key {
  color: var(--tok-kw);
}

.event-value {
  color: var(--uni-fg);
}

.event-source {
  padding: 0 6px;
  border-radius: 6px;
  background: var(--uni-hover);
  color: var(--uni-muted);
}

.event-source--agent {
  background: var(--uni-accent-soft);
  color: var(--uni-accent);
}

.event-source--programmatic {
  background: rgb(163 82 0 / 0.12);
  color: var(--tok-str);
}

.event-empty {
  color: var(--uni-faint);
  font-family: var(--uni-font-sans);
}

/* Reference sections: Parts, API, Accessibility */
.ref-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-margin-top: 16px;
}

.ref-title {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--uni-line);
  font-size: 19px;
  font-weight: 650;
}

.ref-body {
  padding: 14px 16px;
  border: 1px solid var(--uni-line);
  border-radius: 12px;
  background: var(--uni-panel);
  backdrop-filter: blur(24px);
}

.ref-note {
  margin: 0 0 10px;
  color: var(--uni-muted);
  font-size: 13px;
}

.ref-empty {
  color: var(--uni-faint);
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ref-table th {
  padding: 6px 10px;
  border-bottom: 1px solid var(--uni-line);
  color: var(--uni-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.ref-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--uni-line);
  vertical-align: top;
}

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

.ref-table code {
  font-family: var(--uni-font-mono);
  font-size: 12px;
}

.ref-chip {
  display: inline-block;
  margin: 0 4px 2px 0;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--uni-hover);
  color: var(--uni-muted);
  font-family: var(--uni-font-mono);
  font-size: 11px;
}

.ref-chip--create {
  background: var(--uni-accent-soft);
  color: var(--uni-accent);
}

.ref-chip--option {
  background: rgb(139 61 214 / 0.12);
  color: var(--tok-kw);
}

.api-group + .api-group {
  margin-top: 18px;
}

.api-component {
  margin: 0 0 6px;
  font-family: var(--uni-font-mono);
  font-size: 14px;
}

.api-kind {
  width: 72px;
}

.api-signature {
  color: var(--uni-fg);
  white-space: nowrap;
}

.api-doc {
  color: var(--uni-muted);
}

.a11y-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.a11y-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.a11y-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--uni-line);
  border-radius: 8px;
  background: var(--uni-raised);
  font-size: 13px;
}

.a11y-row ul {
  flex-basis: 100%;
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--uni-danger);
}

.a11y-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.a11y-row--pass .a11y-mark {
  background: var(--uni-success-soft);
  color: var(--uni-success);
}

.a11y-row--fail .a11y-mark {
  background: var(--uni-danger-soft);
  color: var(--uni-danger);
}

.a11y-row--missing {
  border-style: dashed;
}

.a11y-row--missing .ref-note {
  margin: 0;
}

.a11y-pattern {
  font-weight: 600;
}

.nav-story {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--uni-hover);
  color: var(--uni-faint);
  font-size: 11px;
}

.demo-center {
  justify-content: center;
  padding: 40px 0;
}

.demo-target {
  display: grid;
  place-items: center;
  height: 120px;
  border: 1px dashed var(--uni-line);
  border-radius: var(--uni-radius-lg);
  color: var(--uni-muted);
}

/* Helpers the stories use */
.demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.demo-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.demo-narrow {
  max-width: 380px;
}

.demo-note {
  margin: 0;
  color: var(--uni-muted);
  font-size: var(--uni-font-size-sm);
}

.demo-panel {
  padding: 12px;
  border: 1px dashed var(--uni-line);
  border-radius: var(--uni-radius);
  background: var(--uni-surface);
  color: var(--uni-muted);
}

.demo-frame {
  position: relative;
  min-height: 260px;
  align-content: flex-start;
}

.demo-task {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-dock {
  display: flex;
  height: 300px;
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius-lg);
  overflow: hidden;
  background: var(--uni-surface);
}

.demo-dock > .uni-dock {
  flex: 1;
}

.demo-split {
  position: relative;
  display: flex;
  height: 200px;
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius);
  overflow: hidden;
}

.demo-grow {
  flex: 1;
  border: 0;
  border-radius: 0;
}

/* Phone-sized windows: the sidebar floats over the story, and the story keeps the width */
@media (max-width: 760px) {
  .page {
    padding: 14px 12px 48px;
  }

  .api-signature {
    white-space: normal;
  }

  .gallery > .uni-pane {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 56px;
    z-index: 20;
    box-shadow: 0 24px 60px -12px rgb(0 0 0 / 0.5);
  }

  .story {
    padding: 14px 12px 12px;
    gap: 12px;
  }

  .story-title {
    font-size: 22px;
  }

  .story-meta__spacer {
    display: none;
  }

  .story-toolbar {
    flex-wrap: wrap;
  }

  .inspect-toggle span {
    display: none;
  }

  .view-switch .uni-tab {
    padding: 5px 8px;
  }
}

.demo-dock--short {
  height: 200px;
}

.demo-json {
  max-height: 110px;
  margin: 0;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius);
  background: var(--g-code-bg);
  font-family: var(--uni-font-mono);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
}

.demo-statusbar {
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius);
  overflow: hidden;
}

.demo-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius-lg);
  background: var(--uni-raised);
  color: var(--uni-muted);
  font-size: 13px;
}

.demo-tall {
  min-height: 96px;
}

.demo-strong {
  color: var(--uni-fg);
  font-weight: 600;
}

.demo-outline {
  padding: 8px;
  border: 1px dashed var(--uni-line);
  border-radius: var(--uni-radius);
}

/* The Colors page: a row of swatches per role, each split into its light and dark values */
.theme-probe {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
  visibility: hidden;
}

.colors-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 16px;
}

.colors-legend {
  display: inline-flex;
  gap: 12px;
  color: var(--uni-muted);
  font-size: var(--uni-font-size-sm);
}

.colors-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.colors-legend .icon,
.swatch-value .icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.swatch-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px 14px;
}

.swatch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.swatch-chip {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 72px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius-lg);
  background: transparent;
  cursor: copy;
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}

.swatch-chip:hover {
  box-shadow: 0 0 0 3px var(--uni-accent-soft);
}

.swatch-chip:focus-visible {
  outline: 2px solid var(--uni-focus);
  outline-offset: 2px;
}

.swatch-half {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.swatch-shadow {
  width: 44%;
  height: 46%;
  border-radius: var(--uni-radius);
}

.swatch-status {
  position: absolute;
  inset: auto 6px 6px auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--uni-tooltip-bg);
  color: var(--uni-tooltip-fg);
  font-size: 11px;
  font-weight: 600;
}

.swatch-status:empty {
  display: none;
}

.swatch-name {
  overflow: hidden;
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch-values {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.swatch-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 100%;
  padding: 1px 4px;
  margin-left: -4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--uni-muted);
  font-family: var(--uni-font-mono);
  font-size: 11.5px;
  text-align: left;
  cursor: copy;
}

.swatch-value span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch-value:hover:not(:disabled) {
  background: var(--uni-hover);
  color: var(--uni-fg);
}

.swatch-value:disabled {
  cursor: default;
}

.swatch-usage {
  margin: 0;
  color: var(--uni-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

/* The marble diagram of the Rx examples (Timeline.scala) */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--uni-line);
  border-radius: var(--uni-radius-lg);
  background: var(--uni-surface);
}

.tl-lane {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.tl-label {
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
}

.tl-status {
  display: flex;
  gap: 8px;
  margin-left: auto;
  color: var(--uni-muted);
}

.tl-value {
  font-family: var(--uni-font-mono);
  color: var(--uni-fg);
}

.tl-state {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--uni-hover);
  color: var(--uni-faint);
  font-size: 11px;
}

.tl-state--done {
  background: var(--uni-success-soft);
  color: var(--uni-success);
}

.tl-state--failed {
  background: var(--uni-danger-soft);
  color: var(--uni-danger);
}

.tl-track {
  position: relative;
  height: 30px;
  overflow: hidden;
}

/* 50 windows wide; one second per grid line */
.tl-strip {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5000%;
  background:
    linear-gradient(var(--uni-line), var(--uni-line)) 0 50% / 100% 1px no-repeat,
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(0.2% - 1px),
      color-mix(in srgb, var(--uni-line) 60%, transparent) calc(0.2% - 1px),
      color-mix(in srgb, var(--uni-line) 60%, transparent) 0.2%
    );
  will-change: transform;
}

.marble {
  position: absolute;
  box-sizing: border-box;
  top: 50%;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1.5px solid var(--uni-accent);
  border-radius: 999px;
  background: var(--uni-accent-soft);
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
  font-size: 11px;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.marble--error,
.marble--failed {
  border-color: var(--uni-danger);
  background: var(--uni-danger-soft);
  color: var(--uni-danger);
}

/* An end is a bar across the line */
.marble--done,
.marble--failed {
  min-width: 0;
  width: 4px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: var(--uni-success);
}

.marble--failed {
  background: var(--uni-danger);
}

.marble--failed .marble__glyph {
  position: absolute;
  left: 8px;
  font-size: 12px;
}

.tl-axis {
  display: flex;
  justify-content: space-between;
  color: var(--uni-faint);
  font-size: 11px;
}

.demo-list {
  margin: 0;
  padding-left: 18px;
  font-size: var(--uni-font-size-sm);
}

/* Get started: numbered steps, each with its files to copy */
.page--guide {
  max-width: 920px;
}

.start-step {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 16px;
}

.start-step > p {
  margin: 0;
  color: var(--uni-muted);
  font-size: 14px;
  line-height: 1.6;
}

.start-step p code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--uni-raised);
  color: var(--uni-fg);
  font-family: var(--uni-font-mono);
  font-size: 12.5px;
}

.start-step a {
  color: var(--uni-accent);
}

.start-step__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 19px;
  font-weight: 650;
}

.start-step__num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--uni-accent);
  color: var(--uni-accent-fg, #fff);
  font-size: 13px;
  font-weight: 700;
}

.start-step > .start-note {
  font-size: 13px;
}

/* A file to copy: the code panel's toolbar and lines, sized to its text */
.code-snippet {
  min-width: 0;
  height: auto;
  overflow: hidden;
  border: 1px solid var(--uni-line);
  border-radius: 12px;
}

.code-snippet .code-block {
  flex: none;
  padding: 10px 14px 12px;
}

/* Keep blank lines */
.code-snippet .code-line {
  min-height: 1.6em;
}

.code-snippet .code-line:hover {
  background: none;
}

.start-version {
  font-family: var(--uni-font-mono);
  font-size: 12px;
}

.start-next {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.start-step .start-next__card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--uni-line);
  border-radius: 12px;
  background: var(--uni-raised);
  color: var(--uni-fg);
  text-decoration: none;
}

.start-next__card:hover {
  border-color: var(--uni-accent);
}

.start-next__title {
  font-weight: 650;
}

.start-next__hint {
  color: var(--uni-muted);
  font-size: 13px;
}
