/* Lab chrome follows the site theme; specimen and palette colours keep their own roles. */
html[data-lab-theme] body:is([data-lab-layout],[data-studio-page]) {
  --paper:var(--lab-ui-bg); --ink:var(--lab-ui-ink);
  --muted:var(--lab-ui-muted); --line:var(--lab-ui-line);
  --soft:var(--lab-ui-surface); --surface:var(--lab-ui-surface);
  background:var(--lab-ui-bg); color:var(--lab-ui-ink);
}
/* The component preview selector may set data-palette on body. This more
   specific mapping keeps that choice independent of the surrounding Lab. */
html[data-lab-theme] body[data-lab-layout=components][data-palette] {
  --paper:var(--lab-ui-bg); --ink:var(--lab-ui-ink);
  --muted:var(--lab-ui-muted); --line:var(--lab-ui-line);
  --soft:var(--lab-ui-surface);
}
html[data-lab-theme] body[data-lab-layout=foundation] .index {
  background:var(--lab-ui-bg); color:var(--lab-ui-ink);
}
html[data-lab-theme] body[data-lab-layout=foundation] .search input {
  background:transparent; color:var(--lab-ui-ink);
}
html[data-lab-theme] body[data-lab-layout=foundation] .filter.active {
  background:var(--lab-ui-ink); color:var(--lab-ui-bg);
}
html[data-lab-theme] body[data-lab-layout=foundation] .index nav a span {
  color:var(--lab-ui-muted);
}
/* These are the original black/white foundations, rather than site chrome.
   Their local tokens preserve readable samples in either surrounding theme. */
html[data-lab-theme] body[data-lab-layout=foundation] .preview {
  --ink:#171717; --paper:#fff; --surface:#f7f7f6; --soft:#eeeeec;
  --line:#dededb; --muted:#686865; color:var(--ink);
  color-scheme:light;
}
html[data-lab-theme] body[data-lab-layout=foundation] :is(.demo-dialog,.demo-drawer) {
  background:var(--lab-ui-raised); color:var(--lab-ui-ink);
}
html[data-lab-theme] body[data-lab-layout=foundation] :is(.demo-dialog,.demo-drawer) :is(.btn,.icon-button) {
  background:var(--lab-ui-raised); color:var(--lab-ui-ink);
}
html[data-lab-theme] body[data-lab-layout=foundation] :is(.demo-dialog,.demo-drawer) .btn.primary {
  background:var(--lab-ui-ink); color:var(--lab-ui-bg);
}
html[data-lab-theme] body[data-lab-layout=foundation] :is(.toast,.toast button) {
  color:var(--lab-ui-bg);
}
html[data-lab-theme] body[data-lab-layout=foundation] #clear-search {
  background:var(--lab-ui-raised); color:var(--lab-ui-ink);
}
/* Dialog surfaces and native menus are UI, not a selected palette colour. */
html[data-lab-theme] :is(body[data-lab-layout=components],body[data-studio-page]) :is(dialog,.cs-role-select>select,.cs-preset-label select) {
  color-scheme:inherit;
}
/* The reference board uses fixed neutral values in its original inline CSS. */
html[data-lab-theme] body:has(.reference-main) {
  background:var(--lab-ui-bg); color:var(--lab-ui-ink);
}
html[data-lab-theme] :is(.reference-intro>span,.reference-intro p,.reference-section>span,.reference-section h2+p,.reference-section li>span,.reference-section li p,.reference-section li small) {
  color:var(--lab-ui-muted);
}
html[data-lab-theme] .reference-section {
  border-color:var(--lab-ui-line);
}
html[data-lab-theme] .reference-section li {
  border-color:var(--lab-ui-soft-line);
}
html[data-lab-theme] .reference-back {
  border-color:var(--lab-ui-ink);
}

body[data-studio-page=contrast] #contrast-matrix{scroll-margin-top:calc(var(--align-lab-header) + 8px)}

.cs-role-details>summary{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:24px;list-style:none;cursor:pointer;font-size:14px;font-weight:500;letter-spacing:-.3px}
.cs-role-details>summary::-webkit-details-marker{display:none}
.cs-role-details>.cs-role-heading{margin:12px 0 10px}
.cs-role-details>.cs-role-heading>button{flex:none}
