:root {
  --tree-green: #63cf82;
  --tree-green-bright: #9bf0ae;
  --tree-line: #33453a;
  --tree-panel: rgba(10, 15, 12, .9);
  --tree-muted: #98a59c;
}

.tree-page-body {
  display: block;
  min-height: 100vh;
  overflow-x: hidden;
  color: #f4f7f2;
  background:
    radial-gradient(circle at 50% 5%, rgba(30, 105, 58, .25), transparent 38rem),
    #070a08;
}

.tree-page-main {
  width: min(1840px, calc(100% - 20px));
  margin: 0 auto;
  padding: 6.5vh 0 72px;
}

.tree-kicker {
  margin: 0 0 8px;
  color: #69c783;
  font: 700 .76rem/1.2 Calibri, sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.tree-shell {
  overflow: hidden;
  border: 1px solid #2b3830;
  border-radius: 18px 18px 0 0;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(38, 104, 55, .15), transparent 58%),
    var(--tree-panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .32);
}

.tree-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 58px;
  padding: 9px 14px;
  border-bottom: 1px solid #29362e;
  background: rgba(7, 11, 8, .72);
  font-family: Calibri, sans-serif;
}

.tree-toolbar button,
.tree-toolbar input,
.selection-bar button {
  min-height: 38px;
  border: 1px solid #35483b;
  border-radius: 8px;
  color: #eff5f0;
  background: #111914;
  font: inherit;
}

