:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #1266a8;
  --accent-dark: #0b4d80;
  --danger: #a93434;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 650;
}

#reference,
#status {
  color: var(--muted);
}

.muted-line {
  color: var(--muted);
  margin-bottom: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

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

.button-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.input-toolbar {
  display: grid;
  grid-template-columns: minmax(130px, 160px) minmax(90px, 110px) auto;
  align-items: end;
  gap: 8px;
}

.compact-control {
  min-width: 0;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 1px dashed #9aa8b8;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfe;
  margin-bottom: 12px;
}

.drop-zone.dragover {
  border-color: var(--accent);
  color: var(--accent);
  background: #edf6fc;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.checkbox-label {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.checkbox-label input {
  width: auto;
  min-height: 0;
  align-self: center;
}

input,
select,
button,
.file-button,
.link-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

button,
.file-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
}

button:hover,
.file-button:hover,
.link-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.link-button {
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: #fff;
  color: var(--accent);
  border-color: #b9d7ee;
}

/* Searchable species dropdown */
.placement-select {
  position: relative;
  width: 100%;
}

.placement-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 1px solid #b9d7ee;
  border-radius: 4px;
  font: inherit;
  color: inherit;
  background: #fff;
}

.placement-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(24, 119, 195, 0.15);
}

.placement-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid #b9d7ee;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(15, 44, 68, 0.12);
  max-height: 320px;
  overflow-y: auto;
}

.placement-options {
  padding: 4px 0;
}

.placement-option {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.placement-option:hover,
.placement-option[aria-selected="true"] {
  background: #edf6fc;
}

.placement-option:disabled {
  color: #8a97a3;
  cursor: not-allowed;
}

.placement-option-empty {
  padding: 0.55rem 0.75rem;
  color: #8a97a3;
  font-style: italic;
}

.secondary-button:hover {
  background: #edf6fc;
  border-color: var(--accent);
}

.danger-button {
  background: var(--danger);
  border-color: var(--danger);
}

.danger-button:hover {
  background: #872626;
  border-color: #872626;
}

.file-button input {
  display: none;
}

.row-button {
  min-height: 30px;
  padding: 0 10px;
  background: #fff;
  color: var(--danger);
  border-color: #e7b7b7;
}

.row-button:hover {
  background: #fff3f3;
  border-color: var(--danger);
}

.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.select-button {
  min-height: 30px;
  padding: 0 10px;
  background: #fff;
  color: var(--accent);
  border-color: #b9d7ee;
}

.select-button:hover {
  background: #edf6fc;
  border-color: var(--accent);
}

.delete-button {
  min-height: 30px;
  padding: 0 10px;
  background: #fff;
  color: var(--danger);
  border-color: #e7b7b7;
}

.delete-button:hover {
  background: #fff3f3;
  border-color: var(--danger);
}

.saved-sketch-table .selected-row td {
  background: #edf6fc;
}

.digest-text {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.file-flag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.file-progress {
  display: grid;
  gap: 4px;
  min-width: 190px;
}

.file-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.file-progress-label span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-progress progress {
  height: 8px;
}

.file-progress-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.file-progress-error .file-progress-label,
.file-progress-error .file-progress-detail {
  color: var(--danger);
}

.actions {
  display: grid;
  grid-template-columns: auto auto minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
}

progress {
  width: 100%;
  height: 12px;
}

.result-panel {
  min-height: 220px;
}

.result-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.result-tab {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.result-tab.is-active {
  border-color: #1d5f3a;
  background: #ecf8f1;
  color: #174b32;
}

.warning-panel {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #e6c46a;
  border-radius: 6px;
  background: #fff8df;
  color: #6f4f00;
}

.warning-panel strong {
  display: block;
  margin-bottom: 4px;
}

.warning-panel ul {
  margin: 0;
  padding-left: 18px;
}

.warning-panel li + li {
  margin-top: 3px;
}

.species-profile-panel {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #bfd7ed;
  border-radius: 6px;
  background: #f7fbff;
  overflow-x: auto;
}

.species-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--accent-dark);
}

.species-profile-head div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.species-profile-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.species-profile-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(340px, 440px);
  gap: 12px;
  align-items: start;
}

