/* ==========================================================================
   Sassly UI — library site (shared by react/ and html/)
   Not needed by components. Section 1 (stage) is stable; the shell follows.
   ========================================================================== */

/* ---------- 1. Stage: centres and scales a live demo ---------- */
.sx-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: opacity var(--sx-dur-3) var(--sx-ease-out), filter var(--sx-dur-3) var(--sx-ease-out);
}

.sx-stage[data-fading] {
  opacity: 0;
  filter: blur(6px);
}

.sx-stage__scale {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  transform: translate(-50%, -50%) scale(var(--sx-stage-scale, 1));
  transform-origin: center;
}

/* Detail page: the stage grows with the demo; wide demos are fitted by script (--sx-stage-scale). */
.sx-stage--fluid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 460px;
  padding: 56px 24px;
}

/* The track stays as wide as the frame, so a wider demo overflows both sides equally and the
   top-centre scale brings it back inside. */
.sx-stage--fluid > .sx-stage__scale {
  position: relative;
  left: auto;
  top: auto;
  width: max-content;
  justify-self: center;
  transform: scale(var(--sx-stage-scale, 1));
  transform-origin: top center;
  margin-bottom: calc((var(--sx-stage-scale, 1) - 1) * var(--sx-stage-h, 0px));
}

/* Embed: the page is only the stage (gallery iframes, #/embed/<slug>) */
html[data-embed],
html[data-embed] body {
  height: 100%;
  overflow: hidden;
  background: var(--sx-canvas);
}

.sx-stage--embed {
  position: fixed;
  inset: 0;
  background: var(--sx-canvas);
}

.sx-embed-missing {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--sx-muted);
  background: var(--sx-canvas);
}

/* Standalone HTML component page before the shell is drawn */
.sx-demo {
  position: relative;
}

/* Screen: the fixed 1280x800 box a template renders in for previews. Templates fill it and adapt
   to its size with container queries; in page view it becomes the whole window. */
.sx-screen {
  position: relative;
  width: 1280px;
  height: 800px;
  overflow: hidden;
  border-radius: var(--sx-r-xl);
  background: var(--sx-shell);
  color: var(--sx-ink);
  box-shadow: var(--sx-card-shadow);
  container: sx-screen / size;
  isolation: isolate;
}

html[data-pageview],
html[data-pageview] body {
  height: 100%;
  overflow: hidden;
  background: var(--sx-shell);
}

.sx-pageview .sx-screen,
.sx-pageview--react .sx-screen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border-radius: 0;
  box-shadow: none;
}

/* ==========================================================================
   2. Site tokens (site chrome only)
   ========================================================================== */
:root,
[data-theme="neutral"] {
  --site-side-w: 256px;
  --site-gap: 8px;
  --site-panel-r: 16px;
  --site-hero-size: 24px;
  --site-title-size: 32px;
  --site-title-weight: 600;
  --site-brand-bg: #0a0a0a;
  --site-brand-ink: #ffffff;
  --site-brand-dot: #dd0674;
}

[data-theme="neutral"][data-mode="dark"] {
  --site-brand-bg: #ededed;
  --site-brand-ink: #0c0c0d;
  --site-brand-dot: #f2559f;
}

[data-theme="onix"] {
  --site-hero-size: 28px;
  --site-title-size: 34px;
  --site-title-weight: 700;
  --site-brand-bg: #233d4d;
  --site-brand-ink: #ffffff;
  --site-brand-dot: #fe7f2d;
}

[data-theme="onix"][data-mode="dark"] {
  --site-brand-bg: #3a5f74;
  --site-brand-dot: #ff8a3d;
}

/* ==========================================================================
   3. App frame: sidebar on the shell ground, content in an inset panel
   ========================================================================== */
body.sx-site {
  background: var(--sx-shell);
  transition: background-color var(--sx-dur-3) var(--sx-ease-out);
}

@media (min-width: 900px) {
  body.sx-site {
    overflow: hidden;
  }
}

.sx-app {
  display: grid;
  grid-template-columns: var(--site-side-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns var(--sx-dur-4) var(--sx-ease-out);
}

.sx-app[data-side="closed"] {
  grid-template-columns: 0 minmax(0, 1fr);
}

/* ---------- Sidebar ---------- */
.sx-side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: var(--site-side-w);
  height: 100vh;
  height: 100dvh;
  padding: 10px 8px 12px 10px;
  overflow: hidden;
  transition: transform var(--sx-dur-4) var(--sx-ease-out), opacity var(--sx-dur-3) var(--sx-ease-out);
}

.sx-app[data-side="closed"] .sx-side {
  transform: translateX(-24px);
  opacity: 0;
  pointer-events: none;
}

.sx-side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding-left: 6px;
}

.sx-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: var(--sx-fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--sx-ink);
  text-decoration: none;
  border-radius: var(--sx-r-sm);
}

.sx-brand__mark {
  width: 20px;
  height: 20px;
  flex: none;
}

.sx-brand__mark rect {
  fill: var(--site-brand-bg);
  transition: fill var(--sx-dur-3) var(--sx-ease-out);
}

.sx-brand__mark path {
  stroke: var(--site-brand-ink);
}

.sx-brand__mark circle {
  fill: var(--site-brand-dot);
}

.sx-iconbtn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--sx-r-md);
  color: var(--sx-muted);
  transition: background-color var(--sx-dur-1) var(--sx-ease-out), color var(--sx-dur-1) var(--sx-ease-out), transform var(--sx-dur-2) var(--sx-ease-out);
  --sx-icon-size: 16px;
}

.sx-iconbtn:hover {
  color: var(--sx-ink);
  background: var(--sx-fill);
}

.sx-iconbtn:active {
  transform: scale(0.94);
}

.sx-side__search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 6px 0 10px;
  border-radius: var(--sx-r-lg);
  color: var(--sx-muted);
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
  text-align: left;
  transition: box-shadow var(--sx-dur-2) var(--sx-ease-out), color var(--sx-dur-2) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-side__search:hover {
  color: var(--sx-ink-2);
  box-shadow: var(--sx-shadow-2);
}

