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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-1);
  color: var(--fg-1);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  height: 100vh;
  overflow: hidden;
}

a {
  color: var(--fg-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--dur-fast) var(--ease-standard);
}
a:hover { color: var(--carnelian-bright); }

/* === Shell layout === */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  height: 100vh;
}

html[data-sidebar="collapsed"] .shell {
  --sidebar-w: var(--sidebar-w-collapsed);
}

/* === Header === */
.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-6);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-hair);
  flex-shrink: 0;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-shrink: 0;
}

.header__project {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--fg-brand);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.header__divider {
  width: 1px;
  height: 22px;
  background: var(--border-soft);
  flex-shrink: 0;
}

.header__section {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--fg-1);
  font-variation-settings: "opsz" 24;
  letter-spacing: -0.01em;
}

.header__actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-left: auto;
}

.sidebar__toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--fg-3);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}

.sidebar__toggle:hover {
  background: var(--bg-3);
  border-color: var(--border-soft);
  color: var(--fg-1);
}

.sidebar__toggle:focus-visible {
  outline: 2px solid var(--carnelian);
  outline-offset: 2px;
}

.sidebar__toggle svg {
  width: 16px;
  height: 16px;
  transition: transform var(--dur-base) var(--ease-out);
}

html[data-sidebar="collapsed"] .sidebar__toggle svg {
  transform: rotate(180deg);
}

.header__status {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--fg-4);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.header__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chlorophyll);
}

/* === Sidebar === */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border-hair);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-4) 0;
}

.sidebar__section {
  padding: var(--sp-2) var(--sp-5);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-top: var(--sp-5);
}

.sidebar__section:first-child {
  margin-top: 0;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 40px;
  padding: var(--sp-2) var(--sp-5);
  text-decoration: none;
  color: var(--fg-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}

.sidebar__link:hover {
  background: var(--bg-3);
  color: var(--fg-1);
  text-decoration: none;
}

.sidebar__link--active {
  background: rgba(179, 27, 27, 0.04);
  color: var(--carnelian);
  border-left-color: var(--carnelian);
  font-weight: var(--fw-semi);
}

.sidebar__link--inactive {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar__icon {
  width: 16px;
  height: 16px;
  opacity: 0.6;
  flex-shrink: 0;
}

.sidebar__link--active .sidebar__icon {
  opacity: 1;
}

.sidebar__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__footer {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border-top: 1px solid var(--border-hair);
  flex-shrink: 0;
}

.sidebar__commit {
  font-size: 11px;
  color: var(--gray-400);
  font-family: monospace;
}

html[data-sidebar="collapsed"] .sidebar__section {
  width: calc(100% - var(--sp-5));
  height: 1px;
  margin: var(--sp-4) auto var(--sp-2);
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: var(--border-hair);
}

html[data-sidebar="collapsed"] .sidebar__section:first-child {
  margin-top: 0;
  background: transparent;
}

html[data-sidebar="collapsed"] .sidebar__link {
  justify-content: center;
  gap: 0;
  padding: var(--sp-3) 0;
}

html[data-sidebar="collapsed"] .sidebar__link--active {
  border-left-color: transparent;
}

html[data-sidebar="collapsed"] .sidebar__icon {
  width: 18px;
  height: 18px;
}

html[data-sidebar="collapsed"] .sidebar__label {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

html[data-sidebar="collapsed"] .sidebar__footer {
  flex-direction: column;
  justify-content: center;
  padding-right: 0;
  padding-left: 0;
}

html[data-sidebar="collapsed"] .sidebar__commit {
  text-align: center;
}

html[data-sidebar="collapsed"] .sidebar__body {
  scrollbar-width: none;
}

html[data-sidebar="collapsed"] .sidebar__body::-webkit-scrollbar {
  display: none;
}

.sidebar-tooltip {
  position: fixed;
  z-index: 2000;
  top: 0;
  left: 0;
  padding: 6px 9px;
  border: 1px solid rgba(247, 246, 242, 0.12);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-2);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%) translateX(-2px);
  transition: opacity var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard),
              visibility var(--dur-fast) var(--ease-standard);
}

.sidebar-tooltip--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* === Main content === */
.main {
  overflow-y: auto;
  padding: var(--sp-6);
}

.main__header {
  margin-bottom: var(--sp-6);
}

.main__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-brand);
  margin-bottom: var(--sp-2);
}

.main__title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 500;
  font-variation-settings: "opsz" 48;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--fg-1);
}

.main__subtitle {
  font-size: var(--fs-base);
  color: var(--fg-3);
  margin-top: var(--sp-2);
  line-height: 1.55;
}

.main__location {
  font-size: var(--fs-lg);
  color: var(--fg-3);
  margin-top: var(--sp-1);
}

/* === Dashboard sections === */
.dash-section {
  margin-bottom: var(--sp-7);
}

.dash-section__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-hair);
}

