/* web-ai-showcase — shared design system (Refined Warm Editorial Lab).
   Warm alabaster paper + crisp elevated surfaces + indigo accent, Georgia display + humanist sans
   body, light + dark. Every semantic ink/surface pair meets WCAG AA (>= 4.5:1). */

:root {
  color-scheme: light dark;

  /* Surfaces & ink — Light */
  --color: #191816;
  --background: #f9f8f4;
  --bg: var(--background);
  --bg-secondary: #f2efe8;
  --bg-raised: #ffffff;
  --border: #e2ddd3;
  --border-strong: #857e74;
  --muted: #57534e;

  /* Accent & semantic status — Light (all >= 5.1:1 on every surface) */
  --accent: #3f35e8;
  --accent-hover: #3128cc;
  --accent-ink: #ffffff;
  --good: #156c32;
  --bad: #b42318;
  --warn: #8a5a00;

  /* Rhythm, radii & elevation */
  --space: 1rem;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgb(25 24 22 / 0.05), 0 1px 3px rgb(25 24 22 / 0.04);
  --shadow-md: 0 6px 18px -4px rgb(25 24 22 / 0.09), 0 2px 6px -1px rgb(25 24 22 / 0.05);
  --shadow-btn: 0 1px 2px rgb(25 24 22 / 0.14), inset 0 1px 0 rgb(255 255 255 / 0.16);

  /* Typography */
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-body: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;

  accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color: #efece6;
    --background: #151412;
    --bg: var(--background);
    --bg-secondary: #26231f;
    --bg-raised: #1e1c19;
    --border: #34302b;
    --border-strong: #7a7369;
    --muted: #a8a096;
    --accent: #8cb4ff;
    --accent-hover: #a6c6ff;
    --accent-ink: #0b1220;
    --good: #6ee79c;
    --bad: #f88a90;
    --warn: #f2c464;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.32), 0 1px 3px rgb(0 0 0 / 0.22);
    --shadow-md: 0 10px 24px -6px rgb(0 0 0 / 0.48), 0 3px 8px -2px rgb(0 0 0 / 0.3);
    --shadow-btn: 0 1px 2px rgb(0 0 0 / 0.38), inset 0 1px 0 rgb(255 255 255 / 0.14);
  }
}

/* Cross-document view transitions between catalogue and model pages.
   Chrome SKIPS a cross-document transition when the incoming document misses its deadline, which on
   this site happens reliably on a cold (uncached) navigation of a heavy route: 11 of 12 cold runs
   observed a skip against 1 of 6 warm ones (web-ai-showcase-67b). A skip rejects a browser-internal
   promise, and Chrome reports it with no source position, so it appears in the console as
   "Uncaught (in promise) AbortError: Transition was skipped" with nothing in our code involved:
   attaching a handler to the transition exposed on pagereveal/pageswap — even before any page script
   ran — did NOT suppress it on that path, and a minimal two-page site with the same opt-in never
   reproduced it at all. It is not caused by the reduced-motion block below (an order-controlled
   matrix shows the motion preference is irrelevant) and it does not break navigation: links resolve,
   there are no network failures, and the visitor simply gets an instantaneous page change.
   If the console noise ever matters, the options are to cut the incoming document cold latency
   (prefetch/prerender the ladder links) or to classify this exact AbortError in the console-clean
   checks with a positive control that a real page error still fails — not to catch it in page code.
   Classified in scripts/browser.mjs (web-ai-showcase-43l): exact name + message match
   retains positive control that real page/script errors continue to fail console cleanliness. */
@view-transition {
  navigation: auto;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  line-height: 1.65;
  color: var(--color);
  background: var(--background);
  padding: clamp(1rem, 3vw, 2.25rem);
  max-width: 1140px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}

::selection {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Editorial typography hierarchy */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--color);
  text-wrap: balance;
}
h1 {
  font-size: clamp(1.85rem, 3.2vw, 2.5rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0.15rem 0 0.55rem;
}
h2 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2.35rem 0 0.8rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.45rem;
}
h3 {
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 1.45rem 0 0.45rem;
}