.sx-side__search > span:first-of-type {
  flex: 1;
}

.sx-side__kbds {
  display: inline-flex;
  gap: 3px;
}

.sx-side__nav {
  display: grid;
  gap: 1px;
}

.sx-navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  color: var(--sx-ink-2);
  text-decoration: none;
  transition: background-color var(--sx-dur-1) var(--sx-ease-out), color var(--sx-dur-1) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-navlink > .sx-icon {
  color: var(--sx-muted);
  transition: color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-navlink:hover {
  color: var(--sx-ink);
  background: var(--sx-fill);
}

.sx-navlink[aria-current="page"] {
  color: var(--sx-ink);
  background: var(--sx-fill-strong);
}

.sx-navlink[aria-current="page"] > .sx-icon {
  color: var(--sx-ink);
}

.sx-side__setting {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 6px 0 8px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  color: var(--sx-ink-2);
  text-align: left;
  transition: background-color var(--sx-dur-1) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-side__setting:hover,
.sx-side__setting[aria-expanded="true"] {
  background: var(--sx-fill);
}

.sx-side__setting > .sx-icon:first-child {
  color: var(--sx-muted);
}

.sx-side__setting > span:nth-of-type(1) {
  flex: 1;
}

.sx-side__setting > .sx-icon:last-child {
  --sx-icon-size: 13px;
  color: var(--sx-faint);
}

.sx-side__groups {
  flex: 1;
  min-height: 0;
  margin: 0 -4px;
  padding: 2px 4px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}

.sx-side__groups::-webkit-scrollbar {
  display: none;
}

.sx-group + .sx-group {
  margin-top: 6px;
}

.sx-group__head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  font-weight: 500;
  color: var(--sx-ink);
  text-align: left;
  transition: background-color var(--sx-dur-1) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-group__head:hover {
  background: var(--sx-fill);
}

.sx-group__head > .sx-icon:first-child {
  color: var(--sx-muted);
}

.sx-group__count {
  font-size: var(--sx-fs-xs);
  font-weight: 400;
  color: var(--sx-muted);
}

.sx-group__chev {
  --sx-icon-size: 13px;
  color: var(--sx-faint);
  transition: transform var(--sx-dur-3) var(--sx-ease-out);
}

.sx-group[data-collapsed] .sx-group__chev {
  transform: rotate(-90deg);
}

.sx-group__body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--sx-dur-4) var(--sx-ease-out), opacity var(--sx-dur-3) var(--sx-ease-out);
}

.sx-group[data-collapsed] .sx-group__body {
  grid-template-rows: 0fr;
  opacity: 0;
}

.sx-group__body > ul {
  min-height: 0;
  overflow: hidden;
  position: relative;
  margin: 2px 0 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.sx-group__body > ul::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 15px;
  width: 1px;
  background: var(--sx-line);
}

.sx-sidelink {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px 0 13px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  color: var(--sx-muted);
  text-decoration: none;
  transition: background-color var(--sx-dur-1) var(--sx-ease-out), color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-sidelink > span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sx-sidelink:hover {
  color: var(--sx-ink);
  background: var(--sx-fill);
}

.sx-sidelink[aria-current="page"] {
  color: var(--sx-ink);
  background: var(--sx-fill-strong);
}

.sx-sidelink[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: -3px;
  width: 1.5px;
  border-radius: 1px;
  background: var(--sx-ink);
}

.sx-newdot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--sx-mark);
  box-shadow: 0 0 0 3px var(--sx-mark-soft);
}

/* ---------- Panel ---------- */
.sx-main {
  position: relative;
  min-width: 0;
  margin: var(--site-gap) var(--site-gap) var(--site-gap) 0;
  height: calc(100vh - var(--site-gap) * 2);
  height: calc(100dvh - var(--site-gap) * 2);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  border-radius: var(--site-panel-r);
  background-color: var(--sx-panel);
  background-image: var(--sx-panel-wash);
  background-repeat: no-repeat;
  box-shadow: var(--sx-ring), 0 1px 3px rgba(10, 10, 10, 0.04);
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  view-transition-name: sx-main;
  transition: background-color var(--sx-dur-3) var(--sx-ease-out);
}

.sx-app[data-side="closed"] .sx-main {
  margin-left: var(--site-gap);
}

/* ---------- Top bar ---------- */
.sx-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 14px 0 20px;
  pointer-events: none;
  transition: background-color var(--sx-dur-3) var(--sx-ease-out), box-shadow var(--sx-dur-3) var(--sx-ease-out);
}

.sx-top > * {
  pointer-events: auto;
}

.sx-main:not([data-view="gallery"]) .sx-top[data-scrolled] {
  background: var(--sx-panel);
  box-shadow: 0 1px 0 var(--sx-line-soft);
}

.sx-top__lead {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.sx-top__menu {
  display: none;
}

.sx-app[data-side="closed"] .sx-top__open {
  display: inline-grid;
}

.sx-top__open {
  display: none;
}

.sx-top__crumbs {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--sx-dur-3) var(--sx-ease-out), transform var(--sx-dur-3) var(--sx-ease-out);
}

.sx-top[data-scrolled] .sx-top__crumbs {
  opacity: 1;
  transform: none;
}

.sx-top__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Mode toggle: sun | moon with a sliding thumb */
.sx-modeswitch {
  position: relative;
  display: inline-flex;
  padding: 2px;
  border-radius: var(--sx-r-pill);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
}

.sx-modeswitch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
  transition: transform var(--sx-dur-3) var(--sx-ease-out);
}

.sx-modeswitch[data-value="dark"]::before {
  transform: translateX(28px);
}

.sx-modeswitch > button {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--sx-muted);
  transition: color var(--sx-dur-2) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-modeswitch > button[aria-pressed="true"] {
  color: var(--sx-ink);
}

