:root {
  --bg: #f4f2ed;
  --ink: #151515;
  --muted: #68675f;
  --line: #ded9ce;
  --panel: #fffcf4;
  --accent: #0f766e;
  --accent-dark: #0a4e49;
  --danger: #d92d20;
  --mask: #d97706;
  --token: #2563eb;
  --partial-keep: #7c3aed;
  --keep: #6b7280;
  --shadow: 0 18px 50px rgba(18, 18, 18, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(15, 118, 110, 0.05) 0 1px, transparent 1px 100%),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "IBM Plex Sans KR", "Apple SD Gothic Neo", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: clamp(248px, 16vw, 292px) minmax(0, 1fr) clamp(320px, 20vw, 380px);
  gap: 18px;
  height: 100vh;
  padding: 18px;
  overflow: hidden;
}

.control-panel,
.inspector {
  background: rgba(255, 252, 244, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  height: calc(100vh - 36px);
  min-height: 0;
}

.control-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow: auto;
}

.top-lab-button {
  width: 100%;
  margin-bottom: 14px;
  justify-content: flex-start;
  padding: 0 14px;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.inspector-head strong {
  display: block;
  font-size: 16px;
}

.brand span,
.inspector-head span,
.section-label,
.file-name,
.helper-text,
.legend,
.feedback-box p {
  color: var(--muted);
  font-size: 12px;
}

.panel-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.panel-section.compact {
  display: grid;
  gap: 10px;
  border-bottom: 0;
  margin-top: auto;
}

#fileInput {
  display: none;
}

.file-drop {
  display: grid;
  gap: 9px;
  place-items: center;
  min-height: 158px;
  padding: 20px;
  border: 1px dashed #b8b0a2;
  background: #fbf7ed;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.file-drop:hover,
.file-drop.dragging {
  border-color: var(--accent);
  background: #eff8f5;
  transform: translateY(-1px);
}

.file-drop svg {
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.file-drop strong {
  font-size: 15px;
}

.file-name {
  margin: 10px 0 0;
  word-break: break-word;
}

.section-label {
  margin-bottom: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  background: #f2eee4;
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

.helper-text {
  margin: 9px 0 0;
  line-height: 1.5;
}

.sample-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sample-links button,
.type-selectors label {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.type-selectors {
  display: grid;
  gap: 8px;
}

.type-selectors label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.type-selectors input {
  accent-color: var(--accent);
}

.tuning-grid {
  display: grid;
  gap: 8px;
}

.tuning-grid label {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 9px;
}

.tuning-grid span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.tuning-grid b {
  color: var(--accent);
}

.tuning-grid input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.tuning-grid input[type="number"],
.tuning-grid select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 8px;
  color: var(--ink);
  font-weight: 800;
}

.tuning-grid input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.tuning-actions {
  display: grid;
  grid-template-columns: 1fr 0.65fr;
  gap: 8px;
  margin-top: 10px;
}

.sample-links button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.policy-table {
  display: grid;
  gap: 6px;
}

.policy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fffdf8;
  font-size: 12px;
}

.policy-row strong {
  font-size: 12px;
}

.policy-row div span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.pipeline {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pipeline li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.pipeline li::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 2px solid #b8b0a2;
}

.pipeline li.active {
  color: var(--ink);
}

.pipeline li.active::before {
  border-color: var(--accent);
  background: var(--accent);
}

.primary,
.secondary,
.icon-button,
.feedback-actions button,
.feedback-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  min-height: 44px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary:disabled {
  cursor: not-allowed;
  color: #a4a09a;
}

.secondary.small {
  width: 100%;
  min-height: 36px;
  font-size: 12px;
}

.primary.small {
  width: 100%;
  min-height: 36px;
  font-size: 12px;
}

.workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 36px);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.workspace-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 4px 16px;
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0;
}

.workspace-top p {
  margin: 0;
  color: var(--muted);
}

.metrics {
  display: flex;
  gap: 8px;
}

.metrics div {
  min-width: 78px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.68);
}

.metrics strong,
.metrics span {
  display: block;
}

.metrics strong {
  font-size: 20px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.canvas-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.preview-frame {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.8);
  box-shadow: var(--shadow);
  overflow: auto;
}

.preview-frame figcaption {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.96);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  background:
    linear-gradient(45deg, #ece7dc 25%, transparent 25%),
    linear-gradient(-45deg, #ece7dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ece7dc 75%),
    linear-gradient(-45deg, transparent 75%, #ece7dc 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.inspector {
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  border-color: var(--line);
  background: #fff;
}

.inspector-actions {
  display: flex;
  gap: 8px;
}

.icon-button:disabled {
  cursor: not-allowed;
  color: #a4a09a;
  background: #f8f5ed;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.remove {
  background: var(--danger);
}

.dot.mask {
  background: var(--mask);
}

.dot.token {
  background: var(--token);
}

.dot.partial-keep {
  background: var(--partial-keep);
}

.dot.keep {
  background: var(--keep);
}

.detection-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 14px 0;
  min-height: 200px;
  max-height: 100%;
  flex: 1;
}

.mask-list-panel {
  display: grid;
  gap: 10px;
}

.mask-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mask-list-meta span {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mask-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
  animation: rise 220ms ease both;
}

.mask-row.is-off {
  opacity: 0.58;
}

.mask-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}

