/* Leonardo Codex (Story 3510) -- the shared look for every Codex page. Owned by builder F2;
   other pages add their own <page>.css and reuse these tokens and classes.
   Pinned chrome: .cx-shell is a full-height flex column that never scrolls; each pane has exactly
   one scroller. Write BOTH heights -- 100vh alone lets the tool bar strip slide off on a phone.
   A closed / archived / deprecated thing is shown by COLOUR, never a strike-through. */

:root {
    --cx-bg: #EEF0F4;
    --cx-card: #FFFFFF;
    --cx-line: #DDE1E8;
    --cx-line-soft: #EEF0F3;
    --cx-ink: #111827;
    --cx-ink-2: #374151;
    --cx-ink-3: #6B7280;
    --cx-bar: #1F2937;
    --cx-accent: #2563EB;
    --cx-accent-soft: #DBEAFE;
    --cx-green: #15803D;
    --cx-green-soft: #DCFCE7;
    --cx-amber: #B45309;
    --cx-amber-soft: #FEF3C7;
    --cx-red: #B91C1C;
    --cx-red-soft: #FEE2E2;
    --cx-radius: 8px;
    --cx-tree-w: 320px;
}

body { background: var(--cx-bg); margin: 0; color: var(--cx-ink); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.cx-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; width: 100%; box-sizing: border-box; }
#lwIconBand, .ct-header, .cx-toolbar, .cx-statusbar { flex: 0 0 auto; }

