:root {
  --gold: #9a7803;
  --gold-light: #c39704;
  --paper: #fffdf8;
  --ink: #111;
  --muted: #444;
  --line: #222;
  --zebra: #f7f4ee;
  --danger: #8b1c3c;
  --col-left: minmax(0, 1.15fr);
  --col-right: minmax(260px, 0.85fr);
  --font-serif: "Times New Roman", Times, "Nimbus Roman", Georgia, serif;
  --font-mono: "Courier New", Courier, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.42;
}

.print-only {
  display: none !important;
}

.global-progress {
  max-width: 1200px;
  width: 100%;
  margin: 0.6rem auto 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: transparent;
  border: 0;
}

.global-progress .progress-track {
  width: 100%;
  height: 10px;
  flex: none;
}

.global-progress-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink);
}

.global-progress-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.global-progress-detail {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
}

.progress-track {
  height: 5px;
  background: var(--zebra);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold-light);
  transition: width 0.25s ease;
}

.progress-fill.indeterminate {
  width: 40% !important;
  animation: indet 1.2s ease-in-out infinite;
}

@keyframes indet {
  0% { margin-left: 0; }
  50% { margin-left: 60%; }
  100% { margin-left: 0; }
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 2px solid var(--line);
  padding: 0.85rem 1.25rem 0.65rem;
  background: linear-gradient(to bottom, #fff, var(--paper));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.masthead-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.masthead-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.masthead-logo {
  flex-shrink: 0;
  width: auto;
  height: 3.25rem;
  max-width: 8.5rem;
  object-fit: contain;
}

.masthead-brand-text {
  min-width: 0;
}

.masthead-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.header-search {
  max-width: 1200px;
  margin: 0.65rem auto 0;
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

.header-search .header-query {
  flex: 1 1 auto;
}

.header-search .field-input {
  width: 100%;
}

.header-search .btn-lg {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  margin: 0.1rem 0 0;
  font-size: 1.45rem;
  font-weight: bold;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.masthead-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.05rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
}

.print-header {
  max-width: 1200px;
  margin: 0.75rem auto 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.planner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 2rem;
  display: grid;
  grid-template-columns: var(--col-left) var(--col-right);
  gap: 1.25rem 1.5rem;
  align-items: start;
}

.planner > .banner {
  grid-column: 1 / -1;
}

.banner {
  margin: 0 0 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: #fff;
}

.banner-warn {
  border-color: #a16207;
  background: #fffbeb;
  color: #713f12;
}

.banner-error {
  border-color: var(--danger);
  background: #fef2f2;
  color: var(--danger);
}

.banner-info {
  border-color: #1d4ed8;
  background: #eff6ff;
  color: #1e3a8a;
}

.banner-ok {
  border-color: var(--gold);
  background: var(--zebra);
  color: var(--ink);
}

.col {
  min-width: 0;
}

.block {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.block:last-child {
  border-bottom: 0;
}

.block-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.lede {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.block-head .block-title {
  margin: 0;
}

.block-actions {
  display: flex;
  gap: 0.25rem;
}

.meta {
  margin: 0.25rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.search-form,
.search-config {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
}

.search-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

.search-meta-params {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem 0.65rem;
  align-items: end;
}

.search-meta .field-label,
.search-meta-params .field-label {
  white-space: nowrap;
}

.field-param {
  min-width: 0;
}

.field-param .field-input {
  width: 100%;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  border: 1px solid var(--line);
}

.mode-btn {
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 0.35rem 0.4rem;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  cursor: pointer;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
}

.mode-btn:last-child {
  border-right: 0;
}

.mode-btn.on {
  background: var(--zebra);
  font-weight: bold;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.field-grow {
  flex: 1 1 12rem;
}

.field-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.field-input {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.35rem 0.45rem;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  min-width: 0;
}

.field-input:focus {
  outline: 1px solid var(--gold-light);
  border-color: var(--gold-light);
}

.search-actions {
  align-items: center;
  gap: 0.65rem;
}

.field-compact {
  flex: 0 0 auto;
  min-width: 5.5rem;
}

.field-compact .field-input {
  min-width: 4.5rem;
}

.field-mode {
  min-width: 0;
}

.btn-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.38rem 0.7rem;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  min-height: 2rem;
}

.btn-sm {
  padding: 0.28rem 0.55rem;
  font-size: 0.74rem;
  font-weight: normal;
  min-height: 1.75rem;
}

.btn-lg {
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  min-height: 2.25rem;
}

.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
}

.file-btn input {
  display: none;
}

.status-line {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 6rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.status-line.ready {
  color: var(--gold);
  font-weight: bold;
}

.status-line.error {
  color: var(--danger);
}

.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.btn.secondary {
  background: var(--zebra);
}

.btn.ghost {
  background: transparent;
  font-weight: normal;
}

.btn.danger {
  color: var(--danger);
  border-color: var(--danger);
  font-weight: normal;
}

.btn.danger:hover {
  background: #fef2f2;
}

.status-line.warn {
  color: #a16207;
}

.lib-pane {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.55rem;
}

.lib-pane-toolbar {
  margin-bottom: 0.65rem;
}

#library-block {
  display: flex;
  flex-direction: column;
}

.lib-row {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}

.lib-row-mine {
  grid-template-columns: 1fr 1fr;
}

.lib-row-import {
  grid-template-columns: 1fr;
}

.lib-import-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.lib-import-opt input {
  accent-color: var(--primary);
}

.lib-row-main {
  flex: 1 1 auto;
  grid-template-columns: minmax(10rem, 0.34fr) minmax(0, 0.66fr);
  align-items: stretch;
  min-height: 22rem;
}

.lib-pane-list,
.lib-pane-catalog-list,
.lib-pane-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.lib-pane-list .lib-list,
.lib-pane-catalog-list .lib-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.lib-legend {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  color: var(--muted);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem 0.5rem;
}

.lib-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  white-space: nowrap;
}

.lib-legend .dot {
  width: 0.45rem;
  height: 0.45rem;
  flex-shrink: 0;
}

@media (min-width: 520px) {
  .lib-legend {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.lib-dots {
  display: inline-flex;
  gap: 0.2rem;
  margin-right: 0.35rem;
  flex-shrink: 0;
  vertical-align: middle;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.dot.ok {
  background: #15803d;
  border-color: #15803d;
}

.dot.bad {
  background: var(--danger);
  border-color: var(--danger);
}

.dot.pending {
  background: #a16207;
  border-color: #a16207;
}

.lib-item-title {
  display: inline;
}

.lib-item-line {
  display: flex;
  align-items: center;
  min-width: 0;
}

.lib-item-line .lib-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  flex: 0 0 auto;
}

.pane-head .pane-title {
  margin: 0;
}

.lib-pane-catalog-list,
.lib-pane-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.lib-pane-detail {
  min-height: 14rem;
}

.pane-title {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: bold;
}

.pane-hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.lib-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lib-toolbar .field-input {
  width: 100%;
}

.lib-pane-import .drop {
  margin-bottom: 0.35rem;
}

.import-groups {
  display: grid;
  gap: 0.65rem;
}

.import-group {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--zebra);
  padding: 0.5rem 0.55rem;
}

.import-group-label {
  margin: 0 0 0.35rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.import-group-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: stretch;
}

.import-group-actions .btn,
.import-group-actions .file-btn {
  width: 100%;
  justify-content: center;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-group .lib-import-opt {
  margin-top: 0.4rem;
}

.import-group .pane-hint {
  margin-top: 0.35rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.lib-detail-links {
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-size: 0.78rem;
}

.lib-detail-links a {
  color: var(--ink);
}

.lib-detail-desc {
  margin: 0.35rem 0 0.55rem;
  font-size: 0.84rem;
  line-height: 1.45;
}

.lib-detail h4 {
  margin: 0.65rem 0 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.detail-list {
  margin: 0.2rem 0 0.5rem;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.detail-list li {
  margin-bottom: 0.2rem;
}

.lib-list {
  overflow: auto;
  max-height: 11rem;
  min-height: 6rem;
}

.lib-pane-catalog-list .lib-list {
  max-height: none;
  min-height: 0;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin: 0.35rem 0;
}

.pill-row button {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.12rem 0.4rem;
  font-family: var(--font-serif);
  font-size: 0.68rem;
  cursor: pointer;
}

.pill-row button.on {
  background: var(--zebra);
  font-weight: bold;
}

.lib-pane-detail .lib-detail {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.lib-item-row {
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  width: 100%;
  flex: 0 0 auto;
}

.lib-item-row.on .lib-item {
  background: var(--zebra);
}

.lib-item-row .lib-item {
  flex: 1 1 auto;
  min-width: 0;
}

.lib-item-del {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  align-self: center;
}

.lib-item-del:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #fef2f2;
}

.lib-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.lib-detail-actions-danger {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.query-presets {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.5rem 0 0.75rem;
}

.query-preset {
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.45rem 0.55rem;
  background: var(--zebra);
}

.query-preset-label {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: bold;
}

.query-preset-q {
  margin: 0 0 0.3rem;
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.35;
}

.query-preset-meta {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.query-preset-expect {
  margin: 0 0 0.45rem;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
}

.query-expect-tag {
  font-weight: bold;
  color: var(--ink);
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  margin-right: 0.25rem;
}

.lib-item {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.3rem 0.2rem;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 2px;
}

.lib-item:hover,
.lib-item.on {
  background: var(--zebra);
}

.lib-item .sub {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
}

.lib-detail {
  font-size: 0.85rem;
}

.lib-detail h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.lib-detail .meta {
  margin: 0 0 0.35rem;
}

.btn-row .btn {
  flex: 0 0 auto;
}

.drop {
  display: block;
  text-align: center;
  padding: 0.55rem;
  border: 1px dashed var(--line);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 0.45rem;
}

.drop.drag {
  border-color: var(--gold-light);
  background: var(--zebra);
}

.url-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.file-btn {
  display: inline-flex;
  cursor: pointer;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.eval-metrics table {
  margin-top: 0.35rem;
}

.qrels-area {
  width: 100%;
  min-height: 4rem;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.hit {
  margin-bottom: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
}

.hit.selected {
  background: var(--zebra);
  padding-left: 0.35rem;
  margin-left: -0.35rem;
}

.hit-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: bold;
}

.hit-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.hit-row .hit-open {
  flex: 1;
}

.hit-rank {
  display: inline-block;
  min-width: 1.25rem;
  margin-right: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.hit-judge {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-shrink: 0;
}

.judge-btn {
  font-size: 0.68rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: var(--paper);
  cursor: pointer;
  font-family: var(--font-mono);
}

.judge-btn.active {
  background: var(--zebra);
  border-color: var(--ink);
}

.judge-btn.active.top {
  background: rgba(196, 151, 4, 0.2);
}

.judge-chip {
  background: rgba(196, 151, 4, 0.15);
}

.results-toolbar {
  margin: 0.5rem 0 0.75rem;
}

.stack-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.alpha-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  width: 100%;
}

.alpha-range {
  flex: 1;
  min-width: 4rem;
}

.alpha-out {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  min-width: 2.5rem;
}

.ranking-advanced {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

.ranking-advanced-summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.ranking-stage-list {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
}

.ranking-stage-list li {
  margin-bottom: 0.25rem;
}

.field[hidden] {
  display: none;
}

.hit-open {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.hit-snippet {
  margin: 0.25rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.hit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.25rem 0;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--line);
  background: #fff;
}

.hit-trace-host {
  margin: 0.35rem 0 0;
}

.json-tree-host {
  margin-top: 0.55rem;
}

.json-tree-panel {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  padding: 0.4rem 0.5rem;
}

.json-tree-compact {
  font-size: 0.68rem;
}

.json-tree-head {
  margin-bottom: 0.25rem;
}

.json-tree-title {
  font-size: 0.65rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.json-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.jt-children {
  list-style: none;
  margin: 0.1rem 0 0.15rem;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.jt-details {
  margin: 0.08rem 0;
}

.jt-details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  line-height: 1.35;
}

.jt-details > summary::-webkit-details-marker {
  display: none;
}

.jt-details > summary::before {
  content: "▸";
  font-size: 0.6rem;
  color: var(--muted);
  flex-shrink: 0;
}

.jt-details[open] > summary::before {
  content: "▾";
}

.jt-leaf {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.06rem 0;
  line-height: 1.35;
}

.jt-key {
  font-weight: bold;
  flex-shrink: 0;
}

.jt-meta {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.62rem;
}

.jt-val {
  font-family: var(--font-mono);
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jt-string {
  color: #1e40af;
}

.jt-number {
  color: #0f766e;
}

.jt-boolean {
  color: #7c3aed;
}

.jt-null {
  color: var(--muted);
}

.json-raw {
  margin-top: 0.35rem;
  font-size: 0.65rem;
}

.json-raw > summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}

.json-raw pre {
  margin: 0.35rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  line-height: 1.35;
  white-space: pre-wrap;
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 0.4rem;
  background: var(--zebra);
  max-height: 14rem;
  overflow: auto;
}

.hit-passage {
  margin-top: 0.45rem;
  padding: 0.5rem 0.55rem;
  border-left: 2px solid var(--gold-light);
  background: #fff;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.hit-passage.loading {
  color: var(--muted);
  font-style: italic;
  font-size: 0.8rem;
}

.hit-passage .passage-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.glossary {
  margin: 0;
  font-size: 0.8rem;
}

.glossary dt {
  font-weight: bold;
  margin-top: 0.45rem;
}

.glossary dt:first-child {
  margin-top: 0;
}

.glossary dd {
  margin: 0.15rem 0 0;
  color: var(--muted);
  line-height: 1.4;
}

mark {
  background: #f0e2a8;
  padding: 0 0.05em;
}

.document-panel {
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.65rem;
  background: #fff;
}

.doc-title {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.doc-id {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.doc-body {
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.pipeline-root {
  font-size: 0.82rem;
}

.pipeline-preview {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.5rem 0.55rem;
}

.pipeline-preview-section {
  margin-bottom: 0.55rem;
}

.pipeline-preview-section:last-of-type {
  margin-bottom: 0.35rem;
}

.pipeline-preview-title {
  margin: 0 0 0.3rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.pipeline-preview-note {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.pipeline-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pipeline-step {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.32rem 0.45rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-bottom: 0.2rem;
  font-size: 0.78rem;
  line-height: 1.3;
}

.pipeline-step.active {
  background: var(--zebra);
  border-color: var(--gold-light);
}

.pipeline-step-label {
  font-weight: bold;
  white-space: nowrap;
}

.pipeline-step-detail {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-prose {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.mermaid-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  padding: 0.65rem;
  background: #fff;
  min-height: 8rem;
  max-height: 14rem;
}

.mermaid-wrap-lg {
  min-height: 24rem;
  max-height: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.mermaid-wrap svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.pipeline-stages {
  margin-top: 0.55rem;
}

.pipeline-stages caption {
  caption-side: top;
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-bottom: 0.25rem;
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.kv-table th,
.kv-table td {
  border: 1px solid var(--line);
  padding: 0.28rem 0.4rem;
  text-align: left;
  vertical-align: top;
}

.kv-table th {
  width: 38%;
  font-weight: normal;
  color: var(--muted);
  background: var(--zebra);
}

.kv-table thead th {
  font-weight: bold;
  color: var(--ink);
  background: #ece6d8;
}

.data-table td,
.data-table th {
  font-size: 0.72rem;
}

.stat-section {
  margin-bottom: 0.85rem;
}

.stat-heading {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.chart-box {
  border: 1px solid var(--line);
  padding: 0.5rem 0.55rem 0.6rem;
  background: #fff;
  overflow: hidden;
}

.chart-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.chart-box-head h4 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: bold;
  min-width: 0;
}

.chart-expand {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 0.25rem 0.45rem;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 8.5rem;
  min-height: 8rem;
  max-height: 8.5rem;
}

.chart-canvas-wrap-lg {
  height: 22rem;
  min-height: 18rem;
  max-height: none;
}

.chart-grid-lg {
  gap: 1rem;
}

.chart-empty {
  margin: 0;
  padding: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.viz-info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.viz-block {
  font-size: 0.82rem;
}

.trace-raw pre {
  margin: 0.35rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  padding: 0.45rem;
  background: var(--zebra);
}

.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.foot a {
  color: var(--ink);
}

.fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.5);
}

.fs-overlay[hidden] {
  display: none !important;
}

body.fs-open {
  overflow: hidden;
}

.fs-dialog {
  width: min(96vw, 1080px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.fs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.fs-title {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
}

.fs-body {
  overflow: auto;
  padding: 0.85rem;
  flex: 1;
  min-height: 0;
}

.fs-body .chart-grid {
  grid-template-columns: 1fr;
}

.pdf-report-preview-wrap {
  padding: 0.5rem 0.85rem 0.85rem;
}

.pdf-report-preview-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.pdf-report-notes-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
}

.pdf-report-notes-input {
  min-height: 4.5rem;
  resize: vertical;
}

.pdf-report-preview-actions {
  margin-bottom: 0.75rem;
}

.pdf-report-preview {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.75rem 0.85rem;
  max-height: 62vh;
  overflow: auto;
}

.pdf-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 8.5pt;
}

.pdf-list li {
  margin-bottom: 0.15rem;
}

.pdf-link {
  color: #1e40af;
  text-decoration: underline;
}

.pdf-link-url {
  display: block;
  font-family: var(--font-mono);
  font-size: 7pt;
  color: #555;
  margin-top: 0.1rem;
}

.pdf-appendix {
  break-inside: avoid-page;
}

.pdf-json-appendix {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 6.5pt;
  line-height: 1.3;
  white-space: pre-wrap;
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0.45rem;
  background: var(--zebra);
  max-height: 28rem;
  overflow: auto;
}

@media print {
  .pdf-json-appendix {
    max-height: none;
    overflow: visible;
    font-size: 6pt;
  }

  .pdf-link-url {
    display: inline;
  }
}

.pdf-report-print-root {
  display: none;
}

.pdf-report {
  font-family: var(--font-serif);
  font-size: 10pt;
  line-height: 1.45;
  color: #000;
}

.pdf-report-masthead {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2pt solid #000;
}

.pdf-report-logo {
  display: block;
  width: auto;
  height: 48px;
  max-width: 7rem;
  object-fit: contain;
  margin-bottom: 0.35rem;
}

.pdf-report-kicker {
  margin: 0;
  font-size: 7pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #444;
}

.pdf-report-title {
  margin: 0.15rem 0 0;
  font-size: 16pt;
  font-weight: bold;
}

.pdf-report-meta {
  margin: 0.25rem 0 0;
  font-size: 8pt;
  color: #444;
}

.pdf-report-section {
  margin-bottom: 0.75rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-report-h2 {
  margin: 0 0 0.35rem;
  font-size: 9pt;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 0.5pt solid #000;
  padding-bottom: 0.12rem;
}

.pdf-report-query {
  margin: 0;
  font-size: 11pt;
  font-weight: bold;
}

.pdf-report-lede {
  margin: 0;
  font-size: 9pt;
}

.pdf-report-notes-body {
  margin: 0;
  font-size: 9pt;
  white-space: pre-wrap;
}

.pdf-kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
}

.pdf-kv th,
.pdf-kv td {
  border: 0.5pt solid #999;
  padding: 0.2rem 0.35rem;
  text-align: left;
  vertical-align: top;
}

.pdf-kv th {
  width: 28%;
  font-weight: bold;
  background: #f5f5f5;
}

.pdf-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8pt;
}

.pdf-results-table th,
.pdf-results-table td {
  border: 0.5pt solid #999;
  padding: 0.2rem 0.3rem;
  text-align: left;
  vertical-align: top;
}

.pdf-results-table th {
  font-weight: bold;
  background: #f5f5f5;
}

.pdf-result-snippet-row td {
  font-size: 7.5pt;
  color: #333;
  border-top: 0;
  padding-top: 0;
}

.pdf-report-foot {
  margin-top: 0.75rem;
  padding-top: 0.35rem;
  border-top: 0.5pt solid #999;
  font-size: 7pt;
  color: #555;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

@media (max-width: 900px) {
  .header-search {
    flex-direction: column;
    align-items: stretch;
  }

  .header-search .btn-lg {
    width: 100%;
  }

  .planner {
    grid-template-columns: 1fr;
  }

  .lib-row-mine,
  .lib-row-main {
    grid-template-columns: 1fr;
  }

  .lib-list,
  .lib-pane-list .lib-list,
  .lib-pane-catalog-list .lib-list {
    max-height: 9rem;
    min-height: 5rem;
  }

  .import-group-actions {
    grid-template-columns: 1fr;
  }

  .search-meta-params {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-btn:nth-child(4),
  .mode-btn:nth-child(5) {
    grid-column: span 1;
  }
}

@media print {
  @page {
    margin: 1.2cm 1.4cm;
    size: A4;
  }

  body.pdf-report-print * {
    visibility: hidden;
  }

  body.pdf-report-print .pdf-report-print-root,
  body.pdf-report-print .pdf-report-print-root * {
    visibility: visible;
  }

  body.pdf-report-print .pdf-report-print-root {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0;
  }

  body.pdf-report-print .masthead,
  body.pdf-report-print .planner,
  body.pdf-report-print .foot,
  body.pdf-report-print .fs-overlay {
    display: none !important;
  }

  body:not(.pdf-report-print) {
    font-size: 10pt;
    background: #fff;
    color: #000;
  }

  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .masthead {
    padding: 0 0 0.4rem;
    border-bottom: 2pt solid #000;
    background: none;
  }

  .title {
    font-size: 16pt;
  }

  .planner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
    max-width: none;
    padding: 0.5rem 0;
  }

  .block {
    break-inside: avoid;
    page-break-inside: avoid;
    border-bottom: 0;
    margin-bottom: 0.65rem;
    padding-bottom: 0;
  }

  .block-title {
    font-size: 9pt;
    color: #000;
    border-bottom: 0.5pt solid #000;
    padding-bottom: 0.15rem;
  }

  .field-input,
  .btn,
  .mode-group,
  .lib-import,
  .drop {
    display: none !important;
  }

  .lib-row-mine,
  .lib-row-main {
    grid-template-columns: 1fr;
  }

  .lib-list {
    max-height: none;
    overflow: visible;
  }

  .hit.selected {
    background: #f5f5f5;
  }

  .chart-canvas-wrap {
    height: 10rem;
    min-height: 9rem;
  }

  .mermaid-wrap svg {
    max-width: 100%;
    height: auto;
  }

  a[href]::after {
    content: none;
  }
}
