/* UI Catalogue: mobile-first styles. Tokens: primitives -> semantic -> component.
   Breakpoints (min-width): 480 / 768 / 1024 / 1440. Touch targets >= 44px. Motion: transform/opacity only. */

/* ---------- tokens ---------- */
:root {
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-s: 8px; --r-m: 12px; --r-l: 20px; --r-pill: 999px;
  --gap: 12px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: 140ms; --dur: 240ms; --dur-slow: 340ms;
  --header-h: 56px; --nav-h: 64px;
  --z-sticky: 20; --z-nav: 30; --z-dialog: 100;

  --bg: #fafaf9; --surface: #ffffff; --surface-2: #f2f2f0; --surface-3: #e9e9e6;
  --text: #111113; --muted: #595d65; --faint: #8a8e96;
  --border: rgb(17 17 19 / .10); --border-strong: rgb(17 17 19 / .22);
  --accent: #4f46e5; --accent-ink: #ffffff; --accent-text: #4338ca; --accent-soft: rgb(79 70 229 / .10);
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 8px 24px rgb(0 0 0 / .07);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / .08), 0 24px 64px rgb(0 0 0 / .18);
  --scrim: rgb(10 10 12 / .52);
  --skeleton-a: #ececea; --skeleton-b: #f6f6f4;
}
[data-theme="dark"] {
  --bg: #0f0f10; --surface: #161618; --surface-2: #1d1d20; --surface-3: #27272b;
  --text: #f2f2f3; --muted: #a3a3ab; --faint: #75757d;
  --border: rgb(255 255 255 / .09); --border-strong: rgb(255 255 255 / .2);
  --accent: #5b5ff0; --accent-ink: #ffffff; --accent-text: #a9acff; --accent-soft: rgb(91 95 240 / .18);
  --danger: #ff8a80;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .35);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / .5), 0 24px 64px rgb(0 0 0 / .6);
  --scrim: rgb(0 0 0 / .66);
  --skeleton-a: #1b1b1e; --skeleton-b: #232327;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f10; --surface: #161618; --surface-2: #1d1d20; --surface-3: #27272b;
    --text: #f2f2f3; --muted: #a3a3ab; --faint: #75757d;
    --border: rgb(255 255 255 / .09); --border-strong: rgb(255 255 255 / .2);
    --accent: #5b5ff0; --accent-ink: #ffffff; --accent-text: #a9acff; --accent-soft: rgb(91 95 240 / .18);
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .35);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / .5), 0 24px 64px rgb(0 0 0 / .6);
    --scrim: rgb(0 0 0 / .66);
    --skeleton-a: #1b1b1e; --skeleton-b: #232327;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 16px/1.55 var(--font-sans); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  overflow-wrap: break-word;
}
img, video, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-text); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.18; text-wrap: balance; margin: 0; letter-spacing: -.015em; }
p { margin: 0; text-wrap: pretty; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--r-s); transition: transform var(--dur-fast); }
.skip:focus { transform: translateY(72px); }
.wrap { width: 100%; max-width: 1440px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 40px); }
.mono { font-family: var(--font-mono); }
.eyebrow { font: 500 11px/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface); font-weight: 500; font-size: 14px;
  text-decoration: none; color: var(--text); white-space: nowrap;
  transition: background-color var(--dur-fast), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.1); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 44px; padding: 0; }
.btn .count { min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: 600 11px/20px var(--font-mono); text-align: center; padding-inline: 5px; }

