/*
 * Supply UI preview page (/ui/): the page's own layout and showpieces.
 * Everything here is built from the system's tokens, so it follows the theme too.
 */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

@font-face {
  font-family: "Reddit Mono Variable";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/reddit-mono-latin-wght-normal.woff2") format("woff2-variations");
}

@font-face {
  font-family: "DM Sans Variable";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("fonts/dm-sans-latin-wght-normal.woff2") format("woff2-variations");
}

@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 400;
  --ui-icon-weight: 1;
  font-display: swap;
  src: url("fonts/courier-prime-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 700;
  --ui-icon-weight: var(--ui-icon-bold);
  font-display: swap;
  src: url("fonts/courier-prime-latin-700-normal.woff2") format("woff2");
}

/* The icons, written into the page: never shown by itself. */
.pv-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/*
 * A block waits just below its place and rises in when it comes on screen: at once for what the page opens on,
 * on scroll for the rest. Hidden from the first paint (the class is set in <head>), so nothing flashes.
 * .pv-shown starts the rise; .pv-done, set when it is over, makes the block an ordinary block again.
 */
.pv-js :is(.pv-bento > *, .pv-section-head, .pv-stage, .pv-icons, .pv-index > *, .dx-footer):not(.pv-done) {
  opacity: 0;
  translate: 0 2.5rem;
  transition:
    opacity calc(var(--ui-dur-slow) * 1.6) var(--ui-ease),
    translate calc(var(--ui-dur-slow) * 1.6) var(--ui-ease-out);
  transition-delay: calc(var(--reveal-i, 0) * 90ms);
}

.pv-js :is(.pv-bento > *, .pv-section-head, .pv-stage, .pv-icons, .pv-index > *, .dx-footer).pv-shown:not(.pv-done) {
  opacity: 1;
  translate: none;
}

/* The first screen: the hero's lines rise in one after another as the page opens. */
.pv-hero-text > * {
  animation: pv-rise calc(var(--ui-dur-slow) * 1.6) var(--ui-ease-out) backwards;
}

.pv-hero-text > :nth-child(2) { animation-delay: 90ms; }
.pv-hero-text > :nth-child(3) { animation-delay: 180ms; }
.pv-hero-text > :nth-child(4) { animation-delay: 270ms; }

/*
 * The page first shows a ready-made copy of every block, and the live components then take its place. The hero's
 * entrance waits, held at its first frame, until the live hero is in (live.tsx marks its block data-pv-mounted), so
 * it plays once and not again on the new copy. Without scripts, pv-js is taken off after a moment and it plays then.
 */
.pv-js [data-live]:not([data-pv-mounted]) :is(.pv-hero-text > *, .pv-float),
.pv-js [data-live]:not([data-pv-mounted]) *,
.pv-js [data-live]:not([data-pv-mounted]) *::before,
.pv-js [data-live]:not([data-pv-mounted]) *::after {
  animation-play-state: paused;
}

/* Until its live copy is in, a block's ready-made copy has no fades of its own either, so nothing plays twice. */
.pv-js [data-live]:not([data-pv-mounted]) * {
  transition: none;
}

@keyframes pv-rise {
  from {
    opacity: 0;
    translate: 0 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pv-hero-text > * {
    animation: none;
  }

  .pv-js :is(.pv-bento > *, .pv-section-head, .pv-stage, .pv-icons, .pv-index > *, .dx-footer):not(.pv-done) {
    opacity: 1;
    translate: none;
    transition: none;
  }
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

.pv {
  overflow-x: clip;
  padding-bottom: 6rem; /* room for the dock */
}

/* Every section of the page is as wide as the example screens. */
.pv .ui-container {
  --max: 1280px;
}

/* ── Top bar ───────────────────────────────────────────────────────── */

.pv-top {
  position: sticky;
  top: 0;
  z-index: var(--ui-z-sticky);
  border-bottom: 1px solid color-mix(in oklab, var(--ui-border) 60%, transparent);
  background: var(--ui-bg);
}

.pv-top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-4);
  height: 3.5rem;
}

.pv-wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  font-size: var(--ui-text-md);
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

/* The mark: the Supply Family logo, in the text colour. */
.pv-mark {
  flex: none;
  width: auto;
  height: 1.375rem;
  fill: currentColor;
}

.pv-top-nav {
  display: none;
  gap: 2px;
}

/* The page's sections in a row where there is room for all of them; below that, the burger opens them. */
@media (min-width: 1024px) {
  .pv-top-nav {
    display: flex;
    align-items: center;
  }
}

.pv-top-sections {
  display: flex;
  gap: 2px;
}

/* ── Hero ──────────────────────────────────────────────────────────── */

.pv-hero {
  position: relative;
  padding-block: clamp(3rem, 8vw, 6.5rem) clamp(3rem, 7vw, 5.5rem);
  /* Pieces near the sides never widen the page; nothing is cut off above or below. */
  overflow-x: clip;
  isolation: isolate;
}

.pv-hero-text {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  text-align: center;
  pointer-events: none;
}

.pv-hero-text > * {
  pointer-events: auto;
}

.pv-headline {
  margin-top: var(--ui-space-5);
  font-size: clamp(2.75rem, 8.4vw, 6.25rem);
  font-weight: 620;
  --ui-icon-weight: var(--ui-icon-bold);
  line-height: 0.98;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.pv-lead {
  max-width: 44rem;
  margin-top: var(--ui-space-5);
  font-size: clamp(1.0625rem, 1.6vw, 1.3125rem);
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--ui-fg-muted);
  text-wrap: pretty;
}

.pv-hero-text .pv-lead {
  max-width: 35rem;
}

.pv-hero-actions {
  justify-content: center;
  margin-top: var(--ui-space-8);
}

/* ── The cloud: real pieces of the kit, loose around the headline ──── */

/*
 * Each piece drifts on its own, follows the pointer by its own depth, and flies in when the
 * page opens. Small screens: the pieces gather in a loose cluster under the buttons.
 * Wide screens: they spread out on both sides of the text.
 */
.pv-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-5) var(--ui-space-6);
  max-width: 50rem;
  margin: var(--ui-space-12) auto 0;
  padding-inline: var(--ui-space-4);
  --mx: 0;
  --my: 0;
}