.sx-pillbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--sx-r-pill);
  font-size: var(--sx-fs-base);
  font-weight: 500;
  color: var(--sx-ink);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--sx-dur-1) var(--sx-ease-out), box-shadow var(--sx-dur-2) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-pillbtn:hover,
.sx-pillbtn[aria-expanded="true"],
.sx-pillbtn[aria-current="page"] {
  background: var(--sx-fill-strong);
}

.sx-pillbtn--mark {
  color: var(--sx-mark-ink);
  background: var(--sx-mark-soft);
  box-shadow: inset 0 0 0 1px var(--sx-mark-line), 0 1px 0 var(--sx-mark-line);
}

.sx-pillbtn--mark:hover {
  background: var(--sx-mark-soft);
  box-shadow: inset 0 0 0 1px var(--sx-mark), 0 1px 0 var(--sx-mark-line);
}

.sx-swatch {
  display: inline-flex;
  width: 14px;
  height: 14px;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--sx-line);
}

.sx-swatch > i {
  flex: 1;
}

.sx-swatch--neutral > i:nth-child(1) { background: #0a0a0a; }
.sx-swatch--neutral > i:nth-child(2) { background: #2f6bff; }
.sx-swatch--onix > i:nth-child(1) { background: #233d4d; }
.sx-swatch--onix > i:nth-child(2) { background: #fe7f2d; }

/* ---------- Theme menu (popover) ---------- */
.sx-thememenu {
  position: fixed;
  z-index: var(--sx-z-pop);
  width: 260px;
  padding: 6px;
  border-radius: var(--sx-r-lg);
  background: var(--sx-surface);
  box-shadow: var(--sx-shadow-pop);
  --sx-pop-origin: top left;
}

.sx-thememenu__label {
  padding: 6px 8px 4px;
  font-size: var(--sx-fs-2xs);
  font-weight: 500;
  color: var(--sx-muted);
}

.sx-thememenu__opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px;
  border-radius: var(--sx-r-md);
  text-align: left;
  transition: background-color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-thememenu__opt:hover,
.sx-thememenu__opt[data-active] {
  background: var(--sx-fill);
}

.sx-thememenu__opt > span:nth-child(2) {
  display: grid;
  flex: 1;
  line-height: 1.3;
}

.sx-thememenu__opt b {
  font-weight: 500;
  color: var(--sx-ink);
}

.sx-thememenu__opt small {
  font-size: var(--sx-fs-xs);
  color: var(--sx-muted);
}

.sx-thememenu__opt > .sx-icon {
  --sx-icon-size: 14px;
  color: var(--sx-accent);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--sx-dur-2) var(--sx-ease-out), transform var(--sx-dur-3) var(--sx-ease-spring);
}

.sx-thememenu__opt[aria-checked="true"] > .sx-icon {
  opacity: 1;
  transform: none;
}

.sx-thememenu__sep {
  height: 1px;
  margin: 6px -6px;
  background: var(--sx-line-soft);
}

/* Thumbnails drawn in CSS: a little panel in each theme or surface */
.sx-thumb {
  position: relative;
  width: 46px;
  height: 32px;
  flex: none;
  overflow: hidden;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px var(--sx-line);
}

.sx-thumb::before,
.sx-thumb::after {
  content: "";
  position: absolute;
}

.sx-thumb--neutral { background: #f5f5f5; }
.sx-thumb--neutral::before { inset: 7px 8px 7px 8px; border-radius: 4px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08); }
.sx-thumb--neutral::after { left: 13px; top: 12px; width: 14px; height: 3px; border-radius: 2px; background: #2f6bff; box-shadow: 0 6px 0 #d4d4d4; }
.sx-thumb--onix { background: #f3f2ed; }
.sx-thumb--onix::before { inset: 7px 8px 7px 8px; border-radius: 4px; background: #fff; box-shadow: 0 0 0 1px rgba(27, 35, 41, 0.1); }
.sx-thumb--onix::after { left: 13px; top: 12px; width: 14px; height: 3px; border-radius: 2px; background: #fe7f2d; box-shadow: 0 6px 0 #233d4d; }
.sx-thumb--flat { background: var(--sx-surface-2); }
.sx-thumb--flat::before { inset: 7px 8px; border-radius: 4px; background: var(--sx-surface); box-shadow: 0 0 0 1px var(--sx-line); }
.sx-thumb--tray { background: var(--sx-tray); }
.sx-thumb--tray::before { inset: 7px 8px; border-radius: 4px; background: var(--sx-surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.14); }

/* ==========================================================================
   4. Page content
   ========================================================================== */
.sx-page {
  padding: 0 28px 64px;
}

.sx-hero {
  padding: 28px 0 34px;
  max-width: 720px;
}

.sx-hero__title {
  font-size: var(--site-hero-size);
  font-weight: var(--sx-display-weight);
  letter-spacing: var(--sx-display-tracking);
  line-height: 1.25;
  color: var(--sx-ink);
}

.sx-hero__title span {
  display: block;
  color: var(--sx-ink);
}

[data-theme="onix"] .sx-hero__title span + span {
  color: var(--sx-ink-2);
}

/* ---------- Tabs (sticky; the top-bar actions float over their right end) ---------- */
.sx-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  margin: 0 -28px;
  padding: 0 300px 0 28px;
  background: transparent;
  transition: background-color var(--sx-dur-3) var(--sx-ease-out), box-shadow var(--sx-dur-3) var(--sx-ease-out);
}

.sx-tabs[data-stuck] {
  background: var(--sx-panel);
  box-shadow: 0 1px 0 var(--sx-line-soft);
}

.sx-tabs__list {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 22px;
  height: 100%;
}

.sx-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--sx-fs-base);
  color: var(--sx-ink-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--sx-dur-2) var(--sx-ease-out);
}

.sx-tab:hover {
  color: var(--sx-ink);
}

.sx-tab[aria-current="page"] {
  color: var(--sx-ink);
  font-weight: 500;
}

.sx-tab__count {
  font-size: var(--sx-fs-xs);
  font-weight: 400;
  color: var(--sx-muted);
  font-variant-numeric: tabular-nums;
}

.sx-tab--new .sx-tab__count {
  color: var(--sx-mark-ink);
}

.sx-tabs__ink {
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--ink-w, 0px);
  height: 1.5px;
  border-radius: 1px;
  background: var(--sx-ink);
  transform: translateX(var(--ink-x, 0px));
  transition: transform var(--sx-dur-4) var(--sx-ease-out), width var(--sx-dur-4) var(--sx-ease-out);
}

.sx-tabs__rule {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 0;
  height: 1px;
  background: var(--sx-line-soft);
}

.sx-tabs[data-stuck] .sx-tabs__rule {
  opacity: 0;
}

.sx-tabs__sep {
  width: 1px;
  height: 16px;
  margin: 0 12px 0 18px;
  background: var(--sx-line);
}

.sx-tabs__theme {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 6px 0 4px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  color: var(--sx-ink-2);
  transition: background-color var(--sx-dur-1) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-tabs__theme:hover,
.sx-tabs__theme[aria-expanded="true"] {
  background: var(--sx-fill);
}

.sx-tabs__theme > .sx-icon:first-child {
  color: var(--sx-muted);
}

.sx-tabs__theme > .sx-icon:last-child {
  --sx-icon-size: 13px;
  color: var(--sx-faint);
}

/* ---------- Gallery grid ---------- */
.sx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding-top: 22px;
}

.sx-grid__empty {
  grid-column: 1 / -1;
  padding: 80px 0;
  text-align: center;
  color: var(--sx-muted);
}

.sx-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 5px;
  border-radius: var(--sx-r-xl);
  background: var(--sx-surface);
  box-shadow: var(--sx-ring);
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
  transition: box-shadow var(--sx-dur-3) var(--sx-ease-out), background-color var(--sx-dur-3) var(--sx-ease-out);
}

.sx-tile:hover {
  box-shadow: 0 0 0 1px var(--sx-line-strong), 0 6px 18px -10px rgba(10, 10, 10, 0.18);
}

.sx-tile:focus-within:has(.sx-tile__link:focus-visible) {
  box-shadow: var(--sx-focus-ring);
}

.sx-tile__preview {
  position: relative;
  aspect-ratio: 350 / 230;
  overflow: hidden;
  border-radius: calc(var(--sx-r-xl) - 5px);
  background: var(--sx-canvas);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
  isolation: isolate;
}

.sx-tile__preview > .sx-stage,
.sx-tile__preview > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  color-scheme: normal;
}

.sx-tile__preview > iframe {
  opacity: 0;
  transition: opacity var(--sx-dur-4) var(--sx-ease-out);
}

.sx-tile__preview > iframe[data-loaded] {
  opacity: 1;
}

.sx-tile__chips {
  position: absolute;
  z-index: 2;
  top: 9px;
  left: 9px;
  right: 9px;
  display: flex;
  gap: 5px;
  pointer-events: none;
}

.sx-tile__chips > :last-child:not(:first-child) {
  margin-left: auto;
}

.sx-tile__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 7px 10px;
}