.field {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: var(--r-m);
  background: var(--surface); border: 1px solid var(--border-strong); transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field svg { color: var(--muted); }
.field input { flex: 1; min-width: 0; height: 46px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.field input::placeholder { color: var(--faint); }
.field input::-webkit-search-cancel-button { display: none; }
.field kbd { display: none; font: 500 11px var(--font-mono); color: var(--muted); border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px 6px; }
.field .clear { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.field .clear:hover { background: var(--surface-2); }
.field .clear[hidden] { display: none; }

.seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); gap: 2px; max-width: 100%; }
.seg button { min-height: 38px; padding: 0 14px; border-radius: var(--r-pill); font-size: 14px; font-weight: 500; color: var(--muted); transition: background-color var(--dur-fast), color var(--dur-fast); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 14px; white-space: nowrap; color: var(--text); transition: background-color var(--dur-fast), border-color var(--dur-fast);
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
.chip small { font: 500 11px var(--font-mono); opacity: .65; }
.chip.remove { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); padding-right: 8px; }
.chip.remove svg { width: 16px; height: 16px; }

/* ---------- header ---------- */
.top { background: var(--bg); border-bottom: 1px solid var(--border); }
.top .row { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -.02em; color: var(--text); text-decoration: none; min-height: 44px; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.brand .mark svg { width: 18px; height: 18px; stroke-width: 2; }
.top nav.desk { display: none; margin-left: 12px; gap: 4px; }
.top nav.desk a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--r-pill); text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; }
.top nav.desk a:hover, .top nav.desk a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.top .grow { flex: 1; }
.top .connect-top { display: none; }

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-nav); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-top: 1px solid var(--border);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: var(--r-m); text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.bottom-nav a[aria-current="page"] { color: var(--accent-text); }
.bottom-nav a[aria-current="page"] svg { transform: translateY(-1px); }
.bottom-nav a:active { background: var(--surface-2); }

/* ---------- hero ---------- */
.hero { padding-block: 14px 6px; display: grid; gap: 12px; }
.hero .eyebrow, .hero .hero-title br, .hero .ctas .btn:not(.primary) { display: none; }
.hero .hero-title { margin: 0; line-height: 1.12; font-size: clamp(26px, 7.4vw, 56px); font-weight: 600; letter-spacing: -.035em; text-wrap: balance; }
.hero p.lead { color: var(--muted); font-size: clamp(15px, 3.8vw, 18px); max-width: 60ch; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero .ctas { display: flex; flex-wrap: wrap; gap: 10px; }
.hero .ctas .btn.primary { flex: 1; }
.hero .stats { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.hero .stats b { font: 600 15px var(--font-mono); color: var(--text); font-variant-numeric: tabular-nums; }
.hero .stats span { font-size: 12px; color: var(--muted); margin-left: 4px; }
.hero[hidden] { display: none; }

/* ---------- sticky filter bar ---------- */
.bar { position: sticky; top: 0; z-index: var(--z-sticky); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid transparent; padding-block: 10px 8px; transition: border-color var(--dur); }
.bar.stuck { border-bottom-color: var(--border); }
.bar .line { display: flex; gap: 8px; align-items: center; }
.bar .line .field { flex: 1; min-width: 0; }
@media (max-width: 359px) { #fbtn .lbl { display: none; } #fbtn { padding: 0 12px; } }
.tabs-top { display: none; }
.rail { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent 100%); margin-inline: calc(clamp(16px, 4vw, 40px) * -1); padding-inline: clamp(16px, 4vw, 40px); }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-block: 12px 4px; min-height: 40px; }
.meta-row .count { font: 500 13px var(--font-mono); color: var(--muted); margin-right: auto; font-variant-numeric: tabular-nums; }

/* ---------- grid / cards ---------- */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); padding-block: 8px 24px; }
.card { position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: var(--r-m); text-decoration: none; color: inherit; content-visibility: auto; contain-intrinsic-size: auto 240px; }
.card .thumb { position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-m); overflow: hidden; background: linear-gradient(110deg, var(--skeleton-a) 30%, var(--skeleton-b) 50%, var(--skeleton-a) 70%); background-size: 200% 100%; border: 1px solid var(--border); isolation: isolate; }
.card .thumb img, .card .thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--dur), transform var(--dur-slow) var(--ease-out); }
.card .thumb img.ok, .card .thumb video.ok { opacity: 1; }
.card:hover .thumb img { transform: scale(1.025); }
.card .badge { position: absolute; left: 8px; top: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: var(--r-pill); background: rgb(0 0 0 / .62); color: #fff; font: 500 11px var(--font-mono); backdrop-filter: blur(6px); }
.card .badge svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.card .info { padding: 10px 2px 2px; display: grid; gap: 2px; }
.card .t { font-size: 14px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:focus-visible { outline-offset: 4px; }
.card.app .strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px; border-radius: var(--r-m); background: var(--surface-2); border: 1px solid var(--border); }
.card.app .strip.web { grid-template-columns: 1fr; }
.card.app .strip .shot { aspect-ratio: 9 / 19; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.card.app .strip.web .shot { aspect-ratio: 16 / 10; }
.card.app .strip.web .shot:nth-child(n+2) { display: none; }
.card.app .strip img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); font: 500 10.5px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

.empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: 12px; text-align: center; padding: 56px 16px; color: var(--muted); }
.empty h2 { font-size: 20px; color: var(--text); }
.sentinel { height: 1px; }
.more { display: flex; justify-content: center; padding: 8px 0 32px; }

