/* CBook reader: /cbook/. Scoped under .cb so the shared site stylesheet stays untouched. */
.cb {
  --cb-green:#096b68; --cb-pine:#163d3a; --cb-ink:#192623; --cb-muted:#4e5c57; --cb-cream:#fffbde;
  --cb-ground:#f6f6f1; --cb-paper:#fdfdf9; --cb-line:#d9ddd5; --cb-soft:#e4eee8;
  /* View heat scale: 5 steps from pale cream to the Lazi green. */
  --cb-heat-1:#f1efd2; --cb-heat-2:#d3e6c5; --cb-heat-3:#94c7ad; --cb-heat-4:#3f978a; --cb-heat-5:#096b68;
  --cb-head:'Inter',Arial,sans-serif; --cb-body:'Roboto',Arial,sans-serif;
  display:block; background:var(--cb-ground); color:var(--cb-ink); font:400 16px/1.65 var(--cb-body); padding:28px 0 56px;
}
.cb a { color:var(--cb-green); }
.cb h1,.cb h2,.cb h3 { font-family:var(--cb-head); color:var(--cb-ink); }
.cb .cb-wrap { width:calc(100% - 64px); }
.cb img { object-fit:contain; }
.cb :focus-visible { outline:3px solid var(--cb-green); outline-offset:3px; }
.cb-body dialog :focus-visible { outline:3px solid var(--cb-green); outline-offset:3px; }