.pv-float {
  rotate: var(--tilt, 0deg);
  transform: translate(calc(var(--mx) * var(--depth, 16) * 1px), calc(var(--my) * var(--depth, 16) * 1px));
  transition: transform 0.9s var(--ui-ease-out);
  animation:
    pv-fly-in 1.1s var(--ui-ease-out) backwards,
    pv-drift var(--t, 7s) ease-in-out var(--delay, 0s) infinite alternate;
}

/* The pieces around the hero float without a drop shadow (a toast has one of its own elsewhere). */
.pv-float > .ui-card,
.pv-float > .ui-toast,
.pv-float > .ui-chip,
.pv-float > .ui-segmented {
  box-shadow: none;
}

@keyframes pv-fly-in {
  from {
    opacity: 0;
    transform: translate(var(--from-x, 0), var(--from-y, 4rem)) scale(0.7);
  }
}

@keyframes pv-drift {
  from { translate: 0 -0.4rem; }
  to { translate: 0 0.5rem; }
}

.pv-knob-card {
  gap: var(--ui-space-2);
  /* As wide as its one row of colours: the room round them grows with the look's size, and a fixed width sent the
     last dot to a second row on some looks and not others. */
  width: max-content;
  min-width: 14rem;
  padding: var(--ui-space-4) var(--ui-space-5);
}

.pv-knob-card .pv-brands {
  flex-wrap: nowrap;
}

.pv-people-card,
.pv-ring-card {
  flex-direction: row;
  align-items: center;
  gap: var(--ui-space-4);
  padding: var(--ui-space-3) var(--ui-space-4);
}

.pv-ring-card .ui-ring {
  --size: 3.25rem;
  font-size: var(--ui-text-xs);
}

.pv-float--h {
  width: 11.5rem;
}

.pv-float--h .ui-card-body {
  padding: var(--ui-space-3) var(--ui-space-4);
}

.pv-float--e {
  width: 13.5rem;
}

.pv-float--e .ui-toast {
  grid-template-columns: 1fr;
}

/* A real switch inside a chip (a chip normally hides its input and shows itself as chosen). */
.ui-chip .pv-inline-switch {
  position: relative;
  display: inline-block;
  opacity: 1;
  pointer-events: auto;
}

/* The switch is the chosen state here: the chip stays plain, or a switched-on switch would vanish into an ink chip. */
.ui-chip:has(.pv-inline-switch):has(input:checked) {
  border-color: var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-fg);
}

/* A phone shows the pieces you can play with, and a few more. */
@media (max-width: 620px) {
  .pv-float--extra {
    display: none;
  }

  .pv-cloud {
    gap: var(--ui-space-4);
    margin-top: var(--ui-space-10);
  }
}

/* Wide screens: the pieces leave the flow and spread out on both sides of the headline. */
@media (min-width: 1240px) {
  .pv-hero {
    min-height: 47rem;
  }

  .pv-cloud {
    position: absolute;
    inset: 0 auto;
    left: 50%;
    display: block;
    width: min(100%, 92rem);
    max-width: none;
    margin: 0;
    padding: 0;
    translate: -50% 0;
    pointer-events: none;
  }

  .pv-float {
    position: absolute;
    pointer-events: auto;
  }

  .pv-float--a { top: 11%; left: 7%; }
  .pv-float--b { top: 27%; left: 2.5%; }
  .pv-float--c { top: 49%; left: 8%; }
  .pv-float--d { top: 66%; left: 3.5%; }
  .pv-float--e { top: 79%; left: 9%; }

  .pv-float--f { top: 10%; right: 6%; }
  .pv-float--g { top: 30%; right: 13%; }
  .pv-float--h { top: 41%; right: 2.5%; }
  .pv-float--i { top: 70%; right: 7%; }
  .pv-float--j { top: 87%; right: 15%; }
}

@media (prefers-reduced-motion: reduce) {
  .pv-float {
    animation: none;
    transition: none;
  }
}

/* ── Example screens ───────────────────────────────────────────────── */

.pv-examples {
  position: relative;
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3rem, 8vw, 6rem);
  border-top: 1px solid var(--ui-border);
  background: var(--ui-bg);
}


/* A brand colour to pick: its own colour, whatever the page is set to. The chosen one is ringed in ink. */
.pv-dot {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: var(--dot, var(--ui-fg));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ui-fg) 12%, transparent);
  outline: 2px solid transparent;
  outline-offset: 2px;
  cursor: pointer;
  transition:
    transform var(--ui-dur-fast) var(--ui-ease),
    outline-color var(--ui-dur-fast) var(--ui-ease);
}

.pv-dot:hover {
  transform: scale(1.2);
}

.pv-dot[aria-pressed="true"] {
  outline-color: var(--ui-ink);
}

/*
 * The last dot of the brand colours: the one slot for your own colour. Always a rainbow ring, so it reads as "pick
 * your own"; inside, a plus until a colour is picked, then that colour.
 */
.pv-dot--any {
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, var(--own, var(--ui-surface)) 62%, transparent 64%),
    conic-gradient(from 0deg, oklch(0.75 0.17 30), oklch(0.85 0.17 100), oklch(0.75 0.17 160), oklch(0.7 0.15 250), oklch(0.7 0.19 320), oklch(0.75 0.17 30));
  color: var(--ui-fg);
}

.pv-dot--any .ui-icon {
  width: 0.7rem;
  height: 0.7rem;
}

.pv-brands {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-3);
  min-height: var(--ui-h-sm);
}

.pv-brand-popup {
  width: 16rem;
}

/* The three colour choices of the look, side by side where there is room. */
.pv-colour-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: var(--ui-space-4) var(--ui-gutter);
}

/* The brand colour has the row to itself; the greys and the page share the next one. */
.pv-colour-choices > :first-child {
  grid-column: 1 / -1;
}

.pv-panel-wide {
  grid-column: 1 / -1;
}

/* ── Bento: example screens ────────────────────────────────────────── */

.pv-bento {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ui-gutter);
}

.pv-tile {
  min-width: 0;
}

.pv-tile > .ui-card-body {
  flex: 1;
}

/* Three small tool cards with painted covers. */
.pv-tile--tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ui-gutter);
}