.skeleton .thumb { animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- dialogs (bottom sheet on mobile, centered on desktop) ---------- */
dialog { padding: 0; border: 0; color: var(--text); background: var(--surface); max-width: none; max-height: none; overscroll-behavior: contain; }
dialog::backdrop { background: var(--scrim); }
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-height: 92dvh; height: auto; border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: var(--shadow-lg);
  flex-direction: column; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet[open] { display: flex; }
dialog.sheet[open] { animation: sheet-in var(--dur) var(--ease-out); }
dialog.sheet.full { height: 96dvh; }
dialog.sheet.closing { animation: sheet-out var(--dur-fast) ease-in forwards; }
dialog.sheet[open]::backdrop { animation: fade-in var(--dur); }
@keyframes sheet-in { from { transform: translateY(32px); opacity: .4; } }
@keyframes sheet-out { to { transform: translateY(24px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 20px; flex: none; }
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 4px 20px 20px; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-foot { flex: none; display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.sheet-foot .btn { flex: 1; }
.group { padding-block: 14px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.group:last-child { border-bottom: 0; }
.group h3 { font: 500 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
select.sel { width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--border-strong); font-size: 16px; }

/* detail */
.detail .stage { position: relative; background: var(--surface-2); display: grid; place-items: center; min-height: 220px; max-height: 52dvh; overflow: hidden; flex: none; }
.detail .stage img, .detail .stage video { width: 100%; height: 100%; max-height: 52dvh; object-fit: contain; }
.detail .stage .spin { position: absolute; inset: 0; background: linear-gradient(110deg, var(--skeleton-a) 30%, var(--skeleton-b) 50%, var(--skeleton-a) 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.detail .stage .spin.off { display: none; }
.detail .close { position: absolute; top: 10px; right: 10px; z-index: 3; background: rgb(0 0 0 / .55); color: #fff; backdrop-filter: blur(6px); }
.detail .close:hover { background: rgb(0 0 0 / .75); }
.detail .panel-side { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.detail .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; background: rgb(0 0 0 / .5); color: #fff; backdrop-filter: blur(6px); display: none; }
.detail .nav-btn.prev { left: 10px; } .detail .nav-btn.next { right: 10px; }
.detail .body { padding: 18px 20px 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; overflow-y: auto; flex: 1; align-content: start; -webkit-overflow-scrolling: touch; }
.detail h2 { font-size: 22px; }
.detail .desc { color: var(--muted); font-size: 15px; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.detail dt { color: var(--muted); font: 500 11px/1.9 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.detail dd { margin: 0; min-width: 0; }
.detail .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail .tags button { height: 30px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); font-size: 12.5px; background: var(--surface); }
.detail .tags button:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.detail .similar { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; margin-inline: -20px; padding-inline: 20px; scrollbar-width: thin; }
.detail .similar a { flex: none; width: 150px; scroll-snap-align: start; text-decoration: none; color: inherit; }
.detail .similar .thumb { aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.detail .similar img { width: 100%; height: 100%; object-fit: cover; }
.detail .similar span { display: block; font-size: 12px; margin-top: 6px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.screens { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.screens figure { margin: 0; display: grid; gap: 8px; align-content: start; }
.screens button.shotbtn { display: block; width: 100%; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.screens img { width: 100%; height: auto; }
.screens figcaption { font-size: 12px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.screens figcaption b { font: 500 11px var(--font-mono); color: var(--faint); margin-right: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); z-index: 300; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-pill); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity var(--dur), transform var(--dur) var(--ease-out); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer ---------- */
footer.site { margin-top: 24px; padding-block: 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
footer.site .cols { display: grid; gap: 20px; }
footer.site a { color: var(--text); }
footer.site ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------- prose pages (connect / docs) ---------- */
.page { padding-block: 24px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.page > *, .doc-layout > * { min-width: 0; }
.page h1 { font-size: clamp(30px, 7vw, 52px); letter-spacing: -.035em; font-weight: 600; }
.page h2 { font-size: clamp(21px, 4.5vw, 28px); }
.page .lead { color: var(--muted); font-size: clamp(16px, 3.8vw, 19px); max-width: 62ch; margin-top: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.panel > * { min-width: 0; }
.cards3 { display: grid; gap: 12px; }
.cards3 .panel h3 { font-size: 16px; } .cards3 .panel p { color: var(--muted); font-size: 14px; }
.code { position: relative; border-radius: var(--r-m); background: #0f0f10; color: #e8e8ec; border: 1px solid var(--border); }
.code pre { margin: 0; padding: 14px 52px 14px 14px; overflow-x: auto; font: 13px/1.6 var(--font-mono); tab-size: 2; }
.code button { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; border-radius: 10px; color: #c9c9d1; display: grid; place-items: center; }
.code button:hover { background: rgb(255 255 255 / .1); color: #fff; }
.tablist { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tablist::-webkit-scrollbar { display: none; }
.tablist button { flex: none; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface); font-size: 14px; font-weight: 500; }
.tablist button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
.tabpanel[hidden] { display: none; }
.tools { display: grid; gap: 8px; }
.tool { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--r-m); border: 1px solid var(--border); background: var(--surface); }
.tool code { font: 600 13px var(--font-mono); color: var(--accent-text); }
.tool span { font-size: 14px; color: var(--muted); }
.steps { counter-reset: s; display: grid; gap: 12px; padding: 0; list-style: none; margin: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 44px; color: var(--muted); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font: 600 13px var(--font-mono); }
.steps li b { color: var(--text); font-weight: 600; }

.idref { font: 500 .8em var(--font-mono); background: var(--accent-soft); color: var(--accent-text); padding: .1em .45em; border-radius: 5px; text-decoration: none; white-space: nowrap; }
.idref:hover { text-decoration: underline; }
.md { max-width: 78ch; }
.md h1 { font-size: clamp(26px, 6vw, 38px); margin-bottom: 14px; }
.md h2 { margin-top: 36px; margin-bottom: 10px; font-size: 22px; }
.md h3 { margin-top: 26px; margin-bottom: 8px; font-size: 18px; }
.md h4 { margin-top: 18px; font-size: 16px; }
.md p, .md li { color: color-mix(in srgb, var(--text) 88%, var(--bg)); }
.md p { margin-block: 10px; } .md ul, .md ol { padding-left: 22px; } .md li { margin-block: 5px; }
.md code { font: .88em var(--font-mono); background: var(--surface-2); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
.md pre { background: #0f0f10; color: #e8e8ec; padding: 14px; border-radius: var(--r-m); overflow-x: auto; font-size: 13px; line-height: 1.6; }
.md pre code { background: none; padding: 0; color: inherit; }
.md blockquote { margin: 14px 0; padding: 4px 16px; border-left: 3px solid var(--accent); color: var(--muted); }
.md .tablewrap { overflow-x: auto; margin-block: 14px; border: 1px solid var(--border); border-radius: var(--r-m); }
.md table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.md th, .md td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.md th { background: var(--surface-2); font: 600 12px var(--font-mono); letter-spacing: .04em; white-space: nowrap; }
.md td code { white-space: nowrap; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-block: 20px; }
.toc { display: flex; gap: 6px; overflow-x: auto; font-size: 14px; padding-bottom: 4px; scrollbar-width: none; margin-inline: calc(clamp(16px, 4vw, 40px) * -1); padding-inline: clamp(16px, 4vw, 40px); }
.toc::-webkit-scrollbar { display: none; }
.toc a { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); text-decoration: none; color: var(--muted); white-space: nowrap; background: var(--surface); }
.toc a:hover { color: var(--text); }
.toc a[aria-current="page"] { background: var(--text); color: var(--bg); border-color: transparent; }
.toc .eyebrow { display: none; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

/* ---------- breakpoints ---------- */
@media (min-width: 480px) {
  .hero .ctas .btn:not(.primary) { display: inline-flex; }
  .hero .ctas .btn.primary { flex: none; }
  .hero .eyebrow { display: block; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .cards3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  :root { --gap: 16px; --header-h: 64px; }
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .top nav.desk { display: flex; }
  .top .connect-top { display: inline-flex; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px var(--gap); }
  .tabs-top { display: inline-flex; }
  .toast { bottom: 24px; }
  .field kbd { display: inline-block; }
  .cards3 { grid-template-columns: repeat(3, 1fr); }
  .screens { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .doc-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 40px; }
  .toc { position: sticky; top: 24px; max-height: calc(100dvh - 48px); overflow-y: auto; display: grid; gap: 4px; align-content: start; margin-inline: 0; padding-inline: 0; }
  .toc a { display: block; min-height: 0; padding: 8px 10px; border: 0; border-radius: var(--r-s); background: none; white-space: normal; }
  .toc a:hover, .toc a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
  .toc .eyebrow { display: block; padding: 10px 10px 4px; }
  dialog.sheet:not(.drawer) {
    position: fixed; inset: 0; margin: auto; width: min(1180px, calc(100vw - 48px)); max-height: min(860px, calc(100dvh - 48px)); height: auto; border-radius: var(--r-l);
  }
  dialog.sheet:not(.drawer).full { height: min(860px, calc(100dvh - 48px)); }
  dialog.sheet:not(.drawer)[open] { animation: pop-in var(--dur) var(--ease-out); }
  @keyframes pop-in { from { transform: scale(.97); opacity: 0; } }
  dialog.drawer { inset: 0 0 0 auto; width: 420px; max-height: none; height: 100dvh; border-radius: var(--r-l) 0 0 var(--r-l); }
  dialog.drawer[open] { animation: drawer-in var(--dur) var(--ease-out); }
  @keyframes drawer-in { from { transform: translateX(32px); opacity: .4; } }
  .grab { display: none; }
  .detail.sheet:not(.drawer) { flex-direction: row; }
  .detail .stage { flex: 1 1 62%; max-height: none; min-height: 0; }
  .detail .stage img, .detail .stage video { position: absolute; inset: 0; max-height: none; object-fit: contain; }
  .detail .panel-side { flex: 0 0 380px; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); }
  .detail .nav-btn { display: grid; }
}
@media (min-width: 1024px) {
  .hero { grid-template-columns: 1fr auto; align-items: end; padding-block: 40px 20px; }
  .hero .hero-title br { display: inline; }
  .hero p.lead { display: block; }
  .hero .ctas { justify-content: flex-end; }
  .rail { margin-inline: 0; padding-inline: 0; mask-image: none; flex-wrap: wrap; overflow: visible; }
  .footer-cols { grid-template-columns: 2fr 1fr 1fr; }
  footer.site .cols { grid-template-columns: 2fr 1fr 1fr; }
}
@media (min-width: 1440px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
@media (hover: none) { .card:hover .thumb img { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
