/* ==========================================================================
   OctyVIBE design-system docs — shared structure.
   Every value comes from /ds/<system>/tokens.css; /ds/<system>/style.css
   adds the personality. Nothing here hard-codes a colour.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-text); font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color var(--dur-emphasis) var(--ease-standard), color var(--dur-emphasis) var(--ease-standard);
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p, figure, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
p { max-width: 66ch; text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; font-family: var(--font-display); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: var(--icon-sw, 1.75); stroke-linecap: round; stroke-linejoin: round; }
.ic--sm { width: 16px; height: 16px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- type styles (from tokens) ---------- */
.t-display { font: var(--fw-display) clamp(calc(var(--fs-display) * .56), 6.4vw + .5rem, var(--fs-display))/var(--lh-display) var(--font-display); letter-spacing: var(--ls-display); text-transform: var(--tt-display); }
.t-h1 { font: var(--fw-h1) clamp(calc(var(--fs-h1) * .7), 3.6vw + .8rem, var(--fs-h1))/var(--lh-h1) var(--font-display); letter-spacing: var(--ls-h1); text-transform: var(--tt-h1); }
.t-h2 { font: var(--fw-h2) clamp(calc(var(--fs-h2) * .8), 2vw + .9rem, var(--fs-h2))/var(--lh-h2) var(--font-display); letter-spacing: var(--ls-h2); text-transform: var(--tt-h2); }
.t-h3 { font: var(--fw-h3) var(--fs-h3)/var(--lh-h3) var(--font-display); letter-spacing: var(--ls-h3); text-transform: var(--tt-h3); }
.t-body-lg { font: var(--fw-body-lg) var(--fs-body-lg)/var(--lh-body-lg) var(--font-text); letter-spacing: var(--ls-body-lg); }
.t-body { font: var(--fw-body) var(--fs-body)/var(--lh-body) var(--font-text); }
.t-small { font: var(--fw-small) var(--fs-small)/var(--lh-small) var(--font-text); }
.t-caption { font: var(--fw-caption) var(--fs-caption)/var(--lh-caption) var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: var(--tt-caption); }
.t-mono { font: var(--fw-mono) var(--fs-mono)/var(--lh-mono) var(--font-mono); }

/* ---------- portfolio strip (excluded from the 2-font rule, like the demos) ---------- */
.demobar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 0 max(16px, env(safe-area-inset-left));
  background: #17171A; color: #E9E7E2; font: 500 13px/1.2 Inter, system-ui, sans-serif;
}
.demobar a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; color: #fff; text-decoration: none; white-space: nowrap; }
.demobar a:hover { text-decoration: underline; text-underline-offset: 3px; }
.demobar__what { opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demobar .ic { width: 16px; height: 16px; stroke-width: 2; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 12px 16px; background: var(--primary); color: var(--primary-ink); border-radius: var(--radius-sm); }
.skip:focus { top: 12px; }

/* ---------- doc header ---------- */
.doc-head {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px; min-height: 64px;
  padding: 8px max(16px, env(safe-area-inset-left)) 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: var(--border-w) solid var(--line);
}
.doc-brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.doc-brand__mark { width: 22px; height: 22px; flex: none; }
.doc-brand small { font-weight: 400; color: var(--muted); }
.doc-systems { display: flex; gap: 4px; margin-left: 8px; }
.doc-systems a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-size: 14px; }
.doc-systems a:hover { color: var(--ink); background: var(--surface-2); }
.doc-systems a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.doc-systems b { font-family: var(--font-mono); font-weight: 500; font-size: 12px; }
.doc-head__end { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* theme switch: two real options, icon + word */
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border: var(--border-w) solid var(--line); border-radius: var(--radius-pill); background: var(--surface); }
.theme-switch button { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out); }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); box-shadow: var(--elev-1); }
.theme-switch .ic { width: 16px; height: 16px; }

/* ---------- layout ---------- */
.doc-wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }
.doc-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: clamp(32px, 5vw, 80px); align-items: start; }
.doc-side { position: sticky; top: 88px; padding: 40px 0 40px; max-height: calc(100vh - 88px); overflow: auto; scrollbar-width: thin; }
.doc-side h2 { font: var(--fw-caption) var(--fs-caption)/1.4 var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: uppercase; color: var(--muted); margin: 24px 0 6px; }
.doc-side h2:first-child { margin-top: 0; }
.doc-side a { display: flex; align-items: center; min-height: 32px; padding: 0 10px; margin-left: -10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-size: 14px; transition: color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out); }
.doc-side a:hover { color: var(--ink); background: var(--surface-2); }
.doc-side a[aria-current="true"] { color: var(--ink); font-weight: 600; background: var(--surface-2); }
.doc-main { min-width: 0; padding: 40px 0 120px; }