.ct-header { background: var(--cx-bar); color: #fff; padding: 8px 12px; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 40px; }
.ct-header h1 { margin: 0; font-size: 15pt; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-header h1 .cx-ico { vertical-align: -3px; margin-right: 6px; }
.ct-header button { color: #fff; background: transparent; border: 1px solid #4B5563; border-radius: 4px; padding: 0 12px; min-height: 40px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ct-header button:hover { background: #374151; }

.cx-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding: 10px; }
.cx-wrap { width: 100%; max-width: 1200px; margin: 0 auto; box-sizing: border-box; }

.cx-toolbar { background: #fff; border-bottom: 1px solid var(--cx-line); padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cx-toolbar .grow { flex: 1 1 200px; min-width: 0; }
.cx-toolbar .spacer { flex: 1 1 auto; }

/* ---------------------------------------------------------------- buttons */
.cx-btn { background: #E5E7EB; color: var(--cx-ink); border: none; border-radius: 6px; padding: 0 14px; min-height: 40px; font: inherit; font-size: 13px; font-weight: 600;
          cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; box-sizing: border-box; }
.cx-btn:hover { background: #D1D5DB; }
.cx-btn.primary { background: var(--cx-accent); color: #fff; }
.cx-btn.primary:hover { background: #1D4ED8; }
.cx-btn.good { background: var(--cx-green); color: #fff; }
.cx-btn.danger { background: var(--cx-red-soft); color: #991B1B; }
.cx-btn.danger-solid { background: var(--cx-red); color: #fff; }
.cx-btn.small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.cx-btn.ghost { background: transparent; border: 1px solid #D1D5DB; }
.cx-btn:disabled { opacity: .5; cursor: default; }
.cx-iconbtn { background: transparent; border: 1px solid #D1D5DB; border-radius: 6px; color: var(--cx-ink-2); min-width: 40px; height: 40px; padding: 0 8px; font-size: 15px; line-height: 1;
              cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.cx-iconbtn:hover { background: var(--cx-accent-soft); border-color: #93C5FD; color: #1D4ED8; }
.cx-iconbtn:disabled { opacity: .35; cursor: default; }

.cx-btn:focus-visible, .cx-iconbtn:focus-visible, .cx-card.link:focus-visible, .cx-row:focus-visible, .cx-tile:focus-visible, .cx-tree-row .lbl:focus-visible,
.cx-menu-item:focus-visible, .cx-choose-row:focus-visible, .cx-crumb:focus-visible, .cx-chip:focus-visible, .cx-status:focus-visible, .cx-twist:focus-visible,
.cx-toc a:focus-visible, .cx-pick-row:focus-visible, .ct-header button:focus-visible, a:focus-visible { outline: 2px solid #60A5FA; outline-offset: 2px; }

/* ---------------------------------------------------------------- chips */
.cx-status { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #fff; background: #6B7280; white-space: nowrap; line-height: 18px; }
button.cx-status { border: none; cursor: pointer; font-family: inherit; min-height: 28px; }
.cx-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #E5E7EB; color: var(--cx-ink-2);
           white-space: nowrap; line-height: 18px; text-decoration: none; border: none; font-family: inherit; }
a.cx-chip, button.cx-chip { cursor: pointer; min-height: 28px; box-sizing: border-box; }
a.cx-chip:hover, button.cx-chip:hover { background: var(--cx-accent-soft); color: #1D4ED8; }
.cx-chip.good { background: var(--cx-green-soft); color: #166534; }
.cx-chip.warn { background: var(--cx-amber-soft); color: #92400E; }
.cx-chip.bad { background: var(--cx-red-soft); color: #991B1B; }
.cx-chip.quiet { background: #F3F4F6; color: var(--cx-ink-3); }
.cx-chip .cx-ico { width: 13px; height: 13px; }
.cx-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #6B7280; flex: 0 0 auto; }
.cx-muted { color: var(--cx-ink-3); font-size: 12px; }
.cx-ico { flex: 0 0 auto; }

/* ---------------------------------------------------------------- cards + lists (home) */
.cx-section-title { display: flex; align-items: center; gap: 10px; margin: 14px 2px 6px; font-size: 12px; font-weight: 700; letter-spacing: .5px; color: #4B5563; text-transform: uppercase; }
.cx-section-title:first-child { margin-top: 2px; }
.cx-section-title .spacer { flex: 1; }
/* Folding sections on the Codex home (2026-10-06): the title is the fold button, remembered per user. */
.cx-foldbtn { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; padding: 4px 2px; margin: -4px 0; min-height: 32px;
    font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; }
.cx-foldbtn:hover { color: #1D4ED8; }
.cx-foldbtn .caret { display: inline-block; width: 12px; font-size: 11px; }
.cx-foldbody[hidden] { display: none; }
/* The header fold tucks the search box and the count tiles away. */
.ct-header .cx-headfold { flex: 0 0 auto; }
.cx-top-folded .cx-search, .cx-top-folded .cx-tiles { display: none; }
@media print { .cx-foldbody[hidden] { display: block; } .cx-foldbtn .caret, .cx-headfold { display: none; } }
.cx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.cx-card { background: var(--cx-card); border: 1px solid var(--cx-line); border-radius: var(--cx-radius); padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); position: relative; min-width: 0; box-sizing: border-box; }
.cx-card.link { cursor: pointer; }
.cx-card.link:hover { border-color: #93C5FD; box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.cx-card.space { border-left: 5px solid var(--cx-edge, #6B7280); padding-right: 50px; }
.cx-card.archived { background: #F3F4F6; }
.cx-card.archived h2 { color: var(--cx-ink-3); }
.cx-card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 700; line-height: 1.25; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.cx-card h2 .cx-ico { color: var(--cx-edge, #6B7280); width: 20px; height: 20px; }
.cx-card .desc { font-size: 13px; color: var(--cx-ink-2); line-height: 1.45; margin: 2px 0 6px; overflow-wrap: anywhere; }
.cx-card .stand { font-size: 12.5px; color: var(--cx-ink-2); line-height: 1.45; margin: 6px 0; padding: 6px 8px; background: #F9FAFB; border-radius: 6px; border-left: 3px solid var(--cx-edge, #9CA3AF); white-space: pre-wrap; overflow-wrap: anywhere; }
.cx-card .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.cx-card .cx-card-menu { position: absolute; top: 6px; right: 6px; border-color: transparent; }

.cx-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cx-tile { background: var(--cx-card); border: 1px solid var(--cx-line); border-radius: var(--cx-radius); padding: 10px 12px; text-decoration: none; color: var(--cx-ink); display: flex; flex-direction: column; gap: 2px; min-height: 40px; cursor: pointer; font: inherit; text-align: left; }
.cx-tile:hover { border-color: #93C5FD; }
.cx-tile .n { font-size: 24px; font-weight: 750; line-height: 1.1; }
.cx-tile .l { font-size: 12px; color: var(--cx-ink-3); font-weight: 600; }
.cx-tile .x { font-size: 12px; font-weight: 700; color: var(--cx-red); }
.cx-tile.warn .n { color: var(--cx-amber); }
.cx-tile.accent { background: var(--cx-accent); border-color: var(--cx-accent); color: #fff; justify-content: center; }
.cx-tile.accent .l { color: #DBEAFE; }

.cx-list { background: var(--cx-card); border: 1px solid var(--cx-line); border-radius: var(--cx-radius); overflow: hidden; }
.cx-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; min-height: 40px; box-sizing: border-box; border-top: 1px solid var(--cx-line-soft); text-decoration: none; color: var(--cx-ink); cursor: pointer; }
.cx-row:first-child { border-top: none; }
.cx-row:hover { background: #F5F8FF; }
.cx-row .cx-ico { color: var(--cx-ink-3); }
.cx-row .main { flex: 1; min-width: 0; }
.cx-row .t { display: block; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.cx-row .p { display: block; font-size: 11.5px; color: var(--cx-ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-row .when { font-size: 11.5px; color: var(--cx-ink-3); white-space: nowrap; }
.cx-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 14px; align-items: start; }

.cx-search { display: flex; gap: 8px; align-items: stretch; margin: 0 0 4px; }
.cx-search input[type="search"] { display: block; flex: 1; width: 100%; min-width: 0; box-sizing: border-box; min-height: 44px; padding: 8px 12px; border: 1px solid #C9CDD6; border-radius: 8px; font: inherit; font-size: 15px; background: #fff; color: var(--cx-ink); }

.cx-fail { background: var(--cx-amber-soft); color: #78350F; border: 1px solid #FCD34D; border-radius: var(--cx-radius); padding: 10px 12px; font-size: 13px; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cx-loading { color: var(--cx-ink-3); font-size: 13px; padding: 18px 8px; text-align: center; }

/* ---------------------------------------------------------------- space: two panes */
.cx-split { flex: 1; min-height: 0; display: flex; width: 100%; box-sizing: border-box; position: relative; }
.cx-treepane { flex: 0 0 var(--cx-tree-w); width: var(--cx-tree-w); min-width: 0; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--cx-line); box-sizing: border-box; }
.cx-treepane-head { flex: 0 0 auto; display: none; align-items: center; gap: 8px; padding: 8px 10px; background: var(--cx-bar); color: #fff; font-weight: 700; font-size: 14px; }
.cx-treepane-head .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-treepane-head button { color: #fff; background: transparent; border: 1px solid #4B5563; border-radius: 4px; min-height: 40px; padding: 0 12px; font: inherit; font-size: 13px; cursor: pointer; }
.cx-tree-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cx-pagepane { flex: 1; min-width: 0; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.cx-scrim { display: none; }

/* ---------------------------------------------------------------- tree */
.cx-tree { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cx-tree-tools { flex: 0 0 auto; padding: 8px; border-bottom: 1px solid var(--cx-line-soft); display: flex; flex-direction: column; gap: 6px; }
.cx-tree-tools .line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cx-tree-tools input.cx-tree-filter { display: block; width: 100%; box-sizing: border-box; min-height: 40px; padding: 6px 10px; border: 1px solid #C9CDD6; border-radius: 6px; font: inherit; font-size: 13px; background: #fff; color: var(--cx-ink); }
.cx-tree-tools .cx-check { font-size: 12px; color: var(--cx-ink-2); display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.cx-tree-tools .spacer { flex: 1; }
.cx-tree-scroll { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 24px; }
.cx-tree-row { display: flex; align-items: center; gap: 2px; min-height: 40px; padding-right: 6px; border-left: 3px solid transparent; position: relative; box-sizing: border-box; }
.cx-tree-row:hover { background: #F5F8FF; }
.cx-tree-row.selected { background: var(--cx-accent-soft); border-left-color: var(--cx-accent); }
.cx-tree-row.archived .lbl { color: #9CA3AF; font-weight: 400; }
.cx-tree-row.archived .cx-ico, .cx-tree-row.archived .cx-dot { opacity: .45; }
.cx-tree-row.deprecated .lbl { color: var(--cx-ink-3); }
.cx-tree-row.dragging { opacity: .45; }
.cx-tree-row.drop-before { box-shadow: inset 0 3px 0 var(--cx-accent); }
.cx-tree-row.drop-after { box-shadow: inset 0 -3px 0 var(--cx-accent); }
.cx-tree-row.drop-inside { background: #BFDBFE; box-shadow: inset 0 0 0 2px var(--cx-accent); }
.cx-grip { flex: 0 0 auto; width: 22px; height: 40px; display: inline-flex; align-items: center; justify-content: center; color: #9CA3AF; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; font-size: 14px; }
.cx-grip:hover { color: #1D4ED8; }
.cx-grip:active { cursor: grabbing; }
.cx-twist { flex: 0 0 auto; width: 28px; height: 40px; border: none; background: transparent; color: var(--cx-ink-3); cursor: pointer; font-size: 11px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.cx-twist span { display: inline-block; transition: transform .12s; }
.cx-twist.open span { transform: rotate(90deg); }
.cx-twist.leaf { visibility: hidden; }
.cx-tree-row .lbl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 2px; background: transparent; border: none; font: inherit; font-size: 13.5px; color: var(--cx-ink);
                    text-align: left; cursor: pointer; text-decoration: none; }
.cx-tree-row .lbl .cx-ico { color: var(--cx-ink-3); width: 16px; height: 16px; }
.cx-tree-row .lbl .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-tree-row.selected .lbl { font-weight: 700; }
.cx-tree-row .badges { display: inline-flex; gap: 4px; align-items: center; flex: 0 0 auto; }
.cx-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; box-sizing: border-box; }
.cx-badge.act { background: var(--cx-accent-soft); color: #1D4ED8; }
.cx-badge.com { background: #EDE9FE; color: #5B21B6; }
.cx-dot.review { background: #F59E0B; box-shadow: 0 0 0 2px #FEF3C7; }
.cx-tree-rowtools { display: flex; gap: 4px; padding: 2px 6px 6px; background: var(--cx-accent-soft); border-left: 3px solid var(--cx-accent); flex-wrap: wrap; }
.cx-tree-rowtools .cx-iconbtn { background: #fff; min-width: 40px; }
.cx-tree-more { display: block; width: 100%; text-align: left; border: none; background: transparent; color: var(--cx-accent); font: inherit; font-size: 12px; min-height: 36px; cursor: pointer; }
.cx-tree-empty { padding: 14px 12px; font-size: 13px; color: var(--cx-ink-3); }

/* ---------------------------------------------------------------- page view */
.cx-page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 10px 14px 60px; box-sizing: border-box; display: flex; gap: 18px; align-items: flex-start; }
.cx-page-main { flex: 1; min-width: 0; }
.cx-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12.5px; color: var(--cx-ink-3); margin-bottom: 4px; }
.cx-crumb { color: var(--cx-accent); text-decoration: none; padding: 6px 4px; border-radius: 4px; background: transparent; border: none; font: inherit; font-size: 12.5px; cursor: pointer; min-height: 32px; }
.cx-crumb:hover { background: var(--cx-accent-soft); }
.cx-crumbs .sep { color: #9CA3AF; }
.cx-page-title { margin: 2px 0 8px; font-size: 26px; line-height: 1.2; font-weight: 750; overflow-wrap: anywhere; display: flex; gap: 10px; align-items: flex-start; }
.cx-page-title .cx-ico { width: 26px; height: 26px; margin-top: 3px; color: var(--cx-ink-3); }
.cx-page.archived .cx-page-title { color: var(--cx-ink-3); }
.cx-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.cx-banner { border-radius: var(--cx-radius); padding: 8px 12px; font-size: 13px; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid transparent; }
.cx-banner .msg { flex: 1 1 200px; min-width: 0; }
.cx-banner.draft { background: var(--cx-amber-soft); border-color: #FCD34D; color: #78350F; }
.cx-banner.deprecated { background: #F3F4F6; border-color: #D1D5DB; color: var(--cx-ink-2); }
.cx-banner.readonly { background: #EFF6FF; border-color: #BFDBFE; color: #1E3A8A; }
.cx-banner.archived { background: #F3F4F6; border-color: #D1D5DB; color: var(--cx-ink-2); }
.cx-banner a { color: inherit; font-weight: 700; }

.cx-props { background: #fff; border: 1px solid var(--cx-line); border-radius: var(--cx-radius); padding: 8px 12px; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.cx-prop .k { font-size: 11px; color: var(--cx-ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.cx-prop .v { font-size: 13.5px; overflow-wrap: anywhere; }
.cx-prop .v a { color: var(--cx-accent); }
.cx-prop .v.none { color: #9CA3AF; }

.cx-page-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.cx-page-body { background: #fff; border: 1px solid var(--cx-line); border-radius: var(--cx-radius); padding: 14px 16px; min-width: 0; overflow-wrap: anywhere; }
.cx-page-body .pmd > :first-child { margin-top: 0; }
.cx-page-body img { max-width: 100%; height: auto; }
.cx-page-body pre { overflow-x: auto; }
.cx-page-body table { display: block; max-width: 100%; overflow-x: auto; }
.cx-page-body :target, .cx-page-body .cx-flash { animation: cxFlash 2s ease-out; }
@keyframes cxFlash { from { background: #FEF3C7; } to { background: transparent; } }
.cx-plain { white-space: pre-wrap; font-size: 14px; line-height: 1.55; }

.cx-sec { margin-top: 16px; }
.cx-sec > h2 { font-size: 12px; font-weight: 700; letter-spacing: .5px; color: #4B5563; text-transform: uppercase; margin: 0 2px 6px; }
.cx-child-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.cx-child { background: #fff; border: 1px solid var(--cx-line); border-radius: var(--cx-radius); padding: 8px 10px; text-decoration: none; color: var(--cx-ink); display: block; min-height: 40px; box-sizing: border-box; border-left: 4px solid var(--cx-edge, #9CA3AF); }
.cx-child:hover { border-color: #93C5FD; border-left-color: var(--cx-edge, #9CA3AF); box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.cx-child .t { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.cx-child .t .cx-ico { color: var(--cx-ink-3); width: 16px; height: 16px; }
.cx-child .e { font-size: 12.5px; color: var(--cx-ink-2); line-height: 1.4; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cx-child .m { font-size: 11.5px; color: var(--cx-ink-3); margin-top: 4px; }
.cx-linklist { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-footer { margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--cx-line); font-size: 12px; color: var(--cx-ink-3); }

.cx-toc { flex: 0 0 230px; width: 230px; position: sticky; top: 10px; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); overflow: auto; background: #fff; border: 1px solid var(--cx-line); border-radius: var(--cx-radius); padding: 8px 6px; box-sizing: border-box; font-size: 12.5px; }
.cx-toc h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #4B5563; margin: 2px 8px 4px; }
.cx-toc a { display: block; padding: 6px 8px; border-radius: 4px; color: var(--cx-ink-2); text-decoration: none; line-height: 1.3; overflow-wrap: anywhere; }
.cx-toc a:hover { background: var(--cx-accent-soft); color: #1D4ED8; }
.cx-toc a.l1 { font-weight: 700; } .cx-toc a.l3 { padding-left: 20px; } .cx-toc a.l4, .cx-toc a.l5, .cx-toc a.l6 { padding-left: 32px; color: var(--cx-ink-3); }
.cx-toc-btn { display: none; }

/* ---------------------------------------------------------------- roll the side panes away
   (2026-10-06, Tony: "the same feature gmail client has"). The Pages tree rolls to a strip on the
   left, the Contents list to a strip on the right; a tap on a strip brings it back. Remembered per
   device in the database. Wide screens only -- narrower ones already use the drawer and sheet. */
.cx-rollbar { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #F8FAFC; border-bottom: 1px solid var(--cx-line); font: 600 12px "Segoe UI", system-ui, sans-serif; color: #475569; }
.cx-rollbar .t { flex: 1 1 auto; min-width: 0; text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }
.cx-roll { background: #fff; color: #475569; border: 1px solid #CBD5E1; border-radius: 3px; cursor: pointer; font-size: 11px; line-height: 1; padding: 5px 8px; }
.cx-roll:hover, .cx-roll:focus-visible { background: #ECF4FD; }
.cx-rail { display: none; flex: 0 0 34px; width: 34px; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; background: #F1F5F9; border: none; color: #0A66C2; font: 600 12px "Segoe UI", system-ui, sans-serif; box-sizing: border-box; }
.cx-rail:hover, .cx-rail:focus-visible { background: #DBEAFE; outline: none; }
.cx-rail-text { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.cx-rail[hidden] { display: none !important; }
.cx-rail-left { border-right: 1px solid var(--cx-line); }
.cx-split.cx-tree-min > .cx-treepane { display: none; }
.cx-split.cx-tree-min > .cx-rail-left { display: flex; }
.cx-toc .cx-rollbar { margin: -8px -6px 6px; border-radius: var(--cx-radius) var(--cx-radius) 0 0; }
.cx-rail-right { position: sticky; top: 10px; align-self: flex-start; min-height: 140px; border: 1px solid var(--cx-line); border-radius: var(--cx-radius); }
.cx-page.cx-toc-min > .cx-toc { display: none; }
.cx-page.cx-toc-min > .cx-rail-right { display: flex; }
/* The room a rolled-away side gives back goes to the page. */
.cx-split.cx-tree-min .cx-page, .cx-page.cx-toc-min { max-width: 1440px; }

/* ---------------------------------------------------------------- menu, modals, toast */
.cx-menu { position: fixed; z-index: 1400; background: #fff; border: 1px solid #C9CDD6; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.22); padding: 4px; min-width: 210px; max-width: calc(100vw - 16px); overflow: auto; box-sizing: border-box; }
.cx-menu-item { display: block; width: 100%; text-align: left; background: transparent; border: none; border-radius: 5px; padding: 0 12px; min-height: 40px; font: inherit; font-size: 13.5px; color: var(--cx-ink); cursor: pointer; }
.cx-menu-item:hover { background: var(--cx-accent-soft); }
.cx-menu-item.danger { color: #991B1B; }
.cx-menu-item.danger:hover { background: var(--cx-red-soft); }
.cx-menu-sep { height: 1px; background: var(--cx-line); margin: 4px 2px; }

.cx-overlay { position: fixed; inset: 0; z-index: 1500; background: rgba(17,24,39,.55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; box-sizing: border-box; overflow: auto; }
.cx-modal { background: #fff; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.35); width: 100%; max-width: 560px; box-sizing: border-box; padding: 14px 16px; }
.cx-modal-small { max-width: 440px; }
.cx-modal.danger { border-top: 5px solid var(--cx-red); }
.cx-modal-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.cx-modal-msg { font-size: 14px; line-height: 1.5; color: var(--cx-ink-2); overflow-wrap: anywhere; }
.cx-modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.cx-form-intro { font-size: 13px; color: var(--cx-ink-2); margin-bottom: 8px; line-height: 1.45; }
.cx-field { margin-bottom: 10px; }
.cx-field label { display: block; font-size: 12px; color: #4B5563; font-weight: 600; margin-bottom: 3px; }
.cx-field label .req { color: var(--cx-red); }
.cx-field input[type="text"], .cx-field input[type="date"], .cx-field input[type="number"], .cx-field textarea, .cx-field select {
    display: block; width: 100%; box-sizing: border-box; min-height: 40px; padding: 8px 10px; border: 1px solid #C9CDD6; border-radius: 6px; font: inherit; font-size: 14px; background: #fff; color: var(--cx-ink); }
.cx-field textarea { resize: vertical; line-height: 1.45; }
.cx-field input[type="color"] { display: block; width: 100%; height: 40px; box-sizing: border-box; padding: 2px; border: 1px solid #C9CDD6; border-radius: 6px; background: #fff; }
.cx-field .voice-mic-wrap, .cx-search .voice-mic-wrap, .cx-tree-tools .voice-mic-wrap { display: block; }
.cx-field .ps-select { width: 100%; box-sizing: border-box; min-height: 40px; }
.cx-field .cx-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--cx-ink); font-weight: 500; min-height: 40px; cursor: pointer; }
.cx-field .cx-check input { width: 18px; height: 18px; }
.cx-hint { font-size: 11.5px; color: var(--cx-ink-3); margin-top: 3px; }
.cx-form-error { color: #991B1B; background: var(--cx-red-soft); border-radius: 6px; font-size: 13px; padding: 8px 10px; margin-top: 4px; }
.cx-form-error:empty { display: none; padding: 0; margin: 0; }
.cx-pick { position: relative; }
.cx-pick-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: #fff; border: 1px solid #C9CDD6; border-radius: 6px; box-shadow: 0 8px 22px rgba(0,0,0,.18); max-height: 260px; overflow: auto; margin-top: 2px; }
.cx-pick-row { display: block; width: 100%; text-align: left; background: transparent; border: none; border-top: 1px solid var(--cx-line-soft); padding: 6px 10px; min-height: 40px; font: inherit; cursor: pointer; }
.cx-pick-row:first-child { border-top: none; }
.cx-pick-row:hover { background: var(--cx-accent-soft); }
.cx-pick-row .t { display: block; font-size: 13.5px; font-weight: 600; color: var(--cx-ink); }
.cx-pick-row .p { display: block; font-size: 11.5px; color: var(--cx-ink-3); }
.cx-pick-none { padding: 10px; font-size: 13px; color: var(--cx-ink-3); }
.cx-choose { display: flex; flex-direction: column; gap: 4px; }
.cx-choose-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: #F9FAFB; border: 1px solid var(--cx-line); border-radius: 6px; padding: 0 12px; min-height: 44px; font: inherit; font-size: 14px; cursor: pointer; color: var(--cx-ink); }
.cx-choose-row:hover { background: var(--cx-accent-soft); border-color: #93C5FD; }
.cx-choose-row.on { border-color: var(--cx-accent); box-shadow: inset 0 0 0 1px var(--cx-accent); font-weight: 700; }
.cx-choose-row .lbl { flex: 1; }
.cx-choose-row .hint { font-size: 12px; color: var(--cx-ink-3); font-weight: 400; }
.cx-move-tree { border: 1px solid var(--cx-line); border-radius: 6px; height: 46vh; min-height: 220px; display: flex; flex-direction: column; overflow: hidden; }

.cx-toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 2100; background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); box-sizing: border-box; }
.cx-toast.show { opacity: 1; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
    .cx-toc { display: none; }
    .cx-toc.as-sheet { display: block; position: fixed; z-index: 1300; top: 96px; right: 8px; left: auto; width: min(320px, calc(100vw - 16px)); max-height: 70vh; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
    .cx-toc-btn { display: inline-flex; }
    .cx-toc .cx-roll, .cx-rail-right { display: none !important; }
    .cx-page.cx-toc-min > .cx-toc.as-sheet { display: block; }
}
@media (max-width: 820px) {
    .cx-treepane { position: absolute; z-index: 1200; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); flex: none; transform: translateX(-105%); transition: transform .18s ease-out; box-shadow: 6px 0 24px rgba(0,0,0,.25); border-right: none; }
    .cx-split.drawer-open .cx-treepane { transform: translateX(0); }
    .cx-treepane-head { display: flex; }
    .cx-tree-rollbar, .cx-rail-left { display: none !important; }
    .cx-split.cx-tree-min > .cx-treepane { display: flex; }
    .cx-split.drawer-open .cx-scrim { display: block; position: absolute; inset: 0; z-index: 1100; background: rgba(17,24,39,.45); }
    .cx-page { padding: 8px 8px 60px; }
    .cx-page-title { font-size: 21px; }
    .cx-page-body { padding: 10px 10px; }
    .cx-body { padding: 8px; }
    .cx-overlay { padding-top: 3vh; }
}
@media (min-width: 821px) {
    #btnPages { display: none; }
}
@media print {
    .cx-treepane, .cx-toc, .cx-page-tools, .cx-menu, .cx-overlay, .cx-rail { display: none !important; }
}
@media (pointer: coarse) {
    .cx-btn.small, button.cx-status, a.cx-chip, button.cx-chip, .cx-crumb { min-height: 40px; }
    a.cx-chip, .cx-crumb { display: inline-flex; align-items: center; }
}
