/* Studio and Techniques panels. Extends site.css only through its variables. */
.ps-main { min-width: 0; }
.ps-hero { padding: 8px 0 8px; }
.ps-hero h1 { max-width: 20ch; margin-bottom: 0.35em; }
.ps-hero .lead { color: var(--ink-2); font-size: clamp(1.05rem, 2vw, 1.25rem); max-width: 62ch; margin-bottom: 0; }
.ps-lead { color: var(--ink-2); max-width: 66ch; }
.ps-note { color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; max-width: 66ch; }
.ps-dim { color: var(--muted); }
.ps-sec { margin: 56px 0 0; scroll-margin-top: calc(var(--header-h) + 16px); }
.ps-sec > h2 { margin-top: 0; }
.ps-sec h3 { scroll-margin-top: calc(var(--header-h) + 16px); }

/* Stats strip and sub navigation */
.ps-stats { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 24px 0 8px; }
.ps-stats li { margin: 0; display: flex; align-items: baseline; gap: 8px; padding: 8px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; }
.ps-stats b { font-size: 1.15rem; color: var(--accent-strong); }
.ps-stats span { color: var(--ink-2); font-size: 0.92rem; }
.ps-subnav { margin: 20px 0 8px; }
.ps-subnav .pills { margin: 0; }
.ps-subnav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); font-weight: 650; }

