/* The demo site's own frame. Every colour is a role or a finer token of the theme that is on, every size a scale,
   so the page itself is a test of both. The parts bring their own sheets (ui.css, picker.css, flow.css). */
html { background: var(--bg); color: var(--text); font-size: var(--fs-14); line-height: var(--lh-body); scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
button { font: inherit; color: inherit; }

/* ---- the bar */
.d-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: var(--line-hair) solid var(--border); padding-top: env(safe-area-inset-top); }
.d-bar-in { display: flex; align-items: center; gap: var(--s-2); max-width: 1240px; margin: 0 auto; padding: var(--s-2) max(var(--s-4), env(safe-area-inset-right)) var(--s-2) max(var(--s-4), env(safe-area-inset-left)); min-height: 56px; box-sizing: border-box; }
.d-name { font-size: var(--fs-20); font-weight: var(--fw-display); letter-spacing: -0.02em; }
.d-version { font-size: var(--fs-12); color: var(--muted); padding: 2px var(--s-2); border: var(--line-hair) solid var(--border); border-radius: var(--r-pill); }
.d-version:empty { display: none; }
.d-grow { flex: 1; }
.d-chip { display: inline-flex; align-items: center; gap: var(--s-2); min-height: max(36px, var(--hit)); max-width: 56vw; padding: 0 var(--s-3) 0 var(--s-2); border-radius: var(--r-pill); background: var(--panel); border: var(--line-hair) solid var(--control-border); cursor: pointer; }
.d-look-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: var(--line-hair) solid var(--control-border); background: radial-gradient(circle, var(--accent) 0 34%, var(--bg) 38%); }
.d-look-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-13); }
.d-icon { display: inline-grid; place-items: center; width: max(36px, var(--hit)); height: max(36px, var(--hit)); padding: 0; border-radius: var(--r-button); background: none; border: var(--line-hair) solid transparent; cursor: pointer; }
.d-icon .ic, .d-note-b .ic { width: var(--s-5); height: var(--s-5); }
.d-flip .ic { transform: scaleX(-1); }