.pv-tile--tools .ui-card-body {
  padding: var(--ui-space-4);
}

.pv-tile--tools .ui-card-cover {
  flex: 1;
  min-height: 7rem;
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: auto;
}

@media (min-width: 720px) {
  .pv-bento {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .pv-tile--figure { grid-column: span 3; grid-row: span 2; }
  .pv-tile--invite { grid-column: span 3; }
  .pv-tile--meeting { grid-column: span 3; }
  .pv-tile--tools { grid-column: span 6; }
  .pv-tile--filters { grid-column: span 4; }
  .pv-tile--settings { grid-column: span 2; }
}

@media (min-width: 1100px) {
  .pv-bento {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .pv-tile--figure { grid-column: span 5; grid-row: span 1; }
  .pv-tile--invite { grid-column: span 4; }
  .pv-tile--meeting { grid-column: span 3; }
  .pv-tile--tools { grid-column: span 5; }
  .pv-tile--filters { grid-column: span 4; }
  .pv-tile--settings { grid-column: span 3; }
}

.pv-figure-bars {
  --height: 9rem;
}

.pv-bar-labels {
  display: flex;
  gap: var(--ui-space-2);
  margin-top: var(--ui-space-2);
  text-align: center;
}

.pv-bar-labels span {
  flex: 1;
}

.pv-tile--meeting .ui-card-body {
  padding-bottom: var(--ui-space-4);
}

.pv-rows {
  display: grid;
  gap: var(--ui-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pv-row,
.pv-setting {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  min-width: 0;
}

.pv-setting {
  cursor: pointer;
}

.pv-row .ui-grow,
.pv-setting .ui-grow {
  display: grid;
}

.pv-row-title {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

/* ── Patterns ──────────────────────────────────────────────────────── */

/* The maker: the picture on one side, its settings on the other. */
.pv-stage.pv-maker {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ui-gap-xl);
}

@media (min-width: 860px) {
  .pv-stage.pv-maker {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: stretch;
  }
}

.pv-maker-art {
  width: 100%;
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: 4 / 3;
  border-radius: var(--ui-radius-nested);
}

@media (min-width: 860px) {
  .pv-maker-art {
    min-height: 26rem;
    min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
    aspect-ratio: auto;
  }
}

.pv-maker-form {
  min-width: 0;
}

/* Two rows of six. */
.pv-maker-swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--ui-space-2);
}

/* One palette: its paints side by side. The chosen one carries the mix mark: click it again to mix its colours. */
.pv-maker-swatch {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: var(--paints);
  cursor: pointer;
  transition: box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.pv-maker-swatch[aria-pressed="true"] {
  box-shadow:
    0 0 0 2px var(--ui-surface),
    0 0 0 4px var(--ui-fg);
}

.pv-maker-mix {
  display: grid;
  place-items: center;
  width: calc(1.5 * var(--ui-u));
  height: calc(1.5 * var(--ui-u));
  border-radius: var(--ui-radius-round);
  background: var(--ui-surface);
  color: var(--ui-fg);
  opacity: 0;
  transform: scale(0.8);
  transition:
    opacity var(--ui-dur-fast) var(--ui-ease),
    transform var(--ui-dur-fast) var(--ui-ease);
}

.pv-maker-mix svg {
  width: calc(0.875 * var(--ui-u));
  height: calc(0.875 * var(--ui-u));
}

.pv-maker-swatch[aria-pressed="true"] .pv-maker-mix {
  opacity: 1;
  transform: none;
}

.pv-maker-foot {
  margin-top: auto;
  padding-top: var(--ui-space-4);
}

.pv-patterns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(13rem, 45%), 1fr));
  gap: var(--ui-gutter);
}

.pv-pattern {
  display: grid;
  gap: var(--ui-space-2);
  margin: 0;
}

.pv-pattern-art {
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: 4 / 3;
  border-radius: var(--ui-radius-lg);
}

.pv-pattern-people {
  margin-top: var(--ui-space-8);
}

/* A block written with the kit's components sits in the page as if its parts were written there directly. */
[data-live] {
  display: contents;
}

/* ── The live pieces and the agent demo ────────────────────────────── */

.pv-pieces {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: var(--ui-gap-xl) var(--ui-gutter);
  align-items: start;
}

.pv-piece {
  min-width: 0;
}

/* A piece that needs the whole row: a board, a waterfall. */
.pv-piece--wide {
  grid-column: 1 / -1;
}


/* The steps of a build read as a list, not as a conversation that grows. */
.pv-built-log {
  min-height: 0;
}

.pv-piece-wait {
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: 4 / 3;
  border-radius: var(--ui-radius-nested);
}

.pv-panels {
  height: 11rem;
  border-radius: var(--ui-radius-nested);
}

.pv-panel-body {
  padding: var(--ui-space-4);
}

/* ── Sections ──────────────────────────────────────────────────────── */

.pv-section {
  padding-block: clamp(3rem, 8vw, 6rem);
  border-top: 1px solid var(--ui-border);
}

.pv-section-head {
  margin-bottom: var(--ui-space-10);
}

.pv-h2 {
  max-width: 18ch;
  margin-top: var(--ui-space-3);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 650;
  --ui-icon-weight: var(--ui-icon-bold);
  line-height: 1;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

/* A framed panel for a group of examples. */
.pv-stage {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-5);
  min-width: 0;
  padding: var(--ui-pad-lg);
  border: 1px solid var(--ui-card-border);
  box-shadow: var(--ui-card-shadow);
  border-radius: var(--ui-radius-xl);
  background: var(--ui-surface);
  background-image: var(--ui-card-fill);
}

/* What sits inside a stage is one step less round than the stage. */
.pv-stage :where(.ui-card, .ui-list, .ui-table-wrap, .ui-accordion, .ui-empty, .ui-filedrop, .pv-screen, .pv-slide) {
  border-radius: var(--ui-radius-nested);
}

.pv-split,
.pv-demos {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ui-gutter);
}

@media (min-width: 860px) {
  .pv-split {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }

  /* Half-width cards fill the gap before a full-width one, so no spot stays empty. */
  .pv-demos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row dense;
  }

  .pv-stage--wide {
    grid-column: 1 / -1;
  }
}

