/* Component kit page. Sits on example.css (the design language page) and adds the control and stage layout. */
.kp-row { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--sp-6); align-items: start; }
.kp-ctls { display: grid; gap: var(--sp-4); }
.kp-ctl-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: 14px; line-height: var(--lh-2); }
.kp-ctl-h > span:first-child { font-weight: 500; }
.kp-type { margin-left: auto; font-size: 12px; line-height: var(--lh-1); color: var(--text-secondary); }
.kp-seg { flex-wrap: wrap; max-width: 100%; }
.kp-seg > label { height: calc(var(--h-3) - 6px); font-size: 13px; }
.kp-set { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.kp-tog { position: relative; height: var(--h-2); padding: 0 var(--sp-3); border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--surface-1); font: inherit; font-size: 13px; color: var(--text-secondary); cursor: pointer; transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.kp-tog::after { content: ""; position: absolute; inset: -8px 0; }
.kp-set { row-gap: var(--sp-2); }
.kp-tog[aria-pressed="true"] { color: var(--text-primary); border-color: color-mix(in oklab, var(--leaf) 55%, transparent); background: color-mix(in oklab, var(--leaf) 12%, var(--surface-1)); }
.kp-select, .kp-text { width: 100%; max-width: 320px; }

.kp-stage { position: sticky; top: 80px; padding: var(--sp-4); scroll-margin: 80px 0 var(--sp-4); }
.kp-stage-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-4); font-size: 12px; line-height: var(--lh-1); color: var(--text-secondary); }
.kp-slot { transition: max-width var(--dur-sheet) var(--ease-ios); max-width: 100%; }
.kp-slot.chat { max-width: 360px; }
.kp-log { margin-top: var(--sp-4); }
.kp-log h4 { margin: 0 0 var(--sp-2); font-size: 12px; line-height: var(--lh-1); font-weight: 500; color: var(--text-secondary); }
.kp-log ol { list-style: none; margin: 0; padding: 0; }
.kp-log li { display: flex; gap: var(--sp-2); padding: 2px 0; min-width: 0; }
.kp-log code { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.kp-by { flex: none; width: 72px; font-size: 12px; line-height: var(--lh-1); color: var(--text-secondary); }

.kp-out { margin-top: var(--sp-2); }
.kp-pre { margin: 0; padding: var(--sp-3) var(--sp-4); font-family: var(--font-mono); font-size: 12px; line-height: var(--lh-1); color: var(--text-primary); overflow: auto; max-height: 360px; white-space: pre; }
.kp-check { margin: var(--sp-2) 0 0; font-size: 12px; line-height: var(--lh-1); color: var(--text-secondary); }
.kp-qs { margin: 0; padding: 0; list-style: none; counter-reset: q; max-height: 360px; overflow: auto; }
.kp-qs li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; column-gap: var(--sp-2); padding: var(--sp-1) 0; border-top: 1px solid var(--border-subtle); font-size: 13px; line-height: var(--lh-2); counter-increment: q; }
.kp-qs li::before { content: counter(q); color: var(--text-secondary); font-variant-numeric: tabular-nums; font-size: 12px; }
.kp-ans { grid-column: 2; font-size: 12px; line-height: var(--lh-1); color: var(--text-secondary); overflow-wrap: anywhere; }
.kp-when { grid-column: 3; grid-row: 1; font-size: 12px; line-height: var(--lh-2); color: var(--text-secondary); white-space: nowrap; }
.kp-schema { margin-top: var(--sp-4); font-size: 13px; line-height: var(--lh-2); }
.kp-schema summary { cursor: pointer; color: var(--text-secondary); margin-bottom: var(--sp-2); }

@media (max-width: 900px) {
  .kp-row { grid-template-columns: minmax(0, 1fr); }
  .kp-stage { position: static; order: -1; }
  .kp-ctls { order: 0; }
}
@media (pointer: coarse), (max-width: 720px) {
  .kp-seg > label { height: calc(var(--h-4) - 6px); }
  .kp-tog { height: var(--h-4); }
  .kp-tog::after { inset: 0; }
}
@media (max-width: 760px) {
  .kp-stage { padding: var(--sp-3); }
  .kp-stage-h { flex-direction: column; align-items: flex-start; }
  .kp-slot.chat { max-width: none; }
}

/* Touch: every link, summary and label answers a 40px tap. The box grows outward only on the side that is short,
   so neighbours side by side do not steal each other's taps. */
@media (pointer: coarse), (max-width: 720px) {
  .ex :is(a, summary, label, button):not(.btn) { position: relative; }
  .ex :is(a, summary, label, button):not(.btn)::before { content: ""; position: absolute; inset: min(0px, calc((100% - 40px) / 2)); }
}
.ex .ex-head code, .ex .kp-check code { white-space: normal; overflow-wrap: anywhere; }

/* The page is drawn by script: hold a screen of room so nothing below it moves when it lands. */
#dz, #kit { min-height: 100vh; }
/* In-page links ease there and stop with the heading clear of the header. */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
.ex-sec, .ex-sec[id], .dz-spec, [id] { scroll-margin-top: 72px; }
@media (pointer: coarse), (max-width: 720px) { .ex .ex-toc { row-gap: 2px; } .ex .ex-toc a { min-height: 40px; } }
@media (pointer: coarse), (max-width: 720px) { .ex .kp-seg { height: auto; gap: var(--sp-1); } .ex .kp-seg > label { min-height: 40px; } }
@media (pointer: coarse), (max-width: 720px) { .ex .g-segmented > label { min-width: 44px; justify-content: center; } }
@media (pointer: coarse), (max-width: 720px) { .ex .top a.mark { display: inline-flex; align-items: center; min-height: 40px; } .ex footer a { display: inline-flex; align-items: center; min-height: 40px; } .ex .ex-hero-ctl .g-segmented { height: auto; } .ex .ex-hero-ctl .g-segmented > label { min-height: 40px; } .ex :is(input.input, input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="url"]) { min-height: 40px; } .ex .ui-field > label.label { min-height: 40px; display: flex; align-items: center; } }
@media (pointer: coarse), (max-width: 720px) { .ex .kp-schema > summary { display: flex; align-items: center; min-height: 40px; } }