:where(a) {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: from-font;
  text-decoration-color: color-mix(in srgb, var(--accent) 42%, transparent);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
:where(a:hover) {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.lede {
  font-size: clamp(1.04rem, 1.4vw, 1.15rem);
  line-height: 1.62;
  max-width: 62ch;
  color: color-mix(in srgb, var(--color) 88%, var(--muted));
  margin: 0.45rem 0 1.2rem;
  text-wrap: pretty;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}
:where(p.crumbs, nav.crumbs) {
  margin: 0 0 1rem;
}
.crumbs a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.crumbs a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.muted {
  color: var(--muted);
}

/* Shared top-level navigation utility (.site-nav).
   Zero-specificity :where() plus :not(.button, .nav-link) preserves page-local CTAs and
   custom list navs (e.g. index.html's <nav class="site-nav"><ul>) without double-boxing. */
:where(.site-nav) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 1.5rem;
}
:where(.site-nav:not(:has(ul))) {
  gap: 0.25rem;
  padding: 0.3rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
:where(.site-nav a:not(.button, .nav-link)) {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
:where(.site-nav a:not(.button, .nav-link):hover) {
  color: var(--color);
  background: color-mix(in srgb, var(--bg-raised) 70%, transparent);
}
:where(.site-nav a:not(.button, .nav-link)[aria-current="page"]),
:where(.site-nav a:not(.button, .nav-link).active) {
  color: var(--color);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}

/* Use-case ladder navigation bar (.ladder-nav) on model overview + rung pages.
   Sticky + frosted so visitors can hop between Overview / Basics / Practical / Wild / Multi-model
   from anywhere on a long page without scrolling back to the top. */
:where(.ladder-nav) {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0 1.25rem;
  padding: 0.35rem;
  background: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
:where(.ladder-nav a) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.42rem 0.85rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
:where(.ladder-nav a:hover) {
  color: var(--color);
  background: color-mix(in srgb, var(--bg-raised) 70%, transparent);
}
:where(.ladder-nav a[aria-current="page"]) {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
@media (max-width: 640px) {
  :where(.ladder-nav) {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    max-inline-size: 100%;
    gap: 0.25rem;
    padding: 0.3rem;
  }
  :where(.ladder-nav a) {
    flex: 0 0 auto;
    padding: 0.42rem 0.72rem;
  }
}

/* Catalogue grid — content-visibility keeps offscreen cards cheap to render. */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1.1rem;
  margin: 1.5rem 0;
}
.model-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.model-card:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
/* Keyboard focus mirrors hover on the shared card (web-ai-showcase-24n): the accent border +
   lift is the card's designed "interactive" signal, so keyboard focus gets the same signal the
   pointer already gets — consistency with the hover treatment, not a new affordance. */
.model-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.model-card h3 {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.3;
  transition: color 0.15s ease;
}
.model-card:hover h3,
.model-card:focus-visible h3 {
  color: var(--accent);
}
.model-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}
.model-card .tags {
  margin-top: auto;
  padding-top: 0.25rem;
}

/* Tags: task / modality / backend / size — soft tinted pills with >= 4.5:1 AA contrast */
.tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 500;
  line-height: 1.3;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--muted);
}
.tag-run {
  background: color-mix(in srgb, var(--good) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--good) 32%, var(--border));
  color: var(--good);
}
.tag-webgpu {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  color: var(--accent);
}
.tag-flag {
  background: color-mix(in srgb, var(--warn) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--warn) 35%, var(--border));
  color: var(--warn);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Panels for the interactive control surface + the "see inside" viz. */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  padding: clamp(1rem, 2.5vw, 1.35rem);
  margin: 1.15rem 0;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--bg-raised) 60%, transparent);
}
.panel > h2:first-child,
.panel > h3:first-child {
  margin-top: 0;
}
.panel > :last-child {
  margin-bottom: 0;
}

/* Buttons — zero-specificity :where() keeps page-local button variants (.chip, .exg-item, .danger)
   free to override cleanly without specificity wars, while plain buttons & .button links get
   borderless tactile elevation and crisp press feedback. */
