/* ── Docs layout ──────────────────────────────────────────── */
.docs-header { border-bottom-color: var(--hairline); }
.docs-header .header-inner { max-width: none; }
.nav-toggle { display: none; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); border-radius: 8px; width: 2rem; height: 2rem; cursor: pointer; }
.docs { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
.sidebar {
  position: sticky; top: 57px; align-self: start; height: calc(100vh - 57px); overflow-y: auto;
  padding: 1.5rem 1rem 2rem var(--gutter); display: flex; flex-direction: column; gap: 1px;
  border-right: 1px solid var(--hairline); font-size: var(--t-sm);
}
.side-h { margin: 1.1rem 0 0.35rem 0.6rem; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--graphite); }
.side-h:first-child { margin-top: 0; }
.sidebar a { padding: 0.32rem 0.6rem; border-radius: 6px; text-decoration: none; color: var(--graphite); }
.sidebar a:hover { color: var(--ink); background: var(--seg); }
.sidebar a[aria-current] { color: var(--ink); background: var(--seg); font-weight: 600; }
#page { padding: 2.25rem var(--gutter) 5rem; min-width: 0; outline: none; }
#page article { max-width: 1040px; }
#page h1 { margin: 0.2rem 0 0.4rem; font-size: clamp(1.9rem, 1.4rem + 1.5vw, 2.6rem); line-height: 1.1; letter-spacing: -0.03em; font-weight: 800; }
#page h2 { margin: 2.75rem 0 0.9rem; font-size: 1.3rem; letter-spacing: -0.01em; }
#page .lede { margin: 0 0 1.25rem; font-size: 1.05rem; }
.eyebrow { margin: 0; font: 600 0.75rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--amber-ink); }
.muted, .deps { color: var(--graphite); font-size: var(--t-sm); }
.deps a { color: var(--ink); }
.prose { max-width: 760px !important; }
.prose p { color: var(--graphite); }
.prose code, .muted code { background: var(--seg); padding: 0.1em 0.35em; border-radius: 4px; color: var(--ink); }
.prose .command, .prose .codeblock { margin: 0.75rem 0 1rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Playground ───────────────────────────────────────────── */
.playground { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 0; margin-top: 1.5rem;
  border: 1px solid var(--hairline); border-radius: 14px; overflow: hidden; background: var(--surface); }
.pv { display: flex; flex-direction: column; min-width: 0; }
.pv-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding: 0.6rem; border-bottom: 1px solid var(--hairline); }
.pv-bar .seg button { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.pv-bar select, .props select, .props input:not([type]), .props input[type=text] {
  font: 500 0.8rem var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 7px; padding: 0.35rem 0.5rem; min-width: 0; width: 100%;
}
.pv-bar select { width: auto; background: var(--seg); border-color: transparent; padding: 0.42rem 0.6rem; font-weight: 600; }
.pv-stage { position: relative; flex: 1; min-height: 260px; display: grid; place-items: center; padding: 2.5rem 1.5rem; transition: background-color .2s; overflow: hidden; }
.pv-stage.tall { min-height: 360px; align-items: start; }
.props { border-left: 1px solid var(--hairline); padding: 0.9rem; display: flex; flex-direction: column; gap: 0.55rem; max-height: 560px; overflow-y: auto; background: var(--canvas); }
.props-h { margin: 0 0 0.2rem; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: var(--t-sm); }
.link-btn { border: 0; background: none; color: var(--graphite); font: 500 0.8rem var(--font); cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; }
.prop { display: flex; flex-direction: column; gap: 0.25rem; }
.prop > label { font: 500 0.74rem var(--mono); color: var(--graphite); }
.prop-bool { flex-direction: row; justify-content: space-between; align-items: center; }
.prop input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--amber); }
.num { display: flex; align-items: center; gap: 0.5rem; }
.num input[type=range] { flex: 1; min-width: 0; accent-color: var(--amber); }
.num input[data-unset] { opacity: 0.45; }
.num output { font: 0.75rem var(--mono); min-width: 2.6rem; text-align: right; color: var(--ink); }
.num output span { color: var(--graphite); }
.color { display: flex; gap: 0.35rem; align-items: center; }
.color input[type=color] { flex: none; width: 1.9rem; height: 1.9rem; padding: 0; border: 1px solid var(--hairline); border-radius: 7px; background: none; cursor: pointer; }
.color input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.color input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.color input:not([type]) { font-family: var(--mono) !important; }
.x { flex: none; border: 0; background: var(--seg); color: var(--graphite); width: 1.4rem; height: 1.4rem; border-radius: 5px; cursor: pointer; line-height: 1; }
.x:hover { color: var(--ink); }