/* ---- the page: the list of parts beside the cards from 1000 px */
.d-page { max-width: 1240px; margin: 0 auto; padding: 0 max(var(--s-4), env(safe-area-inset-right)) calc(var(--s-12) + env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left)); }
.d-nav { display: none; }
main { min-width: 0; }
@media (min-width: 1000px) {
  .d-page { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s-8); }
  .d-nav { display: flex; flex-direction: column; position: sticky; top: 57px; align-self: start; max-height: calc(100dvh - 57px); overflow-y: auto; padding: var(--s-6) 0; box-sizing: border-box; }
  .d-parts-button { display: none; }
}
.d-nav-part { margin: var(--s-4) 0 var(--s-1); padding: 0 var(--s-3); font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.d-nav-part:first-child { margin-top: 0; }
.d-nav-link { text-align: left; padding: 6px var(--s-3); border: 0; border-radius: var(--r-control); background: none; color: var(--muted); cursor: pointer; font-size: var(--fs-14); }
.d-nav-link[aria-current] { background: var(--sel); color: var(--text); }

.d-top { padding: var(--s-12) 0 var(--s-8); display: flex; flex-direction: column; gap: var(--s-4); align-items: flex-start; }
.d-top h1 { font-size: clamp(44px, 9vw, 72px); font-weight: var(--fw-display); line-height: 1; letter-spacing: -0.04em; }
.d-lead { font-size: var(--fs-18); max-width: 56ch; }
.d-facts { color: var(--muted); font-size: var(--fs-13); }

/* ---- a card */
.d-part { margin: 0 0 var(--s-6); padding: var(--s-5); background: var(--panel); border: var(--line-hair) solid var(--border); border-radius: var(--r-card); }
.d-part-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.d-kicker { font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.d-part h2 { font-size: var(--fs-24); font-weight: var(--fw-strong); line-height: var(--lh-heading); letter-spacing: -0.01em; }
.d-part h3 { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--muted); margin-top: var(--s-3); }
.d-about { margin-top: var(--s-3); max-width: 72ch; font-size: var(--fs-16); color: var(--text); }
.d-stage { margin-top: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.d-note, .d-out { color: var(--muted); font-size: var(--fs-13); max-width: 72ch; }
.d-out { min-height: 1.45em; color: var(--text); }
.d-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.d-note-b { display: inline-flex; align-items: center; gap: var(--s-2); flex: none; }
a.b { display: inline-flex; align-items: center; text-decoration: none; box-sizing: border-box; }
.b[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.b:disabled { opacity: .5; cursor: default; }
.d-count { min-width: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-text); font-size: var(--fs-12); text-align: center; }
.d-count[hidden] { display: none; }
.d-use { margin-top: var(--s-5); border-top: var(--line-hair) solid var(--border); }
.d-use summary, .d-more summary, .d-release summary { cursor: pointer; min-height: max(36px, var(--hit)); display: flex; align-items: center; color: var(--muted); font-size: var(--fs-13); }
.d-use pre, .d-excerpt { margin: 0; padding: var(--s-3) var(--s-4); overflow-x: auto; background: var(--sunk, var(--panel-2)); border: var(--line-hair) solid var(--border); border-radius: var(--r-control); font-size: var(--fs-13); line-height: 1.55; -webkit-overflow-scrolling: touch; }
.d-foot { padding: var(--s-6) 0; color: var(--muted); font-size: var(--fs-13); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2); }

/* ---- fields */
.d-field { box-sizing: border-box; min-height: max(36px, var(--hit)); padding: var(--s-2) var(--s-3); font: inherit; font-size: var(--fs-16); color: var(--text); background: var(--bg); border: var(--line-hair) solid var(--control-border); border-radius: var(--r-control); min-width: 0; }
.d-form { display: flex; flex-direction: column; gap: var(--s-3); }
.d-note-box { width: 100%; resize: vertical; line-height: var(--lh-body); }
.d-earlier { display: flex; flex-direction: column; gap: var(--s-3); }
.d-earlier:empty { display: none; }
.d-earlier-one { padding: var(--s-3); background: var(--panel-2); border-radius: var(--r-control); white-space: pre-wrap; overflow-wrap: anywhere; }
.d-earlier-when { color: var(--muted); font-size: var(--fs-12); }
.d-line { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); min-height: max(40px, var(--hit)); }
.d-line .d-field { max-width: 60%; }
.d-check { display: inline-flex; align-items: center; gap: var(--s-2); min-height: max(36px, var(--hit)); }
.d-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
@media (min-width: 600px) { .sheet.d-sheet-wide { --sheet-w: 760px; } }

