* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1d2330; background: #f4f6fa;
}
#app { display: flex; height: 100vh; overflow: hidden; }
#app.side-collapsed #sidebar { display: none; }

/* sidebar (now holds metadata too) */
#sidebar { flex: 0 0 380px; background: #1f2733; color: #e7ecf3; display: flex; flex-direction: column; min-width: 0; }
.sidebar-header { padding: 12px 14px; border-bottom: 1px solid #313c4c; display: flex; align-items: center; justify-content: space-between; }
.sidebar-header h1 { font-size: 15px; margin: 0; }
.icon-btn, .open-side { background: #2b3543; color: #cdd7e6; border: 1px solid #3a4658; border-radius: 6px; cursor: pointer; padding: 3px 9px; font-size: 14px; }
.icon-btn:hover { background: #38465a; }
.open-side { position: fixed; top: 14px; left: 12px; z-index: 30; background: #1f2733; color: #fff; }
#app.side-collapsed .tree-toolbar { padding-left: 46px; }

/* page nav (RST tree <-> document tree) */
.side-nav { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid #313c4c; }
.side-nav a { flex: 1; text-align: center; text-decoration: none; font-size: 12px; font-weight: 600;
  color: #aab6c8; background: #283340; border: 1px solid #34404f; border-radius: 6px; padding: 5px 8px; }
.side-nav a:hover { background: #313c4c; color: #dde5f0; }
.side-nav a.active { background: #2f6fed; color: #fff; border-color: #2f6fed; }

.side-scroll { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 12px; }
.side-block { background: #283340; border: 1px solid #34404f; border-radius: 8px; padding: 10px; }
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #93a1b5; margin-bottom: 6px; }
.side-title.collapsible { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.side-title.collapsible:hover { color: #c6d0de; }
.side-title .caret { display: inline-block; transition: transform .15s; font-size: 10px; }
.side-title.collapsed .caret { transform: rotate(-90deg); }

#case-list { list-style: none; margin: 0; padding: 0; }
#case-list li { padding: 7px 9px; border-radius: 6px; cursor: pointer; margin-bottom: 3px; display: flex; flex-direction: column; gap: 2px; }
#case-list li:hover { background: #313c4c; }
#case-list li.active { background: #2f6fed; }
.cl-id { font-weight: 600; font-size: 13px; }
.cl-out { font-size: 11px; color: #aebacb; }
#case-list li.active .cl-out { color: #e4ecfa; }
.cl-out.ok { color: #84e3a4; } .cl-out.fail { color: #f3a6a6; }
#case-list li.active .cl-out.ok, #case-list li.active .cl-out.fail { color: #fff; }

/* case header block in sidebar */
.ch-title { font-size: 17px; font-weight: 700; }
.ch-badge { font-size: 12px; color: #aebacb; margin-top: 2px; }
.ch-outcome { margin-top: 6px; font-weight: 600; color: #ffd98a; }
.ch-parties { margin-top: 6px; font-size: 12px; color: #c6d0de; }
.ch-parties .dim { color: #8593a6; }
.ch-pdf { display: inline-block; margin-top: 8px; color: #8ab4ff; text-decoration: none; font-size: 12px; }

/* metadata rows (sidebar, dark) */
.mrow { display: flex; flex-direction: column; padding: 4px 0; border-bottom: 1px solid #313c4c; }
.mk { color: #93a1b5; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.mv { color: #e1e8f1; font-size: 13px; word-break: break-word; }
.mblock { margin-top: 8px; } .mblock > .mk { display: block; margin-bottom: 5px; }
.ref { font-size: 12px; color: #c6d0de; padding: 1px 0; }
.ref.ref-click { cursor: pointer; padding: 3px 6px; border-radius: 5px; }
.ref.ref-click:hover { background: #313c4c; color: #e7eef8; }
.ref.ref-click.active { background: #2f6fed; color: #fff; }
.gt { border-collapse: collapse; width: 100%; font-size: 11px; }
.gt th, .gt td { border: 1px solid #3a4658; padding: 4px 5px; text-align: left; vertical-align: top; color: #dbe3ee; }
.gt th { background: #313c4c; }
.gt td.ok { color: #84e3a4; } .gt td.fail { color: #f3a6a6; }
.gt tr.overall td { background: #313c4c; }

/* main: tree gets a bounded height (not the whole screen) so the full text
   below it stays comfortably visible for tree<->text correspondence */
#main { flex: 1 1 auto; min-width: 0; height: 100vh; overflow: hidden;
        padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: #fff; border: 1px solid #e2e7f0; border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
#tree-section { flex: 0 0 auto; }
#fulltext-section { flex: 1 1 auto; min-height: 180px; }
.panel-head { padding: 8px 12px; font-weight: 600; border-bottom: 1px solid #eef1f7; display: flex; gap: 12px; align-items: baseline; }
.legend-note { font-weight: 400; font-size: 11px; color: #8a93a3; }

/* tree */
.tree-toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #eef1f7; flex-wrap: wrap; }
.toolbar-title { font-weight: 600; }
.toolbar-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.btn { border: 1px solid #cfd6e2; background: #fff; border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12px; }
.btn:hover { background: #eef2fb; }
.zoom-label { font-size: 12px; color: #5b6678; min-width: 38px; text-align: center; }
.sep { width: 1px; height: 18px; background: #dde3ec; }
.legend { display: flex; gap: 6px; font-size: 11px; }
.lg { padding: 1px 7px; border-radius: 9px; }
.lg-seg { background: #eaf2ff; color: #2257c4; }
.lg-multinuc { background: #f3eaff; color: #6a37b5; }
.lg-span { background: #eef1f7; color: #4a5566; }

.tree-wrap { height: 48vh; overflow: auto; cursor: grab;
  background: repeating-linear-gradient(0deg,#fbfcfe,#fbfcfe 1px,transparent 1px,transparent 26px); }
.tree-wrap.grabbing { cursor: grabbing; }
.tree-hint { padding: 5px 12px; font-size: 11px; color: #97a0b0; border-top: 1px solid #eef1f7; }
.rst-tree { display: block; }
.tedge { fill: none; stroke: #b7c0cf; stroke-width: 1.4; }
.tedge.nucleus { stroke: #7f8da0; stroke-width: 2; }
.tedge.multinuc { stroke: #b48bdc; }
.tedge.satellite { stroke-dasharray: 4 3; }
.trel { font-size: 10px; fill: #7a8597; }
.tnode { cursor: pointer; }
.tnode rect { fill: #fff; stroke: #c7cfdc; }
.tnode .tid { font-size: 11px; font-weight: 700; fill: #2a3342; }
.tnode .ttext { font-size: 10px; fill: #5b6678; }
.tnode.segment rect { fill: #eaf2ff; stroke: #9cc0f5; }
.tnode.group.multinuc rect { fill: #f3eaff; stroke: #c4a3e6; }
.tnode.group.collapsed rect { fill: #fff3df; stroke: #e6bd72; }
.tnode.segment.selected rect { fill: #ffe9b8; stroke: #e09b1a; stroke-width: 2; }
.tnode.flash rect { animation: flash .9s ease; }
@keyframes flash { 0%,100% { fill: inherit; } 30% { fill: #ffe07a; } }

/* draggable divider between tree and fulltext */
.divider { flex: 0 0 8px; cursor: row-resize; display: flex; align-items: center;
  justify-content: center; border-radius: 6px; background: #e7ebf2; }
.divider:hover, .divider.dragging { background: #cdd6e6; }
.divider-grip { width: 46px; height: 3px; border-radius: 2px; background: #9aa6ba; }
body.row-resizing { cursor: row-resize; user-select: none; }

/* fulltext (paragraph blocks) — fills the space under the bounded tree */
.fulltext { flex: 1 1 auto; min-height: 0; padding: 8px 12px; overflow-y: auto; }
.par { display: flex; gap: 8px; padding: 4px 10px; }
/* alternate a light background each time the document section changes */
.par.band-0 { background: #fbfcff; }
.par.band-1 { background: #eef3fb; }
.sec-label { padding: 4px 10px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #5b6f93; position: sticky; top: 0; }
.sec-label.band-0 { background: #fbfcff; }
.sec-label.band-1 { background: #eef3fb; }
.par-num { flex: 0 0 34px; color: #98a2b3; font-size: 11px; font-weight: 600; padding-top: 2px; }
.par-body { flex: 1; line-height: 1.7; }
.seg { padding: 0 1px; border-radius: 3px; cursor: pointer; }
.seg:hover { background: #eef2fb; }
.seg.hit { background: #ffe9b8; box-shadow: inset 0 -2px 0 #e09b1a; }

.empty-state { padding: 24px; color: #8a93a3; text-align: center; }

/* ============================== document tree view ============================== */
#doctree-section { flex: 1 1 auto; min-height: 0; }
.toggle { font-size: 12px; color: #5b6678; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.lg-sec { background: #e7f0ff; color: #2257c4; }
.lg-sub { background: #eef1f7; color: #4a5566; }
.lg-par { background: #eafaf0; color: #1f7a45; }
.fnmark-legend { background: #c2185b; color: #fff; }

.doctree-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 14px; background: #fff; }
.dt-doc-caption { font-size: 12px; color: #7a8597; padding: 2px 4px 10px; border-bottom: 1px solid #eef1f7; margin-bottom: 6px; }

.dt-node { }
.dt-children { margin-left: 18px; border-left: 1px solid #eaeef5; padding-left: 8px; }

.dt-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 6px; border-radius: 6px;
  cursor: pointer; }
.dt-row:hover { background: #f3f6fc; }
.dt-caret { flex: 0 0 14px; color: #9aa6ba; font-size: 11px; text-align: center; }
.dt-label { flex: 0 0 auto; font-weight: 700; color: #44506a; min-width: 18px; }
.dt-title { flex: 1 1 auto; min-width: 0; }
.dt-count { flex: 0 0 auto; font-size: 11px; background: #eafaf0; color: #1f7a45; border-radius: 9px; padding: 0 8px; }
.dt-count.dim { background: #f0f2f7; color: #8a93a3; }
.dt-fn { flex: 0 0 auto; font-size: 11px; background: #fff3df; color: #9a6b13; border-radius: 9px; padding: 0 8px; }

/* level styling — sections stand out, subsections lighter */
.dt-row.lvl-sec .dt-title { font-weight: 700; font-size: 14px; color: #1d2330; }
.dt-row.lvl-sub .dt-title { font-weight: 600; color: #2c3850; }
.dt-row.lvl-deep .dt-title { color: #46526a; }

.dt-par { display: flex; gap: 6px; padding: 2px 6px 2px 22px; color: #5b6678; }
.dt-pmark { flex: 0 0 12px; color: #b9c2d2; font-size: 11px; }
.dt-ptext { flex: 1; font-size: 12.5px; line-height: 1.6; }
.dt-ptext.full { color: #2c3344; }

/* inline citation highlights (color-coded by material type) */
.cite { background: #eaf2ff; color: #2257c4; border-bottom: 1px dotted #6f9ae8;
  border-radius: 3px; padding: 0 2px; cursor: pointer; }
.cite:hover { background: #d6e6ff; }
.cite-statute, .cite-regulation { background: #eaf7ee; color: #2f7a3f; border-bottom-color: #7bb98a; }
.cite-statute:hover, .cite-regulation:hover { background: #d6efde; }
.cite-patent { background: #f3eaff; color: #6a37b5; border-bottom-color: #b48bdc; }
.cite-patent:hover { background: #e8d8fa; }
.cite-exhibit, .cite-record_citation { background: #f3f1ea; color: #8a6d1f; border-bottom-color: #cdb874; }
.cite-ptab_case { background: #eef0f3; color: #4a5566; border-bottom-color: #aab4c2; }
.cite-court_case { background: #eaf2ff; color: #2257c4; border-bottom-color: #6f9ae8; }
.cite-reexam { background: #eef0f3; color: #4a5566; border-bottom-color: #aab4c2; }
/* prior-art reference cited by name (Amir, Aviv, ...) */
.cite-reference { background: #e6f6f1; color: #0f7a5e; border-bottom: 1px dashed #4cae93; font-weight: 600; }
.cite-reference:hover { background: #d2efe5; }

/* footnote reference marks — distinct magenta so they don't read as citations */
.fnmark { color: #fff; background: #c2185b; border-radius: 3px; padding: 0 4px;
  margin: 0 1px; cursor: help; font-weight: 700; }
.fnmark::before { content: "fn"; font-size: 8px; opacity: .85; margin-right: 1px; }
.fnmark:hover { background: #97114a; }

/* shared hover tooltip */
.dt-tip { position: fixed; z-index: 50; max-width: 360px; pointer-events: none;
  background: #1f2733; color: #e7ecf3; border: 1px solid #3a4658; border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 6px 24px rgba(20,28,40,.32); font-size: 12px; line-height: 1.5; }
.dt-tip .tip-title { font-weight: 700; color: #cfe0ff; margin-bottom: 3px; }
.dt-tip .tip-idx { background: #2f6fed; color: #fff; border-radius: 4px; padding: 0 5px; font-size: 11px; }
.dt-tip .tip-body { color: #d3dbe6; }
.dt-tip .tip-material { margin-top: 4px; color: #ffd98a; font-style: italic; }
.dt-tip .tip-dep { margin-top: 6px; padding-top: 5px; border-top: 1px solid #3a4658; color: #e7ecf3; }
.dt-tip .tip-dep b { color: #ffd98a; }
.dt-tip .tip-dep-detail { color: #aebacb; font-size: 11px; margin-top: 2px; }
.dt-tip .tip-link { margin-top: 5px; color: #8ab4ff; word-break: break-all; }

/* a citation that resolves to another (exhibit/record -> actual material) */
.cite.linked { border-bottom-style: solid; }
.cite.linked::after { content: "↳"; font-size: 9px; opacity: .65; margin-left: 1px; vertical-align: super; }

/* citations matching the reference clicked in the sidebar */
.cite.ref-hit { background: #ffe07a !important; color: #5b4300 !important;
  box-shadow: 0 0 0 2px #e6a700; border-radius: 3px; }