.sx-tile__text {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.45;
}

.sx-tile__name {
  font-size: var(--sx-fs-base);
  font-weight: 500;
  color: var(--sx-ink);
}

.sx-tile__desc {
  overflow: hidden;
  font-size: var(--sx-fs-base);
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--sx-muted);
}

.sx-tile__link {
  color: inherit;
  text-decoration: none;
}

.sx-tile__link:focus-visible {
  outline: none;
}

.sx-tile__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.sx-tile__copy {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  color: var(--sx-muted);
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
  transition: color var(--sx-dur-1) var(--sx-ease-out), transform var(--sx-dur-2) var(--sx-ease-out);
  --sx-icon-size: 14px;
}

.sx-tile__copy:hover {
  color: var(--sx-ink);
}

.sx-tile__copy:active {
  transform: scale(0.92);
}

.sx-tile__copy[data-done] {
  color: var(--sx-success);
}

/* ---------- Detail page ---------- */
.sx-detail {
  max-width: 940px;
  margin: 0 auto;
  padding-top: 18px;
}

.sx-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--sx-fs-base);
  color: var(--sx-muted);
  --sx-icon-size: 12px;
}

.sx-crumbs a {
  color: inherit;
  text-decoration: none;
  border-radius: var(--sx-r-xs);
  transition: color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-crumbs a:hover {
  color: var(--sx-ink);
}

.sx-crumbs > span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--sx-ink);
}

.sx-crumbs > .sx-icon {
  color: var(--sx-faint);
}

.sx-detail__title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  font-size: var(--site-title-size);
  font-weight: var(--site-title-weight);
  letter-spacing: var(--sx-display-tracking);
  line-height: 1.15;
}

.sx-detail__summary {
  max-width: 68ch;
  margin-top: 12px;
  font-size: var(--sx-fs-lg);
  line-height: 1.6;
  color: var(--sx-muted);
}

.sx-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.sx-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 4px 0 10px;
  border-radius: var(--sx-r-md);
  font-family: var(--sx-font-mono);
  font-size: 12px;
  color: var(--sx-ink-2);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
  --sx-icon-size: 13px;
}

.sx-file > .sx-icon:first-child {
  color: var(--sx-muted);
}

.sx-file > button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--sx-r-sm);
  color: var(--sx-muted);
  transition: background-color var(--sx-dur-1) var(--sx-ease-out), color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-file > button:hover {
  color: var(--sx-ink);
  background: var(--sx-fill-strong);
}

.sx-file > button[data-done] {
  color: var(--sx-success);
}

.sx-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  margin-bottom: 12px;
}

.sx-toolbar__end {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.sx-toolbar__divider {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--sx-line);
}

.sx-viewswitch {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: var(--sx-r-lg);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
}