/* === Cards === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-5);
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-base) var(--ease-standard);
}

.card:hover {
  border-color: var(--border-soft);
  box-shadow: var(--shadow-2);
}

a.card {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.card__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-brand);
  margin-bottom: var(--sp-3);
}

.card__title {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.01em;
}

.card__desc {
  font-size: var(--fs-sm);
  color: var(--fg-3);
  line-height: 1.55;
}

.card__status {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-hair);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
}

.badge--info {
  background: rgba(30, 77, 216, 0.08);
  color: var(--blueprint);
}

.badge--success {
  background: rgba(46, 125, 79, 0.08);
  color: var(--chlorophyll);
}

.badge--warning {
  background: rgba(244, 160, 44, 0.12);
  color: #b47800;
}

.badge--danger {
  background: rgba(179, 27, 27, 0.08);
  color: var(--carnelian);
}

.badge--neutral {
  background: var(--fog);
  color: var(--fg-4);
}

.badge__label {
  opacity: 0.7;
  font-weight: var(--fw-regular);
  margin-right: 2px;
}

/* === Tables === */
.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-weight: var(--fw-semi);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-4);
  background: var(--bg-3);
  border-bottom: 1px solid var(--border-hair);
}

.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-hair);
  color: var(--fg-2);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: var(--bg-3);
}

/* === Empty states === */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
}

.empty-state__icon {
  font-size: 2rem;
  margin-bottom: var(--sp-4);
  opacity: 0.3;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 500;
  font-variation-settings: "opsz" 24;
  color: var(--fg-3);
  margin-bottom: var(--sp-2);
}

.empty-state__desc {
  font-size: var(--fs-sm);
  color: var(--fg-4);
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.55;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
  text-decoration: none;
  line-height: 1;
}

.btn--primary {
  background: var(--carnelian);
  color: var(--white);
}

.btn--primary:hover {
  background: var(--carnelian-deep);
  color: var(--white);
  text-decoration: none;
}

.btn--secondary {
  background: transparent;
  color: var(--fg-1);
  border-color: var(--ink);
}

.btn--secondary:hover {
  background: rgba(18,20,23,0.06);
}

.btn--ghost {
  background: transparent;
  color: var(--fg-2);
}

.btn--ghost:hover {
  background: rgba(18,20,23,0.06);
  color: var(--fg-1);
}

.btn--danger {
  background: var(--carnelian-bright);
  color: var(--white);
  border-color: transparent;
}

.btn--danger:hover {
  background: var(--carnelian-deep);
  color: var(--white);
  text-decoration: none;
}

.btn--success {
  background: var(--chlorophyll);
  color: var(--white);
  border-color: transparent;
}

.btn--success:hover {
  background: color-mix(in srgb, var(--chlorophyll) 85%, var(--ink));
  color: var(--white);
  text-decoration: none;
}

/* === Toolbar / Filter bar === */
.toolbar {
  margin-bottom: var(--sp-5);
}

.toolbar__form {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* === Annotation workflow tabs === */
.annotation-tabs {
  display: inline-flex;
  gap: 3px;
  margin-bottom: var(--sp-6);
  padding: 4px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg-2) 82%, var(--bg-3));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--white) 70%, transparent);
}

.annotation-tab {
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 var(--sp-4);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  border-radius: var(--r-md);
  border-bottom: 0;
  white-space: nowrap;
}

.annotation-tab:hover {
  color: var(--fg-1);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  text-decoration: none;
}

.annotation-tab--active {
  color: var(--white);
  background: var(--ink);
  box-shadow: var(--shadow-1);
}

/* Toolbar controls share one control language: 34px tall, white editable
   surface, soft border, r-md corners; hover firms the border, focus is the
   carnelian ring. The select drops the native chrome for a drawn chevron. */
.toolbar__search,
.toolbar__select {
  box-sizing: border-box;
  height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  background: var(--white);
  color: var(--fg-1);
  transition: border-color var(--dur-fast) var(--ease-standard);
}

.toolbar__search:hover,
.toolbar__select:hover {
  border-color: var(--border-firm);
}

.toolbar__search:focus,
.toolbar__select:focus {
  outline: none;
  border-color: var(--carnelian);
}

.toolbar__search {
  min-width: 220px;
}

.toolbar__search::placeholder {
  color: var(--fg-4);
}

.toolbar__select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23787468' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

/* The DROPDOWN PANEL is OS chrome — plain CSS can't reach it. Where the
   customizable-select API exists (Chromium 2025+), opt in and theme the
   panel to the paper/ink language; Safari/Firefox keep the native picker,
   same behavior. Our own chevron stays; the base UA one is hidden. */
@supports (appearance: base-select) {
  .toolbar__select,
  .toolbar__select::picker(select) {
    appearance: base-select;
  }

  .toolbar__select::picker-icon {
    display: none;
  }

  .toolbar__select::picker(select) {
    margin-top: 4px;
    padding: 4px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    background: var(--white);
    box-shadow: var(--shadow-2);
  }

  .toolbar__select option {
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    color: var(--fg-1);
    cursor: pointer;
  }

  .toolbar__select option:hover,
  .toolbar__select option:focus {
    background: var(--bg-2);
  }

  .toolbar__select option:checked {
    background: var(--ink);
    color: var(--fg-inverse);
  }

  .toolbar__select option::checkmark {
    display: none;
  }
}

.btn--sm {
  padding: 7px 10px;
  font-size: var(--fs-xs);
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
}

.pagination__info {
  font-size: var(--fs-sm);
  color: var(--fg-4);
  font-family: var(--font-mono);
}

