/* NeuroBERT-NER — Calm, workspace-first route stylesheet across all 5 ladder routes.
 * Strict design-system invariants:
 *   - Uses public/styles.css CSS custom properties ONLY (zero raw hex literals)
 *   - Zero rounded pill soup; crisp architectural 4px/6px/var(--radius-sm) frames
 *   - Zero dashed upload borders; solid 1px hairline controls
 *   - [hidden] { display: none !important; }
 *   - >= 44x44px hit targets on every interactive control, link, button, input, and summary
 *   - Container queries + intrinsic auto-fit grids -> 0px horizontal overflow at 1280px, 390px, 360px
 */

[hidden] {
  display: none !important;
}

/* Skip link for keyboard navigation (modern-web-guidance: accessibility) */
.nb-skip-link {
  position: fixed;
  inset-inline-start: 0.75rem;
  inset-block-start: 0.5rem;
  z-index: 100;
  padding: 0.55rem 0.9rem;
  min-block-size: 44px;
  min-inline-size: 44px;
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.nb-skip-link:focus {
  transform: translateY(0);
}

.nb-sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Enforce >= 44x44px accessible touch targets on every interactive element */
button,
.button,
.model-loader button,
select,
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
summary,
.nb-upload-label,
.nb-check-label {
  min-block-size: 44px;
  min-inline-size: 44px;
}

.crumbs a,
.ladder-nav a,
footer.byline a,
.nb-meta-line a,
.model-loader a,
details.show-code .sc-meta a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  min-inline-size: 44px;
}

.lede a {
  padding-block: 4px;
}

/* Quiet editorial header — compact so primary interactive workspace starts above the fold */
.nb-header {
  margin-block-end: 0.85rem;
}

.nb-header h1 {
  margin: 0.2rem 0 0.35rem;
  text-wrap: balance;
}

.nb-header .lede {
  margin: 0;
  max-inline-size: 72ch;
  text-wrap: pretty;
}

.nb-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.45rem 0 0;
}

.nb-meta-line span + span::before {
  content: "·";
  margin-inline-end: 0.65rem;
  color: var(--border-strong);
}

.nb-loader-slot {
  margin-block-end: 0.85rem;
}

/* Below-the-fold rendering optimization (modern-web-guidance: defer-rendering-heavy-content) */
.nb-below-fold {
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}

/* Primary 2-column workspace: document/highlighter first, calm inspector beside it */
.nb-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(0, 0.92fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 860px) {
  .nb-workbench {
    grid-template-columns: minmax(0, 1fr);
  }
}

.nb-col {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-inline-size: 0;
  container-type: inline-size;
}

.nb-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}

@media (max-width: 760px) {
  .nb-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Calm hairline architectural cards */
.nb-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 0.9rem 1rem;
  min-inline-size: 0;
  box-shadow: var(--shadow-sm);
}

.nb-card h2,
.nb-card h3 {
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  font-size: 1rem;
  text-wrap: balance;
}

.nb-card p {
  text-wrap: pretty;
}

/* Quiet architectural note callout */
.nb-note {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  font-size: 0.86rem;
  line-height: 1.5;
  margin: 0.65rem 0;
}

.nb-note.warn {
  border-inline-start-color: var(--warn);
}

.nb-note.good {
  border-inline-start-color: var(--good);
}

/* Preset & segmented hairline tabs (crisp var(--radius-sm), zero rounded pills) */
.nb-presets,
.nb-toolbar,
.nb-seg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.nb-preset,
.nb-seg button {
  padding: 0.42rem 0.78rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.nb-preset:hover,
.nb-seg button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nb-preset[aria-pressed="true"],
.nb-seg button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.nb-preset[aria-pressed="true"]:hover,
.nb-seg button[aria-pressed="true"]:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}

/* Editor & drop surface (solid hairline — zero dashed borders) */
.nb-editor-wrap {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  background: var(--bg);
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.nb-editor-wrap.is-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}

.nb-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-inline-size: 0;
}

.nb-field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.nb-field label {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--muted);
}

.nb-field output {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color);
}