.sx-viewswitch__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: var(--vw, 0px);
  border-radius: var(--sx-r-md);
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
  transform: translateX(var(--vx, 0px));
  transition: transform var(--sx-dur-3) var(--sx-ease-out), width var(--sx-dur-3) var(--sx-ease-out);
}

.sx-viewswitch > button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 13px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  font-weight: 500;
  color: var(--sx-muted);
  transition: color var(--sx-dur-2) var(--sx-ease-out);
  --sx-icon-size: 14px;
}

.sx-viewswitch > button[aria-selected="true"] {
  color: var(--sx-ink);
}

.sx-preview {
  position: relative;
  overflow: hidden;
  border-radius: var(--site-panel-r);
  background: var(--sx-canvas);
  color: var(--sx-ink);
  box-shadow: inset 0 0 0 1px var(--sx-line);
  transition: background-color var(--sx-dur-3) var(--sx-ease-out);
}

.sx-preview[hidden] {
  display: none;
}

.sx-code {
  position: relative;
  overflow: hidden;
  border-radius: var(--site-panel-r);
  background: var(--sx-surface);
  box-shadow: inset 0 0 0 1px var(--sx-line);
  animation: sx-fade-in var(--sx-dur-3) var(--sx-ease-out);
}

.sx-code__tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding: 0 8px;
  box-shadow: inset 0 -1px 0 var(--sx-line-soft);
}

.sx-code__tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--sx-r-sm);
  font-family: var(--sx-font-mono);
  font-size: 12px;
  color: var(--sx-muted);
  transition: background-color var(--sx-dur-1) var(--sx-ease-out), color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-code__tab:hover {
  color: var(--sx-ink);
}

.sx-code__tab[aria-selected="true"] {
  color: var(--sx-ink);
  background: var(--sx-fill-strong);
}

.sx-code__copy {
  margin-left: auto;
}

.sx-code__body {
  max-height: 560px;
  margin: 0;
  padding: 16px 20px 20px;
  overflow: auto;
  font-family: var(--sx-font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--sx-ink-2);
  tab-size: 2;
  white-space: pre;
}

.sx-code__body code {
  font: inherit;
}

.sx-code__note {
  padding: 28px 20px;
  color: var(--sx-muted);
}

/* Syntax colours, derived from the theme */
.tk-c { color: var(--sx-faint); font-style: italic; }
.tk-s { color: var(--sx-success-ink); }
.tk-k { color: var(--sx-accent-ink); }
.tk-n { color: var(--sx-warning-ink); }
.tk-t { color: var(--sx-info-ink); }
.tk-a { color: var(--sx-mark-ink); }
.tk-p { color: var(--sx-muted); }

.sx-section {
  margin-top: 44px;
}

.sx-section__title {
  font-size: var(--sx-fs-xl);
  font-weight: var(--sx-heading-weight);
  letter-spacing: var(--sx-heading-tracking);
}

.sx-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.sx-guide__col {
  padding: 16px 18px;
  border-radius: var(--sx-r-xl);
  background: var(--sx-surface);
  box-shadow: var(--sx-ring);
}

.sx-guide__col h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--sx-fs-base);
  font-weight: 500;
  --sx-icon-size: 15px;
}

.sx-guide__col--do h3 > .sx-icon { color: var(--sx-success); }
.sx-guide__col--dont h3 > .sx-icon { color: var(--sx-danger); }

.sx-guide__col ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0 0 0 18px;
  color: var(--sx-ink-2);
  line-height: 1.55;
}

.sx-guide__col li::marker {
  color: var(--sx-faint);
}

.sx-props {
  width: 100%;
  margin-top: 14px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--sx-r-xl);
  background: var(--sx-surface);
  box-shadow: var(--sx-ring);
  font-size: var(--sx-fs-base);
}

.sx-props th {
  padding: 10px 14px;
  font-size: var(--sx-fs-xs);
  font-weight: 500;
  text-align: left;
  color: var(--sx-muted);
  background: var(--sx-surface-2);
  box-shadow: inset 0 -1px 0 var(--sx-line-soft);
}

.sx-props td {
  padding: 11px 14px;
  vertical-align: top;
  color: var(--sx-ink-2);
  line-height: 1.5;
}

.sx-props tr + tr td {
  box-shadow: inset 0 1px 0 var(--sx-line-soft);
}

.sx-props td:first-child {
  white-space: nowrap;
  font-family: var(--sx-font-mono);
  font-size: 12px;
  color: var(--sx-ink);
}

.sx-props td:nth-child(2),
.sx-props td:nth-child(3) {
  font-family: var(--sx-font-mono);
  font-size: 12px;
  color: var(--sx-accent-ink);
}

.sx-props td:nth-child(3) {
  color: var(--sx-muted);
}

.sx-usage {
  margin-top: 14px;
}

.sx-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 56px;
}

.sx-pager a {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--sx-r-xl);
  background: var(--sx-surface);
  box-shadow: var(--sx-ring);
  text-decoration: none;
  transition: box-shadow var(--sx-dur-2) var(--sx-ease-out);
}

.sx-pager a:hover {
  box-shadow: 0 0 0 1px var(--sx-line-strong);
}

.sx-pager a:last-child {
  text-align: right;
}

.sx-pager small {
  font-size: var(--sx-fs-sm);
  color: var(--sx-muted);
}

.sx-pager b {
  font-weight: 500;
  color: var(--sx-ink);
}

/* ---------- Docs ---------- */
.sx-docs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 48px;
  max-width: 1040px;
  margin: 0 auto;
  padding-top: 18px;
}

.sx-docs__toc {
  position: sticky;
  top: 72px;
  align-self: start;
  display: grid;
  gap: 2px;
  padding-top: 64px;
}

.sx-docs__toc b {
  padding: 0 10px 6px;
  font-size: var(--sx-fs-xs);
  font-weight: 500;
  color: var(--sx-muted);
}

.sx-docs__toc a {
  padding: 5px 10px;
  border-radius: var(--sx-r-sm);
  font-size: var(--sx-fs-base);
  color: var(--sx-muted);
  text-decoration: none;
  transition: color var(--sx-dur-1) var(--sx-ease-out), background-color var(--sx-dur-1) var(--sx-ease-out);
}