/* === Table extras === */
.table__link {
  color: var(--fg-1);
  font-weight: var(--fw-medium);
  text-decoration: none;
}

.table__link:hover {
  color: var(--carnelian);
  text-decoration: underline;
}

.table__date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
  white-space: nowrap;
}

.table__mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* Edge-derived qualifier after a bare instance name ("· Kadıköy") */
.table__context {
  color: var(--fg-3);
  font-size: var(--fs-xs);
  margin-left: 6px;
  white-space: nowrap;
}

.table__content {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* === Entity list (knowledge-graph browse page) === */

/* Type facet bar — one chip per entity type, dot colored by identity family */
.facetbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.facet {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-pill);
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-standard);
}

.facet:hover {
  border-color: var(--border-firm);
  text-decoration: none;
}

.facet--on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.facet__count {
  font-family: var(--font-mono);
  color: var(--fg-4);
}

.facet--on .facet__count {
  color: var(--mist);
}

.facet__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.facet__dot--catalog { background: var(--chlorophyll); }
.facet__dot--registry { background: var(--blueprint); }
.facet__dot--instance { background: var(--sodium); }
.facet__dot--unknown { background: var(--mist); }

/* When no legend row sits between them (triplets page), give the toolbar
   the same breathing room the legend provides on the entities page. */
.facetbar + .toolbar {
  margin-top: var(--sp-4);
}

/* Run description tail in the triplets subtitle (blast-radius view) */
.subtitle-runline {
  color: var(--fg-4);
  font-size: var(--fs-sm);
}

/* Row-level type badges double as filter toggles: pill styling signals
   clickability, hover ring confirms it, active state reads as a removable
   filter chip (bold ring + ×). */
a.type-link {
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease-standard);
}

/* Compact in table rows — quieter than the canonical name above it */
.table--edges .table__contextline {
  margin-top: 4px;
}

.table--edges a.type-link {
  font-size: 0.6875rem;
  padding: 1px 7px;
  gap: 5px;
}

.table--edges a.type-link .facet__dot {
  width: 6px;
  height: 6px;
}

a.type-link:hover {
  box-shadow: inset 0 0 0 1px currentColor;
  text-decoration: none;
}

a.type-link--on {
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.type-link__x {
  margin-left: 2px;
  font-weight: var(--fw-semi);
}

/* Leading dimension label for pages with more than one facet bar */
.facetbar__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-4);
  align-self: center;
  min-width: 72px;
}

.facetbar__legend {
  font-size: var(--fs-xs);
  color: var(--fg-4);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.facetbar__legend .facet__dot {
  width: 7px;
  height: 7px;
  margin-left: var(--sp-2);
}

/* Sort — segmented control, same visual language as .annotation-tabs */
.sortseg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg-2) 82%, var(--bg-3));
}

.sortseg__label {
  color: var(--fg-4);
  font-size: var(--fs-xs);
  padding: 0 4px 0 8px;
  cursor: default;
}

.sortseg__opt {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-3);
  text-decoration: none;
  white-space: nowrap;
}

.sortseg__opt:hover {
  color: var(--fg-1);
  text-decoration: none;
}

.sortseg__opt--on {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-1);
}

.sortseg__opt--on:hover {
  color: var(--paper);
}

/* Direction arrow on the active segment — re-clicking it flips asc/desc */
.sortseg__dir {
  margin-left: 4px;
  font-family: var(--font-mono);
  opacity: 0.7;
}

/* Entity name cell */
.table__link--strong {
  font-weight: var(--fw-semi);
}

.table__contextline {
  display: block;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-top: 2px;
}

.qid-tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--blueprint);
  border: 1px solid var(--blueprint-soft);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  margin-left: 6px;
  white-space: nowrap;
  text-decoration: none;
}

a.qid-tag:hover {
  border-color: var(--blueprint);
  color: var(--blueprint);
}

a.type-badge {
  text-decoration: none;
}

/* Type badge — tinted by identity family */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  background: var(--fog);
  color: var(--fg-2);
  white-space: nowrap;
}