/* ── Foundations ───────────────────────────────────────────────────── */

.pv-found {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ui-gutter);
}

@media (min-width: 860px) {
  .pv-found {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .pv-found-colour {
    grid-column: span 7;
  }

  .pv-found-type {
    grid-column: span 5;
  }

  /* Two small cards per row, the third under them, until there is room for three. */
  .pv-found-small {
    grid-column: span 6;
  }

  .pv-found-small:last-child {
    grid-column: span 12;
  }
}

@media (min-width: 1100px) {
  .pv-found-small,
  .pv-found-small:last-child {
    grid-column: span 4;
  }
}

/* The greys and the brand colour as one strip, each named for what it is used for. */
.pv-ramp {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 1;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-nested);
}

/* Six side by side only when the panel has room for six; otherwise two rows of three (follows the panel, not the window). */
.pv-found-colour {
  container-type: inline-size;
}

@container (min-width: 40rem) {
  .pv-ramp {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.pv-ramp-step {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 9.5rem;
  padding: var(--ui-space-4);
  background: var(--c);
  color: var(--t);
  font-size: var(--ui-text-xs);
  line-height: 1.3;
}

.pv-ramp-aa {
  margin-bottom: auto;
  font-size: var(--ui-text-xl);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.03em;
}

.pv-ramp-step strong {
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.pv-ramp-step span {
  font-weight: var(--ui-weight);
  --ui-icon-weight: 1;
}

/* A phone's panel: two columns, so each word of a name has room. */
@container (max-width: 24rem) {
  .pv-ramp {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pv-ramp-step {
    min-height: 7.5rem;
  }
}

/* What the four status colours say. */
.pv-says {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ui-space-2);
}

@media (min-width: 1100px) {
  .pv-says {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.pv-say {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  min-width: 0;
  padding: var(--ui-space-3);
  border-radius: var(--ui-radius-box);
  background: var(--soft);
  color: var(--text);
}

.pv-say > span {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.pv-say strong {
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.pv-say small {
  font-size: var(--ui-text-xs);
}

/* The small cards: one setting each, with its number and its slider. */
.pv-found-small {
  justify-content: space-between;
}

.pv-found-num {
  font-size: var(--ui-text-3xl);
  font-weight: 300;
  --ui-icon-weight: 0.8;
  line-height: 1;
  letter-spacing: -0.045em;
}

.pv-shapes {
  display: grid;
  min-width: 0; /* in its flex column: see .pv-shape */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ui-space-3);
}

.pv-shape {
  display: grid;
  /* Safari sizes a square (aspect-ratio) in a grid track from its height unless the item may shrink: without this the
     four squares grow wider than a phone while the window narrows. */
  min-width: 0;
  gap: var(--ui-space-2);
  margin: 0;
  font-size: var(--ui-text-xs);
  color: var(--ui-fg-muted);
  text-align: center;
}

.pv-shape > div {
  /* No minimum of its own: Safari otherwise takes one from its last height and keeps the row from narrowing. */
  min-width: 0;
  aspect-ratio: 1;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface-3);
}

.pv-shape:nth-child(2) > div {
  border-radius: var(--ui-radius-md);
}

.pv-shape:nth-child(3) > div {
  border-radius: var(--ui-radius-lg);
}

.pv-shape:nth-child(4) > div {
  border-radius: var(--ui-radius-round);
}

.pv-shape:nth-child(2) > div {
  background: var(--ui-primary);
}

.pv-sizes {
  align-items: flex-end;
}

/* The three share the row, so the largest never leaves the card. */
.pv-sizes .ui-btn {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: var(--ui-space-1);
}

/* Light and dark side by side: each half works its colours out for itself. */
.pv-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1;
  gap: var(--ui-space-2);
}

/* A small phone: light over dark, so each keeps the width for its line. */
@media (max-width: 400px) {
  .pv-modes {
    grid-template-columns: minmax(0, 1fr);
  }
}

.pv-mode-half {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-space-3);
  min-width: 0;
  padding: var(--ui-space-3);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-nested);
  background: var(--ui-bg);
  color: var(--ui-fg);
}

.pv-mode-card {
  display: grid;
  gap: 2px;
  align-self: stretch;
  padding: var(--ui-space-3);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  font-size: var(--ui-text-xs);
  line-height: 1.3;
}

.pv-mode-card strong {
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.pv-mode-card span {
  color: var(--ui-fg-muted);
}

.pv-mode-half .ui-btn {
  cursor: default;
}

.pv-specimen {
  font-size: clamp(4rem, 9vw, 6.5rem);
  font-weight: 650;
  --ui-icon-weight: var(--ui-icon-bold);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.pv-specimen--mono {
  font-family: var(--ui-font-mono);
  font-weight: 500;
  --ui-icon-weight: var(--ui-icon-medium);
  color: var(--ui-primary-text);
}

/* Type card: a link, a key pair and code side by side under the sample line. */
.pv-type-bits {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-2) var(--ui-space-5);
  font-size: var(--ui-text-base);
}

.pv-type-keys {
  display: inline-flex;
  gap: var(--ui-space-1);
}

/* Mono letters are wider: one step smaller, so the line keeps clear of the card's edge. */
.pv-title-mono {
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xl);
  font-weight: 500;
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.04em;
}

/* What "lines up" means: values in one column, right-aligned, a fine line between rows. */
.pv-ledger {
  display: grid;
  margin: 0;
}

.pv-ledger > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ui-space-4);
  padding-block: var(--ui-space-2);
  border-bottom: 1px solid var(--ui-border);
}

.pv-ledger > div:last-child {
  border-bottom: 0;
}

.pv-ledger dt {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.pv-ledger dd {
  margin: 0;
  font-size: var(--ui-text-base);
}

.pv-skeleton {
  flex: 1;
  height: 0.75rem;
}

.pv-skeleton--short {
  flex: 0 0 30%;
}

.pv-popup-anchor {
  position: relative;
}

.pv-menu[popover] {
  position: absolute;
  inset: auto;
  top: calc(anchor(bottom) + 6px);
  left: anchor(left);
}

/* ── Icons ─────────────────────────────────────────────────────────── */

.pv-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr));
  overflow: hidden;
  border: 1px solid var(--ui-card-border);
  box-shadow: var(--ui-card-shadow);
  border-radius: var(--ui-radius-xl);
  background: var(--ui-surface);
  background-image: var(--ui-card-fill);
}