.pv-stage button { font: inherit; cursor: pointer; }
.qscroll::-webkit-scrollbar { width: var(--bw); }
.qscroll::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
@media (prefers-reduced-motion: reduce) { .pv-stage * { transition: none !important; } }

/* ── Code ─────────────────────────────────────────────────── */
.codeblock { border-radius: 12px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--code-line); color: var(--code-ink); }
.codeblock-bar { display: flex; justify-content: space-between; align-items: center; padding-left: 1rem; border-bottom: 1px solid var(--code-line); font: 0.78rem var(--mono); color: var(--graphite); }
.codeblock-bar .copy { padding: 0.55rem 1rem; }
.codeblock pre { margin: 0; padding: 1rem 1.2rem; overflow: auto; max-height: 520px; font: 0.82rem/1.65 var(--mono); }
.codeblock code { font-size: inherit; }
.codeblock { --hc: #a1a1aa; --hs: #15803d; --hk: #9333ea; --ht: #2563eb; --hp: #be185d; --hn: #c2410c; }
[data-scheme="dark"] .codeblock { --hc: #71717a; --hs: #86efac; --hk: #d8b4fe; --ht: #93c5fd; --hp: #f9a8d4; --hn: #fdba74; }
.codeblock .c { color: var(--hc); font-style: italic; }
.codeblock .s { color: var(--hs); }
.codeblock .k { color: var(--hk); }
.codeblock .t { color: var(--ht); }
.codeblock .p { color: var(--hp); }
.codeblock .n { color: var(--hn); }
.files { display: flex; gap: 0.35rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.files button { border: 1px solid var(--hairline); background: var(--surface); color: var(--graphite); font: 500 0.78rem var(--mono); padding: 0.3rem 0.65rem; border-radius: 7px; cursor: pointer; }
.files button[aria-selected=true] { color: var(--ink); border-color: var(--ink); }
#page > article > .command { max-width: 520px; }

/* Props table */
.table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface); }
.props-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.props-table th { text-align: left; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--graphite); padding: 0.7rem 1rem; border-bottom: 1px solid var(--hairline); }
.props-table td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.props-table tr:last-child td { border-bottom: 0; }
.props-table td span { display: block; color: var(--graphite); font-size: 0.78rem; margin-top: 0.15rem; }
.props-table code { font-size: 0.8rem; }

/* ── Theme builder ────────────────────────────────────────── */
.builder { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.25rem; margin-top: 1.5rem; align-items: start; }
.builder-form { border: 1px solid var(--hairline); border-radius: 14px; max-height: none; position: sticky; top: 80px; max-height: calc(100vh - 100px); }
.builder-form fieldset { border: 0; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.builder-form legend { font-weight: 700; font-size: var(--t-sm); margin-bottom: 0.4rem; }
.builder-out { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.builder-out .pv { border: 1px solid var(--hairline); border-radius: 14px; overflow: hidden; background: var(--surface); }
.builder-out .pv-stage { place-items: start; padding: 1.5rem; }
.tb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; width: 100%; align-items: start; }
.tb-grid > * { min-width: 0; }
.tb-grid > div:first-child { width: auto !important; max-width: 100%; }
.tb-col { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.tb-col input.qinput, .tb-col [data-slider], .tb-col [role=progressbar] { width: 100% !important; }
.out-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn { border: 1px solid var(--ink); background: var(--ink); color: var(--canvas); font: 600 var(--t-sm) var(--font); padding: 0.55rem 0.9rem; border-radius: 8px; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
.builder-out .muted { margin: 0; }

@media (max-width: 1100px) {
  .playground { grid-template-columns: minmax(0, 1fr); }
  .props { border-left: 0; border-top: 1px solid var(--hairline); max-height: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .props-h { grid-column: 1 / -1; }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .builder-form { position: static; max-height: none; }
}
@media (max-width: 820px) {
  .docs { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-grid; place-items: center; }
  .sidebar { position: fixed; z-index: 4; top: 57px; left: 0; width: 260px; background: var(--canvas); transform: translateX(-100%); transition: transform .2s; padding-left: 1rem; }
  .nav-open .sidebar { transform: none; box-shadow: 0 20px 40px rgba(var(--shade), .3); }
}