.type-badge--catalog { background: var(--chlorophyll-soft); color: #1d5636; }
.type-badge--registry { background: var(--blueprint-soft); color: #173a9e; }
.type-badge--instance { background: var(--sodium-soft); color: #8a5507; }

/* Degree — exact edge count; zero grayed out */
.deg {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.deg--zero {
  color: var(--fg-4);
}

/* Neighborhood summary — predicate chips with direction + count */
.nbh {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 340px;
}

.pred-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--fg-2);
  background: var(--bg-3);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  white-space: nowrap;
}

/* The anchor dot = "this row's entity"; the arrow beside it is the only
   thing that flips between outgoing (→) and incoming (←). */
.pred-chip__me {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fg-3);
  flex: 0 0 auto;
}

.pred-chip__dir {
  color: var(--carnelian-deep);
  font-weight: var(--fw-semi);
  line-height: 1;
}

.pred-chip b {
  font-weight: var(--fw-medium);
  color: var(--carnelian-deep);
}

.pred-chip--rest {
  color: var(--fg-4);
  border-style: dashed;
}

.nbh__none {
  font-size: var(--fs-xs);
  color: var(--fg-4);
  font-style: italic;
}

/* Per-row "open in graph viewer" quick action — quiet until the row is hovered */
.rowact {
  text-align: right;
  white-space: nowrap;
}

.rowact a {
  font-size: var(--fs-sm);
  color: var(--fg-4);
  text-decoration: none;
  opacity: 0.35;
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

tr:hover .rowact a {
  opacity: 1;
  color: var(--blueprint);
}

.rowact a:hover {
  background: var(--blueprint-soft);
}

/* === Triplet list (edge browse page) === */

/* Subject column right-aligns against the predicate spine so the arrows
   line up vertically and the table reads as a list of edges. */
.table--edges th.edgecell--subj,
.table--edges td.edgecell--subj {
  text-align: right;
  width: 24%;
}

.table--edges .edgecell--pred {
  text-align: center;
  white-space: nowrap;
  width: 1%;
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

.edge-pred {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--fw-medium);
  color: var(--carnelian-deep);
  white-space: nowrap;
}

.edge-pred--none {
  color: var(--fg-4);
}

/* Confidence — tiny meter + number, tinted by band */
.conf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.conf__bar {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-3);
  overflow: hidden;
  flex: 0 0 auto;
}

.conf__fill {
  display: block;
  height: 100%;
  border-radius: 2px;
}

.conf--high .conf__fill { background: var(--chlorophyll); }
.conf--mid .conf__fill { background: var(--sodium); }
.conf--low .conf__fill { background: var(--carnelian-deep); }

.conf__num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* Evidence count — quiet badge deep-linking to the edge's provenance */
.ev-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  text-decoration: none;
}

a.ev-count:hover {
  border-color: var(--blueprint);
  color: var(--blueprint);
  text-decoration: none;
}

.ev-count--zero {
  border-style: dashed;
  color: var(--fg-4);
}

/* Edge properties — key·value chips, full JSON expandable via <details> */
.props__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  cursor: pointer;
  list-style: none;
  max-width: 300px;
}

.props__summary::-webkit-details-marker {
  display: none;
}

.prop-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 0.6875rem;
  color: var(--fg-2);
  background: var(--bg-3);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  white-space: nowrap;
}

.prop-chip__key {
  font-family: var(--font-mono);
  color: var(--fg-4);
}

.prop-chip--rest {
  color: var(--fg-4);
  border-style: dashed;
}

.props[open] .props__summary .prop-chip {
  border-color: var(--border-firm);
}

.props__json {
  margin-top: var(--sp-2);
  max-width: 300px;
  max-height: 240px;
  overflow: auto;
  padding: var(--sp-2);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--fg-2);
}

.props__json--wide {
  max-width: none;
  max-height: 360px;
}

/* === Triplet detail (fact page) === */

/* The edge sentence as the page title */
.fact-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 12px;
}

.fact-title__node {
  color: inherit;
  text-decoration: none;
}

.fact-title__node:hover {
  color: var(--carnelian-deep);
  text-decoration: none;
}

.edge-pred--title {
  font-size: 0.55em;
  font-weight: var(--fw-semi);
  letter-spacing: 0.02em;
}

.fact-subtitle__arrow {
  color: var(--fg-4);
  margin: 0 2px;
}

.fact-subtitle__id {
  font-size: var(--fs-xs);
  color: var(--fg-4);
}

/* Evidence quote cards */
.fact-ev {
  border-left: 3px solid var(--border-firm);
  padding: var(--sp-2) var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--bg-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.fact-ev__excerpt {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--fg-1);
}

.fact-ev__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* Where in the document the excerpt lives: section outline trail */
.fact-ev__section {
  color: var(--fg-4);
  font-style: italic;
}

/* Side-panel key/value lines */
.fact-side__line {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-top: var(--sp-2);
  overflow-wrap: anywhere;
}

.fact-side__label {
  color: var(--fg-4);
  margin-right: 4px;
}

/* Jargon terms carry a hover explanation — dotted underline signals it */
.fact-side__term {
  border-bottom: 1px dotted var(--fg-4);
  cursor: help;
}

.fact-side__desc {
  color: var(--fg-3);
  font-style: italic;
}

/* Ontology allowed-pairs list */
.ont-pairs {
  margin-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ont-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  padding: 3px 8px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  color: var(--fg-3);
}

.ont-pair--match {
  border-color: var(--chlorophyll);
  color: var(--fg-1);
  background: var(--chlorophyll-soft);
}

.ont-pair__ver {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--fg-4);
}

.ont-note {
  font-size: var(--fs-xs);
  margin-top: var(--sp-3);
}

/* === Entity detail === */
/* Cap and center the whole page (header + grid) so ultrawide screens get
   symmetric margins instead of one dead strip on the right. */
.detail-page {
  max-width: 1480px;
  margin-inline: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--sp-6);
  align-items: start;
}

@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-section {
  margin-bottom: var(--sp-5);
}