/* An icon alone in its square; its name shows in a tooltip on hover or focus. */
.pv-icon {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  outline: none;
  box-shadow: 0 0 0 0.5px var(--ui-border);
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease);
}

.pv-icon:is(:hover, :focus-visible) {
  background: var(--ui-primary-soft);
  color: var(--ui-primary-text);
}

/* ── Install ───────────────────────────────────────────────────────── */

.pv-command {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  padding: var(--ui-space-3) var(--ui-space-3) var(--ui-space-3) var(--ui-space-5);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-xl);
  background: var(--ui-surface);
}

.pv-command code {
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-base);
}

.pv-command code::before {
  content: "$ ";
  color: var(--ui-fg-subtle);
}

/* The downloads under the command: the pieces for a project that takes only some of the kit. */
.pv-links {
  margin-top: var(--ui-space-6);
}

/* The footer of every page (src/docs/site-top.tsx): on /ui/ it spans the window under a line, in the reference it
   closes the page column. */
.dx-footer {
  padding-block: var(--ui-space-8);
  border-top: 1px solid var(--ui-border);
}

.dx .dx-footer {
  margin-top: var(--ui-gap-section);
  padding-bottom: 0;
}

/* ── Dock ──────────────────────────────────────────────────────────── */

/*
 * The bar keeps one size and shape whatever look is picked: it is the page's own control, not a sample of the look.
 * Its sizes are fixed rather than the theme's (which grow with Size and change with Corners), and its text is always Inter.
 */
.pv-dock {
  /* The bar's own corners: fixed on purpose, so it does not change shape with the look it sets. */
  --ui-radius-dock: 1.75rem;
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: var(--ui-z-sticky);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  max-width: calc(100vw - 1.5rem);
  padding: 0.25rem;
  border: 1px solid var(--ui-float-border);
  border-radius: var(--ui-radius-dock);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-lg);
  font-family: var(--ui-font-inter);
  translate: -50% 0;
}

/* Its buttons: one height, generous room around each icon, the same shape whatever the look. */
.pv-dock .ui-btn {
  gap: 0.5rem;
  height: 3rem;
  padding-inline: 1.125rem 1.25rem;
  border-radius: calc(var(--ui-radius-dock) - 0.25rem);
  font-family: var(--ui-font-inter);
  font-size: 0.9375rem;
  font-weight: 500;
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: normal;
}

.pv-dock .ui-btn--icon {
  width: 3rem;
  padding: 0;
}

.pv-dock .ui-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 1.75;
}

/* Sun in dark, moon in light. */
.pv-when-dark,
.pv-when-light {
  display: inline-flex;
}

.pv-when-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .pv-when-dark { display: inline-flex; }
  :root[data-theme="auto"] .pv-when-light { display: none; }
}

:root[data-theme="dark"] .pv-when-dark { display: inline-flex; }
:root[data-theme="dark"] .pv-when-light { display: none; }

/* The sliders, above the dock. Made only of the kit's own pieces. */
.pv-theme[popover] {
  position: fixed;
  inset: auto auto calc(var(--ui-space-4) + 4rem) 50%;
  width: min(calc(34rem * var(--ui-density)), calc(100vw - 1.5rem));
  max-width: none;
  max-height: calc(100dvh - 7rem);
  padding: var(--ui-pad);
  overflow-y: auto;
  border-radius: var(--ui-radius-xl);
  box-shadow: var(--ui-shadow-lg);
  transform-origin: bottom center;
  translate: -50% 0;
}


/* Two settings side by side where there is room, one under the other on a phone. */
.pv-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(calc(13rem * var(--ui-density)), 100%), 1fr));
  gap: var(--ui-space-5) var(--ui-gap-xl);
}

.pv-mode {
  display: flex;
}

.pv-mode .ui-segmented-item {
  flex: 1;
}

/* A short select at the end of a settings row. */
.pv-narrow {
  width: auto;
  min-width: 10rem;
}

/* ── The full list of components ───────────────────────────────────── */

.pv-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(21rem, 100%), 1fr));
  gap: var(--ui-gap-lg) var(--ui-gap-xl);
}

.pv-index-group {
  display: grid;
  gap: var(--ui-space-2);
  align-content: start;
}

/* ── A whole screen, framed ────────────────────────────────────────── */

/* The example screen is a window with an edge: its cards take the closer shadow, like cards in any panel. */
.pv-screen .ui-card {
  box-shadow: var(--ui-card-inner-shadow);
}

.pv-screen {
  overflow: hidden;
  border: 1px solid var(--ui-card-border);
  box-shadow: var(--ui-card-shadow);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-bg);
  background-image: var(--ui-card-fill);
}

.pv-screen-app,
.pv-screen-app .ui-sidebar {
  min-height: 0;
  height: auto;
}

.pv-screen-app .ui-sidebar {
  position: static;
}

.pv-slide {
  border-radius: var(--ui-radius-lg);
}

.pv-pop[popover] {
  position: absolute;
  inset: auto;
  top: calc(anchor(bottom) + 6px);
  left: anchor(left);
  width: 16rem;
}

/* Toasts made by the demo button slide in and out. */
.pv-toast {
  grid-template-columns: 1fr;
  animation: pv-toast-in var(--ui-dur) var(--ui-ease-out);
}

.pv-toast--leaving {
  opacity: 0;
  transform: translateY(0.75rem);
}

@keyframes pv-toast-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

/* The dock sits above the toasts' corner on a phone. */
#pv-toasts {
  bottom: 5.5rem;
}

/* ── Your look: the theme as one code ──────────────────────────────── */

.pv-yourlook {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--ui-gutter);
}

.pv-yourlook > .ui-stack {
  flex: 1 1 22rem;
}

.pv-code {
  font-size: clamp(1.125rem, 2.6vw, 1.75rem);
  font-weight: 500;
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.03em;
  /* A long theme code may break anywhere on a narrow screen (mono text otherwise stays on one line). */
  white-space: normal;
  overflow-wrap: anywhere;
}

