/* Document view (package D). Prefix doc-. Responsive by container width of .doc-view. */
.doc-view { container-type: inline-size; container-name: doc; flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.doc-view kbd { font: 500 10px var(--font-mono); padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted-fg); background: var(--muted); }
.doc-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--border); flex-shrink: 0; min-width: 0; }
.doc-bar-t { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-bar-t strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-bar-m { font-size: 11.5px; color: var(--muted-fg); white-space: nowrap; }
.doc-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--card); }
.doc-seg button { white-space: nowrap; border: 0; background: transparent; padding: 4px 10px; font-size: 11.5px; border-right: 1px solid var(--border); }
.doc-seg button:last-child { border-right: 0; }
.doc-seg button.on { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.doc-seg button:hover:not(.on) { background: var(--muted); }
.doc-grid { flex: 1; min-height: 0; display: flex; position: relative; }

/* outline */
.doc-outline { width: 252px; flex-shrink: 0; background: var(--card); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.doc-ol-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.doc-ol-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.doc-count { font-size: 11px; color: var(--muted-fg); }
.doc-drawer-x { display: none; }
.doc-heatstrip { display: flex; gap: 1px; height: 7px; }
.doc-heatstrip i { flex: 1; background: var(--border); border-radius: 1px; }
.doc-heatstrip i.ok, .doc-heat.ok { background: var(--ok); opacity: .55; }
.doc-heatstrip i.warn, .doc-heat.warn { background: var(--warn); }
.doc-heatstrip i.bad, .doc-heat.bad { background: var(--bad); }
.doc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-chip-f { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--muted-fg); }
.doc-chip-f:hover { border-color: var(--border-strong); }
.doc-chip-f.on { background: var(--primary-50); border-color: var(--primary-300); color: var(--primary-700); font-weight: 600; }
.doc-tagsel { font-size: 11.5px; padding: 4px 8px; }
.doc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; display: inline-block; }
.doc-dot.st-edited { background: var(--st-edited); } .doc-dot.st-pending { background: var(--st-pending); }
.doc-dot.st-flagged, .doc-dot.st-conflict { background: var(--st-flagged); } .doc-dot.st-comment { background: var(--st-comment); }
.doc-ol-scroll { flex: 1; overflow-y: auto; overflow-anchor: none; position: relative; }
.doc-ol-row { height: 30px; display: flex; align-items: center; padding-inline-start: calc(4px + var(--d, 0) * 12px); padding-inline-end: 8px; gap: 2px; border-inline-start: 3px solid transparent; }
.doc-ol-row:hover { background: var(--muted); }
.doc-ol-row.cur { background: var(--secondary-50); }
.doc-ol-row.sel { background: var(--primary-50); border-inline-start-color: var(--primary); }
.doc-ol-tw { width: 18px; height: 22px; border: 0; background: transparent; display: grid; place-items: center; color: var(--faint); flex-shrink: 0; }
.doc-ol-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; border: 0; background: transparent; text-align: start; font-size: 12px; height: 28px; }
.doc-ol-n { font-family: var(--font-mono); font-size: 11px; color: var(--muted-fg); flex-shrink: 0; }
.doc-ol-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-ol-row.lv1 .doc-ol-t { font-weight: 600; }
.doc-heat { width: 4px; height: 16px; border-radius: 2px; flex-shrink: 0; background: transparent; }
.doc-ol-empty { padding: 24px 12px; }
.doc-view.is-ar .doc-ol-scroll { direction: rtl; }

