:root {
  --bg: #f9fafd;
  --surface: #ffffff;
  --surface-muted: #eff1f7;
  --surface-selected: #e6ecfe;
  --text: #1e2333;
  --text-strong: #191e30;
  --muted: #5f6678;
  --muted-soft: #9b9ea5;
  --border: #dfe2ea;
  --border-strong: #bcc4da;
  --primary: #3346b8;
  --primary-dark: #2c3e92;
  --accent: #3346b8;
  --danger: #d42f34;
  --success: #009162;
  --focus: #526ac3;
  --shadow-sm: 0 1px 3px rgba(25, 30, 48, 0.08);
  --shadow-md: 0 8px 24px rgba(51, 70, 184, 0.12);
  --radius: 8px;
  --header-height: 68px;
  --font-body: "Fira Sans", "Microsoft YaHei", sans-serif;
  --font-mono: "Fira Code", ui-monospace, SFMono-Regular, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

:focus-visible {
  outline: 3px solid rgba(82, 106, 195, 0.42);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}
.mono {
  font-family: var(--font-mono);
  font-size: 11px;
}
.muted {
  color: var(--muted);
}

.login-panel {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f6f8ff, #eef3fb);
}
.login-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 34px;
}
.login-brand strong,
.login-brand span {
  display: block;
}
.login-brand strong {
  color: var(--text-strong);
  font-size: 17px;
}
.login-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.login-card h1 {
  margin-bottom: 8px;
  font-size: 28px;
}
.login-description {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 12px;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-field {
  display: grid;
  gap: 6px;
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 600;
}
.login-field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f9fafd;
  color: var(--text-strong);
  font-size: 14px;
}
.login-field input:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.16);
}
.login-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}
.login-code-row .button {
  min-height: 42px;
  white-space: nowrap;
}
.login-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
}
.login-status {
  min-height: 18px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.current-user {
  margin-left: 12px;
  color: var(--text);
}
.answer-card {
  margin: 0 0 16px;
}
.answer-card-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--primary-dark);
}
.answer-card-heading .text-button {
  margin-left: 0;
}
.answer-card-heading .text-button:first-of-type {
  margin-left: auto;
}
.answer-card-content {
  margin: 0;
  color: var(--text-strong);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.answer-card-editor {
  display: block;
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 10px 0px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcff;
  font: inherit;
}
.answer-card-editor:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.14);
}
.identification-details {
  margin: 0 0 16px;
}
.identification-details summary {
  padding: 11px 0;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  text-decoration: none;
  min-width: 190px;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 34px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}
.brand strong {
  font-size: 16px;
  letter-spacing: 0;
}
.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 3px;
}
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  transition:
    color 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}
.tab:hover {
  color: var(--primary-dark);
  background: var(--surface-muted);
}
.tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}
.topbar-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(0, 145, 98, 0.12);
}

main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 30px 28px 48px;
}
.panel {
  display: none;
}
.panel.active {
  display: block;
  animation: panel-in 240ms ease both;
}
@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html,
body {
  height: 100%;
}
body {
  overflow: hidden;
}
main {
  height: calc(100dvh - var(--header-height));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel.active {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.compact-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-height: 42px;
  margin-bottom: 10px;
}
.compact-toolbar .workflow-toolbar {
  margin-left: auto;
}
.ontology-shell,
.workbench-shell,
.knowledge-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.ontology-shell > *,
.workbench-shell > *,
.knowledge-shell > * {
  min-height: 0;
  height: 100%;
}
.graph-panel,
.details-panel,
.queue-panel,
.current-panel,
.category-panel,
.knowledge-panel {
  min-height: 0;
}
.graph-panel,
.details-panel,
.queue-panel,
.current-panel,
.knowledge-panel {
  display: flex;
  flex-direction: column;
}
.graph {
  flex: 1 1 auto;
  min-height: 240px;
  height: auto;
}
.details-panel .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.queue-panel .question-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.current-panel > #current-workspace {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.workspace-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.workspace-pane {
  overflow: auto;
}
.category-panel {
  height: 100%;
  max-height: none;
}
.knowledge-panel-toolbar {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-height: 56px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
}
.knowledge-panel-toolbar .search-control {
  width: min(410px, 100%);
}
.knowledge-panel .knowledge-cards {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  align-content: start;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  margin-bottom: 7px;
  color: var(--text-strong);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
h2 {
  margin-bottom: 0;
  color: var(--text-strong);
  font-size: 17px;
  line-height: 1.2;
}
h3 {
  margin-bottom: 0;
  color: var(--text-strong);
  font-size: 15px;
}
.page-description {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
}
.heading-stats {
  display: flex;
  gap: 18px;
  align-items: center;
}
.stat-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 54px;
}
.stat-block strong {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 18px;
}
.stat-block span {
  color: var(--muted);
  font-size: 11px;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--border);
}
.text-button {
  border: 0;
  padding: 5px 0;
  background: transparent;
  color: var(--primary-dark);
  font-size: 12px;
}
.text-button:hover {
  text-decoration: underline;
}

