/* Catalogue Explorer — exploration prototype */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  color: #1c1f24; background: #f7f7f9;
  height: 100vh;
}

body { display: flex; flex-direction: column; height: 100vh; }

/* ------------------------- header ------------------------- */
header {
  background: #1c2733; color: #f7f7f9;
  padding: 16px 28px 0; flex-shrink: 0;
  position: relative; z-index: 10;
}
header h1 {
  margin: 0;
  font-size: 22px; font-weight: 600; letter-spacing: 0.01em;
}
header .sub {
  margin: 6px 0 14px; font-size: 13px;
  opacity: 0.75; max-width: 800px;
}
nav { display: flex; gap: 4px; margin-top: 10px; }
.tab {
  background: transparent; color: #cdd2d8;
  border: 0; border-bottom: 2px solid transparent;
  padding: 9px 16px; font-size: 13px; font-family: inherit;
  cursor: pointer; transition: color 0.1s;
}
.tab:hover { color: #fff; }
.tab.active { color: #fff; border-bottom-color: #f7a23b; }

/* ------------------------- main ------------------------- */
main { flex: 1; overflow: hidden; }
#loading {
  padding: 40px; font-size: 14px; color: #555;
}
.view {
  height: 100%;
}
.three-col {
  display: grid;
  grid-template-columns: 320px 6px 360px 6px 1fr;
  height: 100%;
}
.col-resizer {
  background: #eef0f3;
  cursor: col-resize;
  border-left: 1px solid #e1e3e7;
  border-right: 1px solid #e1e3e7;
  user-select: none;
  transition: background 0.1s;
}
.col-resizer:hover, .col-resizer.dragging {
  background: #f7a23b;
}
.single-col {
  overflow-y: auto;
  padding: 28px;
}

.left, .middle, .right {
  height: 100%;
  overflow: hidden;
  display: flex; flex-direction: column;
  background: #fff;
}
.left { border-right: 1px solid #e1e3e7; }
.middle { border-right: 1px solid #e1e3e7; }
.right { background: #fff; padding: 0; }

.pane-header {
  padding: 14px 16px 8px;
  border-bottom: 1px solid #eef0f3;
  flex-shrink: 0;
}
.pane-header h2 {
  margin: 0 0 4px;
  font-size: 14px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #6b7380;
}
.pane-header h3 {
  margin: 4px 0 6px;
  font-size: 18px; font-weight: 600;
  color: #1c1f24;
}
.pane-header .hint {
  font-size: 12px; color: #6b7380; margin: 4px 0 8px;
}

#topic-filter, #aspect-filter {
  width: 100%; padding: 6px 10px;
  border: 1px solid #d6dae0; border-radius: 4px;
  font-size: 13px; font-family: inherit;
  margin-top: 6px;
}

.search-results {
  margin-top: 8px;
  border: 1px solid #e1e3e7;
  border-radius: 6px;
  background: #fff;
  max-height: 42vh;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.search-section {
  border-bottom: 1px solid #eef0f3;
}
.search-section:last-child { border-bottom: 0; }
.search-section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px 5px;
  color: #6b7380;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #fafbfc;
}
.search-section-title span {
  font-variant-numeric: tabular-nums;
}
.search-hit {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-areas:
    "kind main"
    "kind meta";
  gap: 1px 8px;
  width: 100%;
  border: 0;
  border-top: 1px solid #f3f4f6;
  background: #fff;
  padding: 8px 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.search-hit:hover { background: #fff5e6; }
.search-hit-kind {
  grid-area: kind;
  align-self: start;
  color: #6b7380;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 2px;
}
.search-hit-main {
  grid-area: main;
  color: #1c1f24;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
  word-break: break-word;
}
.search-hit-meta {
  grid-area: meta;
  color: #6b7380;
  font-size: 11px;
  line-height: 1.3;
  word-break: break-word;
}
.search-empty {
  color: #6b7380;
  font-size: 12px;
  padding: 10px;
}

.auto-scroll-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: #6b7380;
  font-size: 12px;
  user-select: none;
}
.auto-scroll-toggle input {
  margin: 0;
}

/* ----- aspect tree (left pane) ----- */
#aspect-tree {
  overflow-y: auto;
  flex: 1;
}
.aspect-header {
  padding: 10px 14px;
  background: #f3f4f6;
  border-bottom: 1px solid #e1e3e7;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 13px;
}
.aspect-header:hover { background: #e7eaee; }
.aspect-header.expanded {
  background: #fff5e6;
  border-bottom-color: #f0d9a8;
}
.aspect-caret {
  font-size: 11px; color: #6b7380;
  width: 10px; flex-shrink: 0;
}
.aspect-title {
  font-weight: 600; color: #1c1f24;
  flex: 1;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
.aspect-meta {
  font-size: 11px; color: #6b7380;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
ul.topic-list {
  list-style: none; margin: 0 0 4px; padding: 0;
}
li.topic-row {
  padding: 7px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 4px;
  font-size: 13px;
}
li.topic-row:hover { background: #fafbfc; }
li.topic-row.selected {
  background: #fff5e6;
  border-left: 3px solid #f7a23b;
  padding-left: 13px;
}
.topic-tree-icon {
  color: #c2c8d0; font-size: 11px; margin-right: 2px;
}
.topic-name {
  font-weight: 500; color: #1c1f24;
  flex: 1; margin-right: 8px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
.topic-doc-count {
  font-size: 11px; color: #6b7380;
  font-variant-numeric: tabular-nums;
  background: #eef0f3; padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

ul#doc-list, ul#combine-doc-list {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto; flex: 1;
}

/* ----- sub-cluster rows under a topic ----- */
.sub-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px; color: #6b7380;
  width: 22px; height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  margin-right: 4px;
  border-radius: 4px;
  user-select: none;
  transition: background 0.1s;
}
.sub-caret:hover {
  color: #1c1f24;
  background: #e7eaee;
}
.sub-caret-placeholder {
  display: inline-block; width: 22px; height: 22px;
  flex-shrink: 0; margin-right: 4px;
}
li.sub-row {
  padding: 5px 16px;
  border-bottom: 1px solid #f7f8fa;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 12px;
  background: #fafbfd;
  color: #3a3f47;
}
li.sub-row:hover { background: #f1f3f6; }
li.sub-row.selected {
  background: #fff5e6;
  border-left: 3px solid #f7a23b;
  padding-left: 13px;
}
.sub-name {
  flex: 1; margin-right: 6px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  font-style: italic;
}
.sub-confidence {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px; border-radius: 3px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.sub-confidence-high { background: #d4ebd9; color: #2c5e36; }
.sub-confidence-medium { background: #fff0d6; color: #7e5818; }
.sub-confidence-low { background: #eef0f3; color: #6b7380; }
.sub-confidence-no_signal { background: #f5e0dd; color: #8a3a32; }

/* ----- facet badge on sub-row (shows # facets available) ----- */
.facet-badge {
  display: inline-block;
  background: #fff0d6;
  color: #6e4c1c;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid #f0d9a8;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

/* ----- facet filter rendered into topic-summary-phrases ----- */
.facet-filter {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 4px;
}
.facet-row {
  display: flex; flex-direction: column; gap: 4px;
}
.facet-label {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: #6b7380;
}
.facet-name { font-weight: 600; color: #1c1f24; font-size: 12px; text-transform: none; letter-spacing: 0; }
.facet-kind { font-size: 10px; padding: 1px 5px; border-radius: 3px; }
.facet-kind-subject { background: #fff0d6; color: #6e4c1c; }
.facet-kind-attribute { background: #d6ebf5; color: #1f4a66; }
.facet-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.facet-chip {
  background: #fff;
  border: 1px solid #d6dae0;
  color: #1c1f24;
  font-family: inherit;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background 0.1s, border-color 0.1s;
}
.facet-chip:hover { border-color: #1c1f24; }
.facet-chip.on {
  background: #f7a23b;
  border-color: #c47e22;
  color: #1c1f24;
  font-weight: 600;
}
.facet-chip-count {
  font-size: 10px; color: #6b7380;
  font-variant-numeric: tabular-nums;
  background: #eef0f3;
  padding: 0 5px;
  border-radius: 8px;
}
.facet-chip.on .facet-chip-count {
  background: rgba(255,255,255,0.55);
  color: #1c1f24;
}
.facet-clear {
  align-self: flex-start;
  margin-top: 4px;
  background: transparent;
  border: 1px dashed #b0b6bf;
  color: #6b7380;
  font-family: inherit; font-size: 11px;
  padding: 2px 8px; border-radius: 4px;
  cursor: pointer;
}
.facet-clear:hover { border-color: #1c1f24; color: #1c1f24; }

/* ----- legacy LLM tree rows (no longer used; CSS kept harmless) ----- */
.llm-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px; color: #4d8db4;
  width: 20px; height: 20px;
  flex-shrink: 0;
  cursor: pointer;
  margin-right: 3px;
  border-radius: 4px;
  user-select: none;
}
.llm-caret:hover {
  color: #1f4a66;
  background: #d6ebf5;
}
li.llm-row {
  padding: 4px 16px;
  border-bottom: 1px solid #f7f8fa;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 12px;
  background: #f0f5fa;
  color: #1f4a66;
  border-left: 2px solid #d6ebf5;
}
li.llm-row.llm-row-child {
  background: #f5fafd;
  border-left-color: #eef5fa;
}
li.llm-row:hover { background: #e3eef7; }
li.llm-row.selected {
  background: #d6ebf5;
  border-left: 3px solid #4d8db4;
  padding-left: 13px;
}
.llm-name {
  flex: 1; margin-right: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.centroid-hint {
  color: #6b7380; font-style: italic; font-weight: 400;
  font-size: 11px;
}

.trail-parent {
  color: #6b7380; font-weight: 500;
}
.trail-sep {
  color: #c2c8d0; margin: 0 2px;
}

/* ----- click-to-jump from highlighted phrases ----- */
mark.jump { cursor: pointer; }
mark.jump:hover {
  outline: 2px solid #1c1f24;
  outline-offset: 1px;
}

/* phrases that belong to OTHER atoms — muted color, dashed underline,
   click jumps to that other atom */
mark.other-atom {
  background: #f0f1f3;
  color: #6b7380;
  border-radius: 2px;
  padding: 0 2px;
  border-bottom: 1px dashed #b0b6bf;
}
mark.other-atom:hover {
  background: #e0e3e7;
  color: #1c1f24;
  border-bottom-color: #1c1f24;
  outline: 0;
}

.jump-menu {
  position: fixed;
  z-index: 10000;
  background: #fff;
  border: 1px solid #d6dae0;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  min-width: 240px; max-width: 360px;
  padding: 6px 0;
  font-size: 13px;
}
.jump-menu-header {
  padding: 6px 12px 8px;
  border-bottom: 1px solid #eef0f3;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7380;
}
.jump-menu-option {
  display: block; width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 12px;
  text-align: left;
  font-family: inherit; font-size: 13px;
  color: #1c1f24;
  cursor: pointer;
}
.jump-menu-option:hover { background: #f1f3f6; }

/* ----- topic summary (middle pane top) ----- */
#topic-summary {
  padding: 14px 16px;
  border-bottom: 1px solid #eef0f3;
  background: #fffaf2;
  flex-shrink: 0;
  max-height: 50vh;
  overflow-y: auto;
}
#topic-summary h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.topic-summary-meta {
  font-size: 12px; color: #6b7380;
  margin: 0 0 10px;
}
.related-phrases {
  font-size: 12px;
}
.related-phrases-label {
  color: #6b7380; margin-right: 6px;
  text-transform: uppercase; letter-spacing: 0.05em;
  font-size: 11px;
}
.phrase-chip {
  display: inline-block;
  background: #fff; border: 1px solid #e0d4bd;
  color: #6e4c1c;
  padding: 2px 7px; margin: 2px 4px 2px 0;
  border-radius: 3px; font-size: 12px;
  cursor: pointer; font-family: inherit; line-height: inherit;
}
.phrase-chip:hover { background: #f6efe0; border-color: #c9a96a; }
.phrase-chip.on {
  background: #6e4c1c; color: #fff; border-color: #6e4c1c;
}
.phrase-chip-clear {
  color: #999; border-style: dashed; font-style: italic;
}
.phrase-chip-clear:hover { background: #f0f0f0; color: #555; }

/* ----- doc list (middle pane bottom) ----- */
ul#doc-list li, ul#combine-doc-list li {
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer; font-size: 13px;
  display: flex; flex-direction: column;
}
ul#doc-list li:hover, ul#combine-doc-list li:hover { background: #f4f6f8; }
ul#doc-list li.selected, ul#combine-doc-list li.selected {
  background: #fff5e6;
  border-left: 3px solid #f7a23b;
  padding-left: 13px;
}
ul#doc-list li.doc-loading, ul#combine-doc-list li.doc-loading {
  color: #6b7380;
  cursor: default;
  font-style: italic;
  background: #fafbfc;
}
ul#doc-list li.doc-loading:hover, ul#combine-doc-list li.doc-loading:hover {
  background: #fafbfc;
}
.doc-id {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px; color: #6b7380;
  margin-bottom: 2px;
}
.doc-evidence-meta {
  font-size: 11px; color: #6b7380;
}

/* ----- doc detail (right pane) ----- */
#doc-detail, #combine-doc-detail {
  overflow-y: auto;
  padding: 24px 32px;
  flex: 1;
}
.doc-text-header {
  margin: 0 0 16px;
}
.doc-text-header h2 {
  margin: 0 0 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 14px; color: #6b7380;
  font-weight: 500;
}
.doc-text-header .legend {
  font-size: 12px; color: #6b7380;
  display: flex; gap: 14px; align-items: center;
  margin-top: 8px;
}
.legend-chip {
  padding: 1px 7px; border-radius: 3px;
  font-size: 11px;
}
.legend-chip.subject {
  background: #fff0d6; box-shadow: inset 0 -2px 0 #f7a23b;
  color: #6e4c1c;
}
.legend-chip.attribute {
  background: #d6ebf5; box-shadow: inset 0 -2px 0 #4d8db4;
  color: #1f4a66;
}
.legend-chip.other-atom-chip {
  background: #f0f1f3;
  color: #6b7380;
  border-bottom: 1px dashed #b0b6bf;
  padding-bottom: 0;
}
.legend-chip.combine-a {
  background: #fff0d6; box-shadow: inset 0 -2px 0 #f7a23b;
  color: #6e4c1c;
}
.legend-chip.combine-b {
  background: #d4e9d6; box-shadow: inset 0 -2px 0 #4f9d5e;
  color: #2c5e36;
}
.doc-body {
  white-space: pre-wrap;
  font-size: 14px; line-height: 1.7;
  color: #25292f;
}
mark.subject {
  background: #fff0d6;
  border-radius: 2px; padding: 0 2px;
  box-shadow: inset 0 -2px 0 #f7a23b;
}
mark.attribute {
  background: #d6ebf5;
  border-radius: 2px; padding: 0 2px;
  box-shadow: inset 0 -2px 0 #4d8db4;
}
mark.combine-a {
  background: #fff0d6;
  border-radius: 2px; padding: 0 2px;
  box-shadow: inset 0 -2px 0 #f7a23b;
}
mark.combine-b {
  background: #d4e9d6;
  border-radius: 2px; padding: 0 2px;
  box-shadow: inset 0 -2px 0 #4f9d5e;
}
.unrecovered-phrases {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: #fff8ee;
  border-left: 3px solid #f7a23b;
  font-size: 12px;
  color: #6e4c1c;
}
.unrecovered-phrases h4 {
  margin: 0 0 4px;
  font-size: 11px; text-transform: uppercase;
  color: #b07419; letter-spacing: 0.05em;
}

/* ----- co-occurrence summary panel (Combine tab) ----- */
.cooc-summary {
  background: #fffaf2;
  border: 1px solid #f0d9a8;
  border-radius: 4px;
  padding: 10px 14px;
  margin: 0 0 18px;
}
.cooc-side { margin: 4px 0; line-height: 1.9; }
.cooc-side .legend-chip { margin-right: 6px; }
.cooc-side .more { color: #999; font-size: 11px; margin-left: 2px; }
.cooc-summary h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6e4c1c;
}
.cooc-summary ul {
  margin: 0; padding: 0; list-style: none;
}
.cooc-summary li {
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px solid #f5e9d3;
  line-height: 1.45;
}
.cooc-summary li:last-child { border-bottom: 0; }
.cooc-summary code {
  background: #fff; border: 1px solid #f0d9a8;
  padding: 1px 6px; border-radius: 3px;
  color: #6e4c1c; font-size: 12px;
}
.cooc-summary em {
  color: #8a7048; font-style: normal;
}

/* ----- combine pickers ----- */
.combine-pickers {
  padding: 12px 16px;
  flex-shrink: 0;
}
/* Side A and Side B each in their own bordered card, visually separated by a
   "+" divider so it's clear they are two independent picks. */
.combine-side {
  border: 1px solid #d6dae0;
  border-radius: 6px;
  padding: 10px 12px 4px;
  margin-bottom: 4px;
}
/* A/B colors match the doc-highlight colors (A = amber, B = green) so the side
   picker and the highlighted phrases in the document read as the same thing. */
.combine-side-a { border-left: 4px solid #f7a23b; background: #fffaf0; }
.combine-side-b { border-left: 4px solid #4f9d5e; background: #f3faf4; }
.combine-side-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; margin-bottom: 8px;
}
.combine-side-a .combine-side-label { color: #b07419; }
.combine-side-b .combine-side-label { color: #2c5e36; }
.combine-plus {
  text-align: center; font-size: 20px; font-weight: 700;
  color: #9aa3ad; margin: 2px 0;
}
.combine-pickers select:disabled {
  background: #f0f1f3; color: #aaa; cursor: not-allowed;
}
.combine-pickers label {
  display: block;
  font-size: 12px; color: #6b7380;
  margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.combine-pickers select {
  display: block;
  width: 100%;
  padding: 6px 8px;
  margin-top: 4px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #d6dae0; border-radius: 4px;
}

/* ----- about ----- */
.about {
  max-width: 720px; margin: 0 auto;
}
.about h2 { font-size: 22px; margin: 0 0 12px; }
.about h3 { font-size: 16px; margin: 24px 0 8px; }
.about p, .about li { font-size: 14px; line-height: 1.65; }
.about code {
  background: #eef0f3; padding: 1px 5px; border-radius: 3px;
  font-size: 13px;
}

/* ----- generic ----- */
.hint { color: #6b7380; font-size: 13px; }