.species-krona-frame {
  width: 100%;
  min-height: 760px;
  background: #fff;
  border: 1px solid #d7e7f4;
  border-radius: 6px;
  display: block;
}

.species-profile-side {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.species-profile-detail {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #d7e7f4;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.species-profile-table {
  width: 100%;
  min-width: 340px;
  font-size: 12px;
}

.species-profile-table tbody tr {
  cursor: pointer;
}

.species-profile-table tbody tr:hover {
  background: #eef6fb;
}

.placement-panel {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #b8d7c7;
  border-radius: 6px;
  background: #f3fbf6;
  overflow-x: auto;
}

.placement-panel.placement-warning,
.placement-panel.placement-skipped {
  border-color: #dfc273;
  background: #fff8e8;
}

.placement-panel.placement-failed {
  border-color: #e1a8a8;
  background: #fff2f2;
}

.placement-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  color: #1d5f3a;
}

.placement-head > div:first-child {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.placement-subhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 6px;
  color: #1d5f3a;
}

.placement-head span,
.placement-subhead span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.placement-table {
  min-width: 720px;
}

.same-placement-table {
  min-width: 1180px;
}

.map-button,
.small-button {
  min-height: 30px;
  padding: 0 10px;
}

.placement-id-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.placement-id-cell .map-button {
  align-self: stretch;
}

.placement-sample-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.placement-sample-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nearest-neighbor-cell {
  color: #1d5f3a;
  font-weight: 750;
  white-space: nowrap;
}

.nearest-neighbor-cell.is-distant {
  color: #8a5a00;
}

.placement-nn-text-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #cfe3d6;
}

.placement-nn-text-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #1d5f3a;
}

.placement-nn-text-head div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.placement-nn-text-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.placement-nn-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.placement-nn-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.placement-nn-controls input {
  width: 92px;
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid #bcd7ed;
  border-radius: 6px;
  font: inherit;
}

.placement-nn-text-content {
  display: grid;
  gap: 10px;
}

.placement-nn-text-section {
  min-width: 720px;
}

.placement-map-panel {
  min-width: 720px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #cfe3d6;
}

.placement-map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #1d5f3a;
}

.placement-map-head div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.placement-map-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.placement-map-precision-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.placement-map-legend-prefix {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.placement-map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #4b625d;
  font-size: 12px;
  font-weight: 700;
}

.placement-map-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-sizing: border-box;
  background: #2f9d8b;
  border: 2px solid #176156;
}

.placement-map-legend-swatch.is-region-precision {
  background: #4f8fbd;
  border-color: #255f8f;
}

.placement-map-legend-swatch.is-country-precision {
  background: #d4a13f;
  border-color: #8a5f17;
  border-style: dashed;
}

.placement-map-legend-swatch.is-unknown-precision {
  background: #9aa4a8;
  border-color: #5f6a6d;
}

.placement-map-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: start;
}

.placement-map-svg {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  cursor: grab;
  touch-action: none;
}

.placement-map-svg:active {
  cursor: grabbing;
}

.world-map-land,
.world-map-grid {
  vector-effect: non-scaling-stroke;
}

.world-map-ocean {
  fill: #eaf3f6;
}

.world-map-grid {
  stroke: #cadce3;
  stroke-width: 1;
}

.world-map-land {
  fill: #d6e2d8;
  stroke: #b9cbbb;
  stroke-width: 1.2;
}

.world-map-error {
  fill: var(--muted);
  font-size: 16px;
  font-weight: 650;
}

.placement-map-pie-bg {
  fill: #d9dee2;
  stroke: #fff;
  stroke-width: 2;
}

.placement-map-pie-slice {
  fill: #2f9d8b;
}

.placement-map-pie-ring {
  fill: none;
  stroke: #176156;
  stroke-width: 1.4;
}

.placement-map-marker.is-region-precision .placement-map-pie-slice {
  fill: #4f8fbd;
}

.placement-map-marker.is-region-precision .placement-map-pie-ring {
  stroke: #255f8f;
}

.placement-map-marker.is-country-precision .placement-map-pie-bg {
  fill: #e6d9bf;
}

.placement-map-marker.is-country-precision .placement-map-pie-slice {
  fill: #d4a13f;
}