.ontology-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(430px, 0.88fr);
  gap: 18px;
  align-items: stretch;
}
.graph-panel,
.details-panel {
  min-height: 680px;
  overflow: hidden;
}
.graph {
  height: 520px;
  width: 100%;
}
.graph-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}
.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
}
.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-selected {
  background: var(--accent);
}
.legend-neighbor {
  background: var(--primary);
}
.legend-muted {
  background: #c8ccd7;
}
.class-inspector {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 76px;
  padding: 12px 18px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
}
.class-inspector > div:not(.inspector-facts) {
  min-width: 0;
}
.class-inspector strong,
.class-inspector span {
  display: block;
}
.class-inspector strong {
  color: var(--text-strong);
}
.class-inspector > div > span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.empty-icon,
.inspector-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px dashed var(--border-strong);
  border-radius: 50%;
  color: var(--primary);
  font-family: var(--font-mono);
}
.inspector-icon {
  border-style: solid;
  border-color: rgba(51, 70, 184, 0.35);
  background: var(--surface-selected);
}
.inspector-facts {
  display: flex;
  gap: 13px;
  margin-left: auto;
}
.fact strong,
.fact span {
  display: block;
  text-align: right;
}
.fact strong {
  font-family: var(--font-mono);
  font-size: 12px;
}
.fact span {
  color: var(--muted);
  font-size: 10px;
}
.inspector-related {
  max-width: 42%;
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.details-header {
  align-items: center;
}
.search-control {
  position: relative;
  display: block;
  min-width: 220px;
}
.search-control input {
  width: 100%;
  height: 34px;
  padding: 6px 10px 6px 31px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f9fafd;
  color: var(--text-strong);
  font-size: 12px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}
.search-control input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.16);
  outline: 0;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 6px;
  z-index: 1;
  color: var(--muted);
  font-size: 18px;
  line-height: 20px;
  pointer-events: none;
}
.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  color: var(--muted);
  font-size: 11px;
}
.table-wrap {
  overflow: auto;
  max-height: 570px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid #e8eaf0;
  text-align: left;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tbody tr {
  transition: background 160ms ease;
}
tbody tr:hover,
tbody tr:focus-visible {
  background: #f4f6fb;
}
tbody tr.selected {
  background: var(--surface-selected);
  box-shadow: inset 3px 0 var(--primary);
}
.class-link {
  max-width: 170px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: left;
  overflow-wrap: anywhere;
}
.class-link:hover {
  text-decoration: underline;
}
.class-label {
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
}
.empty-state,
.inline-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 180px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}
.empty-state strong,
.inline-empty strong {
  color: var(--text-strong);
}

