/* Theme studio. Uses the docs site's tokens (style.css) so it reads as part of the same site. */

.st { height: calc(100dvh - var(--shell-height)); display: flex; flex-direction: column; font-size: 14px; --line: var(--border); }
.st button.sm:not(.vp *) { padding: var(--space-1) 9px; font-size: 12px; }
.st-spacer { flex: 1; }
.st-icon-btn { width: 32px; height: 32px; padding: 0 !important; display: inline-grid; place-items: center; font-size: 16px !important; flex: none; }
.st .segmented.sm button { padding: 3px 9px; font-size: 12px; }
.st .muted { color: var(--muted); }
.st .small { font-size: 12px; }

/* Top bar */
.st-bar { display: flex; align-items: center; gap: 10px; padding: 9px var(--space-4); border-bottom: 1px solid var(--line); flex: none; }
.st-name { width: 220px; background: transparent; border: 1px solid transparent; color: var(--text); font: 600 16px var(--font); padding: 5px var(--space-2); border-radius: var(--radius); }
.st-name:hover { border-color: var(--line); }
.st-name:focus { border-color: var(--accent); background: var(--surface); }
.st-group { display: flex; gap: 2px; }
.st-saved { font-size: 12px; color: var(--muted); min-width: 92px; text-align: right; }
.st-saved.ok::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.st-saved.bad { color: #ff9b9b; }
.st-menu { position: relative; }
.st-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 270px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: 0 12px 30px #0008; display: grid; gap: 2px; }
.st-menu-list button { text-align: left; border: 0; display: flex; flex-direction: column; gap: 1px; background: none; }
.st-menu-list button:hover { background: var(--surface-2); }
.st-menu-list small { color: var(--muted); font-size: 11.5px; }
.st-menu-list hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-1) 0; }
.st-tabs { display: none; }