.doc-section { padding-top: 56px; }
.doc-section + .doc-section { margin-top: 72px; border-top: var(--border-w) solid var(--line); }
.doc-section__head { display: grid; gap: 12px; margin-bottom: 40px; max-width: 760px; }
.doc-eyebrow { font: var(--fw-caption) var(--fs-caption)/var(--lh-caption) var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: uppercase; color: var(--muted); }
.doc-lede { color: var(--ink-2); font-size: var(--fs-body-lg); line-height: var(--lh-body-lg); }

.doc-block { padding-top: 48px; scroll-margin-top: 80px; }
.doc-block__head { display: grid; gap: 8px; margin-bottom: 24px; max-width: 720px; }
.doc-block__head p { color: var(--ink-2); }
.doc-sub { margin: 32px 0 12px; font: var(--fw-caption) var(--fs-caption)/var(--lh-caption) var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: uppercase; color: var(--muted); }

.doc-stage {
  position: relative; padding: clamp(20px, 3vw, 40px);
  background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-md);
}
.doc-stage--sunk { background: var(--surface-2); }
.doc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.doc-row + .doc-row { margin-top: 20px; }
.doc-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.doc-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }

/* states matrix */
.states { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0; border: var(--border-w) solid var(--line); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.states figure { display: grid; grid-template-rows: 1fr auto; gap: 14px; justify-items: start; align-content: space-between; padding: 20px 18px 14px; border-right: var(--border-w) solid var(--line); border-bottom: var(--border-w) solid var(--line); margin: 0 calc(var(--border-w) * -1) calc(var(--border-w) * -1) 0; min-height: 124px; }
.states figcaption { font: 500 12px/1.3 var(--font-mono); color: var(--muted); }
.states figcaption b { display: block; color: var(--ink); font-weight: 500; font-family: var(--font-text); font-size: 13px; margin-bottom: 2px; }
.states--wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.states--wide figure > :first-child { width: 100%; }

/* spec list */
.spec { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-top: 16px; background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.spec div { padding: 12px 14px; display: grid; gap: 2px; align-content: start; border-right: var(--border-w) solid var(--line); border-bottom: var(--border-w) solid var(--line); margin: 0 calc(var(--border-w) * -1) calc(var(--border-w) * -1) 0; }
.spec dt { font-size: 12px; color: var(--muted); }
.spec dd { font: 500 13px/1.4 var(--font-mono); color: var(--ink); overflow-wrap: anywhere; }

.doc-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; color: var(--ink-2); font-size: var(--fs-small); line-height: var(--lh-small); }
.doc-note .ic { margin-top: 1px; color: var(--muted); }

/* ---------- foundations: colour ---------- */
.roles { border: var(--border-w) solid var(--line); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.roles__head, .role { display: grid; grid-template-columns: minmax(150px, 1.1fr) 1fr 1fr minmax(160px, 1.3fr) 48px; align-items: center; gap: 16px; padding: 10px 16px; }
.roles__head { font: var(--fw-caption) var(--fs-caption)/1.3 var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding-block: 10px; }
.role + .role { border-top: var(--border-w) solid var(--line); }
.role__name b { display: block; font-weight: 600; font-size: 14px; }
.role__name code { font: 400 12px/1.4 var(--font-mono); color: var(--muted); }
.role__val { display: flex; align-items: center; gap: 10px; min-width: 0; }
.role__val code { font: 400 12px/1.3 var(--font-mono); color: var(--ink-2); overflow-wrap: anywhere; }
.role__use { font-size: 13px; color: var(--muted); line-height: 1.4; }
.chip { position: relative; flex: none; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.chip::after { content: ""; position: absolute; inset: 0; background: var(--c); border-radius: inherit; }
.chip--edge::after { box-shadow: inset 0 0 0 1px rgba(128,128,128,.25); }
.copy { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); transition: color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out); }
.copy:hover { color: var(--ink); background: var(--surface-2); }
.copy .ic { width: 18px; height: 18px; }

.contrast { width: 100%; border-collapse: collapse; background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); overflow: hidden; font-size: 14px; }
.contrast-wrap { position: relative; border-radius: var(--radius-md); overflow: auto; }
.contrast th { text-align: left; font: var(--fw-caption) var(--fs-caption)/1.3 var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 10px 14px; white-space: nowrap; }
.contrast td { padding: 10px 14px; border-top: var(--border-w) solid var(--line); vertical-align: middle; }
.contrast td:first-child { min-width: 180px; }
.contrast td:first-child b { display: block; font-weight: 600; }
.contrast td:first-child code { font: 400 12px/1.4 var(--font-mono); color: var(--muted); }
.cr { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.cr__sample { display: inline-grid; place-items: center; width: 52px; height: 36px; border-radius: var(--radius-xs); background: var(--bg); position: relative; overflow: hidden; font-weight: 600; font-size: 15px; }
.cr__sample > span { position: absolute; inset: 0; display: grid; place-items: center; }
.cr__val { font: 500 13px/1 var(--font-mono); min-width: 52px; }
.cr__badge { font: 600 11px/1 var(--font-mono); padding: 4px 6px; border-radius: var(--radius-xs); background: var(--ok-soft); color: var(--ok); letter-spacing: .02em; }
.cr__badge.is-fail { background: var(--danger-soft); color: var(--danger); }
.contrast tr.is-current-light td.col-light, .contrast tr td.is-current { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }

.lab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: stretch; }
.lab__controls { display: grid; gap: 16px; align-content: start; }
.lab__out { display: grid; align-content: space-between; gap: 16px; padding: 24px; border-radius: var(--radius-md); border: var(--border-w) solid var(--line); min-height: 220px; }
.lab__ratio { font: 600 clamp(40px, 6vw, 64px)/1 var(--font-display); letter-spacing: -.03em; }
.lab__verdict { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- foundations: type, space, radius, elevation, motion ---------- */
.type-tester { margin-bottom: 16px; max-width: 520px; }
.type-rows { border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.type-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: baseline; padding: 20px; }
.type-row + .type-row { border-top: var(--border-w) solid var(--line); }
.type-row__meta b { display: block; font-size: 13px; font-weight: 600; }
.type-row__meta code { font: 400 12px/1.5 var(--font-mono); color: var(--muted); }
.type-row__sample { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }

.space-list { display: grid; gap: 10px; }
.space-item { display: grid; grid-template-columns: 110px 56px minmax(0, 1fr); gap: 16px; align-items: center; font: 400 12px/1.4 var(--font-mono); color: var(--muted); }
.space-item b { color: var(--ink); font-weight: 500; }
.space-bar { height: 16px; width: var(--w); background: var(--accent); border-radius: 2px; opacity: .85; }

.radius-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.radius-tile { display: grid; gap: 10px; }
.radius-tile__shape { height: 96px; background: var(--surface-2); border: var(--border-w-strong) solid var(--line-strong); border-radius: var(--r); }
.radius-tile code, .elev-tile code { font: 400 12px/1.4 var(--font-mono); color: var(--muted); }
.radius-tile b, .elev-tile b { display: block; font-size: 13px; font-weight: 600; }

.elev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; padding: 32px; background: var(--surface-2); border-radius: var(--radius-md); }
.elev-tile { display: grid; gap: 12px; }
.elev-tile__shape { height: 110px; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--e); }
.elev-tile p { font-size: 13px; color: var(--ink-2); line-height: 1.45; }