.mask-switch input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.mask-switch span {
  min-width: 31px;
  border: 1px solid var(--line);
  background: #f4f0e7;
  padding: 4px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.mask-switch input:checked + span {
  border-color: #0f766e;
  background: #dff3ec;
  color: #0f766e;
}

.mask-row-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.mask-row-body strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.mask-row-body p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mask-row-body small {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  min-height: 220px;
  text-align: center;
}

.empty-state svg {
  color: var(--accent);
}

.detection-row {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
  animation: rise 220ms ease both;
}

.detection-row header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.badge-group {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.detection-row strong {
  font-size: 14px;
  word-break: break-word;
}

.badge {
  padding: 3px 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.remove {
  background: var(--danger);
}

.badge.mask,
.badge.partial_mask {
  background: var(--mask);
}

.badge.tokenize {
  background: var(--token);
}

.badge.partial_keep {
  background: var(--partial-keep);
}

.badge.keep {
  background: var(--keep);
}

.badge.decision-auto {
  background: #166534;
}

.badge.decision-review {
  background: #b45309;
}

.badge.decision-ignored {
  background: #6b7280;
}

.detection-row dl {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 5px 8px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.detection-row dd,
.detection-row dt {
  margin: 0;
}

.detection-row dd {
  color: var(--ink);
}

.detection-row.is-kept {
  background: #fffaf0;
}

.detection-toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
}

.detection-toggle input {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.detection-toggle span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.detection-toggle small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.detection-feedback {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.feedback-pill {
  min-height: 32px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.feedback-pill:hover,
.feedback-pill.active {
  border-color: var(--accent);
  color: var(--accent);
}

.feedback-pill.active {
  background: #eaf7f2;
}

.feedback-box {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.feedback-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.feedback-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.feedback-actions button {
  min-height: 36px;
  border-color: var(--line);
  background: #fff;
  font-size: 12px;
}

.feedback-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.evaluation-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.evaluation-metrics div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
}

.evaluation-metrics strong,
.evaluation-metrics span {
  display: block;
}

.evaluation-metrics strong {
  font-size: 16px;
}

.evaluation-metrics span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.missed-form {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.missed-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.missed-form input,
.missed-form select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 0 9px;
}

.missed-list {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.missed-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 8px;
  font-size: 12px;
}

.missed-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.missed-item button {
  min-height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

  .control-panel,
  .workspace {
    height: auto;
  }

  .inspector {
    grid-column: 1 / -1;
    height: min(520px, 70vh);
    min-height: 360px;
  }
}

@media (max-width: 780px) {
  .shell {
    display: block;
    padding: 12px;
  }

  .control-panel,
  .inspector,
  .workspace,
  .preview-frame {
    height: auto;
    min-height: auto;
    margin-bottom: 12px;
    overflow: visible;
  }

  .workspace-top,
  .metrics,
  .canvas-grid {
    display: block;
  }

  .preview-frame {
    max-height: 72vh;
    overflow: auto;
  }

  .metrics {
    margin-top: 14px;
  }

  .metrics div {
    display: inline-block;
    margin: 0 6px 6px 0;
  }
}

.mechanism-page {
  height: auto;
  min-height: 100vh;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(15, 118, 110, 0.04) 0 1px, transparent 1px 100%),
    #f4f2ed;
  background-size: 28px 28px;
}

.mechanism-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.94);
  backdrop-filter: blur(14px);
}

.mechanism-topbar > div {
  display: grid;
  gap: 2px;
}

.mechanism-topbar strong {
  font-size: 15px;
}

.mechanism-topbar span,
.mechanism-kicker,
.mechanism-section-head p,
.mechanism-panel dt,
.mechanism-card header span,
.mechanism-detail-grid span,
.mechanism-mini-list span {
  color: var(--muted);
  font-size: 12px;
}

.mechanism-back,
.mechanism-refresh {
  min-height: 38px;
  padding: 0 12px;
  text-decoration: none;
}

.mechanism-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 18px 48px;
}

.mechanism-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 24px;
  align-items: end;
  padding: 22px 0 18px;
}

.mechanism-kicker {
  margin: 0 0 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.mechanism-hero h1 {
  max-width: 760px;
}

.mechanism-hero p {
  margin: 0;
  color: var(--muted);
}

.mechanism-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mechanism-scoreboard div,
.mechanism-panel,
.mechanism-card,
.mechanism-table-wrap,
.mechanism-json {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.9);
  box-shadow: var(--shadow);
}

.mechanism-scoreboard div {
  padding: 12px;
}

.mechanism-scoreboard strong,
.mechanism-scoreboard span {
  display: block;
}

.mechanism-scoreboard strong {
  font-size: 24px;
}

.mechanism-scoreboard span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mechanism-nav {
  position: sticky;
  top: 67px;
  z-index: 9;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0;
  background: rgba(244, 242, 237, 0.92);
  backdrop-filter: blur(12px);
}

.mechanism-nav a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 9px 12px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.mechanism-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mechanism-workbench {
  display: grid;
  grid-template-columns: minmax(320px, 42vw) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  scroll-margin-top: 120px;
  padding: 16px 0 20px;
}

.mechanism-document-pane {
  position: sticky;
  top: 124px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.mechanism-document-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  padding: 12px;
}

.mechanism-document-head div {
  display: grid;
  gap: 2px;
}

.mechanism-document-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mechanism-document-head a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.mechanism-preview-frame {
  display: grid;
  place-items: center;
  min-height: 420px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, #ece7dc 25%, transparent 25%),
    linear-gradient(-45deg, #ece7dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ece7dc 75%),
    linear-gradient(-45deg, transparent 75%, #ece7dc 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  box-shadow: var(--shadow);
}

.mechanism-preview-frame img {
  display: block;
  width: auto;
  max-width: none;
  height: auto;
}

.mechanism-preview-frame img[hidden],
.mechanism-preview-frame p[hidden] {
  display: none;
}

.mechanism-preview-frame p {
  color: var(--muted);
  font-weight: 800;
}

.mechanism-document-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mechanism-document-facts details {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
}

.mechanism-document-facts summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.mechanism-fact {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
}

.mechanism-fact span,
.mechanism-fact strong {
  display: block;
}

.mechanism-fact span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mechanism-fact strong {
  margin-top: 4px;
  font-size: 13px;
  word-break: break-word;
}

.mechanism-page-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.mechanism-board {
  min-width: 0;
}

.mechanism-section-head.compact {
  margin-bottom: 10px;
}

.mechanism-flow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mechanism-flow-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
  padding: 12px;
}

.mechanism-flow-step {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.mechanism-flow-card h3,
.mechanism-flow-card p,
.mechanism-flow-card pre {
  margin: 0;
}

.mechanism-flow-card h3 {
  font-size: 15px;
}

.mechanism-flow-card p,
.mechanism-flow-card pre {
  margin-top: 6px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.55;
}

.mechanism-flow-card pre {
  max-height: 112px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.mechanism-flow-card dl {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 4px 8px;
  margin: 10px 0 0;
  font-size: 11px;
}

.mechanism-flow-card dt,
.mechanism-flow-card dd {
  margin: 0;
}

.mechanism-flow-card dt {
  color: var(--muted);
  font-weight: 800;
}

.mechanism-flow-card dd {
  word-break: break-word;
}

.candidate-explorer {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
}

.candidate-explorer-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.candidate-explorer-head div {
  display: grid;
  gap: 2px;
}

.candidate-explorer-head span,
.score-rationale-panel span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.candidate-explorer-head strong {
  font-size: 16px;
}

.candidate-explorer-head p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.candidate-explorer-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  min-height: 520px;
}

.candidate-button-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 720px;
  overflow: auto;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: rgba(244, 240, 231, 0.54);
}

.candidate-button {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
  color: var(--ink);
  text-align: left;
}

.candidate-button:hover,
.candidate-button.active {
  border-color: var(--accent);
  background: #eff8f5;
}

.candidate-button-text {
  font-size: 13px;
  font-weight: 900;
  word-break: break-word;
}

.candidate-button-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.candidate-button-meta strong {
  color: var(--accent);
  font-size: 12px;
}

.candidate-button-meta em {
  font-style: normal;
}

.candidate-detail {
  min-width: 0;
  max-height: 720px;
  overflow: auto;
  padding: 14px;
}

.candidate-trace-card {
  display: grid;
  gap: 14px;
}

.candidate-trace-card > header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.candidate-trace-card > header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.candidate-trace-card h3,
.candidate-trace-card h4 {
  margin: 0;
}

.candidate-trace-card h3 {
  margin-top: 4px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
  word-break: break-word;
}

.candidate-trace-score {
  display: grid;
  place-items: center;
  min-width: 94px;
  border: 1px solid var(--line);
  background: #151515;
  color: #fff;
  padding: 10px;
}

.candidate-trace-score strong {
  font-size: 28px;
  line-height: 1;
}

.candidate-trace-score span {
  color: #d7d4cd;
  font-size: 11px;
}

.trace-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.trace-stage {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
}

.trace-stage > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.trace-stage p,
.trace-stage pre {
  margin: 0;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.trace-stage dl {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 4px 8px;
  margin: 0;
  font-size: 11px;
}

.trace-stage dt,
.trace-stage dd {
  margin: 0;
}

.trace-stage dt {
  color: var(--muted);
  font-weight: 900;
}

.trace-stage dd {
  word-break: break-word;
}

.candidate-evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.candidate-evidence-grid section {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
}

.evidence-token-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.evidence-token-list div {
  display: grid;
  gap: 3px;
  padding: 8px;
  background: #f6f2e9;
}

.evidence-token-list strong {
  word-break: break-word;
}

.evidence-token-list span,
.evidence-token-list p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}

.score-rationale-panel {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.score-rationale-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.score-rationale-table {
  width: 100%;
  border-collapse: collapse;
  background: #fffdf8;
  font-size: 12px;
}

.score-rationale-table th,
.score-rationale-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.score-rationale-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.mechanism-quick-table-wrap {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.9);
  box-shadow: var(--shadow);
}

.mechanism-quick-table {
  min-width: 780px;
}

.mechanism-quick-table small {
  color: var(--muted);
  line-height: 1.45;
}

.score-calc {
  display: grid;
  gap: 8px;
  min-width: 260px;
}

.score-calc-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.score-calc-total strong {
  font-size: 20px;
}

.score-calc-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.score-calc code,
.mechanism-breakdown code {
  display: block;
  border: 1px solid var(--line);
  background: #fff;
  color: #1f2937;
  padding: 7px 8px;
  font-size: 11px;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
}

.score-calc ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.score-calc li {
  display: grid;
  grid-template-columns: 20px 46px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  font-size: 11px;
}

.score-calc li > span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: #f2eee4;
  color: var(--muted);
  font-weight: 800;
}

.score-calc li strong {
  color: var(--accent-dark);
}

.score-calc li em {
  color: var(--ink);
  font-style: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.case-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.case-summary-card {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
  padding: 12px;
}

.case-summary-card span,
.case-summary-card strong,
.case-summary-card em {
  display: block;
}

.case-summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.case-summary-card strong {
  margin-top: 6px;
  font-size: 28px;
}

.case-summary-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.case-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.case-panel {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
  padding: 14px;
}

.case-panel header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.case-panel header div {
  display: grid;
  gap: 3px;
}

.case-panel header span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.case-panel h3,
.case-panel p {
  margin: 0;
}

.case-panel h3 {
  font-size: 16px;
}

.case-panel header > strong {
  color: var(--accent-dark);
  white-space: nowrap;
}

.case-panel > p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.case-strategies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.case-strategies span {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 800;
}

.case-findings {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
}

.case-finding,
.case-empty {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
}

.case-finding strong,
.case-finding span {
  display: block;
}

.case-finding strong {
  font-size: 13px;
  word-break: break-word;
}

.case-finding span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.case-finding dl {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 5px 8px;
  margin: 10px 0 0;
  font-size: 12px;
}

.case-finding dt,
.case-finding dd {
  margin: 0;
}

.case-finding dt {
  color: var(--muted);
  font-weight: 800;
}

.case-finding dd {
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.case-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.mechanism-section {
  scroll-margin-top: 120px;
  padding: 20px 0;
}

.mechanism-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.mechanism-section-head div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mechanism-section-head span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.mechanism-section h2,
.mechanism-panel h3 {
  margin: 0;
}

.mechanism-section h2 {
  font-size: 22px;
}

.mechanism-grid {
  display: grid;
  gap: 12px;
}

.mechanism-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mechanism-panel {
  padding: 14px;
}

.mechanism-panel h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

.mechanism-panel dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.mechanism-panel dd,
.mechanism-panel dt {
  margin: 0;
}

.mechanism-panel dd {
  word-break: break-word;
}

.mechanism-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 8px;
  margin-bottom: 10px;
}

.mechanism-toolbar input,
.mechanism-toolbar select {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 0 12px;
}

.mechanism-ocr-text {
  max-height: 220px;
  overflow: auto;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
  color: #1f2937;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.mechanism-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.mechanism-table th,
.mechanism-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

.mechanism-table th {
  position: sticky;
  top: 0;
  background: #f8f4ea;
  font-size: 11px;
  text-transform: uppercase;
}

.mechanism-text-cell {
  max-width: 360px;
  word-break: break-word;
}

.mechanism-list {
  display: grid;
  gap: 10px;
}

.mechanism-card {
  padding: 14px;
}

.mechanism-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.mechanism-card header > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.mechanism-card code {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.mechanism-line-text {
  margin: 12px 0;
  line-height: 1.7;
  word-break: break-word;
}

.mechanism-card summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.mechanism-token-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mechanism-token-grid span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 7px;
  font-size: 12px;
}

.mechanism-token-grid small {
  color: var(--muted);
}

.mechanism-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.mechanism-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.mechanism-detail-grid div {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 9px;
}

.mechanism-detail-grid span,
.mechanism-detail-grid strong {
  display: block;
}

.mechanism-detail-grid strong {
  margin-top: 3px;
  font-size: 16px;
}

.mechanism-candidate .mechanism-panel {
  margin-top: 10px;
  box-shadow: none;
}

.mechanism-breakdown {
  margin-top: 12px;
}

.mechanism-breakdown > strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.mechanism-breakdown code {
  margin-bottom: 8px;
}

.mechanism-breakdown ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mechanism-breakdown li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
  font-size: 12px;
}

.mechanism-mini-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.mechanism-mini-list div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px;
}

.mechanism-mini-list strong,
.mechanism-mini-list span {
  display: block;
}

.mechanism-json {
  overflow: auto;
  max-height: 680px;
  padding: 14px;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.55;
}

.mechanism-empty,
.mechanism-empty-row {
  color: var(--muted);
  text-align: center;
}

.tuning-body {
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

.tuning-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.tuning-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: start;
  padding: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.9);
  box-shadow: var(--shadow);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tuning-hero h1,
.tuning-card h2 {
  margin: 0;
}

.tuning-hero p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.tuning-hero-actions {
  display: flex;
  gap: 8px;
}

.tuning-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  margin-top: 18px;
}