/* centre pane */
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.doc-crumb { height: 34px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--card); border-bottom: 1px solid var(--border); overflow: hidden; }
.doc-crumb-in { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; overflow: hidden; }
.doc-crumb-i { border: 0; background: transparent; font-size: 12px; color: var(--muted-fg); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; padding: 2px 4px; border-radius: 6px; }
.doc-crumb-i:hover { background: var(--muted); }
.doc-crumb-i.last { color: var(--fg); font-weight: 500; }
.doc-crumb-i b { font-family: var(--font-mono); font-weight: 500; }
.doc-crumb-sep { color: var(--faint); display: inline-flex; }
.doc-filt-note { border: 1px solid var(--primary-100); background: var(--primary-50); color: var(--primary-700); border-radius: 999px; font-size: 11px; padding: 2px 10px; white-space: nowrap; }
.doc-pane { flex: 1; min-height: 0; display: flex; position: relative; }
.doc-scroll { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; overflow-anchor: none; outline: none; }
.doc-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--primary-100); border-radius: 0; }
.doc-sec { padding: 14px 22px 16px; border-bottom: 1px solid var(--border); border-inline-start: 3px solid transparent; background: transparent; overflow-wrap: anywhere; }
.doc-sec:hover { background: color-mix(in srgb, var(--card) 70%, transparent); }
.doc-sec.sel { background: var(--card); box-shadow: inset 0 0 0 1px var(--primary-100); }
.doc-sec.st-edited { border-inline-start-color: var(--st-edited); } .doc-sec.st-pending { border-inline-start-color: var(--st-pending); }
.doc-sec.st-flagged, .doc-sec.st-conflict { border-inline-start-color: var(--st-flagged); } .doc-sec.st-comment { border-inline-start-color: var(--st-comment); }
.doc-sec.lv1 { padding-top: 24px; background: var(--muted); }
.doc-sec.lv1.sel { background: var(--card); }
.doc-sec.lv1 .doc-t { font-size: 17px; font-weight: 600; }
.doc-sec.lv3 { padding-inline-start: 38px; }
.doc-sec.ctx { padding-bottom: 10px; opacity: .8; }
.doc-sec-h { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.doc-n { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--primary); background: var(--primary-50); padding: 1px 7px; border-radius: 6px; }
.doc-t { font-size: 14px; font-weight: 600; line-height: 1.3; }
.doc-tag { font-size: 10.5px; color: var(--muted-fg); background: var(--muted); border: 1px solid var(--border); padding: 0 7px; border-radius: 999px; }
.doc-st { font-size: 10.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--muted); color: var(--muted-fg); }
.doc-st.st-edited { background: var(--st-edited-bg); color: var(--st-edited); } .doc-st.st-pending { background: var(--st-pending-bg); color: var(--st-pending); }
.doc-st.st-flagged, .doc-st.st-conflict { background: var(--st-flagged-bg); color: var(--st-flagged); } .doc-st.st-comment { background: var(--st-comment-bg); color: var(--st-comment); }
.doc-body { font-size: 14px; line-height: 23px; max-width: 80ch; white-space: normal; }
.doc-body.ar, .doc-edit.ar { font-family: var(--font-ar); font-size: 15.5px; line-height: 28px; }
.doc-empty-body { color: var(--faint); font-style: italic; }
.doc-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.doc-cols > .doc-body.ar, .doc-cols > .doc-missing { padding-inline-start: 20px; border-inline-start: 1px solid var(--border); }
.doc-missing { display: flex; align-items: center; padding: 2px 0; }
.doc-miss-link { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--faint); font-size: 12px; padding: 2px 4px; border-radius: 6px; opacity: .55; }
.doc-miss-link:hover, .doc-miss-link:focus-visible { opacity: 1; color: var(--primary); background: var(--primary-50); }
.doc-xref { border: 0; background: transparent; padding: 0; font: inherit; color: var(--secondary); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.doc-xref:hover { color: var(--primary); }
.doc-xref.bad { color: var(--bad); text-decoration: underline wavy; cursor: help; }
.doc-body .term, .doc-body [data-term], .doc-body .def-term, .doc-body .pf-term { border-bottom: 1px dotted var(--primary-300); cursor: help; }
.doc-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.doc-edit { width: 100%; border: 1px solid var(--primary-300); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; line-height: 23px; background: var(--card); resize: vertical; min-height: 110px; }
.doc-edit-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.doc-hint { font-size: 11.5px; color: var(--muted-fg); }
.doc-mini { width: 20px; flex-shrink: 0; background: var(--card); border-inline-start: 1px solid var(--border); position: relative; cursor: pointer; touch-action: none; }
.doc-mini canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.doc-mini-vp { position: absolute; left: 0; right: 0; top: 0; height: 20px; border: 1.5px solid var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); border-radius: 3px; pointer-events: none; }

