/* IvyLabs Design site chrome. Every value comes from the app's tokens.css, so the page follows the chosen style
   (青藤 / 萌虎 / 像素) and light or dark along with the content. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-canvas); color: var(--text-primary);
  font: var(--type-body); letter-spacing: var(--type-body-tracking); }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: var(--focus-width, 2px) solid var(--focus-ring); outline-offset: 2px; border-radius: 2px; }
img { max-width: 100%; }
code, kbd, pre { font-family: var(--font-mono); }
.skip { position: absolute; inset-inline-start: 8px; top: -48px; padding: 8px 12px; background: var(--bg-surface); border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius-sm); z-index: 20; }
.skip:focus { top: 8px; }
.zh { color: var(--text-muted); font-weight: 500; }
/* Inter's plain capital I reads as a lower-case l in "BostonIvy" and "IvyLabs"; cv08 gives it serifs, as in the README
   banners. Google Fonts drops cv08, so brand names use a self-hosted Latin subset of Inter (SIL OFL 1.1, fonts/inter-ofl.txt). */
@font-face { font-family: "IvyLabs Brand"; src: url("/fonts/inter-brand.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
.ver { font: var(--type-caption); color: var(--on-accent-soft); background: var(--accent-soft); padding: 1px 8px; border-radius: var(--radius-pill); white-space: nowrap; }

/* ---------- whitepaper header ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
  min-height: 56px; padding: var(--space-2) var(--space-6); background: var(--bg-sidebar); border-bottom: var(--border-width) solid var(--border-default); }
.crumb { font: var(--type-caption); color: var(--text-muted); text-decoration: none; }
.crumb:hover { color: var(--text-primary); }
.crumb-sep { color: var(--border-strong); }
.app-title { display: inline-flex; align-items: center; gap: var(--space-2); font: var(--type-heading); color: var(--text-primary); text-decoration: none; }
.switcher { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.seg { display: inline-flex; border: var(--border-width) solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-surface); }
.seg button { font: var(--type-caption); letter-spacing: var(--type-caption-tracking); color: var(--text-secondary); background: transparent; border: 0; padding: 4px 10px;
  min-height: 28px; cursor: pointer; white-space: nowrap; }
.seg button + button { border-inline-start: var(--border-width) solid var(--border-default); }
.seg button:hover { background: var(--bg-hover); color: var(--text-primary); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }

/* ---------- whitepaper layout ---------- */
.layout { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; display: grid; grid-template-columns: 232px minmax(0, 1fr) 200px; gap: var(--space-8);
  padding: 0 var(--space-6); }
.side { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow: auto; padding: var(--space-6) 0; }
.side-menu > summary { display: none; }
.side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side a { display: block; padding: 6px var(--space-3); border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font: var(--type-body); }
.side a:hover { background: var(--bg-hover); color: var(--text-primary); }
.side a[aria-current="page"] { background: var(--bg-selected); color: var(--text-primary); font-weight: 600; }
.nav-section { font: var(--type-caption); color: var(--text-muted); padding: var(--space-4) var(--space-3) var(--space-1); }
.toc { position: sticky; top: 56px; align-self: start; padding: var(--space-6) 0; font: var(--type-caption); }
.toc p { margin: 0 0 var(--space-2); color: var(--text-muted); }
.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; border-inline-start: var(--border-width) solid var(--border-default); }
.toc a { display: block; padding-inline-start: var(--space-3); color: var(--text-secondary); text-decoration: none; }
.toc a:hover { color: var(--accent-text); }

/* ---------- document typography ---------- */
.doc { min-width: 0; padding: var(--space-6) 0 var(--space-16); font-size: 15px; line-height: 1.75; }
.doc > :first-child { margin-top: 0; }
.doc h1 { font-family: var(--font-display); font-size: 32px; line-height: 1.25; font-weight: 700; margin: 0 0 var(--space-6); letter-spacing: var(--type-title-tracking); }
.doc h2 { font-family: var(--font-display); font-size: 22px; line-height: 1.35; font-weight: 700; margin: var(--space-12) 0 var(--space-4); padding-top: var(--space-2);
  border-top: var(--border-width) solid var(--border-subtle); }
.doc h3 { font-size: 17px; line-height: 1.5; font-weight: 600; margin: var(--space-8) 0 var(--space-3); }
.doc p, .doc ul, .doc ol { margin: 0 0 var(--space-4); }
.doc ul, .doc ol { padding-inline-start: 1.4em; }
.doc li + li { margin-top: 4px; }
.doc strong { font-weight: 650; }
.doc code { font-size: .88em; background: var(--bg-sunken); border-radius: 4px; padding: .1em .35em; overflow-wrap: anywhere; }
.doc pre { background: var(--bg-sunken); border: var(--border-width) solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-4); overflow: auto;
  font-size: 13px; line-height: 1.6; margin: 0 0 var(--space-4); }