.workflow-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(520px, 52vw);
}
.progress-copy {
  display: flex;
  flex-direction: column;
  min-width: 72px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.progress-copy .muted {
  font-family: var(--font-body);
  font-size: 10px;
}
.progress-track {
  flex: 1;
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #e4e8f5;
}
.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 260ms ease;
}
.button {
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}
.button-primary {
  background: var(--accent);
  color: #fff;
}
.button-primary:hover {
  background: #2c3ea8;
  box-shadow: 0 4px 12px rgba(51, 70, 184, 0.24);
}
.button-secondary {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--primary-dark);
}
.button-secondary:hover {
  background: var(--surface-selected);
  border-color: var(--primary);
}
.button-small {
  min-height: 31px;
  padding: 6px 10px;
  font-size: 11px;
}

.workbench-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.queue-panel {
  min-height: 650px;
  overflow: hidden;
}
.queue-header-actions,
.current-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-badge {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-selected);
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 11px;
}
.queue-refresh-button,
.current-refresh-button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}
.queue-refresh-button[aria-busy="true"],
.current-refresh-button[aria-busy="true"] {
  animation: queue-refresh-spin 900ms linear infinite;
}
.queue-refresh-button:disabled,
.current-refresh-button:disabled {
  opacity: 0.55;
}
@keyframes queue-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}
.question-list {
  padding: 8px;
}
.question-item {
  display: flex;
  align-items: flex-start;
  width: 100%;
  border-bottom: 1px solid #e8eaf0;
  background: transparent;
  color: inherit;
  transition: background 160ms ease;
}
.question-item:hover {
  background: #f4f6fb;
}
.question-item.selected {
  background: var(--surface-selected);
  box-shadow: inset 3px 0 var(--primary);
}
.question-item-select {
  display: flex;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  gap: 9px;
  padding: 12px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.question-item-select:hover {
  background: rgba(244, 246, 251, 0.8);
}
.question-item-select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.queue-status {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
}
.queue-status.pending,
.state-pill.pending {
  background: #eff1f7;
  color: #5f6678;
}
.queue-status.ready,
.state-pill.ready {
  background: #e6ecfe;
  color: #007cb9;
}
.queue-status.done,
.state-pill.done {
  background: #e7f5f0;
  color: #009162;
}
.queue-status.failed,
.state-pill.failed {
  background: #fef2f2;
  color: var(--danger);
}
.queue-status.running,
.state-pill.running {
  background: #e6ecfe;
  color: var(--primary);
}
.queue-body {
  min-width: 0;
}
.queue-body strong,
.queue-body small {
  display: block;
}
.queue-body strong {
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-body small {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}
.current-panel {
  min-height: 650px;
  overflow: hidden;
}
.empty-current {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 620px;
  padding: 24px;
  color: var(--muted);
}
.empty-current h2 {
  margin-bottom: 6px;
}
.empty-current p {
  margin: 0;
}
.current-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.current-header h2 {
  max-width: 850px;
  line-height: 1.35;
}
.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.meta-part strong {
  color: var(--text);
}
.workspace-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: auto;
}
.workspace-pane {
  min-width: 0;
  padding: 18px 20px 22px;
}
.form-pane {
  order: 0;
  min-height: 420px;
}
.result-pane {
  order: 1;
  border-top: 1px solid var(--border);
}
.pane-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.pane-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-toggle-button {
  display: none;
  width: auto;
  min-width: 48px;
  height: 28px;
  padding: 0 8px;
  color: var(--primary-dark);
  font-size: 11px;
}
.form-pane.form-collapsed #form-content {
  display: none;
}
.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
  border-radius: 4px;
  background: #eff1f7;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}
.state-pill.neutral {
  background: #eff1f7;
  color: var(--muted);
}
.section-label {
  margin: 18px 0 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}