/* Chips */
.ps-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.4em 0 0.6em; }
.ps-chip { display: inline-block; font: 500 0.78rem var(--mono); padding: 3px 9px; border-radius: 999px; background: var(--bg-3); color: var(--ink-2); border: 1px solid var(--line); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ps-chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.ps-chip.tech { font-family: var(--font); background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.ps-chip.path.missing { opacity: 0.6; }

/* Film */
.ps-film { margin: 0 0 1em; }
.ps-film video { width: 100%; aspect-ratio: 16 / 9; background: #0d0e10; border-radius: var(--radius); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.ps-principles .card h3 { font-size: 1.04rem; }

/* Component catalogue */
.ps-comp { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow-sm); padding: 20px 22px 14px; margin: 0 0 18px; scroll-margin-top: calc(var(--header-h) + 16px); }
.ps-comp > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; margin-bottom: 6px; }
.ps-comp h3 { margin: 0; font-size: 1.2rem; }
.ps-comp h3 code { background: none; padding: 0; color: var(--accent-strong); font-size: 1em; }
.ps-src { font: 500 0.78rem var(--mono); color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.ps-src:hover { color: var(--accent-strong); }
.ps-desc { margin: 0.2em 0 0.5em; color: var(--ink); }
.ps-when { margin: 0 0 0.6em; color: var(--ink-2); font-size: 0.95rem; }
.ps-when span { display: inline-block; margin-right: 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 650; color: var(--accent-strong); }
.ps-props { margin: 0 0 6px; }
.ps-props summary { cursor: pointer; font-weight: 600; font-size: 0.93rem; color: var(--ink-2); padding: 6px 0; }
.ps-props summary:hover { color: var(--accent-strong); }
.ps-table { overflow-x: auto; margin: 0 0 1.2em; }
.ps-table table { display: table; min-width: 100%; font-size: 0.9rem; margin: 0; }
.ps-table td, .ps-table th { vertical-align: top; }
.ps-table td code { font-size: 0.82em; white-space: normal; }
.ps-req { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--warn); font-weight: 700; margin-left: 4px; }
.ps-comp pre { margin: 0.4em 0 0.8em; font-size: 0.84rem; }
.ps-fns { display: grid; gap: 10px; margin-bottom: 1.4em; }
.ps-fn { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px 4px; background: var(--bg); scroll-margin-top: calc(var(--header-h) + 16px); }
.ps-fn-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.ps-fn .name { font-weight: 700; color: var(--accent-strong); background: none; padding: 0; font-size: 0.98rem; }
.ps-fn p { margin: 0.3em 0 0.5em; font-size: 0.93rem; color: var(--ink-2); }
.ps-sig { margin: 0 0 10px; padding: 8px 12px; font-size: 0.8rem; background: var(--code-bg); white-space: pre-wrap; word-break: break-word; }

/* Videos */
.ps-video .ps-chips { margin: 4px 0 0; }

/* Tokens */
.ps-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.ps-swatch { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; background: var(--bg); }
.ps-swatch .chip { flex: none; width: 56px; height: 56px; border-radius: 10px; background: #0d0e10; position: relative; overflow: hidden; border: 1px solid var(--line-2); }
.ps-swatch .chip i { position: absolute; inset: 0; background: var(--c); }
.ps-swatch b { display: block; font-size: 0.92rem; }
.ps-swatch code { background: none; padding: 0; color: var(--muted); font-size: 0.78rem; display: block; }
.ps-swatch span { display: block; color: var(--ink-2); font-size: 0.8rem; line-height: 1.35; margin-top: 2px; }
.ps-type { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ps-type-row { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #0d0e10; color: #f2f1ec; }
.ps-type-row:last-child { border-bottom: 0; }
.ps-type-row .meta b { display: block; font: 600 0.85rem var(--mono); color: #f2f1ec; }
.ps-type-row .meta span { display: block; font: 400 0.76rem var(--mono); color: #9a9ca1; }
.ps-type-row .sample { overflow-wrap: anywhere; min-width: 0; }
.ps-ramp-row, .ps-space-row { display: grid; grid-template-columns: 110px 1fr 70px 110px; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ps-space-row { grid-template-columns: 110px 1fr 70px; }
.ps-ramp-row b, .ps-space-row b { font: 600 0.84rem var(--mono); }
.ps-ramp-row span, .ps-space-row span { font-size: 0.88rem; color: var(--ink-2); }
.ps-ramp-row .px { color: var(--muted); }
.ps-ramp-row em { grid-column: 2 / -1; font-style: normal; color: var(--muted); font-size: 0.84rem; margin-top: -6px; }
.ps-ramp .bar, .ps-spaces .bar { height: 14px; background: var(--bg-3); border-radius: 7px; overflow: hidden; }
.ps-ramp .bar i, .ps-spaces .bar i { display: block; height: 100%; background: var(--accent); border-radius: 7px; }
.ps-radii { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 22px; }
.ps-radii div { text-align: center; }
.ps-radii i { display: block; width: 72px; height: 72px; background: var(--accent-soft); border: 2px solid var(--accent); margin: 0 auto 6px; }
.ps-radii b { display: block; font: 600 0.82rem var(--mono); }
.ps-radii span { color: var(--muted); font-size: 0.82rem; }
.ps-safes { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-end; }
.ps-safe { margin: 0; }
.ps-safe .frame { position: relative; background: #0d0e10; border-radius: 6px; border: 1px solid var(--line-2); height: 190px; }
.ps-safe .frame .inner { position: absolute; border: 1.5px dashed #5b8cff; background: rgba(91, 140, 255, 0.09); border-radius: 2px; }
.ps-safe figcaption { margin-top: 8px; font-size: 0.84rem; }
.ps-safe figcaption b { color: var(--ink); }
.ps-curves .card h3 { font: 700 0.95rem var(--mono); }
.ps-plot { width: 100%; max-width: 240px; height: auto; display: block; background: var(--bg-2); border-radius: 8px; border: 1px solid var(--line); }
.ps-plot.sq { max-width: 140px; }
.ps-plot .curve { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ps-plot .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.ps-plot .axis { stroke: var(--line-2); stroke-width: 1; }
.ps-plot .box { fill: none; stroke: var(--line-2); }
.ps-plot .handle { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; }

/* Rendered markdown pages */
.ps-prose { max-width: var(--measure); }
.ps-prose h2 { margin-top: 1.8em; scroll-margin-top: calc(var(--header-h) + 16px); }
.ps-prose h3 { scroll-margin-top: calc(var(--header-h) + 16px); }
.ps-refs { columns: 2; column-gap: 28px; }
.ps-refs li { break-inside: avoid; }
.engines td, .engines th { min-width: 150px; }

/* Techniques */
.pt-rules { list-style: none; padding: 0; margin: 1.2em 0 0; display: grid; gap: 12px; }
.pt-rule { display: grid; grid-template-columns: 40px 1fr; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow-sm); margin: 0; }
.pt-rule .n { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; display: grid; place-items: center; }
.pt-rule h3 { margin: 0 0 4px; font-size: 1.08rem; }
.pt-rule p { margin: 0 0 6px; color: var(--ink-2); }
.pt-filters { position: sticky; top: calc(var(--header-h) + 6px); z-index: 5; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); padding: 10px 0 8px; margin: 0 0 6px; }
.pt-filters select { max-width: 100%; }
.pt-count { color: var(--muted); font-size: 0.88rem; margin: 0 0 8px; }
.pt-group { margin: 40px 0 0; scroll-margin-top: calc(var(--header-h) + 70px); }
.pt-cat { margin: 0; font-size: 1.35rem; }
.pt-cat small { font-size: 0.8rem; font-weight: 650; background: var(--bg-3); color: var(--ink-2); border-radius: 999px; padding: 2px 9px; vertical-align: middle; margin-left: 6px; }
.pt-blurb { color: var(--muted); margin: 2px 0 14px; }
.pt-cards { display: grid; gap: 16px; }
.pt-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow-sm); padding: 20px 22px 16px; scroll-margin-top: calc(var(--header-h) + 80px); max-width: 78ch; }
.pt-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pt-card > header { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.pt-card h3 { margin: 0; font-size: 1.15rem; line-height: 1.25; flex: 1 1 260px; }
.pt-id { font: 600 0.78rem var(--mono); color: var(--accent-strong); background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; }
.pt-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.pt-block h4 { margin: 14px 0 3px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.pt-block p { margin: 0 0 0.6em; }
.pt-block details { margin: 0 0 0.6em; }
.pt-block summary { cursor: pointer; color: var(--accent-strong); font-size: 0.92rem; font-weight: 600; }
.pt-ev { font-size: 0.9rem; color: var(--ink-2); background: var(--bg-2); border-radius: 8px; padding: 8px 12px; }
.pt-ev span, .pt-credit span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--muted); margin-right: 6px; }
.pt-credit { font-size: 0.9rem; color: var(--ink-2); margin: 12px 0 4px; overflow-wrap: anywhere; }
.pt-links { margin: 8px 0 0; font-size: 0.9rem; }
.pt-card.rej { background: var(--bg-2); box-shadow: none; }
.why-no { border-left: 3px solid var(--bad); padding-left: 12px; margin-top: 10px; }
.pt-weak { padding-left: 1.1em; max-width: 78ch; }
.pt-weak li { margin: 0.5em 0; color: var(--ink-2); }

@media (max-width: 820px) {
  .ps-sec { margin-top: 40px; }
  .ps-comp { padding: 16px 16px 10px; }
  .ps-type-row { grid-template-columns: 1fr; gap: 6px; padding: 14px 16px; }
  .ps-ramp-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .ps-ramp-row b { grid-column: 1; }
  .ps-ramp-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .ps-ramp-row span { grid-row: 1; grid-column: 2; }
  .ps-ramp-row .px { grid-row: 3; grid-column: 1 / -1; }
  .ps-ramp-row em { grid-column: 1 / -1; margin: 0; }
  .ps-space-row { grid-template-columns: 1fr auto; }
  .ps-space-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .ps-refs { columns: 1; }
  .pt-rule { grid-template-columns: 34px 1fr; gap: 12px; padding: 14px; }
  .pt-card { padding: 16px 16px 12px; }
  .pt-filters { top: 4px; position: static; }
  .pt-filters input[type="search"] { flex-basis: 100%; }
  .pt-filters select { flex: 1 1 140px; }
  .ps-safe .frame { height: 150px; }
}

/* Mobile table of contents (the sticky sidebar one is hidden at this width) */
.ps-mtoc { display: none; margin: 14px 0 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.ps-mtoc summary { cursor: pointer; padding: 10px 14px; font-weight: 650; font-size: 0.93rem; color: var(--ink-2); }
.ps-mtoc ul { list-style: none; margin: 0; padding: 0 14px 10px; }
.ps-mtoc li { margin: 0; }
.ps-mtoc a { display: block; padding: 6px 0; text-decoration: none; color: var(--ink-2); }
@media (max-width: 960px) {
  .ps-main + .doc-toc { display: none; }
  .ps-mtoc { display: block; }
}

.ps-table td:first-child code { white-space: nowrap; }
.ps-table td:nth-child(2) code { overflow-wrap: anywhere; word-break: break-word; }

/* Robustness at narrow widths: let long paths wrap instead of widening the page */
.ps-chip { white-space: normal; overflow-wrap: anywhere; border-radius: 10px; }
.pt-rule { grid-template-columns: 40px minmax(0, 1fr); }
.pt-cards { grid-template-columns: minmax(0, 1fr); }
.pt-card, .ps-comp, .pt-rule > div { min-width: 0; }
@media (max-width: 820px) { .pt-rule { grid-template-columns: 34px minmax(0, 1fr); } }