.pv-yourlook-text {
  max-width: 46ch;
}

/* ── Small screens ─────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .pv-stage {
    padding: var(--ui-pad-lg);
    border-radius: var(--ui-radius-lg);
  }

  .pv-screen .ui-main {
    padding: var(--ui-space-4);
  }

  .pv-screen .ui-card-body {
    padding: var(--ui-space-4);
  }

  .pv-section-head {
    margin-bottom: var(--ui-space-6);
  }

  .pv-bento {
    margin-top: var(--ui-space-6);
  }

  .pv-index {
    gap: var(--ui-space-5);
  }

  .pv-yourlook .ui-btn {
    flex: 1 1 auto;
  }

  .pv-command {
    padding-left: var(--ui-space-4);
  }
}

/* ── Notifications ─────────────────────────────────────────────────── */

.pv-notify {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ui-gap-xl) var(--ui-gutter);
}

@media (min-width: 860px) {
  .pv-notify {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: calc(var(--ui-gap-xl) * 1.25);
  }
}

.pv-notify-card {
  padding: max(var(--ui-space-2), calc(var(--ui-pad) - var(--ui-space-3)));
}

.pv-toast-static {
  max-width: 24rem;
  box-shadow: var(--ui-shadow-md);
}

.pv-bell[popover] {
  position: absolute;
  inset: auto;
  top: calc(anchor(bottom) + 6px);
  left: anchor(left);
}

/* ── Small-screen menu ─────────────────────────────────────────────── */

.pv-burger {
  margin-inline-end: calc(var(--ui-space-1) * -1);
}

@media (min-width: 1024px) {
  .pv-burger {
    display: none;
  }
}

/* A sheet under the top bar; the links rise in one after another. */
.pv-nav[popover] {
  position: fixed;
  inset: 3.5rem 0 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--ui-space-6) var(--ui-space-4) 7rem;
  overflow-y: auto;
  border: 0;
  background: var(--ui-bg);
  color: var(--ui-fg);
  opacity: 0;
  transition:
    opacity var(--ui-dur) var(--ui-ease),
    overlay var(--ui-dur) allow-discrete,
    display var(--ui-dur) allow-discrete;
}

.pv-nav:popover-open {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

@starting-style {
  .pv-nav:popover-open {
    opacity: 0;
  }
}

.pv-nav-link {
  display: flex;
  align-items: baseline;
  gap: var(--ui-space-4);
  padding-block: var(--ui-space-3);
  border-bottom: 1px solid var(--ui-border);
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 600;
  --ui-icon-weight: var(--ui-icon-bold);
  line-height: 1.1;
  letter-spacing: -0.045em;
  text-decoration: none;
}

.pv-nav-foot {
  margin-top: var(--ui-space-6);
}

.pv-nav-link,
.pv-nav-foot {
  opacity: 0;
  translate: 0 1.25rem;
  transition:
    opacity var(--ui-dur-slow) var(--ui-ease-out),
    translate var(--ui-dur-slow) var(--ui-ease-out),
    color var(--ui-dur-fast) var(--ui-ease);
}

.pv-nav:popover-open .pv-nav-link,
.pv-nav:popover-open .pv-nav-foot {
  opacity: 1;
  translate: 0 0;
  transition-delay: calc(var(--i) * 45ms);
}

@starting-style {
  .pv-nav:popover-open .pv-nav-link,
  .pv-nav:popover-open .pv-nav-foot {
    opacity: 0;
    translate: 0 1.25rem;
  }
}

.pv-nav-link:hover {
  color: var(--ui-primary-text);
}

/* The page behind does not scroll while the menu is open. */
html:has(.pv-nav:popover-open) {
  overflow: hidden;
}


/* ── Examples (/ui/#examples): small working scenes ───────────────── */

/* The examples: a section of the page like the others, with its filter under the heading. */
/* Cards of one height per row; a wide scene takes two columns, and smaller ones fill the gaps. */
.pv-scenes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row dense;
  gap: var(--ui-gutter);
}

@media (min-width: 680px) {
  .pv-scenes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pv-scene--wide {
    grid-column: span 2;
  }
}

@media (min-width: 1080px) {
  .pv-scenes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* One scene: a stage with the working piece, and a caption that names it and the parts it uses. */
.pv-scene {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: clip;
  border: 1px solid var(--ui-card-border);
  border-radius: var(--ui-radius-xl);
  background: var(--ui-surface-2);
  color: var(--ui-fg);
  transition:
    opacity calc(var(--ui-dur-slow) * 1.6) var(--ui-ease),
    translate calc(var(--ui-dur-slow) * 1.6) var(--ui-ease-out);
  transition-delay: calc(var(--i, 0) * 80ms);
}

/* Rises in when it comes on screen; without scripts it is simply there. */
.pv-js .pv-scene:not([data-shown]) {
  opacity: 0;
  translate: 0 2rem;
}

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

  .pv-js .pv-scene:not([data-shown]) {
    opacity: 1;
    translate: none;
  }
}

/* The colours a scene can stand on. All come from the theme: grey layers, a hue, the ink, the brand, a painting. */
.pv-scene--plain,
.pv-scene--paint {
  background: var(--ui-bg);
}

.pv-scene--soft {
  background: var(--ui-surface-3);
}

.pv-scene--tone {
  background: light-dark(oklch(0.935 0.045 var(--tone)), oklch(0.29 0.05 var(--tone)));
}

/* Ink: the scene is dark whatever the page is (data-theme="dark" on it). */
.pv-scene--ink {
  border-color: transparent;
  background: var(--ui-surface-2);
}

.pv-scene--brand {
  border-color: transparent;
  background: var(--ui-primary);
  color: var(--ui-on-primary);
}

.pv-scene-stage {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 15rem;
  padding: var(--ui-pad-lg);
  isolation: isolate;
}

/* On a phone the stage keeps a thin edge round its piece, so the piece keeps the width. */
@media (max-width: 480px) {
  .pv-scene-stage {
    padding: var(--ui-space-3);
  }
}

/* The painting under a paint scene, inset like a well so the piece sits on it. */
.pv-scene-paint {
  position: absolute;
  inset: var(--ui-space-3);
  z-index: -1;
  border-radius: var(--ui-radius-lg);
}