.detail-section__title {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  color: var(--fg-2);
  margin-bottom: var(--sp-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-muted {
  color: var(--fg-3);
}

.evidence-quote {
  border-left: 2px solid var(--blueprint);
  padding: 2px 8px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  line-height: 1.5;
}

.evidence-quote__none {
  color: var(--fg-3);
  font-style: italic;
}

.evidence-quote__meta {
  display: block;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.evidence-cell {
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* Relationships grouped by predicate — one soft card per group, header
   carries direction + predicate + shared-type summary */
.rel-group {
  background: var(--bg-2);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
}

.rel-group__head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: var(--sp-3);
}

.rel-group__dir {
  color: var(--carnelian-deep);
  font-family: var(--font-mono);
  font-weight: var(--fw-semi);
  line-height: 1;
}

.rel-group__pred {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.04em;
  color: var(--fg-1);
}

.rel-group__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
}

.rel-group__items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.rel-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-hair);
  border-radius: var(--r-pill);
  background: var(--white);
  font-size: var(--fs-xs);
  color: var(--fg-1);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-standard);
}

.rel-item:hover {
  border-color: var(--border-firm);
  text-decoration: none;
}

.rel-item__type {
  color: var(--fg-4);
}

.rel-item__conf {
  font-family: var(--font-mono);
  color: var(--fg-4);
}

.rel-item--rest {
  border-style: dashed;
  color: var(--fg-4);
}

.rel-item--hidden {
  display: none;
}

/* "+N more" expander (a <button>) and the browse-all deep link */
button.rel-item {
  font-family: var(--font-sans);
  cursor: pointer;
  background: var(--bg-2);
}

button.rel-item:hover {
  color: var(--fg-2);
  border-color: var(--border-firm);
}

.rel-item--browse {
  color: var(--blueprint);
  border-color: var(--blueprint-soft);
}

/* Sticky neighborhood panel */
.detail-grid__side {
  position: sticky;
  top: var(--sp-4);
}

/* Stacked side cards (triplet detail) breathe apart */
.detail-grid__side .ego-panel + .ego-panel {
  margin-top: var(--sp-4);
}

.ego-panel {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

.ego-panel__title {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-bottom: var(--sp-2);
}

.ego-svg {
  width: 100%;
  height: auto;
}

.ego-svg a {
  text-decoration: none;
}

.ego-svg__orbit {
  fill: none;
  stroke: var(--border-hair);
  stroke-dasharray: 2 4;
}

.ego-svg__edge {
  stroke: var(--mist);
  stroke-width: 1.25;
}

.ego-svg__edge--rest {
  stroke-dasharray: 3 3;
}

.ego-svg__node {
  stroke-width: 1.5;
  transition: stroke-width var(--dur-fast) var(--ease-standard);
}

.ego-svg a:hover .ego-svg__node {
  stroke-width: 3;
}

.ego-svg__node--catalog { fill: var(--chlorophyll-soft); stroke: var(--chlorophyll); }
.ego-svg__node--registry { fill: var(--blueprint-soft); stroke: var(--blueprint); }
.ego-svg__node--instance { fill: var(--sodium-soft); stroke: var(--sodium); }
.ego-svg__node--unknown { fill: var(--fog); stroke: var(--concrete); }

.ego-svg__node--rest {
  fill: var(--fog);
  stroke: var(--concrete);
  stroke-dasharray: 3 2;
}

.ego-svg__label {
  font-family: var(--font-sans);
  font-size: 10.5px;
  fill: var(--fg-2);
  /* Halo so labels stay legible when they sit on a spoke or the orbit. */
  paint-order: stroke;
  stroke: var(--bg-2);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.ego-svg__rest-count {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--fg-3);
}

.ego-svg__focus-ring {
  fill: none;
  stroke: var(--carnelian);
  stroke-opacity: 0.25;
  stroke-width: 2;
}

.ego-svg__focus {
  fill: var(--carnelian);
}

.ego-svg__focus-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--white);
}

/* Dumbbell edge-context panel (triplet detail): two endpoint neighborhoods
   joined by the viewed fact. */
.fact-dumbbell {
  border: 1px solid var(--border-hair);
  border-radius: 8px;
  background: var(--white);
}
/* Cap the drawing size — at full content width the circles and labels blow
   up into a cartoonish scale; the diagram reads best near its design size. */
.fact-dumbbell svg {
  display: block;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}
.ego-svg__bridge {
  stroke: var(--carnelian);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-opacity: 0.85;
}
.ego-svg__bridge-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  fill: var(--carnelian-deep);
  paint-order: stroke;
  stroke: var(--white);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.ego-svg__label--endpoint { font-weight: 600; font-size: 11px; }
.fact-dumbbell__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border-hair);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--fg-3);
}

.ego-panel__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.ego-stat {
  background: var(--bg-3);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
}

.ego-stat__v {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

.ego-stat__l {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-top: 1px;
}

.ego-panel__open {
  display: block;
  text-align: center;
  margin-top: var(--sp-3);
  padding: var(--sp-2);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-decoration: none;
}

.ego-panel__open:hover {
  background: var(--ink-2);
  text-decoration: none;
}

/* === Detail list (key-value pairs) === */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
}

