/* MJX docs — shared look (scripts/docs-build.js). Light + dark; phone first. */
:root {
  --bg: #ffffff; --bg2: #f7f7f8; --bg3: #f0f0f2; --line: #e6e6ea; --text: #17171c; --text2: #4b4b57; --dim: #7a7a86;
  --code-bg: #f5f5f7; --shadow: 0 10px 30px rgba(15, 15, 30, .12); --radius: 12px; --top: 60px;
  --tip: #0f766e; --tip-bg: #ecfdf8; --note: #1d4ed8; --note-bg: #eff5ff; --warn: #b45309; --warn-bg: #fff8eb;
  --imp: #7c3aed; --imp-bg: #f6f1ff; --ok: #15803d; --ok-bg: #effbf2;
  --link: var(--accent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e12; --bg2: #15151b; --bg3: #1c1c24; --line: #2a2a34; --text: #ececf1; --text2: #b9b9c6; --dim: #8a8a98;
    --code-bg: #17171e; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --tip: #5eead4; --tip-bg: #0d2522; --note: #93b4ff; --note-bg: #111a33; --warn: #fbbf24; --warn-bg: #2a1f0a;
    --imp: #c4b5fd; --imp-bg: #1f1733; --ok: #86efac; --ok-bg: #0f2416; color-scheme: dark;
    --link: color-mix(in srgb, var(--accent) 45%, #ffffff);
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e12; --bg2: #15151b; --bg3: #1c1c24; --line: #2a2a34; --text: #ececf1; --text2: #b9b9c6; --dim: #8a8a98;
  --code-bg: #17171e; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  --tip: #5eead4; --tip-bg: #0d2522; --note: #93b4ff; --note-bg: #111a33; --warn: #fbbf24; --warn-bg: #2a1f0a;
  --imp: #c4b5fd; --imp-bg: #1f1733; --ok: #86efac; --ok-bg: #0f2416; color-scheme: dark;
    --link: color-mix(in srgb, var(--accent) 45%, #ffffff);
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--bg); padding: 8px 12px; border-radius: 8px; }
.dim { color: var(--dim); }

/* top bar */
.top { position: sticky; top: 0; z-index: 40; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.brand .tag { font-size: 12px; font-weight: 600; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.search-open { margin-left: auto; display: flex; align-items: center; gap: 8px; height: 36px; min-width: 40px; padding: 0 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--dim); border-radius: 10px; cursor: pointer; font: inherit; font-size: 14px; }
.search-open svg, .theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-open kbd { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--bg); }
.top-links { display: none; gap: 6px; }
.top-links a { color: var(--text2); font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.top-links a.primary { background: var(--text); color: var(--bg); font-weight: 600; }
.top-links a:hover { text-decoration: none; background: var(--bg3); }
.top-links a.primary:hover { background: var(--text); opacity: .9; }
.theme { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--bg2); color: var(--text2); border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.menu { width: 36px; height: 36px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; padding: 0; }
.menu span, .menu span::before, .menu span::after { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; position: relative; content: ""; }
.menu span::before { position: absolute; top: -6px; } .menu span::after { position: absolute; top: 6px; }
@media (max-width: 520px) { .search-open span, .search-open kbd { display: none; } .brand .tag { display: none; } }

/* layout */
.shell { display: grid; grid-template-columns: 1fr; max-width: 1440px; margin: 0 auto; }
.side { position: fixed; inset: var(--top) auto 0 0; width: min(300px, 86vw); background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto;
  padding: 16px 12px 40px; transform: translateX(-102%); transition: transform .2s ease; z-index: 35; }
body.nav-open .side { transform: none; box-shadow: var(--shadow); }
body.nav-open::after { content: ""; position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .3); z-index: 30; }
.side-home { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14.5px; }
.side-home.on { background: var(--bg3); }
.nav-sec { margin-top: 10px; }
.nav-sec summary { list-style: none; cursor: pointer; padding: 6px 10px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--dim);
  display: flex; justify-content: space-between; align-items: center; border-radius: 8px; }
.nav-sec summary::-webkit-details-marker { display: none; }
.nav-sec summary::after { content: "›"; font-size: 15px; transition: transform .15s; }
.nav-sec[open] summary::after { transform: rotate(90deg); }
.nav-sec ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 6px; border-left: 1px solid var(--line); margin-left: 10px; }
.nav-sec a { display: block; padding: 5px 10px; font-size: 14.5px; color: var(--text2); border-radius: 8px; line-height: 1.4; }
.nav-sec a:hover { background: var(--bg2); text-decoration: none; color: var(--text); }
.nav-sec a[aria-current="page"] { color: var(--link); background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 600; }
.main { min-width: 0; padding: 20px 16px 40px; }
.toc { display: none; }
@media (min-width: 960px) {
  .menu { display: none; }
  .top-links { display: flex; }
  .shell { grid-template-columns: 272px minmax(0, 1fr); }
  .side { position: sticky; top: var(--top); height: calc(100vh - var(--top)); transform: none; width: auto; z-index: 1; }
  body.nav-open::after { display: none; }
  .main { padding: 32px 48px 56px; }
  .prose, .page-head, .pager, .foot, .crumbs { max-width: 780px; }
}
@media (min-width: 1240px) {
  .shell { grid-template-columns: 272px minmax(0, 1fr) 240px; }
  .toc { display: block; position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 32px 16px 24px 8px; font-size: 13.5px; }
  .toc-title { font-weight: 650; margin-bottom: 8px; font-size: 13px; }
  .toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
  .toc li a { display: block; padding: 4px 12px; color: var(--dim); margin-left: -1px; border-left: 2px solid transparent; line-height: 1.4; }
  .toc li.l3 a { padding-left: 24px; }
  .toc li a.on { color: var(--link); border-left-color: var(--link); }
  .toc li a:hover { color: var(--text); text-decoration: none; }
}