.doc pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.doc blockquote { margin: 0 0 var(--space-4); padding: var(--space-1) var(--space-4); border-inline-start: 3px solid var(--accent); color: var(--text-secondary); background: var(--bg-sunken); }
.doc img { display: block; margin: var(--space-2) 0 var(--space-4); border-radius: var(--radius-md); }
.doc hr { border: 0; border-top: var(--border-width) solid var(--border-default); margin: var(--space-8) 0; }
.table { overflow-x: auto; margin: 0 0 var(--space-6); border: var(--border-width) solid var(--border-default); border-radius: var(--radius-md); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; }
.doc th, .doc td { text-align: start; vertical-align: top; padding: 8px 12px; border-bottom: var(--border-width) solid var(--border-subtle); }
.doc thead th { background: var(--bg-sunken); font-weight: 600; white-space: nowrap; }
.doc tbody tr:last-child > * { border-bottom: 0; }
.doc tbody th { font-weight: 500; }
.doc tbody th code { white-space: nowrap; }
.lead { font-size: 16px; color: var(--text-secondary); }
.kicker { font: var(--type-caption); color: var(--text-muted); margin: 0 0 var(--space-2); }
.kicker a { color: inherit; }
.doc-title { margin-top: var(--space-6) !important; }

/* overview */
.cover { margin-bottom: var(--space-2); }
.cover iframe { width: 100%; display: block; border: var(--border-width) solid var(--border-default); border-radius: var(--radius-lg); background: var(--bg-canvas); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-8); }
.card { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) var(--space-4); border: var(--border-width) solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-surface); box-shadow: var(--shadow-card); color: var(--text-primary); text-decoration: none; line-height: 1.4; }
.card:hover { border-color: var(--accent); }
.card-kicker { font: var(--type-caption); color: var(--text-muted); }
.card-title { font: var(--type-task); }