/* ---- themes: the sample screen beside the picker */
.d-split { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .d-split { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; } .d-sample { position: sticky; top: 72px; } }
.d-sample { display: flex; flex-direction: column; gap: var(--s-2); }
.d-sample-step { display: flex; align-items: center; gap: var(--s-2); }
.d-sample-step .d-icon { border-color: var(--control-border); background: var(--panel-2); }
.d-sample-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.d-sample-name { font-size: var(--fs-18); font-weight: var(--fw-strong); line-height: var(--lh-heading); }
.d-sample-n { font-size: var(--fs-12); color: var(--muted); }
.d-s-app { display: flex; overflow: hidden; background: var(--bg); border: var(--line-hair) solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-2, none); }
.d-s-side { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4) var(--s-3); background: var(--side); border-right: var(--line-hair) solid var(--border); color: var(--muted); }
.d-s-side .ic { width: var(--s-5); height: var(--s-5); }
.d-s-side .ic:first-child { color: var(--accent); }
.d-s-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: var(--s-3); gap: var(--s-1); }
.d-s-head { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2) var(--s-2); }
.d-s-h { font-size: var(--fs-18); font-weight: var(--fw-strong); }
.d-s-badge { padding: 0 6px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-text); font-size: var(--fs-12); }
.d-s-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-control); }
.d-s-row.sel { background: var(--sel); }
.d-s-row .ic { flex: none; width: var(--s-5); height: var(--s-5); color: var(--muted); }
.d-s-row .ic:last-child { width: var(--s-4); height: var(--s-4); transform: rotate(-90deg); }
.d-s-words { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.d-s-title { font-weight: var(--fw-strong); }
.d-s-sub { color: var(--muted); font-size: var(--fs-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-s-status { display: flex; flex-wrap: wrap; gap: var(--s-3); padding: var(--s-2); font-size: var(--fs-13); font-weight: var(--fw-strong); }
.d-s-status .ok { color: var(--ok); } .d-s-status .warn { color: var(--warn); } .d-s-status .error { color: var(--error); } .d-s-status .info { color: var(--info, var(--accent)); }
.d-s-send { display: flex; gap: var(--s-2); padding-top: var(--s-1); }
.d-s-send .d-field { flex: 1; background: var(--panel); }
.d-picker { min-width: 0; }

/* ---- chroma flow */
.d-ranges { display: grid; gap: var(--s-2) var(--s-6); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: center; }
.d-range-row { display: flex; align-items: center; gap: var(--s-3); min-height: max(36px, var(--hit)); }
.d-range-l { width: 52px; color: var(--muted); font-size: var(--fs-13); }
.d-range-n { width: 36px; text-align: right; font-size: var(--fs-13); }
.d-range { flex: 1; min-width: 0; height: max(28px, var(--hit)); margin: 0; background: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
.d-range::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: var(--control-border); }
.d-range::-moz-range-track { height: 2px; border-radius: 1px; background: var(--control-border); }
.d-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -9px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text); }
.d-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text); }