/* page head */
.crumbs { font-size: 13.5px; color: var(--dim); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.crumbs a { color: var(--dim); }
.page-head h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
.lead { font-size: 18px; color: var(--text2); margin: 0 0 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.chip { background: var(--bg3); border-radius: 999px; padding: 2px 10px; color: var(--text2); font-weight: 500; }
.page-tools { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.page-tools button, .page-tools a { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--bg); color: var(--text2); border-radius: 8px; padding: 3px 10px; cursor: pointer; }
.page-tools a:hover { text-decoration: none; background: var(--bg2); }
@media (max-width: 520px) { .page-tools { margin-left: 0; width: 100%; } }

/* prose */
.prose { font-size: 16px; }
.prose h2 { font-size: 24px; letter-spacing: -.01em; margin: 40px 0 10px; line-height: 1.25; }
.prose h3 { font-size: 19px; margin: 28px 0 8px; line-height: 1.3; }
.prose h4 { font-size: 16px; margin: 22px 0 6px; }
.prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -22px; color: var(--dim); opacity: 0; font-weight: 400; padding-right: 6px; }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; text-decoration: none; }
@media (max-width: 960px) { .anchor { display: none; } }
.prose p { margin: 12px 0; color: var(--text); }
.prose ul, .prose ol { padding-left: 24px; margin: 10px 0; }
.prose li { margin: 5px 0; }
.prose li.task { list-style: none; margin-left: -22px; display: flex; gap: 10px; }
.check { flex: none; width: 16px; height: 16px; border: 1.5px solid var(--dim); border-radius: 4px; margin-top: 5px; }
.check.on { background: var(--accent); border-color: var(--link); }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); display: block; margin: 16px 0; }
.prose video, .prose iframe { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); margin: 16px 0; aspect-ratio: 16 / 9; height: auto; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.prose code { font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; overflow-wrap: anywhere; }
.prose kbd { font: 600 13px/1.5 inherit; font-family: inherit; background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 7px; padding: 1px 8px; white-space: nowrap; color: var(--text); }
.prose blockquote { margin: 16px 0; padding: 4px 16px; border-left: 3px solid var(--line); color: var(--text2); }
.code { position: relative; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; }
.code-title { font-size: 12.5px; color: var(--dim); padding: 8px 14px; border-bottom: 1px solid var(--line); font-family: ui-monospace, Menlo, monospace; }
.code pre { margin: 0; padding: 14px; overflow-x: auto; }
.code pre code { background: none; border: 0; padding: 0; font-size: 13.5px; white-space: pre; overflow-wrap: normal; }
.code .copy { position: absolute; top: 6px; right: 6px; font: 600 12px/1 inherit; font-family: inherit; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--text2); cursor: pointer; }
.table { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); }
.table table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--bg2); font-weight: 650; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }

/* callouts + "where to click" */
.callout { margin: 18px 0; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; }
.callout > :last-child { margin-bottom: 0; } .callout p { margin: 6px 0; }
.callout-title { font-weight: 700; font-size: 13px; letter-spacing: .03em; text-transform: uppercase; }
.callout.note { background: var(--note-bg); border-color: color-mix(in srgb, var(--note) 30%, transparent); } .callout.note .callout-title { color: var(--note); }
.callout.tip { background: var(--tip-bg); border-color: color-mix(in srgb, var(--tip) 30%, transparent); } .callout.tip .callout-title { color: var(--tip); }
.callout.warning { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); } .callout.warning .callout-title { color: var(--warn); }
.callout.important { background: var(--imp-bg); border-color: color-mix(in srgb, var(--imp) 30%, transparent); } .callout.important .callout-title { color: var(--imp); }
.callout.example { background: var(--bg2); border-color: var(--line); } .callout.example .callout-title { color: var(--text2); }
.callout.success { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); } .callout.success .callout-title { color: var(--ok); }
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--bg2); border: 1px dashed var(--line); font-size: 14.5px; }
.path-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin-right: 4px; width: 100%; }
@media (min-width: 640px) { .path-label { width: auto; } }
.crumb { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 2px 10px; font-weight: 600; }
.sep { color: var(--dim); }

/* cards + steps */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 18px 0; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); transition: border-color .15s, transform .15s; }
.card:hover { text-decoration: none; border-color: var(--link); transform: translateY(-1px); }
.card-title { font-weight: 650; }
.card-title::after { content: " →"; color: var(--link); }
.card-text { color: var(--text2); font-size: 14.5px; line-height: 1.5; }
.steps { counter-reset: step; margin: 18px 0; }
.steps > h3 { counter-increment: step; display: flex; gap: 12px; align-items: center; margin-top: 26px; }
.steps > h3::before { content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; display: grid; place-items: center; }
.steps > h3 .anchor { display: none; }
.steps > :not(h3) { margin-left: 40px; }
@media (max-width: 520px) { .steps > :not(h3) { margin-left: 0; } }

/* faq */
.faq details { border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; background: var(--bg); }
.faq summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--dim); font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details > div { padding: 0 16px 8px; color: var(--text2); }

/* pager + footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.pager a { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; color: var(--text); font-weight: 600; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pager a span { font-size: 12.5px; color: var(--dim); font-weight: 500; }
.pager a:hover { border-color: var(--link); text-decoration: none; }
.pager .next { text-align: right; grid-column: 2; }
.foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }

/* search */
.search { position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 20, .45); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.search[hidden] { display: none; }
.search-box { width: 100%; max-width: 640px; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-wrap: wrap; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 16px; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-close { margin: 10px; font: inherit; font-size: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--dim); border-radius: 8px; padding: 0 10px; cursor: pointer; }
.results { list-style: none; margin: 0; padding: 6px; width: 100%; max-height: 60vh; overflow-y: auto; border-top: 1px solid var(--line); }
.results:empty { display: none; }
.results a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.results a:hover, .results a.on { background: var(--bg3); text-decoration: none; }
.results .r-sec { font-size: 12px; color: var(--dim); }
.results .r-t { font-weight: 600; }
.results .r-x { font-size: 13.5px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.results mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; }
.results .none { padding: 14px; color: var(--dim); }

/* videos (MJX Portal → Docs videos; filled by docs.js) */
.videos { margin: 20px 0 24px; }
.videos[hidden] { display: none; }
.videos-title { font-size: 20px; letter-spacing: -.01em; margin: 0 0 10px; line-height: 1.3; }
.v-player { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.v-player iframe, .v-poster { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.v-poster { display: block; margin: 0; padding: 0; background: #000; cursor: pointer; }
.v-poster img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .15s; }
.v-poster:hover img { opacity: .92; }
.v-poster:focus-visible { outline: 3px solid var(--link); outline-offset: -3px; }
.v-play { position: absolute; left: 50%; top: 50%; width: 68px; height: 48px; transform: translate(-50%, -50%); border-radius: 14px; background: rgba(23, 23, 28, .82); transition: background .15s; }
.v-play::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-35%, -50%); border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; }
.v-poster:hover .v-play, .v-poster:focus-visible .v-play { background: #e62117; }
.v-caption { margin-top: 8px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.v-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 12px; margin-top: 14px; }
.v-thumb { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 0; border: 0; background: none; color: var(--text2); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.v-img { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: var(--bg3); }
.v-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.v-thumb:hover .v-img { border-color: var(--line); }
.v-thumb.on .v-img { border-color: var(--link); }
.v-thumb.on .v-t { color: var(--text); font-weight: 600; }
.v-thumb:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 10px; }
.v-t { line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 520px) { .v-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .videos { max-width: 780px; } }