.pv-scene-body {
  width: 100%;
  max-width: 24rem;
  min-width: 0;
}

.pv-scene--wide .pv-scene-body {
  max-width: 46rem;
}

/*
 * Flush: the scene's card is the tile itself, straight on the page. Mixed with the scenes on a
 * coloured stage, so the wall is not card in card everywhere. A flush ink scene is a dark card on the light page.
 */
.pv-scene--flush {
  border-color: transparent;
  background: transparent;
  overflow: visible;
}

.pv-scene--flush .pv-scene-stage {
  place-items: stretch;
  min-height: 0;
  padding: 0;
  background: none;
}

.pv-scene--flush .pv-scene-body,
.pv-scene--wide.pv-scene--flush .pv-scene-body {
  display: grid;
  max-width: none;
}

/* The card hugs its content: a card never grows empty room inside to match a taller neighbour. */
.pv-scene--flush .pv-scene-stage {
  flex: none;
}

/* ── Component reference (/ui/components/, src/docs/app.tsx) ───────── */

/*
 * A bar on top; under it the families in a sticky sidebar, the page in a reading column, and "On this page" at the
 * right. Narrower, "On this page" goes first; on a phone the sidebar moves into the drawer the bar's menu opens.
 */
/* The reference's pages (.dx) and /ui/ (.pv) share the top bar (src/docs/site-top.tsx), so they share its sizes. */
:is(.dx, .pv) {
  --dx-top: calc(var(--ui-h-md) + var(--ui-space-4));
  --dx-side: 15.5rem;
  --dx-toc: 12rem;
  /* The page beside the sidebar: reading column and "On this page", centred, never wider than this. */
  --dx-frame: 66rem;
}

.dx-skip:focus {
  position: fixed;
  z-index: var(--ui-z-toast);
  top: var(--ui-space-2);
  inset-inline-start: var(--ui-space-2);
  width: auto;
  height: auto;
  padding: var(--ui-space-2) var(--ui-space-3);
  clip-path: none;
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
}

.dx-top {
  /* The bar and the sidebar stay still from page to page; only the page between them fades (page-transitions.css). */
  view-transition-name: dx-top;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-bg);
}

.dx-top-inner {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  max-width: var(--dx-frame);
  height: var(--dx-top);
  margin-inline: auto;
  padding-inline: var(--ui-gap-lg);
}

.dx-brand {
  display: flex;
  align-items: baseline;
  gap: var(--ui-space-2);
  color: var(--ui-fg);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  text-decoration: none;
  white-space: nowrap;
}

.dx-mark {
  width: 1.1rem;
  height: 1.15rem;
  align-self: center;
  fill: currentColor;
}

.dx-search {
  flex: 1;
  max-width: 22rem;
  margin-inline-start: auto;
  justify-content: flex-start;
  color: var(--ui-fg-muted);
  text-align: start;
}

.dx-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--dx-frame);
  margin-inline: auto;
}

.dx-side {
  display: none;
}

.dx-main {
  min-width: 0;
  padding: var(--ui-gap-xl) var(--ui-space-4) var(--ui-gap-section);
  outline: none;
}

.dx-families {
  display: grid;
  gap: var(--ui-space-5);
}

/* A hairline between the sections, with the same room above and below it. */
.dx-family + .dx-family {
  padding-top: var(--ui-space-5);
  border-top: 1px solid var(--ui-border);
}

.dx-family-name {
  padding-inline: var(--ui-space-3);
  margin-block-end: var(--ui-space-1);
}

.dx-family .ui-nav {
  flex-direction: column;
}

.dx-family .ui-nav-item {
  height: var(--ui-h-sm);
  font-size: var(--ui-text-sm);
}

.dx-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ui-gap-xl);
}

/* Between the sections of a reading page: more than between blocks, less than between a site's bands. */
.dx-article.ui-stack,
.dx-list.ui-stack {
  --gap: calc(var(--ui-gap-xl) * 1.75);
}

/* The list of components keeps the same reading width as a component's page. */
.dx-list {
  min-width: 0;
  max-width: 48rem;
}

/*
 * The board on the first page (src/docs/start.tsx): a few working components on one surface, a hairline between
 * them, each with its name under it. It lays itself out by its own width, not the window's: one column, then two,
 * then a board of six tracks where the wide pieces take three and the tall ones two rows.
 */
.dx-board-box {
  container-type: inline-size;
}

.dx-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  overflow: clip;
  border: 1px solid var(--ui-card-border);
  border-radius: var(--ui-radius-lg);
  /* The lines between the pieces are the gaps: a hairline over the surface. */
  background: linear-gradient(var(--ui-border), var(--ui-border)), var(--ui-surface);
  background-clip: padding-box;
}

.dx-cell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--ui-space-4);
  min-width: 0;
  min-height: 9.5rem;
  padding: var(--ui-space-5);
  background: var(--ui-surface);
}

.dx-cell-stage {
  display: grid;
  place-items: center;
  min-width: 0;
}

.dx-cell-stage > * {
  max-width: 100%;
}

.dx-cell-name {
  justify-self: start;
  color: var(--ui-fg-muted);
}

/* The painted picture fills its piece: wide in one column, square once it has a narrow piece of its own. */
.dx-cell--picture .dx-cell-stage > * {
  --ratio: 5 / 2;
  justify-self: stretch;
  width: 100%;
}

@container (min-width: 34rem) {
  .dx-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dx-cell--button,
  .dx-cell--segmented {
    grid-column: span 2;
  }

  .dx-cell--picture .dx-cell-stage > * {
    --ratio: 1 / 1;
    max-width: 14rem;
    justify-self: center;
  }
}