.tuning-card {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.9);
  box-shadow: var(--shadow);
  padding: 20px;
}

.tuning-card.wide {
  grid-column: 1 / -1;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.roadmap-grid div,
.lab-field,
.tuning-output {
  border: 1px solid var(--line);
  background: #fffdf8;
}

.roadmap-grid div {
  padding: 14px;
}

.roadmap-grid strong {
  display: block;
  margin-bottom: 8px;
}

.roadmap-grid p,
.lab-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.lab-field {
  display: grid;
  gap: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.lab-field select {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font-weight: 800;
}

.lab-slider-grid {
  margin-top: 12px;
}

#labelDataset {
  width: 100%;
  min-height: 320px;
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #111;
  color: #f7f1e5;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

.lab-actions {
  grid-template-columns: 0.7fr 1fr;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-strip div {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 13px;
}

.metric-strip strong,
.metric-strip span,
.metric-strip small {
  display: block;
}

.metric-strip strong {
  font-size: 24px;
}

.metric-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metric-strip small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.tuning-output {
  min-height: 220px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.tuning-test-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 260px;
}

.tuning-test-actions a {
  text-decoration: none;
}

.tuning-analyzer-frame {
  width: 100%;
  height: min(980px, 82vh);
  min-height: 720px;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.embedded-analyzer {
  height: 100vh;
  overflow: hidden;
}

.embedded-analyzer .shell {
  grid-template-columns: clamp(220px, 18vw, 270px) minmax(0, 1fr) clamp(300px, 24vw, 380px);
  gap: 12px;
  padding: 12px;
}

.embedded-analyzer .control-panel,
.embedded-analyzer .workspace,
.embedded-analyzer .inspector {
  height: calc(100vh - 24px);
}

.embedded-analyzer .brand,
.embedded-analyzer .top-lab-button {
  display: none;
}

.embedded-analyzer .panel-section {
  padding: 14px 0;
}

.embedded-analyzer .file-drop {
  min-height: 118px;
  padding: 14px;
}

.embedded-analyzer .workspace-top {
  padding-top: 0;
}

.embedded-analyzer .workspace-top h1 {
  font-size: clamp(22px, 2.1vw, 30px);
}

.embedded-analyzer .workspace-top p {
  font-size: 13px;
}

.embedded-analyzer .metrics div {
  min-width: 66px;
  padding: 8px;
}

@media (max-width: 900px) {
  .tuning-hero,
  .tuning-layout,
  .roadmap-grid {
    grid-template-columns: 1fr;
  }

  .tuning-hero-actions {
    flex-wrap: wrap;
  }

  .tuning-test-actions {
    min-width: 0;
  }
}

@media (max-width: 920px) {
  .mechanism-topbar,
  .mechanism-hero,
  .mechanism-workbench,
  .mechanism-grid.two,
  .mechanism-toolbar {
    grid-template-columns: 1fr;
  }

  .mechanism-document-pane {
    position: static;
  }

  .mechanism-section-head,
  .mechanism-card header {
    display: grid;
  }

  .mechanism-scoreboard,
  .mechanism-flow,
  .case-summary,
  .case-board,
  .mechanism-detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mechanism-nav {
    top: 127px;
  }
}

@media (max-width: 560px) {
  .mechanism-scoreboard,
  .mechanism-document-facts,
  .mechanism-flow,
  .case-summary,
  .case-board,
  .mechanism-detail-grid {
    grid-template-columns: 1fr;
  }

  .mechanism-panel dl,
  .case-finding dl,
  .mechanism-breakdown li {
    grid-template-columns: 1fr;
  }
}

.four-part-mechanism-page .simple-mechanism-shell {
  width: min(1680px, 100%);
  padding-bottom: 64px;
}

.four-part-mechanism-page .simple-mechanism-hero {
  grid-template-columns: minmax(0, 1fr) minmax(420px, 620px);
  padding: 34px 0 24px;
}

.four-part-mechanism-page .simple-mechanism-hero h1 {
  max-width: 900px;
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.four-part-layout {
  display: grid;
  gap: 22px;
}

.pipeline-part {
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2vw, 28px);
  scroll-margin-top: 88px;
}

.pipeline-part-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.pipeline-part-head > span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.pipeline-part-head h2 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 34px);
  letter-spacing: -0.035em;
}

.pipeline-part-head p {
  max-width: 760px;
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.pipeline-two-column {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(380px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.pipeline-two-column.result-column {
  grid-template-columns: minmax(460px, 1.1fr) minmax(360px, 0.9fr);
}

.part-media-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.part-media-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.part-media-bar .part-media-label {
  margin-bottom: 0;
}

.input-overlay-controls {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.input-overlay-controls button {
  min-height: 30px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--muted);
  padding: 0 9px;
  font-size: 11px;
  font-weight: 900;
}

.input-overlay-controls button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.input-overlay-controls button[data-input-overlay="masked"].is-active {
  border-color: #111;
  background: #111;
  color: #fff;
}

.part-preview-frame {
  justify-content: center;
  align-content: start;
  min-height: 520px;
  max-height: min(82vh, 960px);
  padding: 16px;
}

.preview-image-stage {
  position: relative;
  display: block;
  width: fit-content;
  max-width: min(100%, 980px);
  margin: 0 auto;
}

.part-preview-frame img {
  display: block;
  max-width: min(100%, 980px);
  height: auto;
  transition: opacity 160ms ease, filter 160ms ease;
}

.preview-image-stage img {
  width: auto;
  max-width: 100%;
}

.preview-image-stage.is-overlay-mode img {
  opacity: 0.36;
  filter: grayscale(0.35) contrast(0.88);
}

.preview-image-stage.is-masked-mode img {
  opacity: 0.72;
  filter: none;
}

.input-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.input-overlay-box {
  position: absolute;
  display: block;
  min-width: 3px;
  min-height: 3px;
  appearance: none;
  border: 2px solid rgba(15, 118, 110, 0.92);
  background: rgba(15, 118, 110, 0.2);
  box-shadow: 0 0 0 1px rgba(255, 252, 244, 0.75), 0 6px 16px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.input-overlay-box:hover,
.input-overlay-box.is-selected {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(255, 252, 244, 0.9), 0 0 0 6px rgba(15, 118, 110, 0.35), 0 10px 24px rgba(15, 23, 42, 0.18);
  transform: scale(1.03);
}

.input-overlay-box.ocr {
  border-color: rgba(15, 118, 110, 0.92);
  background: rgba(15, 118, 110, 0.2);
}

.input-overlay-box.candidate {
  border-width: 3px;
  background: rgba(217, 119, 6, 0.26);
  z-index: 2;
}

.input-overlay-box.masked {
  border-color: rgba(17, 17, 17, 0.9);
  background: rgba(17, 17, 17, 0.18);
}

.input-overlay-box.selectable-ocr {
  z-index: 3;
  border: 2px dashed rgba(15, 118, 110, 0.82);
  background: rgba(15, 118, 110, 0.08);
  box-shadow: 0 0 0 1px rgba(255, 252, 244, 0.65);
}

.input-overlay-box.selectable-ocr:hover,
.input-overlay-box.selectable-ocr.is-selected {
  border-style: solid;
  background: rgba(15, 118, 110, 0.28);
}

.input-overlay-box.candidate.decision-auto {
  border-color: rgba(22, 101, 52, 0.98);
  background: rgba(22, 101, 52, 0.28);
}

.input-overlay-box.candidate.decision-review {
  border-color: rgba(180, 83, 9, 0.98);
  background: rgba(180, 83, 9, 0.3);
}

.input-overlay-box.candidate.decision-ignored {
  border-color: rgba(107, 114, 128, 0.95);
  background: rgba(107, 114, 128, 0.22);
}

.input-overlay-box em {
  position: absolute;
  left: 0;
  bottom: 100%;
  max-width: 220px;
  transform: translateY(-2px);
  background: #111;
  color: #fff;
  padding: 3px 6px;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-overlay-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.result-preview-frame {
  min-height: 680px;
}

.part-facts,
.part-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.part-summary-grid.vertical {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.stat-pill {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 13px;
}

.stat-pill span,
.stat-pill strong,
.stat-pill small {
  display: block;
}

.stat-pill span,
.stat-pill small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.stat-pill strong {
  margin: 4px 0 2px;
  font-size: 22px;
  word-break: break-word;
}

.part-detail {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
}

.part-detail summary,
.score-detail summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.part-detail p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.part-scroll {
  max-height: 360px;
  margin-top: 12px;
}

.part-list {
  display: grid;
  gap: 10px;
  max-height: min(760px, 70vh);
  margin-top: 12px;
  overflow: auto;
  padding-right: 6px;
}

.part-list.compact {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-height: 420px;
}

.token-row,
.trace-card {
  border: 1px solid var(--line);
  background: #fffdf8;
}

.token-row {
  display: grid;
  gap: 3px;
  padding: 11px;
}

.token-row strong {
  word-break: break-word;
}

.token-row span,
.token-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.trace-card {
  padding: 14px;
}

.trace-card.compact {
  padding: 12px;
}

.trace-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.trace-card header > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.trace-card header strong {
  font-size: 17px;
  word-break: break-word;
}

.trace-card header span:not(.badge) {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.trace-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.trace-metrics div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
}

.trace-metrics span,
.trace-metrics strong {
  display: block;
}

.trace-metrics span,
.trace-definition dt,
.score-detail small,
.score-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.trace-metrics strong {
  margin-top: 3px;
  word-break: break-word;
}

.trace-definition {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 12px 0;
  font-size: 13px;
}

.trace-definition dt,
.trace-definition dd {
  margin: 0;
}

.trace-definition dd {
  word-break: break-word;
}

.score-detail {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.score-detail ul {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.score-detail li {
  display: grid;
  grid-template-columns: 52px minmax(120px, 0.65fr) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
}

.score-detail li strong {
  color: var(--accent-dark);
}

.score-detail li span {
  font-size: 12px;
  font-weight: 900;
}

.score-detail small {
  line-height: 1.45;
}

.score-note {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.selected-detail-card {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  border: 2px solid var(--accent);
  background: #fffdf8;
  padding: 14px;
  box-shadow: 0 16px 36px rgba(15, 118, 110, 0.12);
}

.selected-detail-card.is-empty {
  border-style: dashed;
  border-color: var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  box-shadow: none;
}

.selected-detail-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.selected-detail-card header span {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.selected-detail-card header strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  word-break: break-word;
}

.selected-json {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.selected-json summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.selected-json pre {
  max-height: 220px;
  margin: 10px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: #111;
  color: #f7f1e5;
  padding: 10px;
  font-size: 11px;
  line-height: 1.55;
}

.reset-work-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 40px;
}

.issue-recorder {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.issue-recorder strong,
.issue-recorder span {
  display: block;
}

.issue-recorder strong {
  font-size: 13px;
}

.issue-recorder span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.issue-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.issue-expected-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 0.9fr) minmax(180px, 1.1fr);
}

.issue-expected-grid label {
  display: grid;
  gap: 5px;
}

.issue-expected-grid select,
.issue-expected-grid input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 8px 10px;
}

.issue-expected-grid p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.issue-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 44px));
  border: 2px solid var(--accent);
  background: #fffdf8;
  color: var(--ink);
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.dataset-lab-body {
  min-height: 100vh;
  overflow: auto;
}

.dataset-lab-shell {
  width: min(1720px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.dataset-lab-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 24px;
}

.dataset-lab-hero h1 {
  margin: 8px 0 8px;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.dataset-lab-hero p {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.6;
}

.dataset-lab-stats,
.dataset-category-grid,
.error-dashboard,
.ml-plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.dataset-lab-stats article,
.dataset-category-grid article,
.error-dashboard article,
.ml-plan-grid article {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 16px;
}

.dataset-lab-stats strong,
.error-dashboard strong {
  display: block;
  font-size: 32px;
  letter-spacing: -0.04em;
}

.dataset-lab-stats span,
.dataset-category-grid span,
.ml-plan-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.dataset-lab-stats small,
.dataset-category-grid small,
.dataset-category-grid p,
.error-dashboard p,
.ml-plan-grid p {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.dataset-lab-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.dataset-lab-tabs button {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--muted);
  padding: 12px 16px;
  font-weight: 900;
}

.dataset-lab-tabs button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.dataset-lab-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.dataset-lab-side,
.dataset-lab-main {
  display: grid;
  gap: 14px;
}

.lab-view {
  display: none;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  padding: 20px;
}

.lab-view.is-active {
  display: block;
}

.view-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.view-head > span {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.view-head h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.view-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.55;
}

.dataset-folder-picker {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 2px dashed var(--line);
  background: #fffdf8;
  cursor: pointer;
  font-weight: 900;
}

.dataset-folder-picker input {
  display: none;
}

.dataset-mini-summary {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.dataset-mini-summary strong {
  font-size: 28px;
}

.dataset-mini-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.dataset-table-wrap {
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.dataset-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dataset-table th,
.dataset-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.dataset-table th {
  position: sticky;
  top: 0;
  background: #fffdf8;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.dataset-table strong,
.dataset-table small {
  display: block;
}

.dataset-table small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.dataset-status {
  display: inline-flex;
  border: 1px solid var(--line);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
}

.dataset-status.is-ready {
  border-color: var(--accent);
  color: var(--accent);
}

.dataset-status.is-missing {
  color: var(--muted);
}

.issue-metric-strip,
.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.issue-metric-strip div,
.metric-strip div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}

.issue-metric-strip strong,
.metric-strip strong {
  display: block;
  font-size: 24px;
}

.issue-metric-strip span,
.metric-strip span,
.metric-strip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.metric-strip small {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.3;
}

.compact-case-list,
.issue-case-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.compact-case-list article {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}

.compact-case-list strong,
.compact-case-list span {
  display: block;
}

.compact-case-list span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.issue-case-card {
  display: grid;
  grid-template-columns: minmax(120px, 240px) minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
}

.issue-case-card img {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: var(--grid);
}

.issue-case-card header span,
.issue-case-card header strong {
  display: block;
}

.issue-case-card header span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.issue-case-card header strong {
  margin-top: 4px;
  font-size: 20px;
}

.issue-case-card p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.issue-case-card dl {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  font-size: 12px;
}

.issue-case-card dt,
.issue-case-card dd {
  margin: 0;
}

.issue-case-card dt {
  color: var(--muted);
  font-weight: 900;
}

.label-actions,
.experiment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.label-builder {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 14px;
}

.label-builder-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(240px, 1fr) minmax(180px, 0.8fr) minmax(220px, 1fr);
  gap: 10px;
}

.label-builder-grid label,
.label-chip-section {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.label-builder-grid input,
.label-builder-grid select,
.label-position-field output {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.label-position-field output {
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.label-chip-row,
.label-builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.label-chip-row button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 900;
  cursor: pointer;
}

.label-chip-row button.is-active {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-dark);
}

.label-mask-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.outcome-help-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
}

.outcome-help-panel > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.outcome-help-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.outcome-help-grid article {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}

.outcome-help-grid strong,
.outcome-help-grid span {
  display: block;
}

.outcome-help-grid strong {
  color: var(--accent);
  font-size: 13px;
}

.outcome-help-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.classification-toolbar,
.classification-toggles,
.classification-actions,
.manual-evaluation-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.classification-toolbar {
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.classification-toggles label {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.classification-actions button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.classification-actions {
  flex: 1 1 460px;
  justify-content: flex-end;
}

.classification-actions .primary.small,
.classification-actions .secondary.small {
  width: auto;
  min-width: 92px;
  padding: 0 14px;
  white-space: nowrap;
}

.policy-purpose-toggle {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  flex: 0 0 auto;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
}

.policy-purpose-toggle button {
  min-width: 82px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 0 12px;
}

.policy-purpose-toggle button:last-child {
  border-right: 0;
}

.policy-purpose-toggle button.is-active::before {
  content: "선택 ";
}

.classification-status {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-help-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.metric-help-panel article {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  padding: 10px;
}

.metric-help-panel strong,
.metric-help-panel span {
  display: block;
}

.metric-help-panel strong {
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
}

.metric-help-panel span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.result-export-help {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
}

.classification-compare-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.classification-compare-grid.detection-compare-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.classification-compare-grid.type-compare-grid {
  width: 100%;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.classification-compare-grid.type-compare-grid > section {
  min-width: 0;
}

.classification-compare-grid.type-compare-grid .part-list.compact {
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
}

.classification-compare-grid h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.policy-eval-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.policy-eval-actions button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ocr-history-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
}

.ocr-options-panel {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px 12px;
}

.ocr-history-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 900;
}

.ocr-options-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.option-help-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  border: 1px dashed rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.045);
  padding: 12px;
}

.option-help-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.6;
}

.option-help-panel strong {
  color: var(--ink);
}

.option-help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.option-help-grid article {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  padding: 10px;
}

.option-help-grid strong,
.option-help-grid span {
  display: block;
}

.option-help-grid strong {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.option-help-grid span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
}

.rule-guide-panel {
  display: grid;
  gap: 10px;
  margin: 10px 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.rule-guide-panel h3,
.rule-guide-panel p {
  margin: 0;
}

.rule-guide-panel h3 {
  font-size: 14px;
}

.rule-guide-panel p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.rule-formula {
  border: 1px dashed rgba(15, 118, 110, 0.42);
  background: rgba(15, 118, 110, 0.07);
  color: var(--accent-dark);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
}

.rule-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.rule-guide-grid article {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
}

.rule-guide-grid strong,
.rule-guide-grid span,
.rule-guide-grid em {
  display: block;
}

.rule-guide-grid strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.rule-guide-grid span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
}

.rule-guide-grid em {
  margin-top: 7px;
  color: var(--accent);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.ocr-inline-grid {
  margin-top: 10px;
}

.trace-card.is-focused {
  border-color: #111;
  background: #fff;
  box-shadow: inset 4px 0 0 #111;
}

.manual-evaluation-panel {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 14px;
}

.manual-evaluation-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.manual-evaluation-form input,
.manual-evaluation-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 0 10px;
}

.label-row-card {
  cursor: pointer;
}

.label-quick-list,
.evaluation-history-list {
  display: grid;
  gap: 8px;
}

.label-quick-list article,
.evaluation-history-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}

.label-quick-list strong,
.label-quick-list span,
.evaluation-history-list strong,
.evaluation-history-list span,
.evaluation-history-list small {
  display: block;
}

.label-quick-list span,
.evaluation-history-list span,
.evaluation-history-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.label-quick-list button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  min-height: 30px;
  padding: 0 9px;
  font-weight: 900;
  cursor: pointer;
}

.tuning-mechanism-page .tuning-top-actions,
.tuning-action-row,
.ocr-profile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tuning-mechanism-page .mechanism-topbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.tuning-mechanism-page .mechanism-shell,
.tuning-mechanism-page.four-part-mechanism-page .simple-mechanism-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-left: 8px;
  padding-right: 8px;
}

.tuning-mechanism-page .tuning-workbench {
  min-height: calc(100vh - 250px);
}

.tuning-mechanism-page .mechanism-workbench-body {
  grid-template-columns: minmax(640px, 1.32fr) minmax(390px, 0.68fr);
}

.tuning-document-pane {
  min-width: 0;
}

.tuning-document-frame {
  align-content: start;
  justify-content: stretch;
  place-items: start stretch;
  min-height: 680px;
  position: relative;
  user-select: none;
}

.tuning-document-frame iframe,
.tuning-document-frame img,
.tuning-document-frame canvas {
  width: 100%;
  border: 0;
  background: #fff;
}

.tuning-document-frame iframe {
  height: 100%;
  min-height: 680px;
}

.tuning-document-frame img {
  height: auto;
  max-height: none;
  object-fit: contain;
}

.tuning-document-frame canvas {
  display: block;
  height: auto;
  min-height: 0;
  justify-self: stretch;
  box-shadow: 0 0 0 1px rgba(26, 22, 16, 0.1);
}

.tuning-document-frame canvas[hidden] {
  display: none;
}

.document-label-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.document-label-box {
  position: absolute;
  appearance: none;
  border: 2px solid var(--accent);
  padding: 0;
  background: rgba(15, 118, 110, 0.14);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  pointer-events: auto;
}

.document-label-box.overlay-ocr {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.12);
}

.document-label-box.overlay-predicted {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.16);
}

.document-label-box.overlay-gold {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.18);
}

.document-label-box.overlay-type-match,
.document-label-box.overlay-policy-match {
  border-color: #15803d;
  background: rgba(21, 128, 61, 0.18);
}

.document-label-box.overlay-type-mismatch,
.document-label-box.overlay-policy-mismatch {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.16);
}

.document-label-box.overlay-policy-mask {
  z-index: 8;
  border-color: #050505;
  background: #050505;
  box-shadow: none;
  opacity: 0.96;
}

.document-label-box.overlay-policy-mask.mask-action-remove {
  border-color: #050505;
  background: #050505;
}

.document-label-box.overlay-policy-mask.mask-action-mask {
  border-color: #050505;
  background:
    repeating-linear-gradient(45deg, #050505 0 4px, #272727 4px 7px),
    #050505;
}

.document-label-box.overlay-policy-mask.mask-action-partial-mask,
.document-label-box.overlay-policy-mask.mask-action-partial-keep,
.document-label-box.overlay-policy-mask.mask-action-tokenize {
  display: flex;
  align-items: center;
  overflow: hidden;
  border-color: rgba(26, 22, 16, 0.32);
  background: rgba(255, 253, 248, 0.96);
  opacity: 1;
}

.document-label-box.overlay-policy-mask.mask-action-partial-mask::after,
.document-label-box.overlay-policy-mask.mask-action-partial-keep::after,
.document-label-box.overlay-policy-mask.mask-action-tokenize::after {
  content: attr(data-mask-text);
  display: block;
  width: 100%;
  padding: 0 4px;
  overflow: hidden;
  color: #111;
  font-size: clamp(9px, 1.15vw, 14px);
  font-weight: 950;
  line-height: 1;
  text-align: left;
  text-overflow: clip;
  white-space: nowrap;
}

.document-label-box.overlay-policy-mask.mask-action-partial-mask::before {
  content: "";
  position: absolute;
  inset: 18% 34% 18% 34%;
  background:
    repeating-linear-gradient(45deg, #050505 0 3px, #2b2b2b 3px 6px),
    #050505;
  opacity: 0.92;
}

.document-label-box.overlay-policy-mask.mask-action-partial-mask::after {
  position: relative;
  z-index: 1;
}

.document-label-box.overlay-policy-mask.mask-action-partial-keep {
  border-color: #7c3aed;
  background: rgba(245, 243, 255, 0.96);
}

.document-label-box.overlay-policy-mask.mask-action-tokenize {
  border-color: #2563eb;
  background: rgba(239, 246, 255, 0.98);
}

.document-label-box.overlay-policy-mask.mask-action-tokenize::after {
  color: #1d4ed8;
}

.document-label-box.is-focused {
  z-index: 5;
  border-color: #111;
  background: rgba(17, 17, 17, 0.12);
  box-shadow: 0 0 0 3px rgba(255, 252, 244, 0.96), 0 0 0 6px rgba(17, 17, 17, 0.22);
}

.document-label-box.is-point {
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.2);
}

.tuning-document-controls {
  display: grid;
  grid-template-columns: minmax(170px, 0.85fr) auto minmax(0, 1.15fr);
  gap: 10px;
  margin-top: 12px;
  align-items: stretch;
}

.tuning-mechanism-page:not([data-active-step="datasetPanel"]) .tuning-document-controls,
.tuning-document-facts {
  display: none;
}

.tuning-document-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tuning-document-controls select {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.mechanism-folder-picker {
  min-height: 40px;
  margin: 0;
}

.restore-document-cache-button {
  min-height: 40px;
  white-space: nowrap;
}

.tuning-document-facts {
  margin-top: 12px;
}

.tuning-panel-layout {
  min-height: 0;
}

.tuning-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 4px;
}

.tuning-drop-zone {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 14px;
  border: 1px dashed var(--line);
  background: rgba(255, 252, 244, 0.82);
  padding: 18px;
  text-align: center;
  color: var(--muted);
}

.tuning-drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-dark);
}

.tuning-drop-zone svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.tuning-drop-zone strong,
.tuning-drop-zone span {
  display: block;
}

.tuning-drop-zone strong {
  color: var(--ink);
  font-size: 16px;
}

.tuning-drop-zone span {
  font-size: 12px;
  font-weight: 900;
}

.tuning-doc-grid button {
  display: grid;
  gap: 5px;
  min-height: 96px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.tuning-doc-grid button.is-active {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.1);
}

.tuning-doc-grid span,
.tuning-doc-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tuning-doc-grid strong {
  color: var(--ink);
  font-size: 15px;
}

.mechanism-label-builder {
  margin-bottom: 12px;
}

.tuning-json-editor {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 12px;
}

.tuning-json-editor summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 900;
}