.motion-list { border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.motion-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 120px; gap: 20px; align-items: center; padding: 16px 20px; }
.motion-row + .motion-row { border-top: var(--border-w) solid var(--line); }
.motion-row__meta b { display: block; font-size: 14px; font-weight: 600; }
.motion-row__meta code { font: 400 12px/1.4 var(--font-mono); color: var(--muted); }
.motion-row__meta p { font-size: 13px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.motion-track { position: relative; height: 44px; border-radius: var(--radius-pill); background: var(--surface-2); }
.motion-dot { position: absolute; top: 6px; left: 6px; width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--ink); }
.curve { width: 100%; max-width: 120px; height: 56px; }
.curve path.c { fill: none; stroke: var(--ink); stroke-width: 2; }
.curve path.g { fill: none; stroke: var(--line); stroke-width: 1; }

/* ---------- components ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 18px; border: var(--border-w) solid transparent; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn .ic { width: 18px; height: 18px; }
.btn--primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn--accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--danger { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); }
.btn--sm { min-height: var(--control-h-sm); padding: 0 12px; font-size: 13px; }
.btn--lg { min-height: var(--control-h-lg); padding: 0 24px; font-size: 16px; }
.btn--icon { padding: 0; width: var(--control-h); }
.btn--block { width: 100%; }
.btn:hover, .btn.is-hover { filter: none; }
.btn--primary:hover, .btn--primary.is-hover { background: color-mix(in srgb, var(--primary) 86%, var(--bg)); }
.btn--accent:hover, .btn--accent.is-hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn--secondary:hover, .btn--secondary.is-hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn--ghost:hover, .btn--ghost.is-hover { background: var(--surface-2); }
.btn--danger:hover, .btn--danger.is-hover { background: color-mix(in srgb, var(--danger) 88%, var(--ink)); }
.btn:focus-visible, .btn.is-focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:active, .btn.is-active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled { background: var(--surface-2); color: var(--muted); border-color: var(--line); cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-loading { cursor: progress; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s cubic-bezier(.5,.15,.5,.85) infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* fields */
.form { display: grid; gap: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 20px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field__label { font-size: 14px; font-weight: 600; color: var(--ink); }
.field__label small { font-weight: 400; color: var(--muted); }
.field__control { position: relative; display: block; }
.field__icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field__icon .ic { width: 18px; height: 18px; }
.field__control--icon .input { padding-left: 42px; }
.field__msg { display: flex; gap: 6px; align-items: flex-start; min-height: 1.45em; font-size: 13px; line-height: 1.45; color: var(--muted); margin-bottom: 10px; }
.field__msg.is-error { color: var(--danger); }
.field__msg .ic { width: 15px; height: 15px; margin-top: 2px; }

.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: 0 14px;
  background: var(--surface); color: var(--ink); border: var(--border-w) solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 16px; line-height: 1.3; outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.textarea { padding: 12px 14px; min-height: 104px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .select:hover, .textarea:hover, .is-hover > .input, .input.is-hover, .select.is-hover { border-color: var(--ink-2); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible, .input:focus, .select:focus, .textarea:focus, .input.is-focus, .select.is-focus {
  border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 26%, transparent); outline: none;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"], .input.is-error, .select.is-error { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 24%, transparent); border-color: var(--danger); }
.input:disabled, .select:disabled, .textarea:disabled, .input.is-disabled { background: var(--surface-2); color: var(--muted); border-color: var(--line); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); }
.select-wrap { position: relative; display: block; }
.select { padding-right: 42px; cursor: pointer; }
.select-wrap > .ic { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-2); width: 18px; height: 18px; }
.select option { background: var(--surface-solid, var(--surface)); color: var(--ink); }
.prefix { display: flex; align-items: stretch; }
.prefix > span { display: inline-flex; align-items: center; padding: 0 12px; border: var(--border-w) solid var(--line-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 15px; white-space: nowrap; }
.prefix > .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; min-width: 0; }

/* segmented */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); max-width: 100%; overflow-x: auto; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label > span { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; min-width: 64px; padding: 0 14px; border-radius: calc(var(--radius-sm) - 2px); color: var(--ink-2); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out); }
.seg input:hover + span { color: var(--ink); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--elev-1), 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* choices */
.choices { display: grid; gap: 2px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-size: 15px; }
.choice__text small { display: block; color: var(--muted); font-size: 13px; }
.choice--between { justify-content: space-between; }
.cbox, .radio {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; width: 20px; height: 20px;
  display: inline-grid; place-content: center; background: var(--surface); border: var(--border-w-strong) solid var(--line-strong); border-radius: var(--radius-xs); cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out);
}
.radio { border-radius: 50%; }
.cbox::before { content: ""; width: 11px; height: 6px; border: solid var(--primary-ink); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform var(--dur-micro) var(--ease-out); }
.cbox:checked, .cbox:indeterminate, .cbox.is-checked { background: var(--primary); border-color: var(--primary); }
.cbox:checked::before, .cbox.is-checked::before { transform: translateY(-1px) rotate(-45deg) scale(1); }
.cbox:indeterminate::before, .cbox.is-mixed::before { width: 10px; height: 0; border-width: 0 0 2px 0; transform: none; }
.cbox.is-mixed { background: var(--primary); border-color: var(--primary); }
.radio::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary-ink); transform: scale(0); transition: transform var(--dur-micro) var(--ease-out); }
.radio:checked, .radio.is-checked { background: var(--primary); border-color: var(--primary); }
.radio:checked::before, .radio.is-checked::before { transform: scale(1); }
.cbox:hover, .radio:hover, .cbox.is-hover, .radio.is-hover { border-color: var(--ink-2); }
.cbox:focus-visible, .radio:focus-visible, .switch:focus-visible, .cbox.is-focus, .radio.is-focus, .switch.is-focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.cbox:disabled, .radio:disabled, .switch:disabled, .is-disabled.cbox, .is-disabled.radio, .is-disabled.switch { opacity: .45; cursor: not-allowed; }
.cbox[aria-invalid="true"], .cbox.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.switch {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; position: relative; width: 44px; height: 26px; cursor: pointer;
  border-radius: var(--radius-pill); background: var(--surface-2); border: var(--border-w-strong) solid var(--line-strong);
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out);
}
.switch::before { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: var(--radius-pill); background: var(--ink-2); transition: transform var(--dur-enter) var(--ease-out), background-color var(--dur-micro) var(--ease-out); }
.switch:checked, .switch.is-checked { background: var(--switch-on, var(--primary)); border-color: var(--switch-on, var(--primary)); }
.switch:checked::before, .switch.is-checked::before { transform: translateX(18px); background: var(--switch-thumb-on, var(--primary-ink)); }
.check-group-err { min-height: 1.45em; font-size: 13px; color: var(--danger); }