.detail-list dt {
  color: var(--fg-4);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.detail-list dd {
  color: var(--fg-2);
  word-break: break-all;
}

.detail-list__mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.detail-list__empty {
  grid-column: 1 / -1;
  color: var(--fg-4);
  font-style: italic;
}

.detail-list--inline {
  grid-template-columns: auto 1fr auto 1fr;
}

@media (max-width: 640px) {
  .detail-list--inline {
    grid-template-columns: auto 1fr;
  }
}

/* === Detail stack (stacked cards for detail pages) === */
.detail-stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* === Section headers (within page) === */
.section-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-hair);
}

.section-header__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 500;
  font-variation-settings: "opsz" 24;
  color: var(--fg-1);
}

.section-header__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
  background: var(--fog);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

/* === Chunk path breadcrumb === */
.chunk-path {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-style: italic;
}

/* === Breadcrumb links === */
.breadcrumb__link {
  color: var(--fg-3);
  text-decoration: none;
}

.breadcrumb__link:hover {
  color: var(--carnelian);
  text-decoration: underline;
}

/* === Feedback === */
.feedback-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.feedback-suggested {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.feedback-suggested__chip {
  display: inline-block;
  padding: 2px 6px;
  background: var(--blueprint-soft);
  color: var(--blueprint);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
}

.feedback-row:hover td {
  background: var(--bg-3);
}

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 20, 23, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay--open {
  display: flex;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border-hair);
}

.modal__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 500;
  font-variation-settings: "opsz" 24;
  color: var(--fg-1);
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--fg-4);
  cursor: pointer;
  line-height: 1;
  padding: var(--sp-1);
}

.modal__close:hover {
  color: var(--fg-1);
}

.modal__body {
  padding: var(--sp-5);
  overflow-y: auto;
}

.modal__thumb {
  max-width: 200px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-hair);
  margin-top: var(--sp-2);
}

.modal__footer {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
  border-top: 1px solid var(--border-hair);
}

.modal--danger .modal__title {
  color: var(--carnelian);
}

.modal__warning {
  background: rgba(179, 27, 27, 0.06);
  border: 1px solid rgba(179, 27, 27, 0.2);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--fg-2);
  line-height: 1.55;
  margin-bottom: var(--sp-4);
}

.modal__warning strong {
  color: var(--carnelian);
}

.modal__confirm-text {
  font-size: var(--fs-sm);
  color: var(--fg-3);
}

/* === Document selection picker === */
.document-selection-chip {
  align-items: center;
  background: color-mix(in srgb, var(--blueprint-soft) 48%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--blueprint) 22%, var(--border-hair));
  border-radius: var(--r-md);
  color: var(--fg-2);
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
}

.document-selection-chip button {
  background: transparent;
  border: 0;
  color: var(--blueprint);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  padding: 0;
  text-decoration: none;
}

.document-selection-chip button:hover {
  text-decoration: underline;
}

.doc-picker-modal {
  background: transparent;
  border: 0;
  inset: 50% auto auto 50%;
  margin: 0;
  max-width: min(720px, calc(100vw - 32px));
  padding: 0;
  position: fixed;
  transform: translate(-50%, -50%);
  width: 720px;
}

.doc-picker-modal::backdrop {
  background: rgba(18, 20, 23, 0.52);
}

.doc-picker {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  color: var(--fg-1);
  display: flex;
  flex-direction: column;
  max-height: min(760px, 84vh);
  overflow: hidden;
}

.doc-picker__header,
.doc-picker__footer {
  align-items: center;
  display: flex;
  gap: var(--sp-4);
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
}

.doc-picker__header {
  border-bottom: 1px solid var(--border-hair);
}

.doc-picker__footer {
  border-top: 1px solid var(--border-hair);
}

.doc-picker__title {
  color: var(--fg-1);
  font-size: var(--fs-lg);
  font-weight: 700;
  margin: 0;
}

.doc-picker__subtitle {
  color: var(--fg-4);
  font-size: var(--fs-xs);
  margin: var(--sp-1) 0 0;
}

.doc-picker__toolbar,
.doc-picker__bulk {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
}

.doc-picker__toolbar {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-hair);
}

.doc-picker__search {
  flex: 1;
  min-width: 220px;
}

.doc-picker__type-filter {
  min-width: 150px;
}

.doc-picker__toggle {
  align-items: center;
  color: var(--fg-3);
  display: inline-flex;
  font-size: var(--fs-xs);
  gap: var(--sp-2);
  white-space: nowrap;
}

.doc-picker__bulk {
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}

.doc-picker__limit {
  color: var(--carnelian);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  margin-left: auto;
}

.doc-picker__list {
  background: var(--bg-2);
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 260px;
  overflow-y: auto;
}

.doc-picker__row {
  align-items: flex-start;
  border-top: 1px solid var(--border-hair);
  cursor: pointer;
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
}

.doc-picker__row:first-child {
  border-top: 0;
}

.doc-picker__row:hover {
  background: var(--bg-3);
}

.doc-picker__row input {
  margin-top: 2px;
}