/* Panels */
.st-body { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--keys-w) 6px var(--edit-w) 6px minmax(0, 1fr); }
.st-body.keys-hidden { grid-template-columns: 0 6px var(--edit-w) 6px minmax(0, 1fr); }
.st-body.keys-hidden .st-keys { visibility: hidden; }
.st-resize { cursor: col-resize; position: relative; }
.st-resize::after { content: ""; position: absolute; inset: 0 2px; background: var(--line); transition: background var(--motion); }
.st-resize:hover::after { background: var(--accent); }
.st-keys, .st-edit, .st-preview { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* Key list */
.st-keys-head { padding: var(--space-3) var(--space-3) var(--space-2); display: grid; gap: var(--space-2); border-bottom: 1px solid var(--line); }
.st-keys-search { min-width: 0 !important; width: 100%; font-size: 13px !important; padding: 7px 10px !important; }
.st-keys-filters { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.st-keys-checks { display: flex; gap: var(--space-3); align-items: center; font-size: 12px; color: var(--muted); }
.st-keys-checks label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.st-keys-count { margin-left: auto; }
.st-keys-list { flex: 1; overflow-y: auto; padding: var(--space-1) 6px 30px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.st-kgroup { content-visibility: auto; contain-intrinsic-size: auto 400px; }
.st-kgroup h3 { position: sticky; top: 0; z-index: 1; background: var(--bg); margin: 0; padding: var(--space-3) var(--space-2) 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.st-kgroup h3 span { font-weight: 400; }
.st-krow { width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0 !important; border-radius: 6px !important; background: none; padding: 7px var(--space-2) !important; position: relative; }
.st-krow:hover { background: var(--surface) !important; }
.st-krow.on { background: var(--surface-2) !important; box-shadow: inset 2px 0 0 var(--accent); }
.st-krow-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st-krow code { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; color: var(--text); }
.st-krow small { font-size: 11.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-krow-mark { position: absolute; right: 8px; top: 10px; width: 7px; height: 7px; border-radius: 50%; }
.st-krow.changed .st-krow-mark { background: var(--accent); }

/* Swatches: checkerboard shows through alpha */
.st-sw { width: 20px; height: 20px; border-radius: 5px; flex: none; position: relative; overflow: hidden; border: 1px solid #ffffff2a; background: conic-gradient(#999 25%, #ddd 0 50%, #999 0 75%, #ddd 0) 0 0 / 8px 8px; margin-top: 1px; }
.st-sw i { position: absolute; inset: 0; }
.st-sw.big { width: 26px; height: 26px; border-radius: var(--radius); margin: 0; }

/* Editor */
.st-edit-tabs { margin: var(--space-3) var(--space-3) 0; align-self: flex-start; }
.st-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 14px var(--space-4) 40px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.st-pane[data-pane="source"] { display: flex; flex-direction: column; overflow: hidden; padding-bottom: var(--space-3); }
.st-pane[hidden] { display: none !important; }
.st-blank h2 { font-size: 18px; font-weight: 600; margin: var(--space-1) 0 var(--space-2); }
.st-blank p { color: var(--muted); line-height: 1.6; margin: 0 0 10px; }
.st-quick, .st-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-chip { font: 600 11px var(--mono) !important; padding: var(--space-1) 7px !important; border-radius: 5px !important; color: var(--text); }
.st-chip.faint { color: var(--muted); }
.st-prop-head { display: flex; gap: var(--space-3); justify-content: space-between; align-items: flex-start; }
.st-kind { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.st-prop h2 { margin: 2px 0 0; font-size: 16px; }
.st-copy-key { all: unset; cursor: copy; font: 700 15px var(--mono); overflow-wrap: anywhere; line-height: 1.35; }
.st-copy-key:hover { color: var(--accent); }
.st-thumb { position: relative; padding: 0 !important; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; flex: none; width: 74px; background: #000; cursor: zoom-in; }
.st-thumb img { display: block; width: 100%; }
.st-thumb-focus { position: absolute; border: 1.5px solid #ffe680; border-radius: 2px; }
.st-desc { color: #d3d8d6; line-height: 1.6; margin: 10px 0 var(--space-2); }
.st-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; margin: 0 0 10px; }
.st-meta a { text-decoration: none; }
.st-verify { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.st-verify.here { background: #2d5a3a; color: #bff0cc; }
.st-verify.elsewhere { background: #2c4157; color: #c4defa; }
.st-verify.none { background: #4d3a22; color: #f5d6a8; }
.st-presence { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: var(--space-1) 0 14px; font-size: 12px; }
.st-presence-label { color: var(--muted); }
.st-pill { font-size: 11.5px; padding: 3px var(--space-2); border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.st-pill.ok { color: #ffc4f6; background: #4a1f45; }
.st-values { display: grid; gap: var(--space-1); }
.st-base-row { display: grid; grid-template-columns: 26px 1fr auto; grid-template-areas: "sw name reset" "sw code src"; gap: 0 10px; align-items: center; padding: 7px 9px; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
.st-base-row:hover { background: var(--surface); }
.st-base-row.on { border-color: var(--accent); background: var(--surface-2); }
.st-base-row .st-sw { grid-area: sw; }
.st-base-name { grid-area: name; font-weight: 600; font-size: 13px; }
.st-base-name em { font-style: normal; font-weight: 400; font-size: 11px; color: var(--accent); margin-left: var(--space-1); }
.st-base-row code { grid-area: code; font-size: 12px; color: var(--muted); }
.st-src { grid-area: src; font-size: 11px; color: var(--muted); text-align: right; }
.st-src.bad { color: #ff9b9b; }
.st-reset { grid-area: reset; font-size: 11px !important; padding: 1px 7px !important; justify-self: end; }
.st-links-note { font-size: 12px; color: var(--muted); margin: 6px 2px 2px; }
.st-linkish { all: unset; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; margin-left: var(--space-1); }
.st-extra h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 0 var(--space-2); font-weight: 600; }
.st-extra p { margin: 0 0 var(--space-2); line-height: 1.55; }
.st-chain code { font-size: 12px; }
.st-contrasts { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.st-contrast { display: flex; align-items: center; gap: 6px; font: 600 12px var(--mono); padding: 3px var(--space-2) 3px 3px; border-radius: var(--radius); background: var(--surface); }
.st-contrast i { font: 700 13px var(--font); width: 30px; height: 24px; border-radius: 4px; display: grid; place-items: center; font-style: normal; }
.st-contrast.ok { color: #bff0cc; }
.st-contrast.meh { color: #f5d6a8; }
.st-contrast.bad { color: #ff9b9b; }

/* Inspector card */
.st-inspect { border: 1px solid #ffe68066; background: #ffe6800a; border-radius: var(--radius); padding: 10px; margin-bottom: var(--space-4); }
.st-inspect-head { display: flex; justify-content: space-between; align-items: flex-start; }
.st-inspect-head small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #ffe680; }
.st-inspect-head b { font-size: 14px; }
.st-iprops { display: grid; gap: 2px; margin-top: var(--space-2); }
.st-iprop { display: flex; align-items: center; gap: 9px; text-align: left; border: 0 !important; background: none; padding: 5px 6px !important; border-radius: 6px !important; }
.st-iprop:hover { background: var(--surface) !important; }
.st-iprop.on { background: var(--surface-2) !important; }
.st-iprop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-iprop-text small { font-size: 11px; color: var(--muted); }
.st-iprop-text code { font-size: 11.5px; font-weight: 600; overflow-wrap: anywhere; }
.st-iprop-text em { font-style: normal; color: #ffb3f5; font-weight: 400; }
.st-fixed { font-size: 12.5px; color: #d3d8d6; margin: var(--space-2) 0 0; line-height: 1.5; padding: var(--space-2); background: var(--surface); border-radius: var(--radius); }
.st-context { font-size: 12px; color: var(--muted); margin: 10px 0 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Colour picker */
.st-picker { margin-top: var(--space-3); display: grid; gap: 10px; padding: var(--space-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.st-sv { position: relative; height: 150px; border-radius: var(--radius); cursor: crosshair; touch-action: none; }
.st-sv-knob { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #0009, 0 2px 4px #0006; pointer-events: none; }
.st-sliders { display: grid; gap: var(--space-2); }
.st-hue, .st-alpha { position: relative; height: 14px; border-radius: 7px; cursor: pointer; touch-action: none; }
.st-hue { background: linear-gradient(90deg, red, #ff0, lime, cyan, blue, #f0f, red); }
.st-alpha { background: conic-gradient(#999 25%, #ddd 0 50%, #999 0 75%, #ddd 0) 0 0 / 10px 10px; }
.st-alpha b { position: absolute; inset: 0; border-radius: 7px; }
.st-hue i, .st-alpha i { position: absolute; top: 50%; width: 14px; height: 18px; margin: -9px 0 0 -7px; border-radius: 4px; border: 2px solid #fff; box-shadow: 0 0 0 1px #0009; pointer-events: none; }
.st-sv:focus-visible, .st-hue:focus-visible, .st-alpha:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-picker-row { display: flex; gap: 6px; align-items: center; }
.st-picker-row select, .st-picker-row input { font-family: var(--mono); padding: 6px 7px; }
.st-colour-code { flex: 1; }
.st-colour-code.bad { border-color: #e06c6c !important; }
.st-alpha-num { width: 54px; }
.st-pct { color: var(--muted); font-size: 12px; margin-left: -3px; }
.st-palette { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.st-chip-swatch { width: 20px; height: 20px; padding: 0 !important; border-radius: 4px !important; overflow: hidden; position: relative; background: conic-gradient(#999 25%, #ddd 0 50%, #999 0 75%, #ddd 0) 0 0 / 8px 8px !important; }
.st-chip-swatch i { position: absolute; inset: 0; }

/* Source */
.st-source-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.st-code { position: relative; flex: 1; min-height: 200px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.st-code pre, .st-code textarea { position: absolute; inset: 0; margin: 0; padding: var(--space-3) 14px; font: 12.5px/1.6 var(--mono); tab-size: 4; white-space: pre; overflow: auto; border: 0; border-radius: 0; background: none; }
.st-code pre { pointer-events: none; color: var(--muted); scrollbar-width: none; }
.st-code textarea { color: transparent; caret-color: var(--text); resize: none; outline: none; }
.st-code textarea::selection { background: #d4dfed40; color: transparent; }
.st-code .ln { display: inline-block; min-width: 100%; }
.st-code .ln.err { background: #e06c6c26; box-shadow: inset 3px 0 #e06c6c; }
.t-key { color: #9ccfff; }
.t-str { color: #c8e6a0; }
.t-hex { text-decoration: underline 3px; text-underline-offset: 3px; }
.t-num, .t-kw { color: #f0b8ff; }
.t-com { color: var(--muted); font-style: italic; }
.t-fn { color: #ffd59a; }
.st-source-status { font-size: 12px; margin-top: var(--space-2); max-height: 120px; overflow-y: auto; }
.st-source-status p { margin: var(--space-1) 0; }
.st-source-status .ok { color: var(--accent); }
.st-source-status .warn { color: #f5d6a8; }
.st-source-status .bad { color: #ff9b9b; }

/* Theme tab */
.st-section { border-bottom: 1px solid var(--line); padding: var(--space-1) 0 var(--space-4); margin-bottom: 14px; }
.st-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: var(--space-1) 0 var(--space-2); font-weight: 600; }
.st-section p { margin: var(--space-1) 0 var(--space-2); line-height: 1.5; }
.st-field { display: grid; gap: var(--space-1); margin-bottom: var(--space-3); }
.st-field > span { font-size: 12px; color: var(--muted); }
.st-field textarea { resize: vertical; }
.st-author { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 6px; margin-bottom: 6px; }
.st-check { display: flex; gap: var(--space-2); align-items: center; margin: 6px 0; cursor: pointer; }
.st-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-2); }
.st-row.wrap { flex-wrap: wrap; }
.st-url { flex: 1; }
.st-drop { font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.st.dropping .st-edit { outline: 2px dashed var(--accent); outline-offset: -6px; }
.warnbox { background: #4d3a2218; border: 1px solid #6b5230; border-radius: var(--radius); padding: 10px var(--space-3); }
.st-problem { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; font-size: 12.5px; }
.st-extra-json { font-size: 11.5px; max-height: 160px; margin: 0; }

/* Preview */
.st-pv-bar { display: flex; align-items: center; gap: 6px; padding: 9px var(--space-3); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.st-pv-bar select, .st-custom input { padding: 5px var(--space-2); max-width: 210px; }
.st-custom { display: flex; align-items: center; gap: var(--space-1); color: var(--muted); font-size: 12px; }
.st-custom input { width: 64px; }
.st-toggle { display: inline-flex; align-items: center; gap: 6px; }
.st-toggle.on { background: #ffe68018; border-color: #ffe680; color: #ffe680; }
.st-stage { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: start center; padding: var(--space-3); background: radial-gradient(circle at 50% 30%, var(--surface-2), var(--bg) 70%); }
.st-stage-inner { position: relative; }
.st-phone-host { position: absolute; left: 0; top: 0; }
.st-phone-host .vp-device { transform-origin: top left; }
.st-pv-foot { margin: 0; padding: var(--space-2) 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); min-height: 34px; }
.st-pv-foot b { font-family: var(--mono); color: #ffb3f5; font-weight: 600; }

.st-help { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px var(--space-6); max-width: 460px; }
.st-help::backdrop { background: #000a; }
.st-help h2 { margin: 0 0 var(--space-3); font-size: 17px; }
.st-help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-4); margin: 0 0 var(--space-3); font-size: 13px; }
.st-help dt { font: 600 12px var(--mono); color: var(--accent); }
.st-help dd { margin: 0; }

@media (max-width: 1250px) {
	.st-body { grid-template-columns: var(--keys-w) 6px var(--edit-w) 6px minmax(0, 1fr); --keys-w: 250px !important; --edit-w: 330px !important; }
	.st-name { width: 150px; }
	.st-saved { display: none; }
}
@media (max-width: 900px) {
	.st { height: calc(100dvh - var(--shell-height)); }
	.st-bar { flex-wrap: wrap; padding: var(--space-2) var(--space-3); gap: 6px; }
	.st-name { width: 100%; order: -1; }
	.st-tabs { display: flex; border-bottom: 1px solid var(--line); }
	.st-tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 10px !important; color: var(--muted); border-bottom: 2px solid transparent; }
	.st-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
	.st-body, .st-body.keys-hidden { display: block; position: relative; }
	.st-resize { display: none; }
	.st-keys, .st-edit, .st-preview { position: absolute; inset: 0; visibility: hidden !important; }
	.st[data-view="keys"] .st-keys, .st[data-view="edit"] .st-edit, .st[data-view="preview"] .st-preview { visibility: visible !important; }
	.st-pv-bar [data-cmd="keys-toggle"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.vp *, .vp-toast { animation: none !important; transition: none !important; }
}

.st-resize:focus-visible { outline-offset: -2px; }
.st-code:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.st-repair-banner { padding: 12px 16px; margin: 0; flex: none; max-height: 30%; overflow: auto; border-bottom: 1px solid var(--line); }