/* cards, badges, avatars */
.card { background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); padding: 24px; display: grid; gap: 12px; align-content: start; }
a.card { text-decoration: none; color: inherit; transition: border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
a.card:hover { border-color: var(--line-strong); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--plain::before { display: none; }
.avatars { display: flex; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 12px; font-weight: 600; color: var(--bg); background: var(--ink-2); border: 2px solid var(--surface); flex: none; }
.avatars .avatar + .avatar { margin-left: -8px; }
.avatar--more { background: var(--surface-2); color: var(--ink-2); }

/* tabs */
.tabs__list { position: relative; display: flex; gap: 4px; border-bottom: var(--border-w) solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-size: 15px; font-weight: 500; white-space: nowrap; transition: color var(--dur-micro) var(--ease-out); }
.tab:hover, .tab.is-hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab:disabled, .tab.is-disabled { opacity: .45; cursor: not-allowed; }
.tab:focus-visible, .tab.is-focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.tab .count { font: 500 12px/1 var(--font-mono); color: var(--muted); }
.tabs__ink { position: absolute; left: 0; bottom: -1px; height: 2px; width: var(--w, 0); transform: translateX(var(--x, 0)); background: var(--ink); transition: transform var(--dur-emphasis) var(--ease-standard), width var(--dur-emphasis) var(--ease-standard); }
.tabs__panel { padding-top: 20px; }
.tabs--static .tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); }