.doc-picker__row-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.doc-picker__row-title {
  color: var(--fg-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-picker__row-meta {
  color: var(--fg-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-picker__empty {
  color: var(--fg-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: var(--sp-5);
  text-align: center;
}

.doc-picker__more {
  align-items: center;
  border-top: 1px solid var(--border-hair);
  display: flex;
  justify-content: center;
  min-height: 42px;
  padding: var(--sp-2);
}

.doc-picker__count {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  margin-right: auto;
}

/* === Bulk action bar === */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: rgba(179, 27, 27, 0.04);
  border: 1px solid rgba(179, 27, 27, 0.15);
  border-radius: var(--r-md);
}

.bulk-bar__count {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-2);
}

/* === Table checkbox column === */
.table__check-col {
  width: 36px;
  text-align: center;
  padding-left: var(--sp-3) !important;
  padding-right: 0 !important;
}

.table__check-col input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* === Document detail thumbnail === */
.doc-detail__thumb {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-hair);
  margin-top: var(--sp-2);
}

/* === Danger zone card === */
.card--danger {
  border-color: rgba(179, 27, 27, 0.2);
}

.card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.card__desc {
  font-size: var(--fs-sm);
  color: var(--fg-3);
  margin-top: var(--sp-1);
}

@media (max-width: 560px) {
  .header {
    gap: var(--sp-3);
    padding-right: var(--sp-4);
    padding-left: var(--sp-4);
  }

  .header__actions {
    margin-left: auto;
  }

  .header__user {
    display: none;
  }
}

@media (max-width: 420px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    height: auto;
    min-height: 100vh;
  }

  .header {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: var(--sp-3) var(--sp-4);
  }

  .header__brand {
    min-width: 0;
  }

  .header__project,
  .header__section {
    font-size: var(--fs-sm);
  }

  .sidebar {
    grid-column: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--sp-1);
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--sp-2) var(--sp-3);
    border-right: 0;
    border-bottom: 1px solid var(--border-hair);
  }

  .sidebar__body {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
  }

  .sidebar__section,
  html[data-sidebar="collapsed"] .sidebar__section {
    display: none;
  }

  .sidebar__link,
  html[data-sidebar="collapsed"] .sidebar__link {
    flex: 0 0 auto;
    justify-content: flex-start;
    gap: var(--sp-2);
    min-height: 36px;
    padding: var(--sp-2) var(--sp-3);
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .sidebar__link--active,
  html[data-sidebar="collapsed"] .sidebar__link--active {
    border-bottom-color: var(--carnelian);
  }

  html[data-sidebar="collapsed"] .sidebar__icon {
    width: 16px;
    height: 16px;
  }

  html[data-sidebar="collapsed"] .sidebar__label {
    width: auto;
    opacity: 1;
  }

  .sidebar__footer,
  html[data-sidebar="collapsed"] .sidebar__footer {
    display: none;
  }

  .main {
    overflow: visible;
    padding: var(--sp-5) var(--sp-4);
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-wrap {
    overflow-x: auto;
  }
}

/* === Selection === */
::selection {
  background: var(--sodium-soft);
  color: var(--ink);
}

/* === Auth header elements === */
.header__user {
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.header__logout {
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  color: var(--fg-2);
  cursor: pointer;
  font-size: var(--fs-xs);
  padding: 2px 8px;
  margin-left: var(--sp-2);
  transition: color 0.15s, border-color 0.15s;
}

.header__logout:hover {
  color: var(--fg-1);
  border-color: var(--fg-2);
}

/* === Alert banners === */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
  line-height: 1.5;
}

.alert code {
  font-family: monospace;
  background: rgba(0,0,0,0.07);
  padding: 1px 4px;
  border-radius: 3px;
}

.alert--warning {
  background: rgba(234, 158, 11, 0.1);
  border-color: rgba(234, 158, 11, 0.3);
  color: var(--fg-1);
}

.alert--danger {
  background: rgba(179, 27, 27, 0.08);
  border-color: rgba(179, 27, 27, 0.25);
  color: var(--fg-1);
}

.alert--success {
  background: rgba(22, 130, 70, 0.08);
  border-color: rgba(22, 130, 70, 0.25);
  color: var(--fg-1);
}

/* === Upload / data-entry forms === */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.form__section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.form__section-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-hair);
}

.form__optional {
  font-weight: 400;
  text-transform: none;
  color: var(--fg-3);
}

.form__row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.form__row--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-3);
}

.form__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-2);
}

.form__required {
  color: var(--danger, #b31b1b);
}

.form__input {
  width: 100%;
  padding: 6px 10px;
  /* --border-soft/--white, NOT the undefined --border-1/--surface-1 this
     rule shipped with: an unresolvable var() drops the whole declaration,
     which left every input in the admin border-less and background-less —
     indistinguishable from plain text. */
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--white);
  color: var(--fg-1);
  font-size: var(--fs-sm);
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.form__input:focus {
  outline: none;
  border-color: var(--sodium);
}

.form__input[type="file"] {
  padding: 4px 6px;
}

.form__checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--fg-1);
  cursor: pointer;
}

.form__checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}

.form__hint {
  color: var(--fg-3);
  font-size: var(--fs-xs);
  display: block;
  margin-top: 2px;
}

.form__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-top: var(--sp-2);
}

/* === Help tips (researcher pages) ===
   Floating layer + circled-? trigger for [data-tip] hovers, driven by the
   shared js/incoming-tooltip.js. .wb-tip is also defined locally in
   _incoming_queue_base.html's style block (same values) — this global copy
   serves pages that don't extend that base. */