.concept-tags,
.knowledge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.concept-tag {
  display: inline-flex;
  padding: 4px 7px;
  border: 1px solid #cbd4f5;
  border-radius: 4px;
  background: #f2f4ff;
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 10px;
}
.concept-tag.compact {
  padding: 3px 5px;
  font-size: 9px;
}
.subgraph-summary {
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
}
.summary-metrics {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 11px;
}
.fill-list {
  display: grid;
  gap: 8px;
}
.fill-item {
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.fill-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.fill-item-head strong {
  color: var(--text-strong);
  font-size: 12px;
}
.fill-field {
  display: flex;
  gap: 8px;
  padding-top: 7px;
  margin-top: 7px;
  border-top: 1px solid #e8eaf0;
  font-size: 11px;
}
.fill-field .mono {
  color: var(--primary-dark);
}
.trace-details {
  margin-top: 20px;
  border-top: 1px solid var(--border);
}
.trace-details summary {
  padding: 12px 0;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.trace-step {
  display: grid;
  grid-template-columns: 24px 92px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid #e8eaf0;
  font-size: 11px;
}
.trace-number {
  color: var(--accent);
  font-family: var(--font-mono);
}
.processing-state {
  padding: 12px;
  border: 1px solid #cbd4f5;
  border-radius: 6px;
  background: #f2f4ff;
  color: var(--primary-dark);
  font-size: 12px;
}
.domain-form {
  display: grid;
  gap: 14px;
}
.form-answer {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8faff;
}
.form-answer label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text-strong);
  font-size: 12px;
}
.answer-input {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text-strong);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}
.answer-input:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.16);
}
.form-section {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.form-section legend {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  width: auto;
  padding: 0 5px;
  color: var(--text-strong);
  font-size: 12px;
}
.field-row {
  display: grid;
  grid-template-columns: minmax(115px, 0.75fr) minmax(100px, 1fr);
  gap: 6px 12px;
  padding: 12px 0;
  border-top: 1px solid #e8eaf0;
}
.field-row:first-of-type {
  border-top: 0;
}
.field-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.field-prop {
  color: var(--primary-dark);
}
.field-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text-strong);
}
.field-input:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.16);
}
.field-help {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
}
.fill-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.fill-overlay.hidden {
  display: none;
}
body.fill-open {
  overflow: hidden;
}
.fill-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.fill-header .fill-close-button {
  justify-self: start;
}
.fill-header .fill-progress {
  justify-self: center;
}
.fill-header .filter-toggle-button {
  justify-self: end;
}
.fill-close-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 10px;
  min-height: 44px;
}
.fill-progress {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
}