.tuning-json-editor .label-editor {
  min-height: 360px;
}

.tuning-evaluation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.tuning-subsection {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 14px;
}

.tuning-subsection .card-head {
  margin-bottom: 12px;
}

.tuning-action-row {
  margin: 12px 0;
}

.tuning-mechanism-page .metric-strip.compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.tuning-mechanism-page .tuning-output {
  max-height: 260px;
}

.label-editor {
  width: 100%;
  min-height: 58vh;
  border: 1px solid var(--line);
  background: #111;
  color: #f7f1e5;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
}

.rule-tuning-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.rule-evaluation-card {
  grid-column: 1 / -1;
}

.metric-strip.compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.tuning-card.flat {
  box-shadow: none;
}

.lab-empty {
  border: 1px dashed var(--line);
  background: #fff;
  color: var(--muted);
  padding: 18px;
  font-weight: 900;
}

@media (max-width: 980px) {
  .dataset-lab-hero,
  .dataset-lab-grid,
  .rule-tuning-layout,
  .label-builder-grid,
  .tuning-document-controls,
  .tuning-evaluation-grid,
  .tuning-doc-grid {
    grid-template-columns: 1fr;
  }

  .dataset-lab-stats,
  .dataset-category-grid,
  .error-dashboard,
  .ml-plan-grid,
  .metric-help-panel,
  .metric-strip.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .issue-case-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .metric-help-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .four-part-mechanism-page .simple-mechanism-hero,
  .pipeline-two-column,
  .pipeline-two-column.result-column {
    grid-template-columns: 1fr;
  }

  .part-preview-frame,
  .result-preview-frame {
    min-height: 420px;
  }
}