@container (min-width: 43rem) {
  .dx-board {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .dx-cell {
    grid-column: span 2;
  }

  .dx-cell--button,
  .dx-cell--segmented {
    grid-column: span 3;
  }

  .dx-cell--calendar,
  .dx-cell--picture {
    grid-row: span 2;
  }
}

.dx-article {
  min-width: 0;
  max-width: 48rem;
}

/*
 * A page of text (the guide, the release notes: src/docs/text.tsx). Text keeps the kit's reading width; tables and
 * code take the column. A long script scrolls inside its block, so the page stays a page.
 */
.dx-text .ui-pre {
  max-height: 26rem;
  overflow: auto;
}

/* Code in a table of the guide is often a whole line (a component with its options): it wraps like the text beside it,
   so a row turned into a block on a phone fits the screen and the table never scrolls sideways. */
.dx-text :is(td, th) .ui-code {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* A heading inside a chapter stands a little apart from what came before it. */
.dx-chapter > .dx-sub:not(:first-child) {
  margin-block-start: var(--ui-space-4);
}

/* A release: its number, and its day beside it on the same line of text. */
.dx-release {
  align-items: baseline;
}

/* A numbered list whose numbers are written out: the guide's rules go on after a block of code, at 11 and at 14. */
.dx-steps {
  display: grid;
  gap: var(--ui-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.dx-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--ui-space-3);
}

.dx-step-n {
  /* As tall as one line of the text beside it, so the number sits on the first line. */
  --_n: calc(var(--ui-text-md) * 1.65);
  display: grid;
  place-items: center;
  width: var(--_n);
  height: var(--_n);
  border-radius: var(--ui-radius-round);
  background: var(--ui-surface-3);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
  color: var(--ui-fg-muted);
}

.dx-toc {
  display: none;
}

.dx-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: var(--ui-space-3);
}

.dx-tile {
  display: grid;
  align-content: start;
  gap: var(--ui-space-1);
  padding: var(--ui-pad-sm);
}

.dx-type {
  /* A long type is a small block of its own: it wraps inside its grey, with room on every side. */
  display: inline-block;
  max-width: 100%;
  padding: var(--ui-space-1) var(--ui-space-2);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: var(--ui-leading);
}

.dx-preview {
  display: grid;
  min-height: 12rem;
  padding: var(--ui-pad-lg) var(--ui-pad);
  border: 1px solid var(--ui-card-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  background-clip: padding-box;
}

/* The preview sits in the middle of its box, at its own width, never wider than the box. A column of things (a form,
   a list) takes a comfortable reading width; something made to fill its box (marked ui-grow, a table, a screen, a
   split) takes the whole box. */
.dx-preview-stage {
  display: grid;
  place-items: center;
  min-width: 0;
}

.dx-preview-stage > * {
  max-width: 100%;
}

.dx-preview-stage > :is(.ui-stack, .ui-list, .ui-card, .ui-cells, .ui-accordion, .ui-dl, .ui-fieldset, .ui-alert, .ui-inset, .ui-ratio) {
  justify-self: stretch;
  width: min(100%, 30rem);
  margin-inline: auto;
}

/* One field: the width of a field in a form. */
.dx-preview-stage > :is(.ui-field, .ui-input-group) {
  justify-self: stretch;
  width: min(100%, 22rem);
  margin-inline: auto;
}

.dx-preview-stage > :is(.ui-grow, .ui-grid, .ui-split, .ui-page-header, .ui-table-wrap, .ui-app, .ui-site-page, .ui-board, .ui-resizable, .ui-tabs) {
  justify-self: stretch;
  width: 100%;
}

/* A whole screen or site page, shown in a box: its own height, not the window's. */
.dx-preview-stage :is(.ui-app, .ui-site-page) {
  min-height: 0;
}

.dx-examples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr));
  gap: var(--ui-gap-lg);
  align-items: start;
}

.dx-example .pv-scene-stage {
  min-height: 0;
}

.dx-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ui-space-3);
  padding-block-start: var(--ui-gap-lg);
  border-top: 1px solid var(--ui-border);
}

.dx-pager-link {
  display: grid;
  gap: 2px;
  padding: var(--ui-pad-sm);
}

.dx-pager-link--next {
  grid-column: 2;
  text-align: end;
}

/* A computer: the sidebar is a full-height column at the window's left edge, under the bar; the page is centred in
   the room beside it. The menu button goes. */
@media (min-width: 900px) {
  .dx-top-inner {
    max-width: none;
    padding-inline: var(--ui-space-5) var(--ui-gap-lg);
  }

  .dx-shell {
    max-width: none;
    padding-inline-start: var(--dx-side);
  }

  .dx-side {
    view-transition-name: dx-side;
    position: fixed;
    inset-block: var(--dx-top) 0;
    inset-inline-start: 0;
    display: block;
    width: var(--dx-side);
    padding: var(--ui-space-4) var(--ui-space-3) var(--ui-gap-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-inline-end: 1px solid var(--ui-border);
    background: var(--ui-surface);
  }

  .dx-menu {
    display: none;
  }

  .dx-main {
    /* Always the full frame: as a grid item with auto margins it would otherwise take its content's width, so the
       column changed size from page to page. */
    width: 100%;
    max-width: var(--dx-frame);
    margin-inline: auto;
    padding-inline: var(--ui-gap-xl);
  }
}

/* Wide: "On this page" at the right of the reading column. */
@media (min-width: 1240px) {
  .dx-page {
    grid-template-columns: minmax(0, 1fr) var(--dx-toc);
  }

  .dx-toc {
    position: sticky;
    top: calc(var(--dx-top) + var(--ui-gap-lg));
    display: grid;
    align-self: start;
    gap: var(--ui-space-2);
  }

  .dx-toc .ui-nav {
    flex-direction: column;
  }

  /* A long name (a chapter of the guide) takes a second line: it never runs out of the column. */
  .dx-toc .ui-nav-item {
    height: auto;
    min-height: var(--ui-h-sm);
    padding-block: var(--ui-space-1);
    font-size: var(--ui-text-sm);
    white-space: normal;
  }
}

.dx-links {
  flex-direction: row;
}

/* Below a computer the pages move into the kit's site menu (its two-line button at the end of the bar), so the bar never runs out. */
@media (max-width: 899px) {
  .dx-links {
    display: none;
  }
}

/* A phone: the search keeps its room. */
@media (max-width: 640px) {
  .dx-brand .ui-mono {
    display: none;
  }

  .dx-search .ui-kbd,
  .dx-search-more {
    display: none;
  }
}

/* The smallest phones: search is its icon alone (its name stays for screen readers). */
@media (max-width: 360px) {
  .dx-search > .ui-grow {
    display: none;
  }

  .dx-search {
    flex: none;
  }
}
