:root {
  color-scheme: dark;
  --bg: #111312;
  --panel: #1b1d1b;
  --panel-2: #232620;
  --line: #393d35;
  --text: #f4f2e9;
  --muted: #aaaea3;
  --accent: #45c7bd;
  --accent-2: #e5bd4f;
  --danger: #ff766c;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
select,
input,
textarea {
  font: inherit;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #171a17;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #4c5148;
  border-radius: var(--radius);
  background: #090a09;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.15;
  font-weight: 750;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 750;
}

.brand p,
.panel-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.case-tools {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.case-tools button {
  align-self: end;
}

.text-wrap,
.select-wrap,
.note-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.text-wrap {
  min-width: 150px;
}

.select-wrap {
  min-width: 190px;
}

.select-wrap.compact {
  min-width: 150px;
}

.case-tools span {
  white-space: nowrap;
}

select,
input[type="search"],
input[type="text"],
textarea {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #10120f;
  padding: 0 30px 0 10px;
}

input[type="search"],
input[type="text"],
textarea {
  width: 100%;
  padding-right: 10px;
}

textarea {
  min-height: 56px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.35;
}

button,
.toggle {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10120f;
  color: var(--text);
  padding: 0 11px;
}

button {
  cursor: pointer;
}

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

.case-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.6fr);
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #151815;
  max-height: 36vh;
  overflow: auto;
}

.case-info.is-hidden {
  display: none;
}

.case-notes {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(160px, 0.7fr) minmax(260px, 1.5fr);
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #151815;
}

.case-notes.is-hidden {
  display: none;
}

.info-section h3 {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 750;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin: 0;
}

.info-grid div {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.info-grid dt {
  color: #d4d1c2;
}

.info-grid dd {
  margin: 0;
  color: var(--text);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 0.34fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.viewer-panel,
.findings-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.viewer-panel {
  grid-template-rows: auto minmax(300px, 1fr) auto;
}

.findings-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.compact-head {
  min-height: 56px;
}

.panel-head > div {
  min-width: 0;
}

.panel-head p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 54vw;
}

.head-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.decode-toggle {
  align-self: end;
  min-height: 34px;
}

.canvas-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(45deg, #0b0b0b 25%, transparent 25%),
    linear-gradient(-45deg, #0b0b0b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0b0b0b 75%),
    linear-gradient(-45deg, transparent 75%, #0b0b0b 75%);
  background-color: #050505;
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  cursor: grab;
}

.canvas-stage.dragging {
  cursor: grabbing;
}

.canvas-stage.has-status::after {
  content: attr(data-status);
  position: sticky;
  left: 12px;
  top: 12px;
  z-index: 2;
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(16, 18, 15, 0.92);
  color: var(--text);
  font-size: 12px;
}

.ct-loader {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: min(440px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 18, 15, 0.94);
  padding: 13px 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.36);
}

.ct-loader.is-hidden {
  display: none;
}

.ct-loader-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.ct-loader-row span:last-child {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.ct-loader-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ct-loader-mode {
  flex: 0 0 auto;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(69, 199, 189, 0.55);
  border-radius: 999px;
  padding: 0 8px;
  color: #d8fffb;
  background: rgba(69, 199, 189, 0.13);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.ct-loader.mode-server .ct-loader-mode {
  border-color: rgba(229, 189, 79, 0.55);
  color: #fff0c4;
  background: rgba(229, 189, 79, 0.14);
}

.ct-loader-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #050605;
  box-shadow: inset 0 0 0 1px var(--line);
}

.ct-loader-bar {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms ease;
}

.ct-loader.mode-server .ct-loader-bar {
  background: var(--accent-2);
}

canvas {
  display: block;
  margin: 12px auto;
  image-rendering: auto;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.controls {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: #171a17;
}

.control-line {
  display: grid;
  grid-template-columns: 62px minmax(100px, 1fr) 72px;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.control-line output {
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.slice-availability-row {
  display: grid;
  grid-template-columns: 62px minmax(100px, 1fr) 150px;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.slice-availability-row::before {
  content: "";
}

.slice-availability {
  width: 100%;
  height: 10px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #050605;
}

.slice-availability-row output {
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 34px;
}

.mode-row {
  gap: 6px;
}

.mode-button.active {
  border-color: var(--accent);
  background: rgba(69, 199, 189, 0.16);
  color: #effffb;
}

.mode-row output {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-2);
}

.findings-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
}

.finding-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 6px;
  background: #10120f;
  padding: 8px;
}

.finding-item.positive {
  border-left-color: var(--danger);
}

.finding-item.negative {
  border-left-color: var(--accent);
}

.finding-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.finding-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.finding-consensus {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.reader-votes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.reader-vote {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.reader-vote.yes {
  border-color: rgba(255, 118, 108, 0.55);
  color: #ffd6d2;
}

.reader-vote.no {
  border-color: rgba(69, 199, 189, 0.42);
  color: #c9fff8;
}

.dataset-credit-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: #151815;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.dataset-credit-footer nav {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dataset-credit-footer a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.dataset-credit-footer a:hover {
  text-decoration: underline;
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .case-tools {
    justify-content: start;
  }

  .case-notes,
  .case-info {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .findings-panel,
  .viewer-panel {
    min-height: 620px;
  }

  .dataset-credit-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 8px;
  }

  .panel-head,
  .head-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .select-wrap,
  .select-wrap.compact,
  .text-wrap {
    min-width: 0;
    width: 100%;
  }

  .control-line {
    grid-template-columns: 54px minmax(0, 1fr) 64px;
  }

  .slice-availability-row {
    grid-template-columns: 54px minmax(0, 1fr) 82px;
  }
}