.placement-map-marker.is-country-precision .placement-map-pie-ring {
  stroke: #8a5f17;
  stroke-dasharray: 4 3;
  stroke-width: 1.8;
}

.placement-map-marker.is-unknown-precision .placement-map-pie-slice {
  fill: #89969b;
}

.placement-map-marker.is-unknown-precision .placement-map-pie-ring {
  stroke: #536064;
}

.placement-map-selectable,
.placement-map-location-row {
  cursor: pointer;
}

.placement-map-marker.is-selected .placement-map-pie-ring {
  stroke: #d84f2a;
  stroke-width: 3;
}

.placement-map-point-halo {
  fill: rgba(47, 157, 139, 0.16);
  stroke: none;
}

.placement-map-point-dot {
  fill: #2f9d8b;
  stroke: #176156;
  stroke-width: 1.8;
}

.placement-map-point-marker.is-region-precision .placement-map-point-halo {
  fill: rgba(79, 143, 189, 0.16);
}

.placement-map-point-marker.is-region-precision .placement-map-point-dot {
  fill: #4f8fbd;
  stroke: #255f8f;
}

.placement-map-point-marker.is-country-precision .placement-map-point-halo {
  fill: rgba(212, 161, 63, 0.18);
}

.placement-map-point-marker.is-country-precision .placement-map-point-dot {
  fill: #d4a13f;
  stroke: #8a5f17;
  stroke-dasharray: 4 2;
}

.placement-map-point-marker.is-unknown-precision .placement-map-point-dot {
  fill: #89969b;
  stroke: #536064;
}

.placement-map-point-label {
  fill: #fff;
  font-size: 10px;
  font-weight: 800;
  pointer-events: none;
}

.placement-map-hover-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(460px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(35, 45, 47, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: 0 8px 24px rgba(25, 36, 38, 0.25);
  pointer-events: none;
}

.placement-map-hover-tooltip[hidden] {
  display: none;
}

.placement-map-location-row.is-selected td {
  background: #fff3e8;
}

.placement-map-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.placement-map-table {
  min-width: 0;
  width: 100%;
}

.placement-tree-panel {
  min-width: 720px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #cfe3d6;
}

.placement-tree-panel.is-fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 1000;
  min-width: 0;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #bcd8ce;
  border-radius: 8px;
  background: #fffaf1;
  box-shadow: 0 20px 60px rgba(27, 45, 45, 0.24);
}

.placement-tree-panel.is-fullscreen .placement-tree-layout {
  grid-template-columns: minmax(560px, 1fr) minmax(280px, 360px);
}

.placement-tree-panel.is-fullscreen .placement-tree-viewport {
  min-height: 520px;
  max-height: calc(100vh - 145px);
}

.placement-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #1d5f3a;
}