.wb-tip {
  position: fixed;
  z-index: 200;
  max-width: 340px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--fg-inverse);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: var(--shadow-2);
  pointer-events: none;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: var(--sp-1);
  border: 1px solid var(--fg-4);
  border-radius: 50%;
  color: var(--fg-3);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: var(--fw-semibold, 600);
  line-height: 1;
  vertical-align: text-bottom;
  cursor: help;
  user-select: none;
  flex: none;
}

.help-tip:hover {
  color: var(--fg-1);
  border-color: var(--fg-3);
  background: var(--bg-3);
}

/* Task detail: contextual curation actions — one row per allowed
   transition, the consequence written next to the button instead of
   hiding in a hover tip. */
.action-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
}

.action-item + .action-item {
  border-top: 1px solid var(--border-hair);
}

.action-item form {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  flex: none;
}

.action-item__desc {
  flex: 1 1 240px;
  color: var(--fg-3);
  font-size: 12.5px;
  line-height: 1.5;
}

.action-item__inline {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--fg-3);
  font-size: 12.5px;
  white-space: nowrap;
}

.action-item__inline .form__input {
  width: 64px;
  padding: 4px 8px;
  font-size: 12.5px;
}

/* Sortable table headers (global twin of the workbench-local .index-sort
   in _incoming_queue_base.html — same look, so sorting reads identically
   everywhere). */
.index-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.index-sort:hover {
  color: var(--fg-1);
}

.index-sort--active {
  color: var(--fg-1);
}

.index-sort__arrow {
  font-size: 9px;
  line-height: 1;
  opacity: 0.45;
}

.index-sort--active .index-sort__arrow {
  opacity: 1;
}

/* Toggle chips for boolean toolbar filters — a bare checkbox floating in
   a toolbar reads as form debris. The chip is legible in both states:
   outlined at rest, ink-filled with a check when active. The real
   checkbox stays in the DOM (the form submits it), visually hidden. */
.filter-chip {
  position: relative;
  box-sizing: border-box;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--white);
  color: var(--fg-2);
  font-size: var(--fs-sm);
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.filter-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-chip:hover {
  border-color: var(--border-firm);
  color: var(--fg-1);
}

.filter-chip:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--fg-inverse);
}

.filter-chip:has(input:checked)::before {
  content: "✓";
  font-size: 11px;
}

.filter-chip:has(input:focus-visible) {
  outline: 2px solid var(--sodium);
  outline-offset: 1px;
}

/* Page-level section heading for content pages (researcher dashboard).
   NOT .form__section-title — that's a fieldset label with margin:0 whose
   rule relies on .form__row spacing below it; borrowed on a content page
   it glues the content straight onto its divider. Typography follows the
   main dashboard's .dash-section__label. */
.page-section-title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin: var(--sp-7) 0 var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-hair);
}

/* Overview: open-tasks-by-band bars. Thin ink marks (red stays reserved
   for status/accent), rounded at the data end only, the value directly
   at the bar end — never in a far-right column across dead space. Zero
   renders as a muted 0 with no bar. */
.band-chart {
  display: grid;
  grid-template-columns: 230px 1fr;
  row-gap: var(--sp-3);
  align-items: center;
  max-width: 760px;
}

.band-chart__label {
  display: flex;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--fg-1);
}

.band-chart__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 20px;
}

.band-chart__bar {
  flex: none;
  height: 12px;
  min-width: 2px;
  background: var(--ink);
  border-radius: 0 4px 4px 0;
}

.band-chart__value {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12.5px;
  color: var(--fg-1);
}

.band-chart__value--zero {
  color: var(--fg-3);
}

.band-chart__share {
  font-size: 12px;
  color: var(--fg-3);
}

/* Task detail: Priority card anatomy — big number + band badge on one
   line, then the score receipt as term pills (hover for what each term
   means), then a single-line pin control. */
.priority-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.priority-receipt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.priority-receipt__term {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11.5px;
  color: var(--fg-2);
  background: var(--bg-2);
  border: 1px solid var(--border-hair);
  border-radius: 999px;
  padding: 2px 9px;
  cursor: help;
  white-space: nowrap;
}

.priority-receipt__context {
  color: var(--fg-3);
  font-size: 12px;
  cursor: help;
}

/* The pin lives on the Priority card (it IS a priority control, not a
   separate action). Hidden on terminal tasks; the long explanation sits
   behind the circled-? tip. */
.pin-form-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.pin-form__label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-3);
  font-size: 12.5px;
  font-weight: var(--fw-semibold, 600);
}

.pin-form {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
}

.pin-form .form__input {
  width: 84px;
  padding: 4px 8px;
  font-size: 13px;
}

.card__hint {
  margin-top: var(--sp-2);
  color: var(--fg-3);
  font-size: 12px;
  line-height: 1.45;
}

/* Clusters page: the per-row CLI copy buttons are identical on every row —
   at rest they read as noise, so they stay invisible (opacity keeps their
   width, no layout jitter) until the row is hovered or focused. */
.cli-actions .btn {
  opacity: 0;
  transition: opacity 0.12s ease;
}

tr:hover .cli-actions .btn,
tr:focus-within .cli-actions .btn,
.cli-actions .btn:focus-visible {
  opacity: 1;
}