:where(button, .button) {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  min-block-size: 2.5rem;
  padding: 0.58rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  max-inline-size: 100%;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease,
    box-shadow 0.15s ease;
}
:where(button, .button):where(:not([hidden])) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
:where(button, .button):where(:not(:disabled):hover) {
  background: var(--accent-hover);
  color: var(--accent-ink);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
:where(button, .button):where(:not(:disabled):active) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
:where(button.secondary, .button.secondary) {
  background: var(--bg-raised);
  color: var(--color);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
:where(button.secondary, .button.secondary):where(:not(:disabled):hover) {
  background: color-mix(in srgb, var(--bg-raised) 92%, var(--accent));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong));
  color: var(--color);
  text-decoration: none;
}
:where(button, .button):where(:disabled) {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Shared keyboard focus ring (web-ai-showcase-24n). NOT an accessibility repair: keyboard focus
   is already visible and compliant via the UA default on every page. This CENTRALIZES the site's
   existing focus idiom — the same :focus-visible + var(--accent) outline already shipped in the
   homepage inline styles (f1f83b1), /explore, lib/capture-ux.js, lib/classify-ui.js,
   lib/example-gallery.js and lib/model-memory-diagnostics.mjs — so all ~1530 pages linking this
   stylesheet get one designed ring instead of the thin 1px UA default. :focus-visible (not
   :focus) keeps pointer clicks clean exactly as before. Every value stays well above >= 3:1
   non-text contrast (light #3f35e8: 6.3-7.3:1; dark #8cb4ff: 7.5-8.8:1). Zero-specificity
   :where() so any local focus rule continues to win unchanged. */
:where(a:any-link, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

input,
textarea,
select {
  /* A native control has an intrinsic min-content width (a <select> derives it from its longest
     option), so inside a narrow flex/grid container it widens the LAYOUT instead of shrinking —
     which is how pages rendered into 404-496px at a requested 360px while every gate stayed green
     (web-ai-showcase-vtk, web-ai-showcase-a2u). Allowing shrink and capping at the container width
     fixes the class at the source; nothing is hidden or clipped, native picker behaviour survives. */
  min-inline-size: 0;
  max-inline-size: 100%;
}
:where(input, textarea, select) {
  font: inherit;
  font-size: 0.94rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:where(input, textarea, select):where(:not(:disabled):hover) {
  border-color: var(--border-strong);
}
:where(input, textarea, select):where(:focus) {
  border-color: var(--accent);
}
:where(input, textarea)::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
:where(input[type="range"], input[type="checkbox"], input[type="radio"]) {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--accent);
}

/* Mobile control/layout constraints (web-ai-showcase-a2u). Three root causes were widening a 360px
   viewport on 20 routes, none of them visible to the old scroll-delta check:
   1. a control has an intrinsic min-content width (a <select> from its longest option, a <textarea>
      from its cols/content) and its flex/grid LABEL defaulted to min-inline-size: auto, so the
      container could not shrink below it;
   2. a wide <table> in a panel had no width cap, so long cell content widened the page;
   3. a <pre>/<code> block with long lines had no wrap, so it widened the page.
   Constraining/wrapping fixes each at the source; nothing is hidden, clipped or scrolled away. */
label {
  min-inline-size: 0;
}
table {
  max-inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th,
td {
  overflow-wrap: anywhere;
  text-align: start;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  overflow-wrap: break-word;
}
thead th {
  background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tbody tr:last-child td,
tbody tr:last-child th {
  border-bottom: 0;
}

pre,
code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
pre {
  max-inline-size: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  line-height: 1.55;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
code {
  overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--bg-secondary) 82%, var(--border));
  border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 5px;
  padding: 0.08em 0.36em;
  font-size: 0.85em;
}
pre code {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
}

/* Long unbreakable strings (URLs, ids, base64) overflow their container as TEXT, which no
   element-width check can see: face-image-quality measured clientWidth 360 with scrollWidth 369 and
   not one element wider than the viewport. overflow-wrap is inherited, so setting it once on body
   covers prose, headings and lists; it only breaks a word when that word cannot fit. */
body {
  overflow-wrap: anywhere;
}
/* 22 route stylesheets copy the same rule — .grid-2 { grid-template-columns: repeat(auto-fit,
   minmax(300px, 1fr)) }. A 300px track minimum cannot fit a panel content box of ~280px at a 360px
   viewport, so the track overflows the panel by ~20px (measured: all-distilroberta-v1/basics and
   all-mpnet-base-v2/basics, 22px over with clientWidth 360). Capping the minimum at the container
   width keeps the identical auto-fit behaviour wherever 300px already fitted and lets the track
   shrink where it did not — the same idiom one route already uses for .param-grid (minmax(min(100%,
   220px), 1fr)). body-prefixed so it wins over the route-injected rule without !important. */
body .grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
/* Sub-class B container constraints (web-ai-showcase-ctq):
   1. Inline grid styles using minmax(300px, 1fr) on practical LLM rungs overflow a ~278px panel content box by 22px.
   2. Translation layouts (.tr-io) using minmax(280px, 1fr) overflow a ~278px panel content box by 2px.
   Capping track minimums at min(100%, ...) prevents container escape while preserving desktop layout. */
body [style*="minmax(300px"],
body [style*="minmax( 300px"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)) !important;
}
body .tr-io {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

/* Model-load progress + status — errors go on the page, never only the console. */
.status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}
.status.err {
  color: var(--bad);
}
.status.ok {
  color: var(--good);
}
progress {
  width: 100%;
  height: 0.5rem;
  accent-color: var(--accent);
  border-radius: 999px;
  overflow: hidden;
  border: 0;
  background: var(--bg-secondary);
}
progress::-webkit-progress-bar {
  background: var(--bg-secondary);
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

/* Shared model-loader (lib/model-loader.js): auto-init status + contextual action. */
.model-loader {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.model-loader p {
  margin: 0;
}
.model-loader button {
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
}
.model-loader .loader-ready-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  min-inline-size: 0;
}
.model-loader .loader-ready-head[hidden] {
  display: none;
}
.model-loader .loader-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}
.model-loader .loader-meta:empty,
.model-loader .loader-meta[hidden] {
  display: none;
}
.model-loader .loader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.model-loader .loader-detail {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}
.model-loader[data-state="checking"],
.model-loader[data-state="initialising"],
.model-loader[data-state="downloading"] {
  border-inline-start-color: var(--accent);
}
/* Compact single-row ready bar: reclaims ~120–160px above the fold on every ready model route
   while keeping Release from memory directly clickable and Details & Memory one click away. */
.model-loader[data-state="ready"] {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  padding: 0.6rem 0.9rem;
  border-color: color-mix(in srgb, var(--good) 40%, var(--border));
  border-inline-start-color: var(--good);
}
.model-loader[data-state="ready"] .loader-ready-head {
  flex: 1 1 13rem;
}
.model-loader[data-state="ready"] .status.ok {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.22rem 0.68rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--good) 32%, var(--border));
  background: color-mix(in srgb, var(--good) 8%, var(--bg-raised));
  color: var(--good);
  font-weight: 600;
  font-size: 0.79rem;
}
.model-loader[data-state="ready"] .status.ok::before {
  content: "";
  display: inline-block;
  inline-size: 0.48rem;
  block-size: 0.48rem;
  border-radius: 50%;
  background: var(--good);
  flex: 0 0 auto;
}
.model-loader[data-state="ready"] .loader-actions {
  margin-inline-start: auto;
  gap: 0.45rem;
}
.model-loader[data-state="ready"] .loader-actions button {
  padding: 0.4rem 0.8rem;
  font-size: 0.84rem;
}
.model-loader[data-state="ready"] .loader-update {
  flex: 1 1 100%;
}
.model-loader .loader-details {
  display: inline-flex;
  flex-direction: column;
  min-inline-size: 0;
}
.model-loader .loader-details-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.model-loader .loader-details-toggle::-webkit-details-marker {
  display: none;
}
.model-loader .loader-details-toggle::after {
  content: "▾";
  font-size: 0.78em;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.model-loader .loader-details[open] > .loader-details-toggle::after {
  transform: rotate(180deg);
}
.model-loader .loader-details-toggle:hover {
  background: color-mix(in srgb, var(--bg-raised) 92%, var(--accent));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong));
}
.model-loader[data-state="ready"] .loader-actions:has(.loader-details[open]) {
  flex: 1 1 100%;
  margin-inline-start: 0;
}
.model-loader .loader-details[open] {
  flex: 1 1 100%;
}
.model-loader .loader-details-body {
  margin-block-start: 0.6rem;
  padding-block-start: 0.65rem;
  border-block-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-inline-size: 0;
}
.model-loader .loader-details-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.model-loader[data-state="unsupported"],
.model-loader[data-state="error"] {
  border-color: color-mix(in srgb, var(--bad) 42%, var(--border));
  border-inline-start-color: var(--bad);
}
.model-loader[data-state="update"],
.model-loader[data-state="partial"] {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  border-inline-start-color: var(--warn);
}
/* A subtle "working" cue on the status while checking/initialising/downloading. */
.model-loader[data-state="checking"] .status::after,
.model-loader[data-state="initialising"] .status::after,
.model-loader[data-state="downloading"] .status::after {
  content: " ⏳";
}

