#results-section { scroll-margin-top: 12px; }
.rank, .facts dd { font-variant-numeric: tabular-nums; }
#results-content { overflow-wrap: anywhere; }
.status-badge { display: inline-block; width: fit-content; padding: 2px 7px; border-radius: 5px; background: #edf1ef; color: #52645b; font-size: 13px; white-space: nowrap; }
.status-badge.good { background: #e3f2e9; color: #28654e; }
.status-badge.warn { background: #fbf1d9; color: #805a1f; }
.status-badge.bad { background: #fae9e2; color: var(--error); }
.original-link { display: inline-flex; white-space: nowrap; flex: 0 0 auto; }
.result-layout { display: grid; grid-template-columns: minmax(188px, 22%) minmax(0, 1fr); }
.candidate-rail { min-width: 0; border-right: 1px solid var(--line); padding: 15px 12px; background: #fafcf9; border-bottom-left-radius: inherit; }
.candidate-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 5px 12px; }
.candidate-heading small { white-space: nowrap; }
.candidate-list, .history-list { list-style: none; padding: 0; }
.candidate-list { display: grid; gap: 5px; max-height: 72vh; overflow: auto; }
.candidate-choice { width: 100%; display: grid; grid-template-columns: 2ch minmax(0, 1fr) auto; align-items: baseline; gap: 7px; text-align: left; padding: 10px 8px; border: 1px solid transparent; border-radius: 7px; }
.candidate-choice[aria-pressed=true] { background: var(--wash); border-color: #b5d6c7; box-shadow: inset 3px 0 var(--teal); }
.candidate-choice:hover { background: #f0f5f0; }
.rank { font: 12px/1.8 var(--mono); color: var(--muted); }
.candidate-name { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.candidate-score { color: var(--teal); font: 600 12px/1.8 var(--mono); white-space: nowrap; }
/* A score earned on a fraction of the section reads as a warning, not a match. */
.candidate-score.partial { color: #9a6a1f; font-weight: 500; }
.result-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.inspection { min-width: 0; padding: clamp(14px, 1.65vw, 24px); }
.candidate-actions, .dialog-drawing-actions { display: flex; justify-content: flex-end; }
.candidate-actions { margin-bottom: 10px; }
.dialog-drawing-actions { margin-top: 12px; }
.drawing-pane, .drawing-heading > div { min-width: 0; }
.drawing-pair, .empty-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.empty-results { padding: 15px; }
.drawing-pane { border: 1px solid var(--line); border-radius: 8px; background: white; overflow: hidden; }
.drawing-heading, .drawing-caption { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 8px 12px; }
.drawing-heading { border-bottom: 1px solid var(--line); }
.drawing-label { display: block; width: fit-content; font-size: 13px; color: var(--teal); font-weight: 600; }
.drawing-name { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-weight: 650; }
.drawing-heading .icon-button { width: 29px; min-height: 29px; flex: 0 0 auto; }
.drawing-caption { flex-wrap: wrap; border-top: 1px solid var(--line); font: 13px/1.6 var(--mono); color: var(--muted); }
.drawing-caption .status-badge { font-family: system-ui, sans-serif; }
.drawing-stage { display: grid; place-items: center; position: relative; height: clamp(220px, 19vw, 295px); isolation: isolate; background-color: #f6f9f5; background-image: linear-gradient(#d6e1d975 1px, transparent 1px), linear-gradient(90deg, #d6e1d975 1px, transparent 1px); background-size: 18px 18px; }
.drawing { position: absolute; top: 9px; width: calc(100% - 18px); height: calc(100% - 53px); user-select: none; }
.drawing.zoomed { cursor: grab; touch-action: none; }
.drawing.zoomed:active { cursor: grabbing; }
.drawing path { fill: none; stroke: #234b43; stroke-width: 1.8px; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.drawing path[data-kind=hole] { stroke: #20758a; }
.drawing path[data-kind=open] { stroke: #a26827; }
.viewport-tools { position: absolute; bottom: 7px; right: 8px; display: flex; align-items: center; gap: 1px; padding: 1px; border: 1px solid #cbd8ce; border-radius: 6px; background: #fffffff2; }
.viewport-tools .icon-button { width: 27px; min-height: 26px; border: 0; background: transparent; }
.viewport-tools .icon-button:hover { background: var(--wash); }
.viewport-tools .icon-button:disabled { opacity: .45; }
.viewport-tools .icon { width: 15px; height: 15px; }
.zoom-level { font: 12px var(--mono); min-width: 32px; text-align: center; }
.drawing-error { display: grid; gap: 8px; justify-items: center; padding: 12px; color: var(--error); }
.facts { display: grid; gap: 8px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts dt { display: block; color: var(--muted); font-size: 13px; }
.facts dd { margin-top: 2px; overflow-wrap: anywhere; }
.library-table { width: 100%; border-collapse: collapse; text-align: left; }
.library-table th { color: var(--muted); font-size: 13px; font-weight: 550; background: #f3f6f1; }
.library-table th, .library-table td { padding: 10px; }
.library-table td { border-bottom: 1px solid #e3eae4; overflow-wrap: anywhere; }
.file-cell { max-width: 48vw; }
.file-name { padding: 2px 0; display: inline-flex; align-items: center; gap: 8px; font-weight: 650; text-align: left; overflow-wrap: anywhere; }
.file-name .icon { color: var(--teal); }
.file-name:hover { color: var(--teal); text-decoration: underline; }
.file-cell small { display: block; }
.row-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.history-list li { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; border-top: 1px solid var(--line); padding: 14px 0; }
.history-list li:first-child { border-top: 0; }
.history-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
dialog { width: min(824px, calc(100% - 24px)); max-height: 92dvh; border: 1px solid #c1d4cb; border-radius: 12px; padding: clamp(16px, 2vw, 27px); color: var(--ink); box-shadow: 0 16px 62px #0c2c3040; }
dialog::backdrop { background: #132f32a8; }
dialog .drawing-stage { height: clamp(240px, 46dvh, 510px); }
dialog .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0; }
dialog .drawing-name { white-space: normal; overflow-wrap: anywhere; }
#revision-dialog { max-width: 560px; }
#revision-name { font-weight: 650; margin: 8px 0 4px; overflow-wrap: anywhere; }
#revision-geometry { margin: 12px 0; }
#revision-reason { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 1000px) {
  .result-layout { grid-template-columns: minmax(0, 1fr); }
  .candidate-rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .candidate-list { display: flex; overflow-x: auto; max-height: none; }
  .candidate-list > li { flex: 0 0 220px; }
  .candidate-choice { width: 100%; height: 100%; }
  .candidate-choice[aria-pressed=true] { box-shadow: inset 0 -2px var(--teal); }
}
@media (max-width: 650px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-cell { max-width: none; }
  .library-table, .library-table tbody, .library-table tr { display: block; }
  .library-table thead { position: absolute; clip-path: inset(50%); }
  .library-table tr { border-top: 1px solid var(--line); padding: 9px 0; }
  .library-table td { display: flex; align-items: baseline; border: 0; padding: 3px 0; gap: 8px; }
  .library-table td:not(:first-child)::before { content: attr(data-label); font-size: 13px; color: var(--muted); }
  .history-name { flex-basis: 100%; } .history-list li .button { margin-left: auto; }
}
@media (max-width: 520px) {
  .inspection { padding: 12px; } .drawing-pair { gap: 6px; } .drawing-heading, .drawing-caption { padding: 6px 7px; }
  .drawing-stage { height: clamp(147px, 42vw, 215px); } .drawing { height: calc(100% - 43px); top: 6px; }
  .drawing-heading .icon-button { width: 25px; min-height: 26px; }
  .drawing-caption { gap: 3px; } .viewport-tools { right: 4px; bottom: 3px; } .zoom-level { display: none; }
  .empty-results { grid-template-columns: minmax(0, 1fr); }
  dialog .zoom-level { display: block; } dialog .facts { grid-template-columns: minmax(0, 1fr); }
}