@media (max-width: 680px) {
  .pipeline-part-head,
  .part-facts,
  .part-summary-grid,
  .part-summary-grid.vertical,
  .trace-metrics,
  .score-detail li {
    grid-template-columns: 1fr;
  }

  .trace-card header {
    display: grid;
  }

  .badge-group {
    justify-content: flex-start;
  }
}

.four-part-mechanism-page {
  height: 100vh;
  overflow: hidden;
}

.four-part-mechanism-page .mechanism-topbar {
  min-height: 64px;
}

.four-part-mechanism-page .simple-mechanism-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1920px, 100%);
  height: calc(100vh - 67px);
  padding: 14px 18px 18px;
  overflow: hidden;
}

.four-part-mechanism-page .simple-mechanism-hero {
  grid-template-columns: minmax(0, 1fr) minmax(380px, 560px);
  gap: 16px;
  padding: 0 0 12px;
  align-items: center;
}

.four-part-mechanism-page .simple-mechanism-hero h1 {
  max-width: 760px;
  margin: 0 0 6px;
  font-size: clamp(22px, 2.4vw, 36px);
  line-height: 1.15;
}

.four-part-mechanism-page .mechanism-kicker {
  margin-bottom: 4px;
}

.four-part-mechanism-page .mechanism-scoreboard {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.four-part-mechanism-page .mechanism-scoreboard div {
  padding: 8px;
  box-shadow: none;
}

.four-part-mechanism-page .mechanism-scoreboard strong {
  font-size: 18px;
}

.four-part-workbench {
  display: grid;
  grid-template-columns: clamp(260px, 18vw, 340px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.mechanism-step-rail {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
}

.mechanism-step-rail button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 12px;
  align-content: center;
  min-height: 0;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.9);
  color: var(--ink);
  padding: 14px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.mechanism-step-rail button:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.mechanism-step-rail button.is-active {
  border-color: var(--accent);
  background: #0f766e;
  color: #fff;
}

.mechanism-step-rail button > span {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.mechanism-step-rail button.is-active > span {
  background: #fff;
  color: var(--accent-dark);
}

.mechanism-step-rail strong,
.mechanism-step-rail small {
  display: block;
  min-width: 0;
}

.mechanism-step-rail strong {
  font-size: clamp(15px, 1vw, 19px);
  letter-spacing: -0.03em;
}

.mechanism-step-rail small {
  color: currentColor;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.72;
  word-break: keep-all;
}

.mechanism-detail-pane {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
}

.detail-pane-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 4px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 244, 0.96);
  backdrop-filter: blur(12px);
}

.detail-pane-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-pane-head h2 {
  margin: 0;
  font-size: clamp(24px, 2vw, 36px);
  letter-spacing: -0.04em;
}

.detail-pane-head p {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.four-part-mechanism-page .four-part-layout {
  display: block;
  padding: 18px;
}

.four-part-mechanism-page .pipeline-part {
  display: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.four-part-mechanism-page .pipeline-part.is-active {
  display: block;
  animation: rise 180ms ease both;
}

.four-part-mechanism-page .pipeline-part-head {
  display: none;
}

.four-part-mechanism-page .pipeline-two-column {
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.82fr);
}

.four-part-mechanism-page .pipeline-two-column.result-column {
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.82fr);
}

.four-part-mechanism-page .part-preview-frame {
  min-height: min(520px, calc(100vh - 290px));
  max-height: calc(100vh - 250px);
}

.four-part-mechanism-page .result-preview-frame {
  min-height: min(560px, calc(100vh - 290px));
}

.four-part-mechanism-page .part-list {
  max-height: calc(100vh - 320px);
}

.four-part-mechanism-page .part-list.compact {
  max-height: calc(100vh - 410px);
}

.four-part-mechanism-page .part-scroll {
  max-height: min(260px, 30vh);
}

@media (max-width: 1180px) {
  .four-part-mechanism-page {
    height: auto;
    overflow: auto;
  }

  .four-part-mechanism-page .simple-mechanism-shell {
    height: auto;
    overflow: visible;
  }

  .four-part-workbench {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .mechanism-step-rail {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    grid-template-rows: none;
    overflow-x: auto;
  }

  .mechanism-detail-pane {
    overflow: visible;
  }

  .four-part-mechanism-page .pipeline-two-column,
  .four-part-mechanism-page .pipeline-two-column.result-column {
    grid-template-columns: 1fr;
  }
}

.four-part-mechanism-page .simple-mechanism-shell {
  grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - 64px);
  padding: 8px 10px 10px;
}

.four-part-mechanism-page .simple-mechanism-hero {
  display: none;
}

.four-part-mechanism-page .four-part-workbench {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.four-part-mechanism-page .mechanism-step-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: none;
  gap: 8px;
  min-height: 0;
}

.four-part-mechanism-page .mechanism-step-rail button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-content: center;
  min-height: 72px;
  padding: 10px 12px;
}