.nb-textarea,
.nb-input,
.nb-select {
  inline-size: 100%;
  max-inline-size: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.94rem;
  line-height: 1.55;
}

.nb-textarea {
  min-block-size: 5.4rem;
  resize: vertical;
}

.nb-textarea.nb-mono-input {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

.nb-field input[type="range"] {
  inline-size: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.nb-textarea:focus-visible,
.nb-input:focus-visible,
.nb-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Solid hairline file upload trigger (zero dashed borders) */
.nb-upload-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.nb-upload-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nb-upload-label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nb-upload-label[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.nb-upload-label input[type="file"] {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border: 0;
}

/* Accessible >=44px checkbox row */
.nb-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--color);
  padding-inline: 0.2rem;
}

.nb-check-label input[type="checkbox"] {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  min-inline-size: 1.15rem;
  min-block-size: 1.15rem;
  accent-color: var(--accent);
  margin: 0;
}

/* Annotated Document Highlighter Surface */
.nb-doc-surface {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.95rem 1.05rem;
  font-size: 1.02rem;
  line-height: 2.05;
  color: var(--color);
  overflow-wrap: break-word;
  word-break: break-word;
}

.nb-entity {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-block-size: 44px;
  min-inline-size: 44px;
  vertical-align: baseline;
  margin: 0.12rem 0.1rem;
  padding: 0.18rem 0.48rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
  cursor: pointer;
  text-align: start;
  transition: border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.nb-entity-static {
  min-block-size: auto;
  min-inline-size: auto;
  padding: 0.08rem 0.38rem;
  cursor: default;
}

.nb-entity:hover {
  box-shadow: var(--shadow-sm);
}

.nb-entity.is-selected,
.nb-entity:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nb-entity-text {
  font-weight: 500;
}

.nb-entity-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.05rem 0.32rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  line-height: 1.25;
}

/* 5 Semantic OntoNotes visual groups — strictly design tokens + color-mix, light & dark WCAG AA */
.nb-grp-actors {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-raised));
}
.nb-grp-actors .nb-entity-tag,
.nb-type-code.nb-grp-actors {
  color: var(--accent);
}
.nb-bar-fill.nb-grp-actors {
  background: var(--accent);
}

.nb-grp-places {
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
  border-bottom-color: var(--good);
  background: color-mix(in srgb, var(--good) 10%, var(--bg-raised));
}
.nb-grp-places .nb-entity-tag,
.nb-type-code.nb-grp-places {
  color: var(--good);
}
.nb-bar-fill.nb-grp-places {
  background: var(--good);
}

.nb-grp-values {
  border-color: color-mix(in srgb, var(--warn) 48%, var(--border));
  border-bottom-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 11%, var(--bg-raised));
}
.nb-grp-values .nb-entity-tag,
.nb-type-code.nb-grp-values {
  color: var(--warn);
}
.nb-bar-fill.nb-grp-values {
  background: var(--warn);
}

.nb-grp-temporal {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--good));
  border-bottom-color: color-mix(in srgb, var(--accent) 55%, var(--good));
  background: color-mix(in srgb, var(--good) 7%, color-mix(in srgb, var(--accent) 6%, var(--bg-raised)));
}
.nb-grp-temporal .nb-entity-tag,
.nb-type-code.nb-grp-temporal {
  color: color-mix(in srgb, var(--accent) 55%, var(--good));
}
.nb-bar-fill.nb-grp-temporal {
  background: color-mix(in srgb, var(--accent) 55%, var(--good));
}

.nb-grp-artifacts {
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
  border-bottom-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 9%, var(--bg-raised));
}
.nb-grp-artifacts .nb-entity-tag,
.nb-type-code.nb-grp-artifacts {
  color: var(--bad);
}
.nb-bar-fill.nb-grp-artifacts {
  background: var(--bad);
}

.nb-type-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.1rem 0.42rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.nb-tag-o {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  padding: 0.1rem 0.42rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
}

/* Category Filter Grid */
.nb-cat-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.45rem;
}

.nb-cat-btn {
  padding: 0.36rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--color);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.nb-cat-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

/* Compact telemetry metric grid with container query adaptability */
.nb-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 118px), 1fr));
  gap: 0.45rem;
}