.byline {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.7;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  .model-card,
  .model-card h3,
  :where(button, .button),
  :where(a),
  .site-nav a,
  :where(.ladder-nav),
  :where(.ladder-nav a),
  .model-loader .loader-details-toggle,
  .model-loader .loader-details-toggle::after,
  input,
  textarea,
  select {
    transition: none;
  }
}

/* Example-gallery selection indicator (web-ai-showcase-yf2).
   The component's own inset outline (lib/example-gallery.js, offset -3px) sits directly over the
   object-fit:cover thumbnail, so the accent ring's inner edge borders the image and can fall to
   ~1.2:1 against it (measured 1.01-1.02:1 over the darkest real thumbnails, 1.88:1 light /
   1.59:1 dark over a saturated blue fixture). For the selected item, draw a two-tone ring above the
   image instead: an outer --accent band plus an inner --bg-raised band, so the accent always
   borders an opaque token surface (measured 7.28:1 light / 8.17:1 dark) whatever the image shows.
   The accent band is a real border rather than a box-shadow band: borders survive forced-colors
   (high-contrast) mode, where box-shadow is not painted, and a border matches this repo's own
   selection idiom (.sample-thumb.active, .chip.active). Higher specificity than the component's
   .exg-item[aria-pressed="true"] rule, so injected-sheet order does not matter. Keyboard focus
   keeps its own outside +2px ring on the item, so selection and focus stay distinct. */