/* toast */
.toasts { position: fixed; z-index: 90; right: 24px; bottom: 24px; display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 12px 8px 12px 14px; background: var(--surface-solid, var(--surface)); color: var(--ink);
  border: var(--border-w) solid var(--line); border-radius: var(--radius-md); box-shadow: var(--elev-2); overflow: hidden; pointer-events: auto;
  animation: toast-in var(--dur-enter) var(--ease-out) both;
}
.toast.is-leaving { animation: toast-out var(--dur-exit) var(--ease-in) both; }
.toast--static { animation: none; pointer-events: auto; }
.toast__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); }
.toast__icon .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.toast--ok .toast__icon { background: var(--ok-soft); color: var(--ok); }
.toast--warn .toast__icon { background: var(--warn-soft); color: var(--warn); }
.toast--danger .toast__icon { background: var(--danger-soft); color: var(--danger); }
.toast__body { min-width: 0; }
.toast__title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.toast__text { font-size: 13px; color: var(--muted); line-height: 1.4; }
.toast__action { min-height: 36px; padding: 0 10px; border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 14px; border-radius: var(--radius-sm); }
.toast__action:hover { background: var(--surface-2); }
.toast__close { display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-sm); }
.toast__close:hover { color: var(--ink); background: var(--surface-2); }
.toast__close .ic { width: 16px; height: 16px; }
.toast__timer { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--ink-2); opacity: .5; transform-origin: left; animation: toast-timer linear forwards; }
.toast:hover .toast__timer, .toast:focus-within .toast__timer { animation-play-state: paused; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes toast-timer { to { transform: scaleX(0); } }
.toast-stack { display: grid; gap: 10px; max-width: 420px; }

/* modal & sheet */
.modal, .sheet { padding: 0; border: 0; color: var(--ink); background: var(--surface-solid, var(--surface)); box-shadow: var(--elev-3); max-width: none; max-height: none; }
.modal { width: min(520px, calc(100vw - 32px)); border-radius: var(--radius-lg); margin: auto; animation: modal-in var(--dur-enter) var(--ease-out) both; }
.modal::backdrop, .sheet::backdrop { background: var(--scrim, rgba(16,16,24,.4)); animation: fade-in var(--dur-enter) var(--ease-out) both; }
.modal.is-closing { animation: modal-out var(--dur-exit) var(--ease-in) both; }
.modal.is-closing::backdrop, .sheet.is-closing::backdrop { animation: fade-out var(--dur-exit) var(--ease-in) both; }
.modal__head { display: flex; gap: 14px; align-items: flex-start; padding: 24px 24px 0; }
.modal__body { padding: 16px 24px 8px; display: grid; gap: 12px; }
.modal__body > p { color: var(--ink-2); }
.modal__foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; flex-wrap: wrap; }
.modal__foot .grow { margin-right: auto; font-size: 13px; color: var(--muted); }
.modal__x { margin-left: auto; margin-top: -8px; margin-right: -10px; }
.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; width: min(440px, 100vw); border-radius: var(--radius-lg) 0 0 var(--radius-lg); display: none; animation: sheet-in var(--dur-enter) var(--ease-out) both; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet.is-closing { animation: sheet-out var(--dur-exit) var(--ease-in) both; }
.sheet__head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 12px 24px; border-bottom: var(--border-w) solid var(--line); }
.sheet__body { flex: 1; overflow: auto; padding: 20px 24px; display: grid; gap: 8px; align-content: start; }
.sheet__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 24px max(16px, env(safe-area-inset-bottom)); border-top: var(--border-w) solid var(--line); }
.sheet__grip { display: none; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes sheet-in { from { transform: translateX(100%); } }
@keyframes sheet-out { to { transform: translateX(100%); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.modal-preview { position: relative; display: grid; place-items: center; padding: clamp(24px, 5vw, 56px) 16px; border-radius: var(--radius-md); background: var(--scrim); overflow: hidden; }
.modal-preview .modal { position: static; display: block; animation: none; }

/* empty state */
.empty { display: grid; justify-items: start; gap: 10px; padding: clamp(24px, 4vw, 40px); border: var(--border-w) dashed var(--line-strong); border-radius: var(--radius-md); }
.empty__glyph { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink-2); margin-bottom: 4px; }
.empty__glyph .ic { width: 22px; height: 22px; }
.empty p { color: var(--ink-2); font-size: 15px; }
.empty .doc-row { margin-top: 8px; }

/* skeleton */
.skel { display: block; background: var(--surface-2); border-radius: var(--radius-xs); }
@media (prefers-reduced-motion: no-preference) { .skel { animation: skel 1.4s var(--ease-standard) infinite alternate; } }
@keyframes skel { from { opacity: 1; } to { opacity: .45; } }
.loadable .when-loading { display: none; }
.loadable.is-loading .when-loading { display: grid; }
.loadable.is-loading .when-ready { display: none; }

/* lists used by demos */
.list { border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; min-height: 60px; }
.list__item + .list__item { border-top: var(--border-w) solid var(--line); }
.list__item .grow { flex: 1; min-width: 0; }
.list__item b { display: block; font-weight: 600; font-size: 15px; }
.list__item small { color: var(--muted); font-size: 13px; }
.list__item.is-new { animation: toast-in var(--dur-enter) var(--ease-out) both; }
.count-line { font-size: 13px; color: var(--muted); margin: 10px 0; }

/* table */
.table-wrap { position: relative; overflow-x: auto; border: var(--border-w) solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font: var(--fw-caption) var(--fs-caption)/1.3 var(--ff-caption, var(--font-text)); letter-spacing: var(--ls-caption); text-transform: uppercase; color: var(--muted); padding: 12px 16px; background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-top: var(--border-w) solid var(--line); vertical-align: middle; }
.table tr.is-new td { animation: toast-in var(--dur-enter) var(--ease-out) both; }
.who { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.who b { display: block; font-weight: 600; }
.who small { color: var(--muted); font-size: 13px; }

/* screens */
.screen { position: relative; border: var(--border-w) solid var(--line); border-radius: var(--radius-lg); background: var(--bg); overflow: hidden; box-shadow: var(--elev-2); }
.screen__bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: var(--border-w) solid var(--line); background: var(--surface); font: 400 12px/1 var(--font-mono); color: var(--muted); }
.screen__bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; }
.screen__bar span { margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen__body { padding: clamp(16px, 3vw, 32px); }
.screen-intro { display: grid; gap: 8px; margin: 0 0 20px; max-width: 720px; }
.screen-intro p { color: var(--ink-2); }
.doc-block--screen + .doc-block--screen { margin-top: 40px; }

/* doctrine list */
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.rule { padding: 20px; display: grid; gap: 6px; align-content: start; border-right: var(--border-w) solid var(--line); border-bottom: var(--border-w) solid var(--line); margin: 0 calc(var(--border-w) * -1) calc(var(--border-w) * -1) 0; }
.rule code { font: 500 12px/1 var(--font-mono); color: var(--muted); }
.rule b { font-weight: 600; }
.rule p { font-size: 14px; color: var(--ink-2); line-height: 1.5; }

/* footer */
.doc-foot { border-top: var(--border-w) solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 14px; }
.doc-foot__in { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: center; }
.doc-foot a { color: var(--ink-2); display: inline-flex; align-items: center; min-height: 44px; }
.doc-foot nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }

/* mobile tab bar */
.tabbar { display: none; }

/* downloads */
.downloads { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .doc-body { grid-template-columns: 170px minmax(0, 1fr); gap: 32px; }
  .roles__head, .role { grid-template-columns: minmax(130px, 1fr) 1fr 1fr 44px; }
  .roles__head .role__use, .role .role__use { display: none; }
}
@media (max-width: 900px) {
  .doc-systems { display: none; }
  .lab { grid-template-columns: 1fr; }
}
@media (max-width: 759px) {
  html { scroll-padding-top: 76px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .doc-body { display: block; }
  .doc-side { display: none; }
  .doc-main { padding-top: 8px; }
  .doc-head { min-height: 60px; gap: 8px; }
  .doc-head__dl { display: none; }
  .doc-brand small { display: none; }
  .theme-switch button { min-height: 44px; padding: 0 10px; }
  .doc-section { padding-top: 40px; }
  .doc-section + .doc-section { margin-top: 48px; }
  .doc-grid-2, .doc-grid-3 { grid-template-columns: 1fr; }
  .btn, .btn--sm { min-height: 44px; }
  .btn--icon { width: 44px; }
  .seg label > span { min-height: 44px; }
  .toast__action, .toast__close { min-height: 44px; min-width: 44px; }
  .doc-side a, .doc-systems a { min-height: 44px; }
  .roles__head { display: none; }
  .role { grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "name copy" "light light" "dark dark"; row-gap: 8px; }
  .role__name { grid-area: name; } .role .copy { grid-area: copy; }
  .role__val--light { grid-area: light; } .role__val--dark { grid-area: dark; }
  .type-row { grid-template-columns: 1fr; gap: 8px; }
  .motion-row { grid-template-columns: 1fr; gap: 12px; }
  .curve { display: none; }
  .space-item { grid-template-columns: 90px 44px minmax(0, 1fr); gap: 10px; }
  .toasts { left: 16px; right: 16px; width: auto; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .sheet { inset: auto 0 0 0; width: 100%; height: auto; max-height: 88vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; animation-name: sheet-up; }
  .sheet.is-closing { animation-name: sheet-down; }
  .sheet__grip { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 8px auto 0; }
  .tabbar {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 4px 4px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); border-top: var(--border-w) solid var(--line);
  }
  .tabbar a { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 58px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .01em; border-radius: var(--radius-sm); }
  .tabbar a[aria-current="true"] { color: var(--ink); }
  .tabbar .ic { width: 22px; height: 22px; }
  .demobar__what { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