.sx-docs__toc a:hover {
  color: var(--sx-ink);
  background: var(--sx-fill);
}

.sx-prose {
  max-width: 72ch;
  font-size: var(--sx-fs-md);
  line-height: 1.7;
  color: var(--sx-ink-2);
}

.sx-prose > h1 {
  margin-top: 18px;
  font-size: var(--site-title-size);
  font-weight: var(--site-title-weight);
  letter-spacing: var(--sx-display-tracking);
  color: var(--sx-ink);
}

.sx-prose > .sx-prose__lede {
  margin-top: 12px;
  font-size: var(--sx-fs-lg);
  color: var(--sx-muted);
}

.sx-prose h2 {
  margin-top: 48px;
  font-size: var(--sx-fs-xl);
  color: var(--sx-ink);
  scroll-margin-top: 72px;
}

.sx-prose h3 {
  margin-top: 28px;
  font-size: var(--sx-fs-lg);
  color: var(--sx-ink);
}

.sx-prose p,
.sx-prose ul,
.sx-prose ol,
.sx-prose pre,
.sx-prose table {
  margin-top: 12px;
}

.sx-prose ul,
.sx-prose ol {
  padding-left: 20px;
}

.sx-prose li + li {
  margin-top: 4px;
}

.sx-prose a {
  color: var(--sx-accent-ink);
}

.sx-prose strong {
  font-weight: 500;
  color: var(--sx-ink);
}

.sx-prose code {
  padding: 1px 5px;
  border-radius: var(--sx-r-xs);
  font-family: var(--sx-font-mono);
  font-size: 0.86em;
  color: var(--sx-ink);
  background: var(--sx-fill);
}

.sx-prose pre {
  padding: 14px 16px;
  overflow: auto;
  border-radius: var(--sx-r-lg);
  font-family: var(--sx-font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--sx-surface);
  box-shadow: var(--sx-ring);
}

.sx-prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  color: var(--sx-ink-2);
}

.sx-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--sx-fs-base);
}

.sx-prose th,
.sx-prose td {
  padding: 8px 10px;
  text-align: left;
  box-shadow: inset 0 -1px 0 var(--sx-line-soft);
}

.sx-prose th {
  font-weight: 500;
  color: var(--sx-muted);
}

.sx-tokens {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.sx-token {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: var(--sx-r-lg);
  background: var(--sx-surface);
  box-shadow: var(--sx-ring);
  font-size: var(--sx-fs-xs);
}

.sx-token > i {
  height: 36px;
  border-radius: var(--sx-r-sm);
  box-shadow: inset 0 0 0 1px var(--sx-line);
}

.sx-token > code {
  padding: 0;
  background: none;
  font-size: 11px;
  color: var(--sx-ink-2);
}

/* ==========================================================================
   5. Command palette, toasts, overlays
   ========================================================================== */
.sx-palette {
  position: fixed;
  inset: 0;
  z-index: var(--sx-z-modal);
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 12vh 16px 16px;
  background: var(--sx-overlay);
  animation: sx-fade-in var(--sx-dur-2) var(--sx-ease-out);
}

.sx-palette[data-closing] {
  animation: sx-fade-out var(--sx-dur-2) var(--sx-ease-in) forwards;
}

.sx-palette__box {
  display: flex;
  flex-direction: column;
  width: min(580px, 100%);
  max-height: min(520px, 76vh);
  overflow: hidden;
  border-radius: var(--sx-r-2xl);
  background: var(--sx-surface);
  box-shadow: var(--sx-shadow-pop);
  animation: sx-palette-in var(--sx-dur-4) var(--sx-ease-out);
}

.sx-palette[data-closing] .sx-palette__box {
  animation: sx-palette-out var(--sx-dur-2) var(--sx-ease-in) forwards;
}

.sx-palette__field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 14px 0 16px;
  box-shadow: inset 0 -1px 0 var(--sx-line-soft);
  color: var(--sx-muted);
  --sx-icon-size: 17px;
}

.sx-palette__field input {
  flex: 1;
  height: 100%;
  border: 0;
  font-size: var(--sx-fs-lg);
  color: var(--sx-ink);
  background: transparent;
  outline: none;
}

.sx-palette__list {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scroll-padding: 6px;
}

.sx-palette__group {
  padding: 10px 10px 4px;
  font-size: var(--sx-fs-2xs);
  font-weight: 500;
  color: var(--sx-muted);
}

.sx-palette__hl {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  height: 38px;
  border-radius: var(--sx-r-md);
  background: var(--sx-fill-strong);
  transform: translateY(var(--hl-y, 0px));
  transition: transform var(--sx-dur-2) var(--sx-ease-out);
  pointer-events: none;
}

.sx-palette__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--sx-r-md);
  font-size: var(--sx-fs-base);
  text-align: left;
  color: var(--sx-ink-2);
  --sx-icon-size: 15px;
}

.sx-palette__item > .sx-icon {
  color: var(--sx-muted);
}

.sx-palette__item[aria-selected="true"] {
  color: var(--sx-ink);
}

.sx-palette__item > span:nth-of-type(1) {
  flex: 1;
}

.sx-palette__item mark {
  color: var(--sx-ink);
  font-weight: 600;
  background: none;
}

.sx-palette__empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--sx-muted);
}

.sx-palette__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 40px;
  padding: 0 14px;
  font-size: var(--sx-fs-xs);
  color: var(--sx-muted);
  background: var(--sx-surface-2);
  box-shadow: inset 0 1px 0 var(--sx-line-soft);
}

.sx-palette__foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sx-toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: var(--sx-z-toast);
  display: grid;
  justify-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.sx-toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 12px;
  border-radius: var(--sx-r-pill);
  font-size: var(--sx-fs-base);
  font-weight: 500;
  color: var(--sx-on-primary);
  background: var(--sx-primary-bg);
  box-shadow: var(--sx-shadow-pop);
  animation: sx-toast-in var(--sx-dur-4) var(--sx-ease-out);
  --sx-icon-size: 15px;
}