.fill-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.fill-question {
  margin: 0;
  font-size: 20px;
  line-height: 1.5;
  color: var(--text-strong);
}
.fill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 12px;
}
.fill-hints {
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafbff;
}
.fill-hints-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  margin-bottom: 6px;
}
.fill-hints:not([open]) .fill-hints-title {
  margin-bottom: 0;
}
.fill-hint-item {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12px;
  line-height: 1.55;
  padding: 2px 0;
}
.fill-hint-label {
  font-weight: 600;
  color: var(--primary-dark);
  flex-shrink: 0;
}
.fill-hint-note {
  color: var(--muted);
}
.fill-answer-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}
.fill-answer-input {
  width: 100%;
  min-height: 220px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--text-strong);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.7;
  resize: vertical;
}
.fill-answer-input:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.16);
}
.fill-fields-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.fill-fields-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  padding: 4px 0;
}
.fill-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: #fff;
}
.fill-footer .button {
  flex: 1;
}
.fill-next-button {
  flex: 1.3;
}
.filter-toggle-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.filter-toggle-button.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(82, 106, 195, 0.08);
}
.form-error-summary {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff7f7;
  color: var(--danger);
  font-size: 11px;
}
.form-error-summary ul {
  margin: 6px 0 0 16px;
  padding: 0;
}
.form-error-summary a {
  color: var(--danger);
}
.inline-error {
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff7f7;
  color: var(--danger);
  font-size: 12px;
}
.inline-empty {
  min-height: 150px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.knowledge-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.category-panel {
  min-height: 650px;
  max-height: 650px;
  overflow: auto;
}
.category-search {
  margin: 15px 16px 10px;
}
.category-tree {
  padding: 0 8px 14px;
}
.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}
.category-item:hover {
  background: var(--surface-muted);
}
.category-item.selected {
  background: var(--surface-selected);
  color: var(--primary-dark);
  font-weight: 600;
}
.category-item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-item-count {
  flex: 0 0 auto;
  min-width: 18px;
  margin-left: auto;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  text-align: center;
}
.category-root {
  margin-bottom: 4px;
  color: var(--primary-dark);
}
.category-pending {
  color: var(--primary-dark);
}
.category-class {
  font-family: var(--font-mono);
}
.knowledge-panel {
  min-height: 650px;
}
.knowledge-cards {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 18px 20px;
}
.knowledge-card {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  min-height: 0;
  padding: 15px 12px;
  border: 0;
  border-bottom: 1px solid #e8eaf0;
  border-radius: 0;
  background: transparent;
  transition:
    background 180ms ease,
    box-shadow 180ms ease;
}
.knowledge-card:hover {
  background: #f4f6fb;
  box-shadow: inset 3px 0 var(--primary);
}
.knowledge-card-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.knowledge-card-head .state-pill {
  flex: 0 0 auto;
}
.knowledge-card h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.knowledge-card-body {
  min-width: 0;
  padding: 0;
}
.knowledge-card-body p {
  min-height: 0;
  margin: 0 0 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.knowledge-tags {
  min-width: 0;
  max-height: 53px;
  overflow: hidden;
}
.concept-tag.compact {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.knowledge-card-actions {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0 0 0 8px;
}

.submitted-answers {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e8eaf0;
}
.submitted-answers-title {
  margin-bottom: 5px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 600;
}
.submitted-answer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 11px;
}
.submitted-answer-label {
  color: var(--muted);
}
.submitted-answer-value {
  color: var(--text-strong);
  font-family: var(--font-mono);
  text-align: right;
  overflow-wrap: anywhere;
}
.toast {
  position: fixed;
  top: 82px;
  left: 50%;
  z-index: 50;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--text-strong);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast[data-kind="loading"] {
  background: var(--primary-dark);
}
.toast[data-kind="error"] {
  background: #991b1b;
  border-color: #fecaca;
}
.toast[data-kind="success"] {
  background: var(--primary-dark);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 30, 48, 0.34);
  backdrop-filter: blur(3px);
}
.dialog-backdrop.hidden {
  display: none;
}
.dialog {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(25, 30, 48, 0.22);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}
.dialog-description {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 12px;
}
.dialog-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}
.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 600;
}
.dialog-field-wide {
  grid-column: 1 / -1;
}
.dialog-field em {
  color: var(--danger);
  font-style: normal;
}
.dialog-field input,
.dialog-field textarea {
  width: 100%;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f9fafd;
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 400;
}
.dialog-field input:focus,
.dialog-field textarea:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(82, 106, 195, 0.16);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