.exg .exg-item[aria-pressed="true"] { position: relative; outline: none; }
.exg .exg-item[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  border: 3px solid var(--accent);
  box-shadow: inset 0 0 0 2px var(--bg-raised);
}
.exg .exg-item[aria-pressed="true"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Unified Global Site Shell (.site-shell-bar / .site-bar), Popovers & ⌘K Palette
   (Wave 9 Shard 1 — token-only, WCAG AA light+dark, >= 44px tap targets)
   ═══════════════════════════════════════════════════════════════════════════ */

:where(.site-shell-bar, .site-bar) {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0 0 1.35rem;
  padding: 0.35rem 0.65rem;
  min-block-size: 3.5rem;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.site-shell-inner {
  display: flex;
  align-items: center;
  gap: 0.45rem 0.75rem;
  min-inline-size: 0;
}

.site-shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.25rem 0.4rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 400;
  letter-spacing: -0.015em;
  color: var(--color);
  text-decoration: none;
  white-space: nowrap;
  flex: 0 0 auto;
}
.site-shell-brand:hover {
  color: var(--accent);
}
.site-shell-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 1.65rem;
  block-size: 1.65rem;
  border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
}

.site-shell-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-inline-size: 0;
}
.site-shell-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.38rem 0.68rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.site-shell-nav a:hover {
  color: var(--color);
  background: color-mix(in srgb, var(--bg-raised) 76%, transparent);
}
.site-shell-nav a[aria-current="page"] {
  color: var(--color);
  background: var(--bg-raised);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.site-shell-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-inline-start: auto;
  flex: 0 0 auto;
}

.site-shell-search,
.site-shell-badge,
.site-shell-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.38rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--color);
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.site-shell-search {
  color: var(--muted);
}
.site-shell-search:hover,
.site-shell-badge:hover,
.site-shell-menu-btn:hover {
  background: color-mix(in srgb, var(--bg-raised) 92%, var(--accent));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong));
  color: var(--color);
}

.shell-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.22rem 0.42rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--muted);
}

.site-shell-badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
}
.site-shell-dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.site-shell-badge[data-gpu="webgpu"] .site-shell-dot {
  background: var(--good);
}
.site-shell-badge[data-gpu="wasm"] .site-shell-dot {
  background: var(--accent);
}

.site-shell-menu-btn {
  display: none;
  border-radius: var(--radius-sm);
}

@media (max-width: 1000px) {
  .site-shell-search-label,
  .site-shell-badge-cache {
    display: none;
  }
}
@media (max-width: 820px) {
  .site-shell-nav {
    display: none;
  }
  .site-shell-menu-btn {
    display: inline-flex;
  }
}
@media (max-width: 480px) {
  :where(.site-shell-bar, .site-bar) {
    padding: 0.25rem 0.4rem;
  }
  .site-shell-inner {
    gap: 0.3rem;
  }
  .site-shell-brand {
    font-size: 0.95rem;
    gap: 0.3rem;
    padding: 0.2rem 0.2rem;
  }
  .site-shell-actions {
    gap: 0.25rem;
  }
  .site-shell-search,
  .site-shell-badge,
  .site-shell-menu-btn {
    padding: 0.35rem 0.48rem;
    gap: 0.28rem;
  }
}

/* Scroll-state progressive elevation for sticky navigation bars (modern-web-guidance). */
@supports (container-type: scroll-state) {
  html {
    container-type: scroll-state;
  }
  @container scroll-state(scrollable: top) {
    :where(.ladder-nav),
    :where(.site-shell-bar, .site-bar),
    .studio-bar {
      background: color-mix(in srgb, var(--bg-raised) 93%, transparent);
      border-color: color-mix(in srgb, var(--border-strong) 55%, var(--border));
      box-shadow: var(--shadow-md);
    }
  }
}

/* Native [popover] panels (Device/Storage badge, mobile nav drawer, studio inspector).
   Uses :is(:popover-open, .\:popover-open) + @starting-style + allow-discrete + overlay. */
.shell-popover[popover],
.studio-popover[popover] {
  position: fixed;
  margin: 0;
  inset: auto;
  inset-block-start: 4.5rem;
  inset-inline-end: clamp(0.75rem, 3vw, 2.25rem);
  inline-size: min(23rem, calc(100vw - 1.5rem));
  max-block-size: min(76dvh, 34rem);
  overflow-y: auto;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--color);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
.shell-popover[popover]:is(:popover-open, .\:popover-open),
.studio-popover[popover]:is(:popover-open, .\:popover-open) {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  opacity: 1;
  transform: translateY(0) scale(1);
  @starting-style {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}
.shell-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-block-end: 0.45rem;
  border-block-end: 1px solid var(--border);
}
.shell-popover-title {
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  color: var(--color);
}
.shell-popover-close {
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
}
.shell-popover-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.84rem;
}
.shell-popover-dl dt {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}
.shell-popover-dl dd {
  margin: 0;
  color: var(--color);
  text-align: end;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}
.shell-popover-links {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-block-start: 0.5rem;
  border-block-start: 1px solid var(--border);
}
.shell-popover-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-block-size: 2.75rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--color);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}
.shell-popover-links a:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}
.shell-popover-links a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-raised));
  color: var(--accent);
  font-weight: 600;
}