/* side panel */
.doc-side { width: 336px; flex-shrink: 0; background: var(--card); border-inline-start: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.doc-side-h { display: flex; align-items: center; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); }
.doc-tab { border: 0; background: transparent; padding: 8px 12px; font-size: 12.5px; color: var(--muted-fg); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.doc-tab.on { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.doc-side-b { flex: 1; overflow-y: auto; padding: 12px; }
.doc-side-empty { padding: 24px 8px; font-size: 12.5px; } .doc-kpis { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.doc-cl-h { display: flex; align-items: baseline; gap: 8px; } .doc-cl-h h4 { font-size: 14px; }
.doc-cl-meta, .doc-cl-acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.doc-cl h5 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-fg); margin: 16px 0 6px; }
.doc-ref { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: start; border: 1px solid var(--border); background: var(--card); border-radius: var(--radius-sm); padding: 5px 8px; margin-bottom: 4px; font-size: 12px; }
.doc-ref:hover { background: var(--muted); } .doc-ref b { font-family: var(--font-mono); color: var(--primary); flex-shrink: 0; }
.doc-ref span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .doc-ref em { font-size: 10.5px; color: var(--faint); font-style: normal; }
.doc-ref.bad { border-color: hsl(0 60% 85%); background: var(--bad-bg); } .doc-ref.bad b, .doc-ref.bad span { color: var(--bad); }
.doc-none { font-size: 12px; color: var(--faint); }
.doc-hist { list-style: none; border-inline-start: 2px solid var(--border); padding-inline-start: 10px; font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.doc-hist span { display: block; font-size: 10.5px; color: var(--muted-fg); }
.doc-cform textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px; }
.doc-lib-i { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-top: 8px; font-size: 12px; } .doc-lib-i.hit { border-color: var(--primary-100); background: var(--primary-50); }
.doc-lib-h { display: flex; gap: 6px; align-items: center; justify-content: space-between; } .doc-lib-m { color: var(--muted-fg); font-size: 11px; margin: 2px 0 6px; } .doc-lib-a { display: flex; gap: 6px; margin-top: 8px; }

/* search */
.doc-search-back { position: absolute; inset: 0; background: hsl(0 0% 9% / .28); z-index: 20; }
.doc-search { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); width: min(700px, calc(100% - 24px)); max-height: calc(100% - 72px); z-index: 21; background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.doc-s-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.doc-s-bar input { flex: 1; border: 0; outline: none; font-size: 15px; background: transparent; min-width: 0; }
.doc-s-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); } .doc-s-filters select { padding: 4px 8px; font-size: 12px; }
.doc-s-res { overflow-y: auto; padding: 6px; flex: 1; }
.doc-s-r { display: block; width: 100%; text-align: start; border: 0; background: transparent; padding: 8px 10px; border-radius: var(--radius-sm); }
.doc-s-r:hover, .doc-s-r.on { background: var(--primary-50); }
.doc-s-t { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; } .doc-s-t b { font-family: var(--font-mono); color: var(--primary); }
.doc-s-sn { display: block; font-size: 12px; color: var(--muted-fg); margin-top: 2px; }
.doc-search mark { background: var(--warn-bg); color: inherit; border-radius: 3px; padding: 0 1px; }
.doc-s-hint { padding: 18px; text-align: center; } .doc-s-foot { padding: 6px 14px; font-size: 11px; color: var(--muted-fg); border-top: 1px solid var(--border); }
.doc-scrim { display: none; }

/* responsive: by container width of the view (the right rail eats space at 1280) */
@container doc (max-width: 1099px) {
  .doc-side { display: none; position: absolute; top: 0; bottom: 0; right: 0; z-index: 12; box-shadow: var(--shadow-lg); width: min(340px, 92%); }
  .doc-view[data-side="open"] .doc-side { display: flex; }
  .doc-view[data-side="open"] .doc-scrim { display: block; position: absolute; inset: 0; z-index: 11; background: hsl(0 0% 9% / .2); }
  .doc-outline { width: 224px; }
}
@container doc (max-width: 699px) {
  .doc-outline { display: none; position: absolute; top: 0; bottom: 0; left: 0; z-index: 12; width: min(300px, 88%); box-shadow: var(--shadow-lg); }
  .doc-view[data-ol="open"] .doc-outline { display: flex; }
  .doc-view[data-ol="open"] .doc-scrim { display: block; position: absolute; inset: 0; z-index: 11; background: hsl(0 0% 9% / .2); }
  .doc-drawer-x { display: inline-flex; }
  .doc-bar-m, .doc-bar .btn span, .doc-bar kbd, .doc-bar-t strong { display: none; }
  .doc-bar { gap: 6px; padding: 8px; } .doc-seg button { padding: 4px 7px; }
  .doc-sec { padding: 12px 14px 14px; } .doc-sec.lv3 { padding-inline-start: 22px; }
  .doc-cols { grid-template-columns: minmax(0, 1fr); gap: 10px; } .doc-cols > .doc-body.ar, .doc-cols > .doc-missing { padding-inline-start: 0; border-inline-start: 0; }
  .doc-side { width: 100%; top: auto; height: 62%; border-top: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}
@container doc (min-width: 1100px) {
  .doc-view[data-side="closed"] .doc-side { display: none; }
  .doc-ol-btn { display: none; }
}
@container doc (min-width: 700px) { .doc-view[data-ol="closed"] .doc-outline { display: none; } }
@media (max-width: 820px) { .view-document .doc-view { height: 84vh; min-height: 520px; flex: none; } }
@media (prefers-reduced-motion: no-preference) { .doc-sec, .doc-ol-row { transition: background .12s; } }
.doc-tools { display: inline-flex; gap: 4px; padding-right: 8px; margin-right: 4px; border-right: 1px solid var(--border); }
.doc-view { container-type: inline-size; }
[data-act=docSearchOpen] span, [data-act=docSearchOpen] kbd { display: none; }
@container (min-width: 1040px) { [data-act=docSearchOpen] span, [data-act=docSearchOpen] kbd { display: inline; } }
@container (max-width: 700px) { .doc-tools .btn span { display: none; } }
@container (max-width: 1100px) { .doc-bar-m { display: none; } }