/* Buttons */
.cb-button { display:inline-flex; align-items:center; justify-content:center; gap:10px; min-height:46px; padding:9px 18px; border:1px solid var(--cb-green); border-radius:4px; background:#fff; color:var(--cb-green)!important; font:600 15px/1.2 var(--cb-head); cursor:pointer; }
.cb-button:hover { background:var(--cb-cream); }
.cb-button--primary { background:var(--cb-green); color:#fff!important; }
.cb-button--primary:hover { background:var(--cb-pine); }
.cb-button[disabled] { opacity:.6; cursor:progress; }
.cb-icon-button { display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; flex:0 0 44px; border:0; border-radius:50%; background:transparent; color:var(--cb-green); font-size:24px; line-height:1; cursor:pointer; }
.cb-icon-button:hover { background:var(--cb-cream); }
.cb-link-button { border:0; background:none; padding:0; color:var(--cb-green); font:inherit; text-decoration:underline; cursor:pointer; }

/* Cover */
.cb-cover { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.05fr); align-items:center; gap:clamp(24px,4vw,56px); background:var(--cb-paper); border:1px solid var(--cb-line); padding:clamp(22px,4.5vw,56px); }
.cb-kicker { color:var(--cb-green); font:700 12px/1.5 var(--cb-head); letter-spacing:.1em; text-transform:uppercase; margin-bottom:10px!important; }
.cb-cover-title { font-size:clamp(2.3rem,5.2vw,4.4rem)!important; font-weight:800; line-height:1.03; letter-spacing:-.045em; }
.cb-byline { margin-top:16px!important; color:var(--cb-pine); font-size:clamp(1rem,2vw,1.15rem); }
.cb-cover-intro { margin-top:12px!important; color:var(--cb-muted); max-width:40ch; }
.cb-cover-actions { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-top:22px; }
.cb-cover-stats { display:flex; flex-wrap:wrap; gap:8px; margin-top:20px!important; color:var(--cb-muted); font-size:14px; }
.cb-cover-stats span { padding:2px 10px; border:1px solid var(--cb-line); border-radius:100px; background:#fff; }
.cb-cover-art { margin:0; background:var(--cb-cream); border-left:6px solid var(--cb-green); border-radius:3px 6px 6px 3px; box-shadow:7px 11px 0 -3px #e1e5d9; overflow:hidden; }
.cb-cover-art img { width:100%; height:auto; }
.cb-cover-index, .cb-popular { margin-top:30px; }
.cb-cover-index h2, .cb-popular h2 { font-size:clamp(1.35rem,3vw,1.9rem); letter-spacing:-.03em; margin-bottom:14px!important; }
.cb-part-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; list-style:none; margin:0; padding:0; }
.cb-part-grid a, .cb-popular-list a { display:flex; flex-direction:column; gap:4px; height:100%; padding:13px 15px; border:1px solid var(--cb-line); background:#fff; color:var(--cb-ink); font-weight:600; line-height:1.35; }
.cb-part-grid a:hover, .cb-popular-list a:hover { border-color:var(--cb-green); }
.cb-part-grid .cb-code, .cb-popular-list .cb-code { color:var(--cb-green); font-size:12px; font-weight:600; }
.cb-popular-list { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; list-style:none; margin:0; padding:0; counter-reset:pop; }
.cb-popular-list small { color:var(--cb-muted); font-weight:400; }

/* Reader */
.cb-reader { display:grid; grid-template-columns:minmax(230px,27%) minmax(0,1fr); background:#fff; border:1px solid var(--cb-line); box-shadow:0 14px 28px #172c2109; }
.cb-sidebar { background:#faf9ef; border-right:1px solid var(--cb-line); min-width:0; }
.cb-sidebar-inner { position:sticky; top:0; max-height:100vh; max-height:100dvh; overflow-y:auto; padding:18px 12px 24px; }
.cb-sidebar-title { font:700 16px/1.3 var(--cb-head); margin:0 8px 10px!important; }
.cb-sidebar-title a { color:var(--cb-ink); }
.cb-toc ol { list-style:none; margin:0; padding:0; }
.cb-toc a { position:relative; display:block; padding:6px 8px 6px 14px; border-radius:3px; color:var(--cb-ink); font-size:14px; line-height:1.38; }
.cb-toc a:hover { background:var(--cb-cream); }
.cb-toc .cb-toc-chapter { margin-top:10px; }
.cb-toc .cb-toc-chapter > a { font:700 14px/1.35 var(--cb-head); color:var(--cb-pine); }
.cb-toc .cb-toc-part > a { font-weight:600; }
.cb-toc .cb-toc-part ol { margin-left:10px; }
.cb-toc .cb-toc-src > a { color:var(--cb-muted); font-style:italic; }
.cb-toc a[aria-current="page"] { background:var(--cb-green); color:#fff; font-weight:700; }
.cb-toc a[aria-current="true"] { background:var(--cb-soft); }
.cb-code { display:inline-block; margin-right:6px; color:var(--cb-green); font:600 .8em/1 var(--cb-head); letter-spacing:.02em; }
.cb-toc a[aria-current="page"] .cb-code { color:#fff; }
.cb-toc--full a { font-size:15px; padding-block:7px; }
/* Heat marker: a bar on the left edge of each TOC entry. */
.cb-toc a[data-heat]::before { content:""; position:absolute; left:3px; top:7px; bottom:7px; width:5px; border-radius:3px; background:var(--cb-heat-1); }
.cb-toc a[data-heat="2"]::before, .cb-heat-legend i[data-heat="2"] { background:var(--cb-heat-2); }
.cb-toc a[data-heat="3"]::before, .cb-heat-legend i[data-heat="3"] { background:var(--cb-heat-3); }
.cb-toc a[data-heat="4"]::before, .cb-heat-legend i[data-heat="4"] { background:var(--cb-heat-4); }
.cb-toc a[data-heat="5"]::before, .cb-heat-legend i[data-heat="5"] { background:var(--cb-heat-5); }
.cb-heat-legend { display:flex; align-items:center; gap:4px; margin:0 8px 8px; color:var(--cb-muted); font-size:12px; }
.cb-heat-legend i { width:18px; height:8px; border-radius:2px; background:var(--cb-heat-1); }
.cb-heat-legend span:first-child { margin-right:4px; }
.cb-heat-legend span:last-child { margin-left:4px; }
.cb-text > .cb-heat-legend { margin:0 0 12px; }

.cb-reading { min-width:0; }
.cb-toolbar { display:flex; align-items:center; gap:14px; padding:4px clamp(14px,4vw,36px); border-bottom:1px solid var(--cb-line); }
.cb-toolbar-link { display:inline-flex; align-items:center; min-height:44px; font-weight:600; font-size:15px; }
.cb-toolbar-space { flex:1; }
.cb-pages { min-height:420px; }
.cb-page { max-width:800px; margin:0 auto; padding:clamp(20px,4vw,46px) clamp(16px,4vw,46px) 30px; }
.cb-page + .cb-page { border-top:1px solid var(--cb-line); }
.cb-js .cb-page + .cb-page { border-top:0; }
.cb-page-head { margin-bottom:22px; }
.cb-page-title { font-size:clamp(1.75rem,3.8vw,2.75rem)!important; font-weight:800; line-height:1.12; letter-spacing:-.035em; }
.cb-page-title .cb-code { display:block; margin:0 0 8px; font-size:14px; letter-spacing:.06em; }
.cb-page-views { margin-top:10px!important; color:var(--cb-muted); font-size:13px; display:flex; align-items:center; gap:7px; }
.cb-page-views i { width:10px; height:10px; border-radius:50%; background:var(--cb-heat-1); }
.cb-page-views i[data-heat="2"] { background:var(--cb-heat-2); } .cb-page-views i[data-heat="3"] { background:var(--cb-heat-3); }
.cb-page-views i[data-heat="4"] { background:var(--cb-heat-4); } .cb-page-views i[data-heat="5"] { background:var(--cb-heat-5); }
.cb-text { font-size:17px; line-height:1.75; }
.cb-text p { margin:0 0 1em; }
.cb-text h3 { font-size:clamp(1.2rem,2.4vw,1.5rem); line-height:1.3; color:var(--cb-pine); margin:1.6em 0 .55em; scroll-margin-top:16px; }
.cb-text h3 .cb-subcode { color:var(--cb-green); font-size:.65em; font-weight:600; vertical-align:2px; }
.cb-text ul, .cb-text ol { margin:.5em 0 1.2em; padding-left:1.35em; }
.cb-text li { margin:.35em 0; }
.cb-text hr { border:0; border-top:1px solid var(--cb-line); margin:1.6em 0; }
.cb-text .ref, .cb-text .cb-cite { font-size:.78em; color:var(--cb-green); white-space:normal; }
.cb-text a.ref { text-decoration:underline dotted; text-underline-offset:3px; }
.cb-text .cb-cite { color:var(--cb-muted); }
.cb-text a:not(.ref) { text-decoration:underline; text-underline-offset:3px; }
/* Keywords: bold links. Solid underline = Lazi article, dotted = citation popup / Google. */
.cb-text a.cb-kw { font-weight:700; color:var(--cb-green); text-decoration:underline dotted; text-decoration-thickness:1.5px; text-underline-offset:3px; }
.cb-text a.cb-kw--lazi { text-decoration-style:solid; }
.cb-text a.cb-kw:hover { color:var(--cb-pine); background:var(--cb-cream); }
.cb-kw-cite { display:inline-flex; align-items:center; justify-content:center; width:17px; height:17px; margin:0 1px 0 3px; vertical-align:2px; border:1px solid var(--cb-green); border-radius:50%; background:#fff; color:var(--cb-green); font:700 11px/1 var(--cb-head); cursor:pointer; padding:0; }
.cb-kw-cite:hover { background:var(--cb-green); color:#fff; }
.cb-kw-label { font:700 12px/1.4 'Inter',Arial,sans-serif; letter-spacing:.06em; text-transform:uppercase; color:#4e5c57; margin:4px 0 6px!important; }
.cb-kw-sources { margin:0 0 14px; padding-left:18px; font-size:14.5px; line-height:1.55; }
.cb-kw-sources li { margin:6px 0; overflow-wrap:anywhere; }
.cb-kw-sources a { color:#096b68; text-decoration:underline; }
.cb-kw-actions { display:flex; flex-wrap:wrap; gap:10px; }
.cb-kw-note { color:#4e5c57; font-size:13px; margin-top:12px!important; }
.cb-dialog--kw .cb-button { text-decoration:none; }
.cb-signature { text-align:right; font-weight:700; font-family:var(--cb-head); }
.cb-sources li { overflow-wrap:anywhere; font-size:15px; line-height:1.6; }
.cb-part-list { list-style:none; padding:0!important; border-top:1px solid var(--cb-line); }
.cb-part-list li { margin:0!important; border-bottom:1px solid var(--cb-line); }
.cb-part-list a { display:block; padding:11px 2px; color:var(--cb-ink); font-weight:600; text-decoration:none!important; }
.cb-part-list a:hover { color:var(--cb-green); }
.cb-table { margin:1.1em 0 1.4em; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.cb-table table { width:100%; border-collapse:collapse; font-size:15px; line-height:1.5; }
.cb-table thead { background:#e9f1ec; color:var(--cb-pine); }
.cb-table th, .cb-table td { border:1px solid var(--cb-line); padding:.55em .7em; text-align:left; vertical-align:top; }
.cb-table tbody th { font-weight:600; }
.cb-mark { background:#ffe98a; color:inherit; border-radius:2px; padding:0 1px; }

.cb-pager { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:10px; padding:10px clamp(14px,4vw,36px); border-top:1px solid var(--cb-line); background:#fafaf5; }
.cb-pager a { display:flex; flex-direction:column; min-height:48px; justify-content:center; color:var(--cb-ink); font-weight:600; line-height:1.3; font-size:14px; }
.cb-pager a small { color:var(--cb-green); font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
.cb-pager a[aria-disabled="true"] { visibility:hidden; }
.cb-pager .cb-next { text-align:right; align-items:flex-end; }
.cb-position { color:var(--cb-muted); font-size:13px; white-space:nowrap; }

/* Comments */
.cb-comments { max-width:800px; margin:0 auto; padding:28px clamp(16px,4vw,46px) 40px; border-top:1px solid var(--cb-line); }
.cb-comments-title { font-size:1.4rem!important; letter-spacing:-.02em; }
.cb-comments-title span { color:var(--cb-muted); font-weight:500; }
.cb-comments-note { color:var(--cb-muted); font-size:15px; margin:6px 0 18px!important; }
.cb-comment-list, .cb-comment-list ol { list-style:none; margin:0; padding:0; }
.cb-comment { padding:14px 0; border-top:1px solid var(--cb-line); }
.cb-comment-list > .cb-comment:first-child { border-top:0; }
.cb-comment ol { margin:10px 0 0 22px!important; border-left:3px solid var(--cb-soft); padding-left:14px!important; }
.cb-comment ol .cb-comment { border-top:0; padding:8px 0; }
.cb-comment-head { display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 10px; }
.cb-comment-name { font:700 15px/1.3 var(--cb-head); }
.cb-comment-date { color:var(--cb-muted); font-size:13px; }
.cb-comment-body { margin:6px 0!important; white-space:pre-line; overflow-wrap:anywhere; font-size:15.5px; }
.cb-comment-url { font-size:13.5px; overflow-wrap:anywhere; margin-bottom:4px!important; }
.cb-comment-url a { text-decoration:underline; }
.cb-comment-actions .cb-link-button { font-size:14px; }
.cb-comments-empty { color:var(--cb-muted); font-style:italic; }
.cb-comment-form { margin-top:22px; padding:18px; background:#fafaf5; border:1px solid var(--cb-line); }
.cb-form-title { font-size:1.1rem!important; margin-bottom:10px!important; }
.cb-replying { background:var(--cb-cream); padding:8px 10px; margin-bottom:10px!important; font-size:14px; }
.cb-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.cb-comment-form label { display:flex; flex-direction:column; gap:4px; font-size:14px; font-weight:600; color:var(--cb-pine); }
.cb-comment-form .cb-optional { font-weight:400; color:var(--cb-muted); }
.cb-comment-form input:not([type=checkbox]), .cb-comment-form textarea { width:100%; border:1px solid #b9c3bd; border-radius:4px; padding:10px; background:#fff; color:var(--cb-ink); font:400 16px/1.4 var(--cb-body); }
.cb-comment-form textarea { resize:vertical; min-height:110px; }
.cb-comment-form input:focus, .cb-comment-form textarea:focus { border-color:var(--cb-green); outline:2px solid var(--cb-soft); }
.cb-form-wide { margin-top:12px; }
.cb-privacy { font-size:13px; color:var(--cb-muted); margin:10px 0!important; }
.cb-comment-form .form-consent { flex-direction:row; align-items:flex-start; gap:8px; font-weight:400; color:var(--cb-ink); }
.cb-comment-form .form-consent input { margin-top:4px; width:18px; height:18px; flex:0 0 18px; }
.cb-form-bottom { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-top:14px; }
.cb-form-bottom label { flex-direction:row!important; align-items:center; gap:8px!important; }
.cb-form-bottom input { width:64px!important; }
.cb-form-status { margin-top:10px!important; font-size:14px; min-height:1em; }
.cb-form-status[data-tone="error"] { color:#a12a1b; }
.cb-form-status[data-tone="ok"] { color:var(--cb-green); }
.cb-edition { margin-top:14px!important; color:var(--cb-muted); font-size:13px; text-align:right; }

/* Floating TOC button: one-column layouts only. */
.cb-fab { display:none; }
.cb-fab-icon { width:15px; height:11px; border-block:2px solid currentColor; position:relative; }
.cb-fab-icon::before { content:""; position:absolute; left:0; right:0; top:2.5px; border-top:2px solid currentColor; }

/* Dialogs */
.cb-dialog { width:min(620px,calc(100% - 24px)); max-height:86vh; max-height:86dvh; padding:clamp(14px,4vw,26px); border:1px solid var(--cb-line); border-radius:8px; color:var(--cb-ink); background:#fff; font:400 16px/1.55 'Roboto',Arial,sans-serif; }
.cb-dialog::backdrop { background:#102c28a9; }
.cb-dialog-head { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:10px; }
.cb-dialog-head h2 { font:700 1.25rem/1.2 'Inter',Arial,sans-serif; margin:0; }
.cb-dialog .cb-icon-button { color:#096b68; }
.cb-dialog--toc { margin:auto auto max(12px, env(safe-area-inset-bottom)); }
.cb-dialog[open] { display:flex; flex-direction:column; }
.cb-dialog--toc .cb-toc, .cb-dialog--search .cb-results-wrap { min-height:0; overflow-y:auto; overscroll-behavior:contain; }
.cb-dialog--search { overflow-y:auto; }
.cb-page-title:focus { outline:none; }
.cb-dialog .cb-heat-legend { margin:0 0 8px; }
.cb-search-form { display:flex; gap:8px; }
.cb-search-form input { flex:1; min-width:0; border:1px solid #096b68; border-radius:4px; padding:10px; font-size:16px; }
.cb-search-hint { color:#4e5c57; font-size:14px; margin:10px 0 6px!important; }
.cb-results { list-style:none; margin:0; padding:0; }
.cb-results li { border-bottom:1px solid #d9ddd5; }
.cb-results a { display:block; padding:10px 4px; color:#192623; }
.cb-results a:hover { background:#f6f6f1; }
.cb-results strong { display:block; color:#096b68; font:600 15px/1.35 'Inter',Arial,sans-serif; }
.cb-results small { display:block; color:#4e5c57; font-size:13px; }
.cb-results p { font-size:14px; line-height:1.5; margin-top:3px!important; color:#33403c; }
.cb-results mark { background:#fff1a8; color:inherit; }
.cb-results-more { margin-top:14px; font-size:14px; }
.cb-results-more h3 { font:700 13px/1.3 'Inter',Arial,sans-serif; text-transform:uppercase; letter-spacing:.06em; color:#4e5c57; margin:12px 0 4px; }
.cb-results-more a { color:#096b68; text-decoration:underline; }
.cb-results-more ul { margin:0; padding-left:18px; }

@media (max-width:980px) {
  .cb-part-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .cb-popular-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .cb-reader { grid-template-columns:minmax(0,1fr); }
  .cb-sidebar, .cb-toolbar-toc { display:none; }
  .cb-fab { display:inline-flex; position:fixed; z-index:20; right:max(14px, env(safe-area-inset-right)); bottom:max(14px, env(safe-area-inset-bottom)); align-items:center; gap:9px; min-height:48px; padding:0 18px; border:0; border-radius:100px; background:var(--cb-green); color:#fff; font:600 15px/1 var(--cb-head); box-shadow:0 4px 16px #193a3552; cursor:pointer; }
  .cb-reader[hidden] + .cb-fab, .cb-fab[hidden] { display:none; }
  .cb-comments { padding-bottom:80px; }
}
@media (max-width:767px) {
  .cb { padding:14px 0 40px; }
  .cb .cb-wrap { width:calc(100% - 24px); }
  .cb-cover { grid-template-columns:1fr; padding:20px 16px; gap:20px; }
  .cb-cover-art { order:-1; }
  .cb-cover-title { font-size:clamp(2.1rem,10vw,3rem)!important; }
  .cb-part-grid, .cb-popular-list { grid-template-columns:1fr; }
  .cb-page { padding:20px 16px 24px; }
  .cb-text { font-size:16.5px; line-height:1.72; }
  .cb-table table { min-width:520px; font-size:14px; }
  .cb-form-grid { grid-template-columns:1fr; }
  .cb-comment-form { padding:14px; }
  .cb-pager a span { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; font-size:13px; }
  .cb-edition { text-align:left; }
}
@media print {
  .cb-sidebar, .cb-toolbar, .cb-pager, .cb-comments, .cb-fab, #bia { display:none!important; }
  .cb-reader { display:block; border:0; box-shadow:none; }
  .cb-page[hidden] { display:block!important; }
}
