/* Tune.Toys documentation site. Tokens mirror packages/brand/src/tokens.css (ink, paper, orange, mint, lilac). */
/* DM Sans from brand/fonts (latin, OFL), copied to /fonts/ by build.mjs. Relative URLs keep /v/ snapshots self-contained. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/dm-sans-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/dm-sans-medium.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/dm-sans-bold.woff2') format('woff2');
}
:root {
  color-scheme: light;
  --ink: #1c1c1b;
  --paper: #fafaf7;
  --surface: #ffffff;
  --muted: #64645f;
  --line: #dcdcd4;
  --brand: #f0442e;
  --brand-ink: #b22914;
  --accent-mint: #3f7d49;
  --accent-lilac: #6a5bb5;
  --mint: #dcebdd;
  --lilac: #ded8f0;
  --code-bg: #f1f1ec;
  --radius: 12px;
  --radius-panel: 20px;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'DM Sans', Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar: 280px;
  --toc: 220px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --ink: #f2f2ec;
    --paper: #151514;
    --surface: #1f1f1d;
    --muted: #a3a39b;
    --line: #34342f;
    --brand: #ff6a55;
    --brand-ink: #ff8f7e;
    --accent-mint: #86c28f;
    --accent-lilac: #aa9ee6;
    --mint: #25382a;
    --lilac: #302b47;
    --code-bg: #262624;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #f2f2ec;
  --paper: #151514;
  --surface: #1f1f1d;
  --muted: #a3a39b;
  --line: #34342f;
  --brand: #ff6a55;
  --brand-ink: #ff8f7e;
  --accent-mint: #86c28f;
  --accent-lilac: #aa9ee6;
  --mint: #25382a;
  --lilac: #302b47;
  --code-bg: #262624;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-padding-top: 76px;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
}
a {
  color: var(--brand-ink);
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-thickness: 2px;
}
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-links {
  position: absolute;
  left: 8px;
  top: -200px;
  z-index: 100;
  display: flex;
  gap: 8px;
}
.skip-links a {
  background: var(--ink);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: var(--radius);
}
.skip-links:focus-within {
  top: 8px;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.brand img {
  width: 28px;
  height: 28px;
}
.brand small {
  color: var(--muted);
  font-weight: 500;
}
.header-links {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.header-links a,
.header-actions a,
.header-actions button,
.nav-toggle {
  color: var(--ink);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.header-links a:hover,
.header-actions a:hover,
.header-actions button:hover,
.nav-toggle:hover {
  border-color: var(--line);
  background: var(--surface);
}
.header-links a[aria-current] {
  font-weight: 700;
  color: var(--brand-ink);
}
/* Search: a header button opens the ⌘K palette (a modal <dialog>); docs.js reveals the button. */
.search {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.search-trigger:hover {
  border-color: var(--muted);
}
.search-trigger span {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.search-trigger svg,
.palette-field svg {
  flex: none;
}
kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--muted);
  font: 12px/1.5 var(--sans);
  white-space: nowrap;
}
.palette {
  width: min(640px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 96px));
  margin: 10vh auto 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.28);
}
.palette[open] {
  display: flex;
  flex-direction: column;
}
.palette::backdrop {
  background: rgb(21 21 20 / 0.45);
}
.palette-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.palette-field input {
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.palette-field input::-webkit-search-cancel-button {
  display: none;
}
.search-results {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
}
.search-results a {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}
.search-results [aria-selected='true'] a {
  background: var(--mint);
}
.search-results mark {
  background: none;
  color: var(--brand-ink);
  font-weight: 700;
}
.search-results small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.search-results .palette-group {
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search-results .search-empty {
  padding: 12px 10px;
  color: var(--muted);
}
.palette-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.nav-toggle {
  display: none;
  border-color: var(--line);
}
.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  gap: 32px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
}
.sidebar {
  position: sticky;
  top: 57px;
  align-self: start;
  max-height: calc(100vh - 57px);
  overflow: auto;
  padding: 20px 4px 40px 0;
  font-size: 14.5px;
}
.sidebar details {
  margin: 2px 0;
}
.sidebar summary {
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.sidebar summary:hover {
  background: var(--surface);
}
.sidebar ul {
  margin: 0 0 6px 12px;
  padding: 0 0 0 10px;
  list-style: none;
  border-left: 1px solid var(--line);
}
.sidebar li a {
  display: block;
  padding: 3px 8px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.sidebar li a:hover {
  background: var(--surface);
}
.sidebar a[aria-current='page'] {
  background: var(--mint);
  font-weight: 700;
}
.content {
  min-width: 0;
  padding: 28px 0 80px;
}
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--muted);
}
.breadcrumbs li + li::before {
  content: '/';
  margin-right: 8px;
}
.breadcrumbs a {
  color: var(--muted);
}
.page-actions {
  float: right;
  display: flex;
  gap: 4px;
  margin: 0 0 8px 16px;
}
.page-actions button,
.page-actions a {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.page-actions button:hover,
.page-actions a:hover {
  color: var(--ink);
}
h1 {
  margin: 0 0 8px;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.lede {
  margin: 0 0 20px;
  font-size: 1.15rem;
  color: var(--muted);
}
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 2em 0 0.6em;
}
h2 {
  font-size: 1.6rem;
  padding-top: 0.4em;
  border-top: 1px solid var(--line);
}
h3 {
  font-size: 1.25rem;
}
.anchor {
  margin-left: 8px;
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  color: var(--muted);
}
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
.anchor:focus {
  opacity: 1;
}
.prose {
  max-width: 78ch;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1em;
}
.prose li {
  margin: 0.25em 0;
}
.prose img {
  max-width: 100%;
  height: auto;
}
code {
  padding: 0.12em 0.4em;
  background: var(--code-bg);
  border-radius: 6px;
  font: 0.88em var(--mono);
}
pre {
  position: relative;
  overflow: auto;
  margin: 0 0 1.2em;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: 13.5px/1.55 var(--mono);
}
pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}
.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 12px var(--sans);
  cursor: pointer;
}
/* Syntax roles from lib/code.mjs (Shiki at build time), drawn from the brand tokens. */
.tk-keyword {
  color: var(--accent-lilac);
}
.tk-string {
  color: var(--accent-mint);
}
.tk-constant,
.tk-link {
  color: var(--brand-ink);
}
.tk-function {
  font-weight: 600;
}
.tk-parameter {
  font-style: italic;
}
.tk-comment {
  color: var(--muted);
  font-style: italic;
}
.tk-punctuation {
  color: var(--muted);
}
/* JSON viewer: nested details from lib/code.mjs. docs.js adds the toolbar and Raw view. */
.json-viewer {
  margin: 0 0 1.2em;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: 13.5px/1.55 var(--mono);
}
.jv-tree {
  overflow: auto;
  padding: 14px 16px 14px 30px;
}
.jv-children {
  padding-left: 2ch;
}
.jv-row,
.json-viewer summary {
  white-space: pre;
}
.json-viewer summary {
  position: relative;
  border-radius: 4px;
  list-style: none;
  cursor: pointer;
}
.json-viewer summary::-webkit-details-marker {
  display: none;
}
.json-viewer summary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -14px;
  width: 6px;
  height: 6px;
  margin-top: -4px;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
}
.json-viewer details[open] > summary::before {
  margin-top: -5px;
  transform: rotate(45deg);
}
.json-viewer summary:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.jv-fold,
.jv-size {
  display: none;
}
.json-viewer details:not([open]) > summary > .jv-fold {
  display: inline;
}
.json-viewer details:not([open]) > summary > .jv-size {
  display: inline;
  margin-left: 1.5ch;
  color: var(--muted);
  font: 12px var(--sans);
}
.json-viewer .jv-raw {
  margin: 0;
  border: 0;
  border-radius: 0;
}
.jv-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.jv-toolbar button {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 12px var(--sans);
  cursor: pointer;
}
.jv-toolbar button[aria-pressed='true'] {
  border-color: var(--ink);
}
.jv-toolbar button:disabled {
  opacity: 0.45;
  cursor: default;
}
blockquote {
  margin: 0 0 1em;
  padding: 2px 16px;
  border-left: 4px solid var(--brand);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.2em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
th,
td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
th {
  background: var(--surface);
  white-space: nowrap;
}
tr:last-child td {
  border-bottom: 0;
}
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  vertical-align: middle;
}
.badge.planned {
  background: var(--lilac);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.banner {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-lilac);
  border-radius: var(--radius);
  background: var(--surface);
}
.banner[hidden] {
  display: none;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 20px;
}
.button {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
}
.button:hover {
  background: var(--brand-ink);
  color: #fff;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}
.cards a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.cards a:hover {
  border-color: var(--brand);
}
.cards strong {
  display: block;
}
.cards span {
  color: var(--muted);
  font-size: 14.5px;
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.pager a {
  display: block;
  max-width: 48%;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.pager a:hover {
  border-color: var(--brand);
}
.pager small {
  display: block;
  color: var(--muted);
}
.pager .next {
  margin-left: auto;
  text-align: right;
}
.page-meta {
  margin-top: 24px;
  color: var(--muted);
  font-size: 14px;
}
.toc {
  position: sticky;
  top: 57px;
  align-self: start;
  max-height: calc(100vh - 57px);
  overflow: auto;
  padding: 28px 0;
  font-size: 13.5px;
}
.toc h2 {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.toc li a {
  display: block;
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  text-decoration: none;
}
.toc li.l3 a {
  padding-left: 22px;
}
.toc li a:hover,
.toc li a[aria-current='true'] {
  color: var(--ink);
  border-left-color: var(--brand);
}
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-top: 24px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.site-footer p {
  margin: 0;
}
.site-footer a {
  color: inherit;
  white-space: nowrap;
}
.site-footer a:hover {
  color: var(--ink);
}
.social-links {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.social-links a {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.social-links a:hover {
  background: var(--surface);
}
figure.diagram {
  margin: 0 0 1.4em;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  overflow-x: auto;
}
figure.diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
}
/* The editor's node card (lib/node-cards.mjs); port dots overhang its edges. */
figure.node-card-figure {
  padding: 20px 28px 12px;
}
figure.node-card-figure .node-card {
  display: block;
  width: fit-content;
  margin: 0 auto 8px;
}
/* A live embed from the app (docs.js) replaces its build-time poster once it answers; it
   reports its own height, so the frame never scrolls. */
figure.live-figure iframe {
  display: block;
  width: 100%;
  height: 360px;
  margin: 0 0 8px;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
}
/* A Patch diagram is the editor canvas at 100%: wide patches scroll inside the figure. */
figure.patch-diagram-figure .patch-diagram {
  display: block;
  width: max-content;
  min-width: 100%;
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
}
figure.diagram figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13.5px;
}
/* Mermaid diagrams are authored in the light brand palette, so their card stays paper in both
   themes. Until drawn (or without JavaScript) the card shows the diagram source. */
figure.mermaid-diagram {
  border-color: #dcdcd4;
  background: #fafaf7;
}
pre.mermaid {
  margin: 0;
  padding: 4px;
  border: 0;
  background: none;
  color: #1c1c1b;
}
pre.mermaid:has(svg) {
  font: inherit;
  white-space: normal;
}
figure.mermaid-diagram svg {
  margin: 0 auto;
}
details.connections {
  margin: 0 0 1.2em;
}
details.connections summary {
  cursor: pointer;
  color: var(--muted);
}
.patch-card {
  margin: 0 0 2em;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}
.patch-card h3 {
  margin-top: 0;
}
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}
@media (max-width: 800px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .nav-toggle {
    display: inline-block;
  }
  .header-links {
    display: none;
  }
  .sidebar {
    position: fixed;
    inset: 57px 0 0 0;
    z-index: 30;
    max-height: none;
    padding: 16px;
    background: var(--paper);
    transform: translateX(-100%);
    visibility: hidden;
  }
  .sidebar[data-open='true'] {
    transform: none;
    visibility: visible;
  }
  .search {
    max-width: none;
  }
  .brand small {
    display: none;
  }
}
@media (max-width: 600px) {
  /* Phone header: Menu, logo, search and Theme; the app link stays in the footer. */
  .site-header {
    gap: 8px;
  }
  .brand span,
  .header-actions a {
    display: none;
  }
  .search {
    min-width: 0;
  }
  .search-trigger kbd,
  .palette-hints {
    display: none;
  }
  .palette {
    margin-top: 12px;
  }
  .page-actions {
    float: none;
    margin: 0 0 8px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .sidebar {
    transition:
      transform 0.2s ease,
      visibility 0.2s;
  }
}
@media print {
  .site-header,
  .sidebar,
  .toc,
  .pager,
  .skip-links,
  .copy-button,
  .jv-toolbar,
  .page-actions,
  .social-links {
    display: none;
  }
  .layout {
    display: block;
  }
}

/* Patch diagrams (tools/render-patch-diagram.mjs) */
.pd{--pd-ink:var(--ink,#1c1c1b);--pd-paper:var(--surface,#fafaf7);--pd-muted:var(--muted,#64645f);--pd-audio:var(--brand,#f0442e);--pd-control:var(--accent-lilac,#7d6fc4);--pd-event:var(--accent-mint,#4f8f57)}
.pd text{font:12px system-ui,sans-serif;fill:var(--pd-ink)}
.pd .pd-sub,.pd .pd-port,.pd .pd-legend{fill:var(--pd-muted);font-size:10.5px}
.pd .pd-box{fill:var(--pd-paper);stroke:var(--pd-ink);stroke-width:1.5}
.pd .pd-head-text{font-weight:600;fill:#1c1c1b}
.pd .pd-cable{fill:none;stroke-width:2;stroke-linecap:round}
.pd .pd-audio{stroke:var(--pd-audio);color:var(--pd-audio)}
.pd .pd-control{stroke:var(--pd-control);color:var(--pd-control)}
.pd .pd-event{stroke:var(--pd-event);color:var(--pd-event)}
.pd .pd-dot{stroke:none;fill:currentColor}
.pd .pd-frame{fill:var(--pd-paper);stroke:var(--pd-ink);stroke-width:1.5}
.pd .pd-widget{fill:none;stroke:var(--pd-muted);stroke-width:1;stroke-dasharray:3 3}
.pd .pd-track{fill:none;stroke:var(--pd-muted);stroke-width:4;stroke-linecap:round}
.pd .pd-value{fill:none;stroke:var(--pd-audio);stroke-width:4;stroke-linecap:round}
.pd .pd-key{fill:var(--pd-paper);stroke:var(--pd-ink);stroke-width:1}
.pd .pd-key-black{fill:var(--pd-ink)}
.pd .pd-fill{fill:var(--pd-audio)}