.four-part-mechanism-page .mechanism-step-rail button > span {
  grid-row: 1 / span 2;
  width: auto;
  min-width: 68px;
  height: 38px;
  padding: 0 10px;
  background: #fff;
  color: var(--accent-dark);
  border: 1px solid var(--line);
  font-size: 14px;
}

.four-part-mechanism-page .mechanism-step-rail button.is-active > span {
  background: #fff;
  color: var(--accent-dark);
}

.four-part-mechanism-page .mechanism-step-rail strong {
  font-size: 18px;
}

.four-part-mechanism-page .mechanism-step-rail small {
  font-size: 11px;
}

.mechanism-workbench-body {
  display: grid;
  grid-template-columns: minmax(640px, 1.32fr) minmax(390px, 0.68fr);
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.mechanism-image-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.mechanism-image-pane .part-media-bar.compact {
  align-items: baseline;
  min-height: 30px;
  margin-bottom: 4px;
}

.mechanism-image-pane .part-media-label {
  font-size: 13px;
}

.mechanism-image-pane .input-overlay-hint {
  margin: 0;
  font-size: 11px;
  text-align: right;
}

.four-part-mechanism-page .workbench-image-frame {
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 2px;
}

.four-part-mechanism-page .preview-image-stage {
  max-width: 100%;
}

.four-part-mechanism-page .part-preview-frame img {
  max-width: 100%;
}

.four-part-mechanism-page .mechanism-detail-pane {
  min-height: 0;
  overflow: auto;
}

.four-part-mechanism-page .detail-pane-head {
  padding: 10px 12px 8px;
}

.four-part-mechanism-page .detail-pane-head h2 {
  font-size: clamp(20px, 1.7vw, 28px);
}

.four-part-mechanism-page .detail-pane-head p {
  font-size: 12px;
}

.four-part-mechanism-page .four-part-layout {
  padding: 10px 12px 12px;
}

.four-part-mechanism-page .part-facts,
.four-part-mechanism-page .part-summary-grid {
  gap: 8px;
}

.four-part-mechanism-page .mechanism-fact,
.four-part-mechanism-page .stat-pill,
.four-part-mechanism-page .trace-card,
.four-part-mechanism-page .token-row {
  box-shadow: none;
}

.four-part-mechanism-page .part-list {
  max-height: calc(100vh - 265px);
}

.four-part-mechanism-page .part-list.compact {
  grid-template-columns: 1fr;
  max-height: calc(100vh - 430px);
}

.four-part-mechanism-page .classification-compare-grid {
  width: 100%;
  align-self: stretch;
  justify-self: stretch;
}

.four-part-mechanism-page .classification-compare-grid.detection-compare-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-part-mechanism-page .classification-compare-grid.type-compare-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.four-part-mechanism-page .classification-compare-grid > section {
  min-width: 0;
  width: 100%;
}

.four-part-mechanism-page .classification-compare-grid .part-list.compact {
  width: 100%;
}

.four-part-mechanism-page #evaluationPanel .classification-toolbar {
  align-items: center;
}

.four-part-mechanism-page #evaluationPanel .classification-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: end;
  align-items: center;
}

.four-part-mechanism-page #evaluationPanel .policy-purpose-toggle {
  grid-template-columns: repeat(3, minmax(74px, auto));
}

.four-part-mechanism-page #evaluationPanel .classification-actions .primary.small,
.four-part-mechanism-page #evaluationPanel .classification-actions .secondary.small {
  width: auto;
  min-width: 86px;
  min-height: 34px;
}

.four-part-mechanism-page .part-scroll {
  max-height: min(220px, 24vh);
}

@media (max-width: 860px) {
  .mechanism-workbench-body {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .four-part-mechanism-page .mechanism-step-rail {
    grid-template-columns: repeat(5, minmax(180px, 1fr));
  }

  .four-part-mechanism-page .workbench-image-frame {
    height: 62vh;
    min-height: 420px;
  }
}