@container (max-width: 340px) {
  .nb-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.nb-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.5rem 0.62rem;
  min-inline-size: 0;
}

.nb-metric span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.25;
}

.nb-metric strong,
.nb-metric b {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0.15rem;
  color: var(--color);
  overflow-wrap: anywhere;
}

/* Distribution bars */
.nb-dist-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nb-dist-row {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.nb-dist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
}

.nb-bar-track {
  inline-size: 100%;
  block-size: 0.52rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.nb-bar-fill {
  display: block;
  block-size: 100%;
  background: var(--accent);
}

/* Semantic tables with guaranteed horizontal scroll safety on 360px mobile */
.nb-table-wrap {
  inline-size: 100%;
  max-inline-size: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.nb-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.nb-table th,
.nb-table td {
  padding: 0.52rem 0.65rem;
  text-align: start;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.nb-table th {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-secondary);
  white-space: nowrap;
}

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

.nb-row-subword {
  background: color-mix(in srgb, var(--warn) 7%, var(--bg-raised));
}

/* 18-class OntoNotes coverage matrix (Basics) */
.nb-class-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 155px), 1fr));
  gap: 0.45rem;
}

.nb-class-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.5rem 0.62rem;
  min-inline-size: 0;
}

.nb-class-cell.is-hit {
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}

.nb-class-cell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
}

.nb-class-cell small {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.74rem;
  color: var(--muted);
}

/* Progress bar for Practical batch queue */
.nb-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.6rem 0;
}

.nb-progress-bar {
  inline-size: 100%;
  block-size: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.nb-progress-fill {
  display: block;
  block-size: 100%;
  inline-size: 0%;
  background: var(--accent);
  transition: inline-size 0.16s ease;
}

/* Architecture facts grid & tucked diagnostics details */
.nb-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 0.55rem;
}

.nb-fact {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.55rem 0.7rem;
  min-inline-size: 0;
}

.nb-fact span {
  display: block;
  font-size: 0.73rem;
  color: var(--muted);
}

.nb-fact code,
.nb-fact b {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.nb-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  margin-top: 0.7rem;
}

.nb-details > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
}

.nb-details-body {
  padding: 0.75rem 0.9rem 0.9rem;
  border-top: 1px solid var(--border);
}

/* Multi-model stage cards & ranked passage cards */
.stage-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.65rem 0;
}

@media (max-width: 720px) {
  .stage-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.75rem 0.85rem;
  min-inline-size: 0;
}

.stage-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.94rem;
}

.stage-card p {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.nb-ranked-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.nb-ranked-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.75rem 0.85rem;
}

.nb-ranked-item.is-top {
  border-color: var(--accent);
  border-inline-start: 4px solid var(--accent);
}

.nb-ranked-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.38rem;
}

.nb-ranked-passage {
  font-size: 0.94rem;
  line-height: 1.75;
  margin: 0.35rem 0 0.45rem;
  overflow-wrap: break-word;
}

.nb-ranked-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

/* Use-case ladder matrix cards */
.nb-ladder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 0.7rem;
}

.nb-ladder-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--color);
  text-decoration: none;
  min-block-size: 44px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.nb-ladder-card:hover,
.nb-ladder-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.nb-ladder-card h3 {
  margin: 0;
  font-size: 0.98rem;
  color: var(--accent);
}

.nb-ladder-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.48;
}

.nb-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.nb-code-box {
  margin: 0.7rem 0;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.79rem;
  line-height: 1.5;
  overflow-x: auto;
  max-inline-size: 100%;
}

.status {
  margin: 0.45rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
}

.status.err {
  color: var(--bad);
  font-weight: 500;
}

.status.ok {
  color: var(--good);
}

/* Key-value inspector list */
.nb-kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.3rem 0.75rem;
  margin: 0;
  font-size: 0.83rem;
}

.nb-kv dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.nb-kv dd {
  margin: 0;
  color: var(--color);
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .nb-preset,
  .nb-seg button,
  .nb-entity,
  .nb-ladder-card,
  .nb-progress-fill {
    transition: none;
  }
}