/* ── Global ⌘K Command Palette (<dialog class="cmd-palette" closedby="any">) ── */
dialog.cmd-palette {
  inset-block-start: min(9vh, 4.75rem);
  margin-inline: auto;
  margin-block: 0 auto;
  inline-size: min(40rem, calc(100vw - 1.5rem));
  max-inline-size: calc(100vw - 1.5rem);
  max-block-size: min(78dvh, 37rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.2s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog.cmd-palette[open] {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0) scale(1);
  @starting-style {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
}
dialog.cmd-palette::backdrop {
  background: rgb(0 0 0 / 0);
  backdrop-filter: blur(0px);
  transition:
    display 0.2s allow-discrete,
    overlay 0.2s allow-discrete,
    background-color 0.2s ease-out,
    backdrop-filter 0.2s ease-out;
}
dialog.cmd-palette[open]::backdrop {
  background: rgb(0 0 0 / 0.48);
  backdrop-filter: blur(3px);
  @starting-style {
    background: rgb(0 0 0 / 0);
    backdrop-filter: blur(0px);
  }
}

.cmd-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-block-end: 1px solid var(--border);
  background: var(--bg-raised);
}
.cmd-input {
  flex: 1 1 auto;
  min-inline-size: 0;
  min-block-size: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--color);
  font-size: 0.96rem;
  padding: 0.45rem 0.75rem;
}
.cmd-input:focus {
  border-color: var(--accent);
  background: var(--bg-raised);
}
.cmd-close {
  flex: 0 0 auto;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
}
.cmd-status {
  margin: 0;
  padding: 0.42rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg-secondary);
  border-block-end: 1px solid var(--border);
}
.cmd-results {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-block-size: 8rem;
  max-block-size: min(54dvh, 25rem);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cmd-option {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.cmd-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
}
.cmd-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-block-size: 2.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: inherit;
  text-decoration: none;
  color: var(--color);
}
.cmd-link:hover {
  color: var(--color);
  background: color-mix(in srgb, var(--bg-secondary) 75%, transparent);
}
.cmd-option[aria-selected="true"] .cmd-link:hover {
  background: transparent;
}
.cmd-main {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  min-inline-size: 0;
  flex: 1 1 auto;
}
.cmd-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color);
  line-height: 1.3;
}
.cmd-option[aria-selected="true"] .cmd-title {
  color: var(--accent);
}
.cmd-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.cmd-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex: 0 0 auto;
}
.cmd-kind {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--muted);
}
.cmd-kind[data-kind="showcase"] {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  color: var(--accent);
}
.cmd-kind[data-kind="model"] {
  background: color-mix(in srgb, var(--good) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--good) 32%, var(--border));
  color: var(--good);
}
.cmd-kind[data-kind="workflow"] {
  background: color-mix(in srgb, var(--warn) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--warn) 35%, var(--border));
  color: var(--warn);
}
.cmd-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}
.cmd-empty {
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.cmd-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.9rem;
  padding: 0.5rem 0.85rem;
  border-block-start: 1px solid var(--border);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

/* ── CSS Subgrid Showcase Card Grids + Scroll-Driven Reveal Enhancement ── */
:where(.showcase-strip, .ideas) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1.15rem;
}
:where(.showcase-strip > .showcase-card, .ideas > .idea) {
  grid-row: span 2;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-rows: subgrid;
  row-gap: 0;
}

@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes webai-showcase-reveal {
      from {
        opacity: 0.01;
        translate: 0 12px;
      }
      to {
        opacity: 1;
        translate: 0 0;
      }
    }
    :where(.showcase-card, .idea) {
      animation: webai-showcase-reveal linear backwards;
      animation-timeline: view(block);
      animation-range: entry 0% entry 24%;
    }
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Full-Bleed Pinnacle App Shell (body.app-shell) — Wave 10 Signature Showcases
   ═══════════════════════════════════════════════════════════════════════════ */

body.app-shell {
  max-width: min(1560px, 100%);
  padding: clamp(0.65rem, 1.5vw, 1.25rem);
}

.studio-bar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  min-block-size: 3.25rem;
  margin: 0 0 0.85rem;
  padding: 0.35rem 0.75rem;
  background: color-mix(in srgb, var(--background) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
.studio-back {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.studio-back:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--bg-raised) 80%, transparent);
}
.studio-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  font-weight: 400;
  line-height: 1.2;
  color: var(--color);
  min-inline-size: 0;
}
.studio-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.studio-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-inline-start: auto;
}
.studio-actions button,
.studio-actions a {
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.38rem 0.78rem;
  font-size: 0.84rem;
}

.loaders-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 0.65rem;
  margin: 0.5rem 0 0.85rem;
}
.loaders-strip .model-loader {
  margin: 0;
}