/* ---- roles and borders */
.d-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: var(--s-2); }
.d-swatch { display: flex; flex-direction: column; gap: 2px; padding: 0 0 var(--s-1); text-align: left; background: none; border: 0; border-radius: var(--r-control); cursor: pointer; }
.d-sw { height: 44px; border-radius: var(--r-control); border: var(--line-hair) solid var(--control-border); }
.d-sw-name { font-size: var(--fs-12); color: var(--muted); }
.d-sw-hex { font-size: var(--fs-12); color: var(--text); min-height: 1.45em; }
.d-surfaces { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-2); }
.d-surface { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3); border: var(--line-hair) solid var(--border); border-radius: var(--r-control); font-size: var(--fs-13); font-weight: var(--fw-strong); }
.d-surface .d-sw-name { font-weight: var(--fw-body); margin-bottom: var(--s-1); }
.d-three { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.d-border-box { gap: var(--s-3); font-weight: var(--fw-body); }
.d-ratio { color: var(--muted); font-size: var(--fs-12); }

/* ---- scales */
.d-type { display: flex; flex-direction: column; gap: var(--s-2); overflow: hidden; }
.d-type-line { display: flex; align-items: baseline; gap: var(--s-3); line-height: var(--lh-heading); white-space: nowrap; }
.d-type-line .d-sw-name { flex: none; width: 52px; }
.d-space { display: flex; flex-direction: column; gap: var(--s-1); }
.d-space-row { display: flex; align-items: center; gap: var(--s-3); }
.d-space-row .d-sw-name:first-child { width: 52px; }
.d-bar-px { height: var(--s-3); background: var(--accent); border-radius: 2px; }
.d-seg { display: inline-flex; align-self: flex-start; padding: 2px; gap: 2px; background: var(--panel-2); border: var(--line-hair) solid var(--control-border); border-radius: var(--r-button); }
.d-seg-b { min-height: max(32px, var(--hit)); padding: 0 var(--s-4); border: 0; border-radius: calc(var(--r-button) - 3px); background: none; color: var(--muted); cursor: pointer; }
.d-seg-b[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.d-corners { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.d-corner { display: grid; place-items: center; width: 104px; height: 72px; font-size: var(--fs-12); color: var(--muted); background: var(--panel-2); border: var(--line-hair) solid var(--control-border); transition: border-radius var(--dur-sheet) var(--ease); }
.d-motion { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; }
.d-lane { display: flex; align-items: center; gap: var(--s-3); width: 100%; max-width: 520px; }
.d-lane .d-sw-name { flex: none; width: 132px; }
.d-lane-track { flex: 1; height: 16px; display: flex; border-radius: var(--r-pill); background: var(--panel-2); }
.d-lane-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); transition: margin-left var(--ease); margin-left: 0; }
.d-lane-dot.far { margin-left: calc(100% - 16px); }
.d-hit-probe { display: block; min-height: var(--hit); height: 0; width: 0; position: absolute; visibility: hidden; }

/* ---- touch */
.d-msgs { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; }
.d-msg { padding: var(--s-2) var(--s-4); min-height: max(36px, var(--hit)); display: flex; align-items: center; box-sizing: border-box; background: var(--panel-2); border: var(--line-hair) solid var(--border); border-radius: var(--r-card); font-size: var(--fs-16); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: default; }
.d-msg:nth-child(2) { align-self: flex-end; background: var(--accent-soft); }
.d-msgs { max-width: 420px; }

/* ---- layers */
.d-trap { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding: var(--s-4); background: var(--panel-2); border: var(--line-hair) dashed var(--control-border); border-radius: var(--r-card); }
.d-trap.held { border-style: solid; border-color: var(--accent); }

/* ---- icons, tables, lists */
.d-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: var(--s-1); }
.d-icon-b { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); padding: var(--s-3) var(--s-1) var(--s-2); background: none; border: var(--line-hair) solid transparent; border-radius: var(--r-control); cursor: pointer; color: var(--text); min-width: 0; }
.d-icon-b .ic { width: var(--s-6); height: var(--s-6); }
.d-icon-b span { font-size: var(--fs-12); color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.d-table { border-collapse: collapse; width: 100%; max-width: 640px; }
.d-table th, .d-table td { text-align: left; padding: var(--s-2) var(--s-4) var(--s-2) 0; font-weight: var(--fw-body); border-bottom: var(--line-hair) solid var(--border); vertical-align: top; }
.d-table th { color: var(--muted); font-size: var(--fs-12); }
.d-list { margin: 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); max-width: 72ch; font-size: var(--fs-16); }
.d-release { border-top: var(--line-hair) solid var(--border); }
.d-release summary { color: var(--text); font-weight: var(--fw-strong); font-size: var(--fs-16); }
.d-release p { margin-bottom: var(--s-3); max-width: 80ch; overflow-wrap: anywhere; }
.d-release code { font-size: .92em; padding: 1px 4px; border-radius: 4px; background: var(--panel-2); }

@media (hover: hover) {
  .d-chip:hover, .d-icon:hover, .d-icon-b:hover { border-color: var(--control-border); background: var(--hover); }
  .d-nav-link:hover { color: var(--text); }
  .d-swatch:hover .d-sw { border-color: var(--text); }
}
@media (max-width: 599.98px) {
  .d-part { margin-left: calc(-1 * var(--s-2)); margin-right: calc(-1 * var(--s-2)); padding: var(--s-4); }
  .d-top { padding: var(--s-8) 0 var(--s-6); }
  .d-part h2 { font-size: var(--fs-20); }
  .d-lane .d-sw-name { width: 108px; }
}
@media (prefers-reduced-motion: reduce) { .d-corner, .d-lane-dot { transition: none; } }

/* a summary laid out as a row loses the browser's marker, so it draws its own */
.d-use summary, .d-more summary, .d-release summary { list-style: none; justify-content: space-between; gap: var(--s-3); }
.d-use summary::-webkit-details-marker, .d-more summary::-webkit-details-marker, .d-release summary::-webkit-details-marker { display: none; }
.d-use summary::after, .d-more summary::after, .d-release summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-right: var(--s-1); border-right: var(--line-focus) solid currentColor; border-bottom: var(--line-focus) solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform var(--dur-fade); }
details[open].d-use > summary::after, details[open].d-more > summary::after, details[open].d-release > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.d-tok { white-space: nowrap; }