.sx-toast[data-leaving] {
  animation: sx-toast-out var(--sx-dur-3) var(--sx-ease-in) forwards;
}

.sx-scrim {
  display: none;
}

@keyframes sx-fade-out {
  to { opacity: 0; }
}

@keyframes sx-palette-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); filter: blur(4px); }
}

@keyframes sx-palette-out {
  to { opacity: 0; transform: translateY(-4px) scale(0.985); }
}

@keyframes sx-toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); filter: blur(4px); }
}

@keyframes sx-toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* ==========================================================================
   6. View transitions: mode reveal, theme crossfade, route change
   ========================================================================== */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

[data-vt="reveal"]::view-transition-new(root) {
  animation: sx-vt-reveal 560ms var(--sx-ease-in-out);
}

[data-vt="fade"]::view-transition-old(root) {
  animation: sx-vt-fade-out 300ms var(--sx-ease-out) forwards;
}

[data-vt="fade"]::view-transition-new(root) {
  animation: sx-vt-fade-in 360ms var(--sx-ease-out);
}

[data-vt="route"]::view-transition-old(sx-main) {
  animation: sx-vt-route-out 160ms var(--sx-ease-in) forwards;
}

[data-vt="route"]::view-transition-new(sx-main) {
  animation: sx-vt-route-in 340ms var(--sx-ease-out);
}

[data-vt]:not([data-vt="route"])::view-transition-old(sx-main),
[data-vt]:not([data-vt="route"])::view-transition-new(sx-main) {
  animation: none;
}

[data-vt="reveal"]::view-transition-group(sx-main),
[data-vt="fade"]::view-transition-group(sx-main) {
  animation-duration: 0s;
}

@keyframes sx-vt-reveal {
  from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 0)); }
  to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 50%) var(--vt-y, 0)); }
}

@keyframes sx-vt-fade-out {
  to { opacity: 0; }
}

@keyframes sx-vt-fade-in {
  from { opacity: 0; filter: blur(3px); }
}

@keyframes sx-vt-route-out {
  to { opacity: 0; transform: translateY(-4px); }
}

@keyframes sx-vt-route-in {
  from { opacity: 0; transform: translateY(8px); }
}

@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* ==========================================================================
   7. Small screens: sidebar becomes a drawer, the page scrolls normally
   ========================================================================== */
@media (max-width: 1100px) {
  .sx-tabs {
    padding-right: 28px;
  }

  .sx-main[data-view="gallery"] .sx-top {
    position: relative;
  }
}

@media (max-width: 640px) {
  .sx-top__docs {
    display: none;
  }
}

