/* Nelix Silicon Lab documentation. Neutral surfaces, thin borders, a reading
   width that stays comfortable, and Nelix purple only where something can be
   pressed or is current. Light and dark themes share one set of names. */
:root {
  --page: #ffffff; --surface: #fafafb; --raised: #ffffff; --ink: #17161d; --body: #3d3b4a; --muted: #6c6a7c;
  --line: #e8e7ee; --line-strong: #d6d4e0; --accent: #6a2df0; --accent-ink: #5321c9; --accent-soft: #f3efff;
  --code-bg: #14121d; --code-ink: #e6e1f5; --code-line: #282438; --inline-bg: #f1eef9; --inline-ink: #3b1d8f;
  --top-bg: rgba(255,255,255,0.86); --shadow: 0 16px 40px rgba(20,16,50,0.14);
  --note-bg: #f7f5fd; --note-line: #ddd5f7; --tip-bg: #f2f9f5; --tip-line: #c6e4d3; --tip-ink: #17603d;
  --warn-bg: #fff9ee; --warn-line: #efdcb1; --warn-ink: #7d5300;
  --sans: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --top: 56px;
}
:root[data-theme="dark"] {
  --page: #0e0d14; --surface: #14131c; --raised: #181722; --ink: #f1eff7; --body: #c9c6d8; --muted: #9793ab;
  --line: #262433; --line-strong: #35324a; --accent: #8f6bff; --accent-ink: #b9a6ff; --accent-soft: #211a3d;
  --code-bg: #0a0910; --code-ink: #e6e1f5; --code-line: #262433; --inline-bg: #231d3d; --inline-ink: #d5c8ff;
  --top-bg: rgba(14,13,20,0.86); --shadow: 0 16px 40px rgba(0,0,0,0.5);
  --note-bg: #18152b; --note-line: #342a5e; --tip-bg: #12201a; --tip-line: #24503a; --tip-ink: #8ed4ae;
  --warn-bg: #231b0e; --warn-line: #57431a; --warn-ink: #f0c36a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0e0d14; --surface: #14131c; --raised: #181722; --ink: #f1eff7; --body: #c9c6d8; --muted: #9793ab;
    --line: #262433; --line-strong: #35324a; --accent: #8f6bff; --accent-ink: #b9a6ff; --accent-soft: #211a3d;
    --code-bg: #0a0910; --code-ink: #e6e1f5; --code-line: #262433; --inline-bg: #231d3d; --inline-ink: #d5c8ff;
    --top-bg: rgba(14,13,20,0.86); --shadow: 0 16px 40px rgba(0,0,0,0.5);
    --note-bg: #18152b; --note-line: #342a5e; --tip-bg: #12201a; --tip-line: #24503a; --tip-ink: #8ed4ae;
    --warn-bg: #231b0e; --warn-line: #57431a; --warn-ink: #f0c36a;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; background: var(--page); color: var(--body); font-family: var(--sans); font-size: 15.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--muted); font-family: var(--mono); font-size: 0.82em; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; padding: 8px 12px; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Header */
.dtop { position: sticky; top: 0; z-index: 50; height: var(--top); background: var(--top-bg); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
.dtop-in { display: flex; align-items: center; gap: 10px; height: 100%; max-width: 1440px; margin: 0 auto; padding: 0 20px; min-width: 0; }
.dbrand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 14.5px; white-space: nowrap; }
.dslash { color: var(--line-strong); font-size: 18px; }
.dtag { color: var(--muted); font-size: 14.5px; font-weight: 550; text-decoration: none; }
.dtag:hover { color: var(--ink); }
.dsearch { position: relative; flex: 1 1 auto; max-width: 440px; min-width: 120px; margin: 0 8px 0 auto; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--muted); }
.dsearch:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dsearch input { flex: 1 1 auto; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; }
.dsearch input::placeholder { color: var(--muted); }
.dsearch input::-webkit-search-cancel-button { display: none; }
.dsearch-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); min-width: min(440px, 92vw); max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--raised); box-shadow: var(--shadow); }
.dsearch-results a { display: block; padding: 8px 10px; border-radius: 7px; color: var(--body); text-decoration: none; }
.dsearch-results a.on, .dsearch-results a:hover { background: var(--accent-soft); }
.dsearch-results b { display: block; color: var(--ink); font-size: 14px; font-weight: 650; }
.dsearch-results .where { display: block; color: var(--muted); font-size: 12px; }
.dsearch-results .snip { display: block; margin-top: 2px; color: var(--body); font-size: 12.5px; line-height: 1.45; }
.dsearch-results mark { background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.dsearch-results p { margin: 0; padding: 12px 10px; color: var(--muted); font-size: 13.5px; }
.dicon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: transparent; color: var(--body); cursor: pointer; }
.dicon:hover { background: var(--surface); color: var(--ink); }
.dmenu { display: none; }
.moon { display: none; }
:root[data-theme="dark"] .sun { display: none; } :root[data-theme="dark"] .moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sun { display: none; } :root:not([data-theme="light"]) .moon { display: block; } }
.dbtn { flex: 0 0 auto; display: inline-flex; align-items: center; height: 34px; padding: 0 13px; border-radius: 8px; background: #6a2df0; color: #fff; font-size: 13.5px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.dbtn:hover { background: #7b42ff; }
.auth, .auth-only { display: none; }
.is-auth .auth { display: inline-flex; } .is-auth .auth-only { display: inline; } .is-auth .guest, .is-auth .guest-only { display: none; }

/* Layout */
.dshell { display: grid; grid-template-columns: 272px minmax(0, 1fr) 220px; max-width: 1440px; margin: 0 auto; }
.k-home .dshell, .k-folder .dshell { grid-template-columns: 272px minmax(0, 1fr); }
.dscrim { display: none; }

/* Tree */
.dnav { position: sticky; top: var(--top); align-self: start; height: calc(100vh - var(--top)); overflow-y: auto; padding: 18px 12px 40px 20px; border-right: 1px solid var(--line); font-size: 14px; scrollbar-width: thin; }
.dnav-home { display: block; margin: 0 0 10px; padding: 6px 10px; border-radius: 7px; color: var(--ink); font-weight: 600; text-decoration: none; }
.dnav-home:hover, .dnav-home.on { background: var(--surface); }
.dfolder { margin: 1px 0; }
.dfolder > summary { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; color: var(--ink); font-weight: 600; cursor: pointer; list-style: none; user-select: none; }
.dfolder > summary::-webkit-details-marker { display: none; }
.dfolder > summary:hover { background: var(--surface); }
.chev { flex: 0 0 auto; width: 6px; height: 6px; margin-left: 2px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s ease; }
.dfolder[open] > summary .chev { transform: rotate(45deg); }
.dfolder-name { flex: 1 1 auto; min-width: 0; }
.dfolder-body { margin: 1px 0 6px 14px; padding-left: 10px; border-left: 1px solid var(--line); }
.dlink { display: block; margin: 1px 0; padding: 5px 10px; border-radius: 6px; color: var(--body); text-decoration: none; line-height: 1.35; }
.dlink:hover { background: var(--surface); color: var(--ink); }
.dlink.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* Main */
.dmain { min-width: 0; padding: 32px 48px 88px; }
.darticle, .k-folder .dmain > *, .dhero, .dsections, .dcount-line { max-width: 740px; }
.dcrumbs { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.dcrumbs a { color: var(--muted); text-decoration: none; }
.dcrumbs a:hover { color: var(--accent-ink); }
h1 { margin: 0 0 10px; color: var(--ink); font-size: 31px; line-height: 1.18; letter-spacing: -0.02em; font-weight: 700; }
.dlede { margin: 0 0 16px; color: var(--body); font-size: 17px; line-height: 1.55; }
.dmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 26px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dchip { padding: 1px 9px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 600; }
.dmeta-text { color: var(--muted); font-size: 12.5px; }
.dtoc-m { display: none; }

/* Article body */
.dbody { font-size: 15.5px; line-height: 1.7; }
.dbody h2 { margin: 38px 0 10px; color: var(--ink); font-size: 21px; line-height: 1.3; letter-spacing: -0.01em; font-weight: 680; }
.dbody h3 { margin: 26px 0 6px; color: var(--ink); font-size: 16.5px; font-weight: 660; }
.dbody h4 { margin: 20px 0 4px; color: var(--ink); font-size: 15.5px; }
.dbody h2:first-child { margin-top: 0; }
.dbody p { margin: 0 0 14px; }
.dbody ul, .dbody ol { margin: 0 0 16px; padding-left: 22px; }
.dbody li { margin: 0 0 6px; }
.dbody li > ul, .dbody li > ol { margin: 6px 0 0; }
.dbody strong { color: var(--ink); font-weight: 650; }
.dbody a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.dbody code { padding: 1px 5px; border-radius: 5px; background: var(--inline-bg); color: var(--inline-ink); font-family: var(--mono); font-size: 0.87em; }
.anchor { margin-left: 8px; color: var(--line-strong); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; }
hr { margin: 28px 0; border: 0; border-top: 1px solid var(--line); }
.code { margin: 0 0 18px; border: 1px solid var(--code-line); border-radius: 10px; background: var(--code-bg); overflow: hidden; }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 5px 6px 5px 14px; border-bottom: 1px solid var(--code-line); color: #8f89ad; font-family: var(--mono); font-size: 11.5px; }
.code-copy { padding: 3px 9px; border: 1px solid #343049; border-radius: 6px; background: transparent; color: #d7d3e2; font: inherit; font-family: var(--sans); font-size: 12px; cursor: pointer; }
.code-copy:hover { background: #1e1a2e; }
.code pre { margin: 0; padding: 12px 14px 14px; overflow-x: auto; }
.code pre code { padding: 0; background: transparent; color: var(--code-ink); font-size: 13px; line-height: 1.62; }
.table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
th { padding: 8px 12px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.03em; text-align: left; white-space: nowrap; }
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.callout { margin: 0 0 18px; padding: 12px 16px; border: 1px solid var(--note-line); border-radius: 10px; background: var(--note-bg); }
.callout p { margin: 0; }
.callout-label { margin-bottom: 2px !important; color: var(--accent-ink); font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.callout.tip { border-color: var(--tip-line); background: var(--tip-bg); } .callout.tip .callout-label { color: var(--tip-ink); }
.callout.warn { border-color: var(--warn-line); background: var(--warn-bg); } .callout.warn .callout-label { color: var(--warn-ink); }

/* Step diagrams */
.flow { display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 0 0 20px; padding: 0 !important; list-style: none; counter-reset: flow; }
.flow li { position: relative; flex: 1 1 130px; min-width: 0; margin: 0 !important; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); }
.flow li b { display: block; color: var(--ink); font-size: 13.5px; font-weight: 650; overflow-wrap: anywhere; }
.flow li span { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.flow li:not(:last-child)::after { content: ""; position: absolute; right: -18px; top: 50%; width: 7px; height: 7px; border-top: 1.5px solid var(--muted); border-right: 1.5px solid var(--muted); transform: translateY(-50%) rotate(45deg); }

/* Figures. Drawings take their colours from the theme; a schematic from the
   synthesis tool stays on white, as the tool drew it. */
.fig { margin: 0 0 22px; }
.fig-art { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow-x: auto; }
.fig-art.paper { background: #ffffff; }
.fig-art.photo { padding: 0; background: #0b0a12; text-align: center; }
.fig-art.photo img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.fig svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.fig figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.fg:not(.paper) text { font-family: var(--sans); font-size: 12px; fill: var(--body); }
.fg .t-ink { fill: var(--ink); font-weight: 600; } .fg .t-muted { fill: var(--muted); } .fg .t-accent { fill: var(--accent-ink); } .fg .t-mono { font-family: var(--mono); fill: var(--ink); }
.fg .s-ink { stroke: var(--ink); stroke-width: 1.4; fill: none; } .fg .s-muted { stroke: var(--muted); stroke-width: 1.2; fill: none; } .fg .s-grid { stroke: var(--line); stroke-width: 1; }
.fg .s-accent { stroke: var(--accent); stroke-width: 1.3; fill: none; } .fg .s-accent-2 { stroke: var(--accent); stroke-width: 2.2; fill: none; } .fg .s-wave { stroke: var(--accent-ink); stroke-width: 1.8; fill: none; stroke-linejoin: round; }
.fg .f-muted { fill: var(--muted); }
.fg .b-surface { fill: var(--raised); stroke: var(--line-strong); stroke-width: 1.2; } .fg .b-page { fill: var(--page); stroke: var(--line-strong); stroke-width: 1; }
.fg .b-accent { fill: var(--accent); } .fg .b-accent-soft { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.fg .b-ink { fill: var(--ink); } .fg .b-warn { fill: var(--warn-line); stroke: var(--warn-ink); stroke-width: 0.8; } .fg .b-ok { fill: var(--tip-line); stroke: var(--tip-ink); stroke-width: 0.8; }
.fg .b-bus { fill: var(--accent-soft); stroke: var(--accent-ink); stroke-width: 1.2; } .fg .b-unknown { fill: var(--surface); stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 2; }

/* After the article */
.dverified { margin: 26px 0 0; padding: 10px 14px; border: 1px solid var(--tip-line); border-radius: 9px; background: var(--tip-bg); color: var(--body); font-size: 13.5px; }
.dverified b { color: var(--tip-ink); }
.drelated { margin: 36px 0 0; padding-top: 20px; border-top: 1px solid var(--line); }
.drelated h2 { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.drelated ul { margin: 0; padding: 0; list-style: none; }
.drelated li { margin: 0 0 6px; }
.drelated a { font-weight: 600; text-decoration: none; }
.drelated a:hover { text-decoration: underline; }
.drelated span { color: var(--muted); font-size: 13.5px; }
.drelated span::before { content: " · "; }
.dpager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 36px 0 18px; }
.dpager a { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; transition: border-color 0.15s ease; }
.dpager a:hover { border-color: var(--accent); }
.dpager b { font-size: 14.5px; font-weight: 620; }
.dpager span { color: var(--muted); font-size: 12px; }
.dnext { text-align: right; }
.dfeedback { margin: 0; color: var(--muted); font-size: 13.5px; }

/* Outline */
.dtoc { position: sticky; top: var(--top); align-self: start; max-height: calc(100vh - var(--top)); overflow-y: auto; padding: 36px 20px 40px 0; font-size: 13px; }
.dtoc-title { margin: 0 0 8px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.dtoc a, .dtoc-m a { display: block; padding: 3px 0 3px 12px; border-left: 1px solid var(--line); color: var(--muted); text-decoration: none; line-height: 1.4; }
.dtoc a.l3, .dtoc-m a.l3 { padding-left: 24px; }
.dtoc a:hover, .dtoc-m a:hover { color: var(--ink); }
.dtoc a.on { border-left-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* Home and section pages */
.dhero { margin-bottom: 28px; }
.dpaths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.dpath { display: flex; flex-direction: column; gap: 3px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--body); text-decoration: none; transition: border-color 0.15s ease; }
.dpath:hover { border-color: var(--accent); }
.dpath b { color: var(--ink); font-size: 14.5px; }
.dpath span { font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.dsections { border-top: 1px solid var(--line); }
.dsection { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dsection h2 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 2px; font-size: 16px; font-weight: 650; }
.dsection h2 a { color: var(--ink); text-decoration: none; }
.dsection h2 a:hover { color: var(--accent-ink); }
.dsection h2 span { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.dsection p { margin: 0; color: var(--muted); font-size: 14px; }
.dcount-line { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.dlist { margin: 8px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.dlist li { border-bottom: 1px solid var(--line); }
.dlist a { display: block; padding: 12px 0; text-decoration: none; }
.dlist b { display: block; color: var(--ink); font-size: 15px; font-weight: 640; }
.dlist a:hover b { color: var(--accent-ink); }
.dlist span { display: block; color: var(--muted); font-size: 14px; }

@media (max-width: 1160px) {
  .dshell { grid-template-columns: 256px minmax(0, 1fr); }
  .dtoc { display: none; }
  .dtoc-m { display: block; margin: 0 0 22px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 13.5px; }
  .dtoc-m summary { color: var(--ink); font-weight: 620; cursor: pointer; }
  .dtoc-m[open] summary { margin-bottom: 8px; }
  .dmain { padding: 28px 30px 72px; }
}
@media (max-width: 820px) {
  .dshell, .k-home .dshell, .k-folder .dshell { display: block; }
  .dmenu { display: inline-flex; }
  .dnav { position: fixed; left: 0; top: var(--top); bottom: 0; z-index: 45; width: min(320px, 86vw); height: auto; background: var(--page); border-right: 1px solid var(--line-strong); transform: translateX(-102%); transition: transform 0.2s ease; visibility: hidden; }
  body.nav-open .dnav { transform: none; visibility: visible; box-shadow: var(--shadow); }
  body.nav-open .dscrim { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 44; background: rgba(10,8,24,0.45); }
  .dmain { padding: 22px 18px 60px; }
  h1 { font-size: 26px; } .dlede { font-size: 16px; }
  .dpaths, .dpager { grid-template-columns: 1fr; }
  .dtop-in { padding: 0 12px; gap: 8px; }
  .dbrand span, .dslash, .dtag, .dsearch kbd { display: none; }
  .dsearch { margin: 0; min-width: 70px; }
  .dbtn { padding: 0 9px; font-size: 12.5px; }
  .dbrand { flex: 0 0 auto; }
  .flow li:not(:last-child)::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .dtop, .dnav, .dtoc, .dtoc-m, .dpager, .dfeedback, .code-copy, .dscrim { display: none !important; } .dshell { display: block; } .dmain { padding: 0; } }

/* Phones: every tap target at least 44 px (design standard). */
@media (max-width: 760px) {
  .dicon { width: 44px; height: 44px; }
  .dbtn { height: 44px; }
}
/* Narrow phones: the light/dark switch leaves the top bar so the search box has room (the page follows the phone's own setting). */
@media (max-width: 420px) { #dtheme { display: none; } }

/* r2-docs: the docs opt in to the lab's smooth page changes (nx-stable does the same on app
   pages), which also stops the "ViewTransition ... opt-in disabled" console error when a
   reader comes to the docs from the app. Browsers without cross-document view transitions
   ignore all of this. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 140ms; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