.placement-tree-head div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.placement-tree-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.placement-tree-outgroup-select,
.placement-tree-query-select {
  min-height: 30px;
  max-width: 230px;
  padding: 0 8px;
  border: 1px solid #b9d7ee;
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.placement-tree-rank-panel {
  margin: 8px 0 10px;
  padding: 8px 10px 10px;
  border: 1px solid #d8e7e3;
  border-radius: 6px;
  background: #fbfdfd;
}

.placement-tree-rank-panel .placement-tree-members {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.placement-tree-rank-panel .nearest-neighbor-table-wrap {
  max-height: 190px;
}

.placement-tree-layout {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: start;
}

.placement-tree-viewport {
  min-height: 360px;
  max-height: 680px;
  overflow: auto;
  border: 1px solid #cfe0dc;
  border-radius: 6px;
  background: #fbfdfd;
}

.placement-tree-svg {
  display: block;
  min-width: 960px;
  min-height: 320px;
}

.placement-tree-bg {
  fill: #fbfdfd;
}

.placement-tree-band {
  fill: #f5faf8;
}

.placement-tree-band.is-selected {
  fill: #fff7ed;
}

.placement-tree-branch {
  stroke: #5c7a73;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.placement-tree-branch.is-selected {
  stroke: #d86036;
  stroke-width: 2.8;
}

.placement-tree-branch.is-context {
  stroke: #5c7a73;
  stroke-width: 2;
}

.placement-tree-branch.is-drillable,
.placement-tree-edge-badge.is-drillable {
  cursor: pointer;
}

.placement-tree-branch.is-drillable:hover,
.placement-tree-edge-badge.is-drillable:hover,
.placement-tree-edge-badge.is-drillable:focus {
  stroke: #fff3c4;
}

.placement-tree-edge-hit {
  stroke: transparent;
  stroke-width: 14;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.placement-local-tree-branch {
  stroke: #5c7a73;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.placement-local-tree-branch.is-query {
  stroke: #d86036;
  stroke-width: 2.4;
}

.placement-local-tree-label-guide {
  stroke: #d2e0dc;
  stroke-width: 0.9;
  vector-effect: non-scaling-stroke;
}

.placement-local-tree-label-guide.is-build-selected {
  stroke: #0b5cad;
  stroke-width: 1.3;
}

.placement-tree-guide {
  stroke: #c7d5d0;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.placement-tree-guide.is-query {
  stroke: #e4a184;
  stroke-width: 1.4;
}

.placement-tree-guide.is-build-selected,
.placement-tree-pendant.is-build-selected {
  stroke: #0b5cad;
  stroke-width: 1.7;
}

.placement-tree-internal-node {
  fill: #f8fbfa;
  stroke: #5c7a73;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.placement-tree-internal-node.is-selected {
  stroke: #d86036;
  stroke-width: 2;
}

.placement-tree-pendant {
  stroke: #7aa197;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.placement-tree-pendant.is-query {
  stroke: #d86036;
  stroke-width: 2.1;
}

.placement-tree-sample {
  cursor: pointer;
  outline: none;
  vector-effect: non-scaling-stroke;
}

.placement-tree-sample.is-public {
  fill: #297f68;
  stroke: #f7fbfb;
  stroke-width: 1.2;
}

.placement-tree-sample.is-expanded-member {
  fill: #f1b64b;
  stroke: #76501a;
  stroke-width: 1.4;
}

.placement-tree-sample.is-cluster {
  fill: #297f68;
  stroke: #ffffff;
  stroke-width: 1.8;
}

.placement-tree-sample.is-local-cluster {
  stroke: #f7fbfb;
  stroke-width: 1.5;
}

.placement-tree-sample.is-placement-tie {
  fill: #7c8a96;
}

.placement-tree-sample.is-query {
  fill: #e85f3a;
  stroke: #6f2110;
  stroke-width: 1.6;
}

.placement-tree-sample.is-selected {
  fill: #f4b33d;
  stroke: #583900;
  stroke-width: 2.2;
}

.placement-tree-sample.is-local-selectable,
.placement-tree-sample-label.is-clickable {
  cursor: pointer;
}

.placement-tree-sample.is-build-selected {
  stroke: #0b5cad;
  stroke-width: 2.8;
}

.placement-tree-sample:hover,
.placement-tree-sample:focus {
  stroke: #101820;
  stroke-width: 2.2;
}

.placement-tree-group-title,
.placement-tree-edge-label,
.placement-tree-sample-label,
.placement-tree-empty-text {
  fill: #263a38;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.placement-tree-group-title {
  font-size: 13px;
  font-weight: 760;
}

.placement-tree-edge-label {
  font-size: 11px;
  fill: #65766f;
}

.placement-tree-edge-badge {
  fill: #506960;
  font-size: 10px;
  font-weight: 760;
  paint-order: stroke;
  stroke: #fffaf1;
  stroke-width: 4px;
}

.placement-tree-edge-badge.is-selected {
  fill: #a33b1f;
}

.placement-tree-scale-line {
  stroke: #7f958d;
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.placement-tree-scale-label {
  fill: #65766f;
  font-size: 10px;
  font-weight: 700;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.placement-local-tree-branch-break {
  stroke: #bf812d;
  stroke-width: 2.4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.placement-local-tree-internal-node {
  fill: #fbfdfd;
  stroke: #638178;
  stroke-width: 2.2;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}

.placement-local-tree-internal-node.is-selected {
  stroke: #c3532d;
  stroke-width: 3;
}

.placement-local-tree-internal-node.is-root {
  stroke: #bf812d;
  fill: #fff7ed;
}

.placement-tree-sample.is-outgroup {
  stroke: #bf812d;
  fill: #fff2c7;
}

.placement-tree-sample-label {
  font-size: 11px;
  fill: #243b38;
}

.placement-tree-sample-label.is-query {
  fill: #8a2e17;
  font-weight: 760;
}

.placement-tree-sample-label.is-build-selected {
  fill: #0b5cad;
  font-weight: 760;
}

.placement-tree-sample.has-nn-rank {
  stroke: #123d67;
  stroke-width: 2.2px;
}

.placement-tree-sample.is-nn-top {
  stroke: #b53d00;
  stroke-width: 3px;
}

.placement-tree-count-label {
  pointer-events: none;
  fill: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 9px;
  font-weight: 800;
}

.placement-tree-empty-text {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.placement-tree-detail {
  max-height: 680px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #cfe0dc;
  border-radius: 6px;
  background: #fff;
}

.placement-tree-detail > strong {
  display: block;
  margin-bottom: 8px;
  color: #1d5f3a;
}

.placement-tree-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.placement-tree-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.placement-tree-expand-button {
  margin: 0;
}

.placement-tree-detail-list {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
}

.placement-tree-detail-list dt {
  color: #65766f;
  font-size: 12px;
  font-weight: 760;
}

.placement-tree-detail-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #172622;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.placement-tree-members {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #d8e1dc;
}

.placement-tree-member-title {
  margin-bottom: 6px;
  color: #4b625d;
  font-size: 12px;
  font-weight: 760;
}

.placement-tree-member-table-wrap {
  max-height: 320px;
  overflow: auto;
  padding-bottom: 18px;
  box-sizing: border-box;
  scrollbar-gutter: stable;
}

.placement-tree-member-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.placement-tree-member-table th,
.placement-tree-member-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #e4ece9;
  text-align: left;
  white-space: nowrap;
}

.placement-tree-member-table th {
  color: #4b625d;
  font-size: 11px;
  font-weight: 760;
}

.placement-tree-member-table td {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.nearest-neighbor-table-wrap {
  max-height: 220px;
}

.nearest-neighbor-table {
  min-width: 620px;
}

.placement-location-samples-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d8e1dc;
}

.placement-location-samples-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #1d5f3a;
}

.placement-location-samples-head div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.placement-location-samples-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.placement-location-table-wrap {
  max-height: 360px;
  overflow: auto;
  padding-bottom: 22px;
  box-sizing: border-box;
  scrollbar-gutter: stable;
}

.placement-location-samples-table {
  min-width: 1500px;
}

.placement-location-samples-table td {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placement-table th,
.placement-table td {
  padding: 6px 8px;
}

.placement-table td {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.placement-table td .map-button {
  font-family: inherit;
}

pre {
  min-height: 160px;
  max-height: 460px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: #101820;
  color: #e8eef5;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}

.error {
  color: var(--danger);
}

@media (max-width: 800px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar,
  .section-head,
  .actions {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .input-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .input-toolbar .file-button {
    grid-column: 1 / -1;
  }

  .placement-map-panel {
    min-width: 0;
  }

  .placement-map-layout {
    grid-template-columns: 1fr;
  }

  .placement-tree-panel {
    min-width: 0;
  }

  .placement-tree-layout {
    grid-template-columns: 1fr;
  }

  .placement-tree-panel.is-fullscreen {
    inset: 8px;
  }

  .placement-tree-panel.is-fullscreen .placement-tree-layout {
    grid-template-columns: 1fr;
  }

  .placement-tree-viewport,
  .placement-tree-detail {
    max-height: 520px;
  }

  .species-profile-layout {
    grid-template-columns: 1fr;
  }

  .species-krona-frame {
    min-height: 680px;
  }
}

@media (max-width: 520px) {
  .controls,
  .input-toolbar {
    grid-template-columns: 1fr;
  }

  .input-toolbar .file-button {
    grid-column: auto;
  }
}

.placement-ast-predictions {
  margin: 6px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line, #d5dee3);
  border-radius: 8px;
  background: #f2faf6;
  font-size: 13px;
  line-height: 1.5;
}

.ast-pred-head { font-weight: 650; margin-bottom: 2px; }
.ast-pred-sus { color: #174b3d; }
.ast-pred-avoid { color: #a33b1f; }
.ast-pred-low-note { color: #6c5a12; margin-top: 3px; }