@media (max-width: 1080px) {
  .topbar {
    gap: 18px;
    padding-inline: 20px;
  }
  .brand {
    min-width: auto;
  }
  .brand small {
    display: none;
  }
  main {
    padding-inline: 20px;
  }
  .ontology-shell {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 112px;
  }
  .topbar {
    flex-wrap: wrap;
    align-content: center;
  }
  .tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }
  .topbar-status {
    margin-left: auto;
  }
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .heading-stats {
    align-self: stretch;
  }
  .workflow-toolbar {
    width: 100%;
    min-width: 0;
  }
  .ontology-shell,
  .workbench-shell,
  .knowledge-shell {
    grid-template-columns: 1fr;
  }
  .graph-panel,
  .details-panel,
  .queue-panel,
  .current-panel,
  .category-panel,
  .knowledge-panel {
    min-height: auto;
  }
  .graph {
    height: min(58vw, 480px);
    min-height: 340px;
  }
  .table-wrap {
    max-height: 430px;
  }
  .queue-panel {
    max-height: 360px;
    overflow: auto;
  }
  .current-panel {
    min-height: 500px;
  }
  .empty-current {
    min-height: 420px;
  }
  body:has(#panel-workbench.active) {
    overflow-x: hidden;
    overflow-y: auto;
  }
  main:has(#panel-workbench.active) {
    height: auto;
    min-height: calc(100dvh - var(--header-height));
    overflow: visible;
  }
  main:has(#panel-workbench.active) > #panel-workbench.active {
    overflow: visible;
  }
  main:has(#panel-workbench.active) .workbench-shell {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
    grid-template-columns: 1fr;
  }
  main:has(#panel-workbench.active) .workbench-shell > * {
    height: auto;
  }
  main:has(#panel-workbench.active) .current-panel,
  main:has(#panel-workbench.active) .result-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  main:has(#panel-workbench.active) .current-panel > #current-workspace {
    overflow: visible;
  }
  main:has(#panel-workbench.active) .current-panel .form-pane,
  main:has(#panel-workbench.active) .result-panel .result-pane {
    overflow: visible;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }
  .topbar {
    padding: 10px 14px;
  }
  .brand {
    flex: 1;
  }
  .brand strong {
    font-size: 14px;
  }
  .topbar-status {
    font-size: 11px;
  }
  .tab {
    flex: 1;
    padding: 8px 6px;
    font-size: 12px;
    white-space: nowrap;
  }
  main {
    padding: 20px 12px 34px;
  }
  .page-heading {
    margin-bottom: 16px;
  }
  .page-description {
    font-size: 12px;
  }
  .heading-stats {
    gap: 14px;
  }
  .panel-card-header {
    padding: 8px;
  }
  .details-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .search-control {
    width: 100%;
    min-width: 0;
  }
  .graph {
    min-height: 300px;
    height: 78vw;
  }
  .graph-footer {
    flex-direction: column;
    padding-inline: 14px;
  }
  .class-inspector {
    align-items: flex-start;
    flex-wrap: wrap;
    padding-inline: 14px;
  }
  .inspector-facts {
    margin-left: 39px;
  }
  .inspector-related {
    width: 100%;
    max-width: none;
    margin-left: 39px;
    text-align: left;
  }
  .workflow-toolbar {
    flex-wrap: wrap;
  }
  .progress-track {
    order: 3;
    flex-basis: 100%;
  }
  .workflow-toolbar .button {
    flex: 1;
  }
  .current-header {
    flex-direction: column;
    padding: 10px 12px;
  }
  .current-header-actions {
    align-self: flex-start;
  }
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .result-pane {
    border-right: 0;
  }
  .workspace-pane {
    padding: 10px;
  }
  .question-list {
    padding: 0;
  }
  .question-item-select {
    padding: 0;
  }
  .pane-heading {
    margin-bottom: 10px;
  }
  .form-section {
    padding: 8px;
  }
  .field-row {
    grid-template-columns: 1fr;
    padding: 8px 0;
    gap: 6px;
  }
  .fill-item {
    padding: 8px;
  }
  .subgraph-summary {
    padding: 8px;
  }
  .processing-state,
  .inline-error {
    padding: 9px;
  }
  .section-label {
    margin-top: 12px;
  }
  .form-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .field-help {
    grid-column: auto;
  }
  .form-actions {
    justify-content: stretch;
  }
  .form-actions .button {
    width: 100%;
  }
  .dialog-fields {
    grid-template-columns: 1fr;
  }
  .dialog-field-wide {
    grid-column: auto;
  }
  .dialog-actions {
    flex-direction: column-reverse;
  }
  .dialog-actions .button {
    width: 100%;
  }
  .knowledge-cards {
    padding-inline: 12px;
  }
  .table-meta {
    padding-inline: 14px;
  }
  .knowledge-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 14px 10px;
  }
  .knowledge-card-body {
    grid-column: 1 / -1;
  }
  .knowledge-card-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    padding: 0;
  }
  .category-panel {
    max-height: 360px;
    overflow: auto;
  }
  .category-search {
    width: auto;
  }
  .knowledge-panel-toolbar {
    padding-inline: 14px;
  }
  .toast {
    top: 72px;
  }
  .login-panel {
    align-items: start;
    padding: 16px 12px;
  }
  .login-card {
    margin-top: 8vh;
    padding: 24px 20px;
  }
  .login-brand {
    margin-bottom: 27px;
  }
  .login-card h1 {
    font-size: 24px;
  }
  .login-code-row {
    grid-template-columns: 1fr;
  }
  .login-code-row .button {
    width: 100%;
  }
  .current-user {
    display: none;
  }
  .topbar-status {
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .topbar-status .text-button {
    margin-left: 0;
    padding: 4px 0;
  }
  main {
    height: calc(100dvh - var(--header-height));
  }
  .ontology-shell,
  .workbench-shell,
  .knowledge-shell {
    overflow: auto;
  }
  .ontology-shell {
    grid-auto-rows: max-content;
  }
  .graph-panel {
    height: 520px;
    min-height: 520px;
  }
  .details-panel {
    height: 620px;
    min-height: 620px;
  }
  .workbench-shell {
    grid-auto-rows: max-content;
  }
  .queue-panel {
    height: 360px;
    min-height: 360px;
  }
  .current-panel {
    height: 700px;
    min-height: 700px;
  }
  .knowledge-shell {
    grid-auto-rows: max-content;
  }
  .category-panel {
    height: 360px;
    min-height: 360px;
    max-height: 360px;
  }
  .knowledge-panel {
    height: 650px;
    min-height: 650px;
  }
  .form-pane {
    min-height: 0;
  }
  .fill-body {
    padding: 16px 12px 20px;
  }
  .fill-question {
    font-size: 18px;
  }
  .fill-answer-input {
    min-height: 180px;
  }
  .fill-body .field-input {
    font-size: 16px;
  }
}