.studio-workspace {
  container: studio / inline-size;
  min-inline-size: 0;
}
.studio-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}
@container studio (inline-size >= 860px) {
  .studio-panes {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  }
}

/* Strictly additive studio-bar brand, popover, loaders-strip & below-the-fold about hooks */
.studio-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  flex: 1 1 16rem;
  min-inline-size: 0;
}
.studio-sep {
  color: var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  user-select: none;
}
html[data-host-mode="standalone"] [data-studio-standalone-trigger],
html:not([data-host-mode="standalone"]) [data-studio-standalone-link],
.studio-actions [hidden] {
  display: none;
}
.studio-sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.studio-skip-link:where(:not(:focus-within, :active)) {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}
.studio-skip-link:focus {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
body.app-shell .panel {
  margin: 0.65rem 0;
  padding: clamp(0.75rem, 1.5vw, 1.05rem);
}
body.app-shell .studio-loaders-region {
  margin: 0 0 0.65rem;
  min-inline-size: 0;
}
body.app-shell .model-pack-bar {
  margin: 0 0 0.65rem;
  padding: 0.6rem 0.85rem;
}
body.app-shell .loaders-strip {
  margin: 0 0 0.65rem;
}
body.app-shell .loaders-strip:has(> [hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.loaders-strip .loader-slot {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.65rem 0.8rem;
  min-inline-size: 0;
}
.loaders-strip .loader-slot-title {
  margin: 0 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.studio-popover-note {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--color);
}
.studio-popover-cta {
  inline-size: 100%;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  justify-content: center;
}
.studio-popover-meta {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
}
.studio-about {
  scroll-margin-top: 4.5rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.studio-about-head {
  margin-bottom: 0.75rem;
}
.studio-about-head .lede {
  margin: 0.35rem 0 0.85rem;
  max-width: 74ch;
}
@media (max-width: 680px) {
  .studio-bar {
    position: static;
    padding: 0.35rem 0.5rem;
    gap: 0.35rem 0.5rem;
  }
  .studio-brand {
    flex: 1 1 100%;
    gap: 0.15rem 0.45rem;
  }
  .studio-sep {
    display: none;
  }
  .studio-back {
    padding-inline: 0.35rem;
  }
  .studio-actions {
    margin-inline-start: 0;
    inline-size: 100%;
  }
  .studio-actions button,
  .studio-actions a {
    flex: 1 1 auto;
    padding: 0.38rem 0.6rem;
    font-size: 0.8rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Workflow Model Pack Bar (.model-pack-bar) — Universal Multi-Model One-Click UX
   (Token-only, WCAG AA light+dark, >= 44×44px tap targets, tabular numerals)
   ═══════════════════════════════════════════════════════════════════════════ */

.model-pack-bar {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-inline-size: 0;
  max-inline-size: 100%;
  margin: 0.75rem 0 0.95rem;
  padding: 0.8rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.model-pack-bar [hidden] {
  display: none;
}
.model-pack-sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.model-pack-bar p {
  margin: 0;
}
.model-pack-bar button {
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  font-variant-numeric: tabular-nums;
}

.model-pack-bar[data-pack-state="checking"] {
  padding: 0.62rem 0.95rem;
  border-inline-start-color: var(--accent);
}
.model-pack-bar[data-pack-state="busy"] {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
  border-inline-start-color: var(--accent);
}
.model-pack-bar[data-pack-state="ready"] {
  padding: 0.6rem 0.9rem;
  border-color: color-mix(in srgb, var(--good) 40%, var(--border));
  border-inline-start-color: var(--good);
}
.model-pack-bar[data-pack-state="partial-error"],
.model-pack-bar[data-pack-state="unsupported"] {
  border-color: color-mix(in srgb, var(--bad) 42%, var(--border));
  border-inline-start-color: var(--bad);
}

.model-pack-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  min-inline-size: 0;
}
.model-pack-summary {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  flex: 1 1 14rem;
  min-inline-size: 0;
}
.model-pack-title {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.25;
  color: var(--color);
}
.model-pack-desc {
  font-size: 0.84rem;
  line-height: 1.45;
}
.model-pack-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  min-inline-size: 0;
}
.model-pack-status {
  font-variant-numeric: tabular-nums;
  color: var(--color);
}
.model-pack-bar[data-pack-state="ready"] .model-pack-status.ok {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.22rem 0.68rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--good) 32%, var(--border));
  background: color-mix(in srgb, var(--good) 8%, var(--bg-raised));
  color: var(--good);
  font-weight: 600;
  font-size: 0.79rem;
}
.model-pack-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.model-pack-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-inline-start: auto;
  max-inline-size: 100%;
}
.model-pack-bar[data-pack-state="ready"] .model-pack-actions button {
  padding: 0.4rem 0.8rem;
  font-size: 0.84rem;
}
.model-pack-toggle {
  font-size: 0.84rem;
  padding: 0.42rem 0.78rem;
}

.model-pack-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  min-inline-size: 0;
}
.model-pack-progress-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-inline-size: 0;
}
.model-pack-progress {
  flex: 1 1 auto;
  min-inline-size: 0;
  inline-size: 100%;
  block-size: 0.56rem;
}
.model-pack-progress::-webkit-progress-value {
  transition: inline-size 0.16s ease;
}
.model-pack-progress:indeterminate::-webkit-progress-bar {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 0%,
    color-mix(in srgb, var(--accent) 42%, var(--bg-secondary)) 50%,
    var(--bg-secondary) 100%
  );
  background-size: 200% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes webai-pack-indeterminate {
    from {
      background-position: 200% 0;
    }
    to {
      background-position: -200% 0;
    }
  }
  .model-pack-progress:indeterminate::-webkit-progress-bar {
    animation: webai-pack-indeterminate 1.6s linear infinite;
  }
}
.model-pack-pct {
  flex: 0 0 auto;
  min-inline-size: 2.6rem;
  text-align: end;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.model-pack-active-stage {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.model-pack-stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-inline-size: 0;
}
.model-pack-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  min-inline-size: 0;
  max-inline-size: 100%;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.73rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  color: var(--color);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.model-pack-chip-num {
  color: var(--muted);
  font-weight: 600;
}
.model-pack-chip-name {
  font-weight: 500;
  color: var(--color);
}
.model-pack-chip-state {
  font-weight: 600;
  color: var(--muted);
}
.model-pack-chip[data-tone="good"] {
  background: color-mix(in srgb, var(--good) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--good) 32%, var(--border));
}
.model-pack-chip[data-tone="good"] .model-pack-chip-state {
  color: var(--good);
}
.model-pack-chip[data-tone="accent"] {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}
.model-pack-chip[data-tone="accent"] .model-pack-chip-state {
  color: var(--accent);
}
.model-pack-chip[data-tone="warn"] {
  background: color-mix(in srgb, var(--warn) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--warn) 35%, var(--border));
}
.model-pack-chip[data-tone="warn"] .model-pack-chip-state {
  color: var(--warn);
}
.model-pack-chip[data-tone="bad"] {
  background: color-mix(in srgb, var(--bad) 8%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--bad) 36%, var(--border));
}
.model-pack-chip[data-tone="bad"] .model-pack-chip-state {
  color: var(--bad);
}