/* components */
iframe.preview { display: block; width: 100%; border: var(--border-width) solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-canvas); }
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--space-6); }
.comp h3 { margin: 0 0 var(--space-1); }
.comp p { margin: 0 0 var(--space-3); font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* assets */
.asset-group h2 { margin-top: var(--space-10); }
.tiles { list-style: none; margin: 0 0 var(--space-6) !important; padding: 0 !important; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.tiles-s { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.tiles-xs { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.tiles li { margin: 0 !important; }
.tiles a { display: flex; flex-direction: column; gap: var(--space-2); color: var(--text-secondary); text-decoration: none; }
.tile-art { display: grid; place-items: center; aspect-ratio: 1; background: var(--bg-sunken); border: var(--border-width) solid var(--border-default); border-radius: var(--radius-md); }
.tiles a:hover .tile-art { border-color: var(--accent); }
.tile-art img { width: 64%; height: 64%; object-fit: contain; margin: 0; border-radius: 0; }
.tiles-xs .tile-art img { width: 40%; height: 40%; }
.tile-name { font: var(--type-caption); overflow-wrap: anywhere; }

/* tokens */
.downloads { list-style: none; padding: 0 !important; display: flex; flex-direction: column; gap: var(--space-2); }
.downloads li { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: baseline; margin: 0 !important; }
.downloads span { color: var(--text-muted); font-size: 14px; }
.tokens-table th[scope="row"] { min-width: 240px; }
.tokens-table thead th:not(:first-child) { white-space: normal; font-size: 12px; line-height: 1.4; min-width: 76px; }
.token-usage { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; font-weight: 400; color: var(--text-muted); }
.tokens-table .sw { flex-direction: column; align-items: flex-start; gap: 2px; }
.tokens-table .sw-chip { width: 32px; height: 22px; }
.tokens-table .sw code { font-size: 11px; color: var(--text-secondary); }
.doc td.usage { white-space: normal; min-width: 220px; color: var(--text-secondary); }
.sw { display: inline-flex; align-items: center; gap: 6px; }
.sw code { background: none; padding: 0; font-size: 12px; }
.sw-chip { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--border-strong); flex: none; }
.type-sample { display: block; color: var(--text-primary); white-space: nowrap; }

/* ---------- index ---------- */
.hub-top { display: flex; align-items: center; min-height: 56px; padding: var(--space-2) var(--space-6); border-bottom: var(--border-width) solid var(--border-default); }
.hub-brand { display: inline-flex; align-items: center; gap: var(--space-2); font: var(--type-heading); color: var(--text-primary); text-decoration: none; }
.hub { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--space-12) var(--space-6) var(--space-16); }
.hub-hero { max-width: 640px; margin-bottom: var(--space-10); }
.hub-hero h1 { font-family: var(--font-display); font-size: clamp(34px, 6vw, 52px); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 var(--space-4); }
.hub-hero p { font-size: 17px; line-height: 1.7; color: var(--text-secondary); margin: 0; }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: var(--space-6); }
.app-card { position: relative; display: flex; flex-direction: column; background: var(--bg-surface); border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; transition: border-color var(--motion-duration) var(--motion-easing), box-shadow var(--motion-duration) var(--motion-easing); }
.app-card:hover { border-color: var(--accent); box-shadow: var(--shadow-raised); }
.app-art { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: var(--border-width) solid var(--border-default); }
.app-style { display: grid; place-items: center; height: 148px; background: var(--bg-canvas); }
.app-style img { width: 84px; height: 84px; }
.app-body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-6); }
.app-body h2 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 1.3; }
.app-link { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-primary); text-decoration: none; }
.app-link::after { content: ""; position: absolute; inset: 0; }
.app-body p { margin: 0; color: var(--text-secondary); line-height: 1.7; }
.app-facts, .app-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.app-facts li { font: var(--type-caption); color: var(--text-secondary); background: var(--bg-sunken); border-radius: var(--radius-pill); padding: 2px 10px; }
.app-links { gap: var(--space-4); }
.app-links a { position: relative; z-index: 1; font: var(--type-task); }

/* ---------- footer ---------- */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-6); padding: var(--space-4) var(--space-6);
  border-top: var(--border-width) solid var(--border-default); font: var(--type-caption); color: var(--text-muted); }
.foot code { font-size: 11px; }

/* ---------- narrow screens ---------- */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .top { position: static; padding: var(--space-2) var(--space-4); }
  .switcher { margin-inline-start: 0; width: 100%; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 var(--space-4); }
  .side { position: static; max-height: none; padding: var(--space-3) 0 0; }
  .side-menu { border: var(--border-width) solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); }
  .side-menu > summary { display: block; padding: var(--space-2) var(--space-3); font: var(--type-task); cursor: pointer; }
  .side-menu ul { padding: 0 var(--space-2) var(--space-2); }
  .doc { padding-top: var(--space-4); }
  .doc h1 { font-size: 26px; }
  .doc th, .doc td { min-width: 6.5em; }
  .hub { padding: var(--space-8) var(--space-4) var(--space-12); }
  .hub-top, .foot { padding-inline: var(--space-4); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* brand names last, so they win over the heading rules above */
.hub-brand, .hub-hero h1, .app-link, [data-theme^="clean-"] .app-title, :root:not([data-theme]) .app-title { font-family: "IvyLabs Brand", var(--font-ui); font-feature-settings: "cv08" 1; }