/* The desktop workbench is a viewport-height, three-column workspace. */
@media (min-width: 901px) {
  body:has(#panel-workbench.active) {
    overflow: hidden;
  }
  main:has(#panel-workbench.active) {
    height: calc(100dvh - var(--header-height));
    overflow: hidden;
  }
  main:has(#panel-workbench.active) > #panel-workbench.active {
    overflow: hidden;
  }
  main:has(#panel-workbench.active) .workbench-shell {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    grid-template-columns: 270px minmax(0, 1.35fr) minmax(360px, 0.8fr);
    align-items: stretch;
  }
  main:has(#panel-workbench.active) .workbench-shell > * {
    height: 100%;
    min-height: 0;
  }
  main:has(#panel-workbench.active) .queue-panel,
  main:has(#panel-workbench.active) .current-panel,
  main:has(#panel-workbench.active) .result-panel {
    min-height: 0;
    overflow: hidden;
  }
  main:has(#panel-workbench.active) .queue-panel .question-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }
  main:has(#panel-workbench.active) .current-panel > #current-workspace {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  main:has(#panel-workbench.active) .current-panel .form-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }
  main:has(#panel-workbench.active) .result-panel {
    display: flex;
    flex-direction: column;
  }
  main:has(#panel-workbench.active) .result-panel .result-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }
  .fill-header,
  .fill-body,
  .fill-footer {
    max-width: 760px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Ontology inheritance tree */
.category-tree-node {
  min-width: 0;
}
.category-tree-row {
  display: flex;
  align-items: center;
  min-width: 0;
  padding-left: calc(var(--category-depth) * 12px);
}
.category-tree-row > .category-item {
  flex: 1 1 auto;
}
.category-tree-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.category-tree-toggle:hover {
  color: var(--primary-dark);
}
.category-tree-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 4px;
}
.category-chevron {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
}
.category-tree-toggle[aria-expanded="true"] .category-chevron {
  transform: rotate(45deg);
}
.category-tree-spacer {
  flex: 0 0 22px;
}
.category-tree-children[hidden] {
  display: none;
}