.model-pack-drawer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-block-start: 0.65rem;
  border-block-start: 1px solid var(--border);
  min-inline-size: 0;
}
.model-pack-drawer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  min-inline-size: 0;
}
.model-pack-drawer-note {
  font-size: 0.8rem;
}
.model-pack-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  max-inline-size: 100%;
}
.model-pack-clear-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.model-pack-confirm-text {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--bad);
  font-weight: 600;
}
.model-pack-confirm-yes {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 42%, var(--border));
  background: color-mix(in srgb, var(--bad) 8%, var(--bg-raised));
}
.model-pack-confirm-yes:hover {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, var(--bg-raised));
  color: var(--bad);
}

/* Progressive disclosure of stacked individual loader cards while pack bar is active.
   High-specificity element-qualified selectors beat page-local .mm-loaders/.loaders-grid rules
   without removing <model-download-status> from the DOM or colliding with page-owned [hidden]. */
html body .model-loader.model-loader-pack-tucked[data-pack-tucked="true"],
html body [data-pack-box-tucked="true"],
html body [data-pack-mount-tucked="true"],
html body [data-pack-grid-tucked="true"] {
  display: none;
}

@media (max-width: 560px) {
  .model-pack-bar {
    padding: 0.72rem 0.8rem;
  }
  .model-pack-actions {
    margin-inline-start: 0;
    flex: 1 1 100%;
  }
  .model-pack-actions button {
    flex: 1 1 auto;
  }
}

/* Reduced-motion overrides placed after overlay/shell declarations so cascade order wins. */
@media (prefers-reduced-motion: reduce) {
  :where(.site-shell-bar, .site-bar),
  .site-shell-nav a,
  .studio-bar,
  .model-pack-bar,
  .model-pack-chip,
  .model-pack-progress::-webkit-progress-value {
    transition: none;
  }
  dialog.cmd-palette,
  dialog.cmd-palette::backdrop,
  .shell-popover[popover],
  .studio-popover[popover] {
    transform: none;
    transition-duration: 0.1s;
  }
  dialog.cmd-palette[open],
  .shell-popover[popover]:is(:popover-open, .\:popover-open),
  .studio-popover[popover]:is(:popover-open, .\:popover-open) {
    transform: none;
    @starting-style {
      transform: none;
    }
  }
}