@media (max-width: 899px) {
  .sx-app,
  .sx-app[data-side="closed"] {
    display: block;
  }

  .sx-side {
    position: fixed;
    z-index: 70;
    top: 0;
    left: 0;
    width: min(300px, 86vw);
    background: var(--sx-shell);
    box-shadow: var(--sx-shadow-pop);
    transform: translateX(-104%);
    opacity: 1;
    pointer-events: auto;
  }

  .sx-app[data-drawer="open"] .sx-side {
    transform: none;
  }

  .sx-scrim {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: var(--sx-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--sx-dur-3) var(--sx-ease-out);
  }

  .sx-app[data-drawer="open"] .sx-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .sx-main,
  .sx-app[data-side="closed"] .sx-main {
    height: auto;
    min-height: 100vh;
    margin: 0;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
  }

  .sx-top {
    padding: 0 10px 0 12px;
    background: var(--sx-panel);
    box-shadow: 0 1px 0 var(--sx-line-soft);
  }

  .sx-main[data-view="gallery"] .sx-top {
    position: sticky;
  }

  .sx-top__menu {
    display: inline-grid;
  }

  .sx-top__open,
  .sx-app[data-side="closed"] .sx-top__open {
    display: none;
  }

  .sx-top__crumbs {
    display: none;
  }

  .sx-page {
    padding: 0 16px 48px;
  }

  .sx-tabs {
    position: relative;
    top: auto;
    margin: 0 -16px;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sx-tabs__rule {
    left: 16px;
    right: 16px;
  }

  .sx-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sx-guide,
  .sx-pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .sx-docs {
    display: block;
  }

  .sx-docs__toc {
    display: none;
  }

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

  .sx-props {
    display: block;
    overflow-x: auto;
  }

  .sx-top__label {
    display: none;
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  .sx-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
   8. Theme customizer panel (shared/customizer.js)
   ========================================================================== */
.sx-thumb--custom {
  background: conic-gradient(from 200deg, #fe7f2d, #dd0674, #7c3aed, #2f6bff, #16a34a, #fe7f2d);
}

.sx-thumb--custom::before {
  inset: 7px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sx-custom {
  position: fixed;
  z-index: var(--sx-z-modal);
  top: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  width: min(364px, calc(100vw - 24px));
  overflow: hidden;
  border-radius: var(--sx-r-2xl);
  color: var(--sx-ink);
  background: var(--sx-surface);
  box-shadow: var(--sx-shadow-pop);
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  visibility: hidden;
  transition:
    transform var(--sx-dur-4) var(--sx-ease-out),
    opacity var(--sx-dur-3) var(--sx-ease-out),
    visibility 0s linear var(--sx-dur-4);
}

.sx-custom[data-state="open"] {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.sx-custom__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 14px 18px;
  box-shadow: inset 0 -1px 0 var(--sx-line-soft);
}

.sx-custom__head div {
  display: grid;
  gap: 2px;
}

.sx-custom__head b {
  font-size: var(--sx-fs-md);
  font-weight: var(--sx-heading-weight);
}

.sx-custom__head small {
  font-size: var(--sx-fs-sm);
  color: var(--sx-muted);
}

.sx-custom__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 18px 8px;
}

.sx-custom__body section {
  display: grid;
  gap: 10px;
  padding: 16px 0;
}

.sx-custom__body section + section {
  box-shadow: inset 0 1px 0 var(--sx-line-soft);
}

.sx-custom__body h3 {
  font-size: var(--sx-fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--sx-muted);
}

.sx-custom__row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.sx-custom__row > span {
  font-size: var(--sx-fs-sm);
  color: var(--sx-ink-2);
}

.sx-custom__seg {
  display: flex;
  padding: 2px;
  border-radius: var(--sx-r-md);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
}

.sx-custom__seg button {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 3px;
  border-radius: calc(var(--sx-r-md) - 2px);
  font-size: var(--sx-fs-xs);
  font-weight: 500;
  white-space: nowrap;
  color: var(--sx-muted);
  transition: background-color var(--sx-dur-2) var(--sx-ease-out), color var(--sx-dur-2) var(--sx-ease-out), box-shadow var(--sx-dur-2) var(--sx-ease-out);
}

.sx-custom__seg button:hover {
  color: var(--sx-ink);
}

.sx-custom__seg button[aria-checked="true"] {
  color: var(--sx-ink);
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
}

.sx-custom__swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.sx-custom__swatch {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
  transition: box-shadow var(--sx-dur-2) var(--sx-ease-out), transform var(--sx-dur-2) var(--sx-ease-out);
}

.sx-custom__swatch:hover {
  transform: scale(1.08);
}

.sx-custom__swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--sx-surface), 0 0 0 3.5px var(--sx-ink);
}

.sx-custom__swatch--auto {
  width: auto;
  padding: 0 8px;
  border-radius: var(--sx-r-pill);
  font-size: var(--sx-fs-2xs);
  font-weight: 500;
  color: var(--sx-muted);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line);
}

.sx-custom__swatch--auto[aria-pressed="true"] {
  color: var(--sx-ink);
  box-shadow: 0 0 0 2px var(--sx-surface), 0 0 0 3.5px var(--sx-ink);
}

.sx-custom__picker {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: conic-gradient(#ff4d4d, #ffd84d, #5bd65b, #4dd6ff, #4d6bff, #d64dff, #ff4d4d);
  cursor: pointer;
}

.sx-custom__picker input {
  position: absolute;
  inset: -4px;
  width: 30px;
  height: 30px;
  opacity: 0;
  cursor: pointer;
}

.sx-custom__picker-dot {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.sx-custom__fonts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.sx-custom__fonts button {
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border-radius: var(--sx-r-md);
  text-align: left;
  background: var(--sx-surface);
  box-shadow: inset 0 0 0 1px var(--sx-line);
  transition: box-shadow var(--sx-dur-2) var(--sx-ease-out), background-color var(--sx-dur-2) var(--sx-ease-out);
}

.sx-custom__fonts button span {
  overflow: hidden;
  font-size: var(--sx-fs-sm);
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sx-custom__fonts button small {
  font-size: var(--sx-fs-xs);
  color: var(--sx-muted);
}

.sx-custom__fonts button:hover {
  box-shadow: inset 0 0 0 1px var(--sx-line-strong);
}

.sx-custom__fonts button[aria-checked="true"] {
  background: var(--sx-accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--sx-accent);
}

.sx-custom__range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sx-custom__range input {
  flex: 1;
  min-width: 0;
  accent-color: var(--sx-accent);
}

.sx-custom__range output {
  width: 34px;
  font-family: var(--sx-font-mono);
  font-size: 12px;
  text-align: right;
  color: var(--sx-ink-2);
}

.sx-custom__foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: var(--sx-surface-2);
  box-shadow: inset 0 1px 0 var(--sx-line-soft);
}

@media (max-width: 560px) {
  .sx-custom {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: min(70vh, 560px);
    transform: translateY(calc(100% + 24px));
  }
}

/* ==========================================================================
   9. Layout switch (templates with several layouts)
   ========================================================================== */
.sx-layoutswitch {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--sx-r-md);
  background: var(--sx-fill);
  box-shadow: inset 0 0 0 1px var(--sx-line-soft);
}

.sx-layoutswitch > button {
  height: 28px;
  padding: 0 10px;
  border-radius: calc(var(--sx-r-md) - 2px);
  font-size: var(--sx-fs-sm);
  font-weight: 500;
  white-space: nowrap;
  color: var(--sx-muted);
  transition: background-color var(--sx-dur-2) var(--sx-ease-out), color var(--sx-dur-2) var(--sx-ease-out), box-shadow var(--sx-dur-2) var(--sx-ease-out);
}

.sx-layoutswitch > button:hover {
  color: var(--sx-ink);
}

.sx-layoutswitch > button[aria-checked="true"] {
  color: var(--sx-ink);
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
}

/* ==========================================================================
   10. Categories: sidebar section labels and gallery filter chips
   ========================================================================== */
.sx-sidecat {
  padding: 10px 8px 3px 13px;
  font-size: var(--sx-fs-2xs);
  font-weight: 500;
  color: var(--sx-faint);
  list-style: none;
}

.sx-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 18px;
}

.sx-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--sx-r-pill);
  font-size: var(--sx-fs-sm);
  font-weight: 500;
  color: var(--sx-muted);
  box-shadow: inset 0 0 0 1px var(--sx-line);
  transition: color var(--sx-dur-2) var(--sx-ease-out), background-color var(--sx-dur-2) var(--sx-ease-out), box-shadow var(--sx-dur-2) var(--sx-ease-out);
}

.sx-cat:hover {
  color: var(--sx-ink);
  box-shadow: inset 0 0 0 1px var(--sx-line-strong);
}

.sx-cat[aria-pressed="true"] {
  color: var(--sx-ink);
  background: var(--sx-raised);
  box-shadow: var(--sx-shadow-1);
}

.sx-cat > small {
  font-size: var(--sx-fs-2xs);
  font-variant-numeric: tabular-nums;
  color: var(--sx-faint);
}