.tree-toolbar button,
.selection-bar button { padding: 0 13px; cursor: pointer; }
.tree-toolbar button:hover:not(:disabled),
.selection-bar button:hover:not(:disabled) { border-color: #66c980; background: #19271d; }
.tree-toolbar button:disabled,
.selection-bar button:disabled { cursor: default; opacity: .38; }

.tree-back::before {
  margin-right: 7px;
  content: "\2190";
}

.tree-breadcrumbs {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tree-breadcrumbs button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 8px;
  border-color: transparent;
  color: #9fada3;
  background: transparent;
}

.tree-breadcrumbs button:disabled {
  color: #e2ebe4;
  opacity: 1;
}

.breadcrumb-separator { color: #526158; }

.tree-search { position: relative; display: flex; }
.tree-search-input-wrap { position: relative; display: flex; }
.tree-search input {
  width: min(220px, 20vw);
  min-width: 130px;
  padding: 0 11px;
  border-radius: 8px 0 0 8px;
  outline: 0;
}
.tree-search input:focus {
  z-index: 1;
  border-color: #62c77c;
  box-shadow: 0 0 0 3px rgba(98, 199, 124, .15);
}
.tree-search button { margin-left: -1px; border-radius: 0 8px 8px 0; }
.tree-search-suggestions {
  position: absolute; z-index: 20; top: calc(100% + 7px); right: 0; left: 0;
  overflow: hidden; min-width: 260px; border: 1px solid #3b5142; border-radius: 8px;
  background: #101713; box-shadow: 0 16px 38px rgba(0, 0, 0, .48);
}
.tree-search-suggestions[hidden] { display: none; }
.tree-search .tree-search-option {
  display: flex; justify-content: space-between; align-items: baseline; width: 100%;
  min-height: 36px; margin: 0; padding: 7px 10px; border: 0; border-radius: 0;
  color: #eaf2ec; background: transparent; text-align: left;
}
.tree-search .tree-search-option + .tree-search-option { border-top: 1px solid #26332b; }
.tree-search .tree-search-option:hover,
.tree-search .tree-search-option.is-active { background: #203225; }
.tree-search-option small { margin-left: 16px; color: #8fa098; text-transform: capitalize; }

.tree-canvas-wrap {
  position: relative;
  min-height: 560px;
  overflow: hidden;
}

#phylogeny {
  display: block;
  width: 100%;
  height: auto;
  min-height: 560px;
  max-height: 76vh;
  overflow: visible;
}

.tree-branch {
  fill: none;
  stroke: var(--tree-line);
  stroke-linecap: round;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
  transition: stroke 180ms ease, stroke-width 180ms ease, opacity 180ms ease;
}

.tree-branch.is-highlighted {
  stroke: var(--tree-green);
  stroke-width: 3.5;
  filter: drop-shadow(0 0 4px rgba(99, 207, 130, .42));
}

.minor-lineage {
  pointer-events: none;
}

.minor-lineage circle {
  fill: #526359;
  stroke: #0b100d;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.minor-lineage text {
  fill: #75837a;
  paint-order: stroke;
  stroke: #0b100d;
  stroke-linejoin: round;
  stroke-width: 3px;
  font: 400 7px/1 Calibri, sans-serif;
}

.minor-lineage.is-highlighted circle { fill: var(--tree-green); }
.minor-lineage.is-highlighted text { fill: #9fd8ad; }

.radial-node {
  cursor: pointer;
  outline: none;
}

.node-halo {
  fill: rgba(99, 207, 130, 0);
  stroke: rgba(99, 207, 130, 0);
  transition: fill 160ms ease, stroke 160ms ease;
}

.radial-node:hover .node-halo,
.radial-node:focus-visible .node-halo {
  fill: rgba(99, 207, 130, .12);
  stroke: rgba(99, 207, 130, .4);
}

.node-photo {
  filter: brightness(.86) saturate(.85);
  transition: filter 160ms ease;
}

.node-photo-fallback { fill: #15231a; }

.node-photo-border {
  fill: none;
  stroke: #708178;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  transition: stroke 160ms ease, stroke-width 160ms ease;
}

.radial-node:hover .node-photo,
.radial-node:focus-visible .node-photo { filter: brightness(1.05) saturate(1); }
.radial-node.is-highlighted .node-photo-border { stroke: var(--tree-green); }
.radial-node.is-selected .node-halo {
  fill: rgba(99, 207, 130, .18);
  stroke: var(--tree-green-bright);
  stroke-width: 1.5;
}
.radial-node.is-selected .node-photo { filter: brightness(1.08) saturate(1.05); }
.radial-node.is-selected .node-photo-border { stroke: #d2f8db; stroke-width: 3; }

.node-label-bg {
  fill: #d8d0ae;
  stroke: #66705e;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .55));
  pointer-events: none;
}

.node-label {
  fill: #182019;
  font: 700 11px/1 "Charm", cursive;
  pointer-events: none;
}

.radial-node.is-selected .node-label-bg { fill: #dcebc9; stroke: var(--tree-green-bright); }
.radial-node.is-selected .node-label { fill: #122315; font-size: 12px; }
.rich-child .node-label { font-size: 10px; }

.selection-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 50px;
  padding: 5px 12px;
  border-top: 1px solid #29362e;
  background: rgba(7, 11, 8, .78);
  font-family: Calibri, sans-serif;
}

.selection-bar > div {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.selection-label {
  color: #75827a;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

#selected-name {
  overflow: hidden;
  color: #eff6f0;
  font-size: 1.12rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid #35533e;
  border-radius: 999px;
  color: #88c798;
  font-size: .65rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

#selected-summary { margin: 0; color: #a6b2aa; font-size: 1rem; font-weight: 600; white-space: nowrap; }
#tree-focus {
  min-height: 34px;
  border-color: #3e7550;
  color: #d8f4df;
  background: #17321f;
  font-weight: 700;
}

.inline-gallery {
  margin-top: 0;
  padding: 22px clamp(12px, 2vw, 30px) 34px;
  border: 1px solid #29362e;
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: rgba(10, 15, 12, .78);
}

.inline-gallery-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
}

.inline-gallery h2 {
  margin: 0;
  color: #eef4ef;
  font: 400 clamp(1.6rem, 4vw, 2.5rem)/1 "Charm", cursive;
}

#gallery-count {
  color: #8f9d94;
  font: 600 1rem/1.4 Calibri, sans-serif;
}

.inline-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: clamp(8px, 1vw, 14px);
  align-items: center;
  padding: 2px;
}

.inline-photo {
  position: relative;
  height: clamp(170px, 16vw, 260px);
  overflow: hidden;
  padding: 0;
  border: 1px solid #304037;
  border-radius: 0;
  background: #0c110e;
  cursor: pointer;
}

.inline-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease, filter 220ms ease;
}

.inline-photo:hover,
.inline-photo:focus-visible { border-color: #6bca83; outline: 0; }
.inline-photo:hover img,
.inline-photo:focus-visible img { filter: brightness(1.08); transform: scale(1.035); }
#gallery-empty { color: var(--tree-muted); font-family: Calibri, sans-serif; }

.tree-page-body .slide-view {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  z-index: 2147483647 !important;
  visibility: visible !important;
  opacity: 1 !important;
  isolation: isolate;
  pointer-events: auto;
  transform: none !important;
}

.tree-page-body .slide-view:not(.is-open) { display: none !important; }
.tree-page-body .slide-view.is-open { display: flex !important; }
.tree-page-body .slide-view .large-image-view {
  z-index: 2;
  width: auto;
  max-width: 66vw;
}
.tree-page-body .slide-view .species-panel,
.tree-page-body .slide-view .taxonomy-panel { z-index: 3; }
.tree-page-body .slide-view .species-panel { z-index: 6; pointer-events: auto; }
.tree-page-body .slide-view .viewer-link-box,
.tree-page-body .slide-view .viewer-external-link { z-index: 7; pointer-events: auto !important; }
.tree-page-body .slide-view .slide-arrow-container { z-index: 4; }
.tree-page-body .slide-view .tree-close { z-index: 5; }

.tree-page-body .slide-view .species-label,
.tree-page-body .slide-view .taxa-list-label {
  color: #111 !important;
}

.tree-page-body .slide-view .taxonomy-panel {
  justify-content: flex-start;
  overflow-y: auto;
  padding: 14px 0;
  box-sizing: border-box;
}

.tree-page-body .slide-view .tree-taxonomy-item {
  flex: 0 0 auto;
  min-height: 25px;
  border: 0;
  color: #111;
  font-size: 2vh;
  line-height: normal;
  box-sizing: border-box;
  appearance: none;
}

.tree-page-body .slide-view .tree-taxonomy-item.is-interactive {
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}

.tree-page-body .slide-view .tree-taxonomy-item.is-interactive:hover,
.tree-page-body .slide-view .tree-taxonomy-item.is-interactive:focus-visible {
  filter: brightness(1.18) saturate(1.25);
  transform: translateX(3px);
  outline: 1px solid #2f8f45;
}

.tree-page-body .slide-view .tree-taxonomy-item.is-intermediate {
  cursor: default;
  color: rgba(17, 17, 17, .5) !important;
}

.tree-page-body .slide-view .tree-taxonomy-item.is-intermediate:hover {
  filter: none;
  transform: none;
}

.tree-close {
  position: fixed;
  z-index: 1000;
  top: 18px;
  right: 24px;
  width: 46px;
  height: 46px;
  border: 1px solid #546058;
  border-radius: 50%;
  color: white;
  background: rgba(0, 0, 0, .72);
  font: 300 2rem/1 Arial, sans-serif;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 760px) {
  .tree-page-main { width: min(100% - 10px, 1840px); padding-top: 6vh; }
  .tree-toolbar { grid-template-columns: auto 1fr; }
  .tree-search { grid-column: 1 / -1; }
  .tree-search-input-wrap,
  .tree-search input { width: 100%; }
  .tree-canvas-wrap { min-height: 400px; overflow-x: auto; }
  #phylogeny { width: 900px; min-height: 430px; }
  .selection-bar { grid-template-columns: 1fr auto; }
  .selection-bar > div { grid-column: 1 / -1; }
  #selected-summary { white-space: normal; }
  .inline-gallery { padding: 16px 10px 24px; }
  .inline-image-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-photo { height: 42vw; }
}
