:root {
  --bg: #000;
  --bg-elevated: #161616;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #8a8a8a;
  --bad: #e05a4a;
  --bad-bg: #271715;
  --radius: 8px;
  --max-width: 1200px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

/* ---------- Navigation ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(6px);
}

.canvas-page .nav {
  position: fixed;
  left: 0;
  right: 0;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
}

.nav-link {
  flex: 0 0 auto;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ---------- Search ---------- */

.search-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 20px 0;
}

.search-input {
  width: 100%;
  max-width: 320px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
}

.search-input:focus {
  outline: none;
  border-color: var(--text-muted);
}

/* ---------- Filter tabs ---------- */

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 20px 20px 0;
  max-width: var(--max-width);
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-label {
  flex: 0 0 auto;
  align-self: center;
  width: 64px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-tab {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.filter-tab:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.filter-tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.filter-tab .count {
  margin-left: 6px;
  opacity: 0.55;
  font-size: 0.78em;
}

.subfilter-tab {
  padding: 5px 13px;
  font-size: 0.8rem;
}

.subfilter-tab.active {
  background: transparent;
  color: var(--text);
  border-color: var(--text);
}

.genus-tab {
  font-style: italic;
}

/* ---------- Gallery grid ---------- */

.gallery-summary {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 60px;
}

.species-card {
  position: relative;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.species-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  padding: 16px;
  transform: rotate(var(--img-rotation, 0deg));
  transition: transform 0.3s ease;
}

.placeholder-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.species-card:hover .species-photo {
  transform: rotate(var(--img-rotation, 0deg)) scale(1.06);
}

.placeholder-photo span {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.species-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0));
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.species-card:hover .species-info {
  opacity: 1;
  transform: translateY(0);
}

.species-info .name {
  font-weight: 600;
  font-style: italic;
  font-size: 0.92rem;
}

.species-info .family {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 24px;
  grid-column: 1 / -1;
}

/* ---------- Species popup ---------- */

.species-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  padding: 24px;
  z-index: 1000;
}

.species-popup-card {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(92vw, 820px);
  max-height: 92vh;
  overflow: auto;
}

.species-popup-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 68vh;
  background: #000;
  padding: 24px;
  overflow: hidden;
}

.species-popup-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(var(--img-rotation, 0deg));
}

.species-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  z-index: 1;
}

.species-popup-close:hover {
  color: var(--text);
}

.species-popup-info {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px 20px;
}

.species-popup-info h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  font-style: italic;
}

.species-popup-info h2.unknown {
  font-style: normal;
  color: var(--text-muted);
}

.species-popup-family {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

.adb-link {
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  transition: border-color 0.15s ease;
}

.adb-link:hover {
  border-color: var(--text-muted);
}

/* Lightbox variant (home page): no card, photo floats over the dimmed wall */

.species-popup.lightbox {
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

.species-popup.lightbox .species-popup-card {
  background: transparent;
  border: none;
  width: auto;
  max-width: 92vw;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.species-popup.lightbox .species-popup-photo {
  background: transparent;
  aspect-ratio: auto;
  width: auto;
  max-height: none;
  padding: 0;
  overflow: visible;
}

.species-popup.lightbox .species-popup-photo img {
  width: auto;
  height: auto;
  max-width: 90vw;
  max-height: 72vh;
}

.species-popup.lightbox .species-popup-close {
  display: none;
}

.species-popup.lightbox .species-popup-info {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 16px 0 0;
}

.species-popup.lightbox .adb-link {
  cursor: pointer;
}

/* ---------- Infinite canvas homepage ---------- */

body.canvas-page,
html:has(body.canvas-page) {
  overflow: hidden;
  height: 100%;
}

.world-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  cursor: grab;
  touch-action: none;
}

.world-viewport.dragging {
  cursor: grabbing;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.float-img {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.float-img img {
  display: block;
  max-width: none;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform: rotate(var(--img-rotation, 0deg));
  transition: filter 0.15s ease, transform 0.2s ease;
}

.float-img:hover {
  z-index: 5;
}

.float-img:hover img {
  transform: rotate(var(--img-rotation, 0deg)) scale(1.1);
  filter: brightness(1.12);
}

.fullscreen-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 50;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.fullscreen-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.fullscreen-btn .fs-exit,
.fullscreen-btn.active .fs-enter {
  display: none;
}

.fullscreen-btn.active .fs-exit {
  display: inline;
}

/* Fullscreen hides the chrome on the full-screen visual pages */
body.is-fullscreen.canvas-page .nav {
  display: none;
}

body.is-fullscreen.canvas-page .layout-bar {
  top: 8px;
}

/* ---------- Floating (svev) page ---------- */

#float-canvas,
.fill-canvas {
  position: fixed;
  inset: 0;
  display: block;
  background: #000;
}

@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .nav-inner {
    padding: 14px 16px;
  }

  .nav-links {
    gap: 16px;
  }

  .nav-link {
    font-size: 0.88rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 8px;
    padding: 0 16px 48px;
  }

  .species-photo {
    padding: 8px;
  }

  .filter-bar {
    padding: 14px 16px 0;
  }

  .filter-label {
    width: auto;
    margin-right: 4px;
  }

  .search-bar,
  .gallery-summary {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ---------- Admin ---------- */

.admin-panel {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 120px;
}

.admin-warning {
  border: 1px solid var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-toolbar .search-input {
  flex: 1 1 240px;
  max-width: 360px;
}

.admin-status {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-left: auto;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.admin-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-card.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}

.admin-card.is-hidden .admin-thumb {
  opacity: 0.25;
}

.admin-thumb-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  cursor: pointer;
  overflow: hidden;
}

.admin-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  transform: rotate(var(--img-rotation, 0deg));
  transition: transform 0.2s ease;
}

.admin-card-tools {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.admin-select {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
  accent-color: var(--text);
  cursor: pointer;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  border-color: var(--text);
}

.admin-fields {
  padding: 10px;
  display: grid;
  gap: 6px;
}

.admin-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.admin-input.name {
  font-style: italic;
}

.admin-input:focus {
  outline: none;
  border-color: var(--text-muted);
}

.admin-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.admin-meta a {
  text-decoration: underline;
}

.admin-meta .warn {
  color: var(--bad);
}

.admin-bulk {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--text-muted);
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.85rem;
}

.admin-bulk .admin-input {
  width: 240px;
}

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  background: transparent;
  color: var(--text);
}

.btn:hover {
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---------- Visualisation pages (shared) ---------- */

.layout-bar {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
}

.layout-bar .filter-tab {
  background: rgba(0, 0, 0, 0.6);
}

.layout-bar .filter-tab.active {
  background: var(--text);
}

.tile-tooltip {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
}

.tile-tooltip span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ---------- Farger ---------- */

.color-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.color-tile {
  position: absolute;
  left: 0;
  top: 0;
  /* Fixed box (TILE_BOX in farger.js), sized with scale so only transforms animate */
  width: 64px;
  height: 64px;
  object-fit: contain;
  cursor: pointer;
  transform: translate(var(--x), var(--y)) rotate(var(--r, 0deg)) scale(var(--s, 1));
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}

.color-tile:hover {
  z-index: 10;
  transition-delay: 0s !important;
  transition-duration: 0.2s;
  transform: translate(var(--x), var(--y)) rotate(var(--r, 0deg)) scale(calc(var(--s, 1) * 3));
}

.cluster-label {
  position: fixed;
  transform: translate(-50%, -100%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  animation: fade-in 0.8s ease 0.6s both;
}

.cluster-label span {
  opacity: 0.6;
  font-weight: 400;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Slektstre ---------- */

#tree-svg {
  cursor: grab;
  font-family: "Manrope", sans-serif;
}

.tree-link {
  fill: none;
  stroke: #3a3a3a;
  stroke-width: 1.2;
  transition: stroke 0.2s ease;
}

.tree-link.depth-1 {
  stroke: #555;
  stroke-width: 2.2;
}

.tree-link.depth-2 {
  stroke-width: 1.6;
}

.tree-link.lit {
  stroke: var(--text);
  stroke-width: 2.4;
}

.tree-root {
  fill: var(--text);
}

.tree-label {
  fill: var(--text-muted);
  font-size: 11px;
  paint-order: stroke;
  stroke: #000;
  stroke-width: 4px;
  pointer-events: none;
}

.tree-label.rank-group {
  fill: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.tree-label.rank-family {
  font-size: 12px;
  font-weight: 600;
}

.tree-label.rank-genus {
  font-style: italic;
  font-size: 10px;
}

.tree-leaf {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.tree-leaf.dim {
  opacity: 0.35 !important;
}

.tree-species {
  fill: var(--text);
  font-size: 12px;
  font-style: italic;
}

.tree-link.group-Nudibranchia { stroke: #4a4a4a; }
.tree-link.group-Sacoglossa { stroke: #4f7a45; }
.tree-link.group-Andre { stroke: #8a5a36; }
.tree-link.lit { stroke: var(--text); }

.tree-legend {
  position: fixed;
  right: 20px;
  bottom: 66px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-item b {
  font-weight: 400;
  opacity: 0.6;
}

.legend-item i {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: #777;
}

.legend-item.group-Sacoglossa i { background: #6fa860; }
.legend-item.group-Andre i { background: #c47f4a; }

.layout-sep {
  flex: 0 0 1px;
  margin: 4px 6px;
  background: var(--border);
}

.tree-label.rank-superorder,
.tree-label.rank-order,
.tree-label.rank-group {
  fill: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.tree-label.rank-suborder {
  fill: #c8c8c8;
  font-size: 13px;
  font-weight: 600;
}

.tree-label.rank-superfamily {
  font-size: 11.5px;
  font-weight: 600;
}

.tree-label.lit {
  fill: var(--text);
}

.tree-label {
  pointer-events: auto;
}

/* ---------- Gallery view toggle ---------- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.view-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.view-btn.active {
  background: var(--text);
  color: var(--bg);
}

.icon-btn.on {
  color: #f2c94c;
  border-color: #f2c94c;
}

/* Farger: spinnable wheel and one-per-species filtering */

.color-stage {
  transform-origin: var(--cx, 50%) var(--cy, 50%);
  transform: rotate(var(--spin, 0deg));
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.color-stage.spinning {
  transition: none;
  will-change: transform;
}

.color-stage.can-spin {
  cursor: grab;
}

.color-stage.dragging,
.color-stage.dragging .color-tile {
  cursor: grabbing;
}

.color-stage.dragging .color-tile:hover {
  transform: translate(var(--x), var(--y)) rotate(var(--r, 0deg)) scale(var(--s, 1));
}

.color-tile.gone {
  opacity: 0;
  pointer-events: none;
}


.tree-legend {
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border);
}

#tree-svg.radial {
  cursor: grab;
}

#tree-svg.radial.spinning {
  cursor: grabbing;
}

/* ---------- Om ---------- */

.about {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 20px 80px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  align-items: center;
}

.about-photo {
  margin: 0;
}

.about-photo img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.about-text h1 {
  margin: 0 0 16px;
  font-size: 1.8rem;
  font-weight: 700;
}

.about-text p {
  margin: 0 0 14px;
  font-size: 1.05rem;
  line-height: 1.65;
  color: #d6d6d6;
}

.about-text .adb-link {
  display: inline-block;
}

@media (max-width: 1000px) {
  .about {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 24px 16px 60px;
  }
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- Nav dropdown ("Utforsk") and admin icon ---------- */

.nav-group {
  position: relative;
  display: flex;
}

.nav-group-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: inherit;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 0 4px;
  cursor: pointer;
  font-family: inherit;
}

.nav-group-btn svg {
  transition: transform 0.15s ease;
}

.nav-group.open .nav-group-btn svg {
  transform: rotate(180deg);
}

.nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: -12px;
  padding-top: 12px;
  z-index: 200;
}

/* The padding above bridges the gap so the menu stays open while moving the mouse to it */
.nav-menu::before {
  content: "";
  position: absolute;
  inset: 12px 0 0;
  background: rgba(12, 12, 12, 0.97);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  z-index: -1;
}

.nav-group.open .nav-menu {
  display: block;
}

@media (hover: hover) {
  .nav-group:hover .nav-menu {
    display: block;
  }
}

.nav-menu-item {
  display: block;
  width: 160px;
  padding: 9px 14px;
  border-radius: 6px;
  margin: 5px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.nav-menu-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.nav-menu-item.active {
  color: var(--text);
}

.nav-admin {
  display: inline-flex;
  color: var(--text-muted);
  opacity: 0.7;
  padding-bottom: 4px;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.nav-admin:hover,
.nav-admin.active {
  color: var(--text);
  opacity: 1;
}


/* Svev: drag to pan */
#float-canvas {
  cursor: grab;
}

#float-canvas.panning {
  cursor: grabbing;
}

/* ---------- Touch devices ---------- */

/* Dragging on these stages should move the content, not scroll or zoom the page */
.color-stage,
#pile-canvas,
#float-canvas,
#tree-svg {
  touch-action: none;
}

@media (max-width: 640px) {
  .layout-bar {
    top: 52px;
    gap: 6px;
    padding: 8px 10px;
  }

  .layout-bar .filter-tab {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .layout-sep {
    display: none;
  }

  .cluster-label {
    font-size: 0.62rem;
  }

  .tree-legend {
    font-size: 0.7rem;
    padding: 6px 9px;
    gap: 2px;
    bottom: 62px;
    right: 12px;
  }

  .about {
    max-width: 560px;
  }
}

/* Tablets: physically smaller than a laptop at the same pixel width */
@media (pointer: coarse) and (min-width: 641px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
}

/* ---------- Shareable species links ---------- */

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

button.adb-link {
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.species-card.highlight {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 4px;
  animation: card-pulse 1.4s ease 0.4s 2;
}

@keyframes card-pulse {
  50% {
    outline-color: transparent;
  }
}

.about-text .copyright {
  margin-top: 28px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Farger: zoom and pan ---------- */

/* Zoom repositions the tiles themselves (see placeTiles in farger.js) */
.color-zoom {
  position: fixed;
  inset: 0;
  touch-action: none;
}

.color-zoom.zoomed .color-stage {
  cursor: move;
}

/* While pinching or panning the tiles follow the fingers directly */
.color-stage.zooming .color-tile {
  transition: none !important;
}

.color-stage.zoom-anim .color-tile {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1) !important;
  transition-delay: 0s !important;
}

/* ---------- Language toggle (NO / EN) ---------- */

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--border);
}

.lang-toggle button {
  border: none;
  background: none;
  padding: 2px 3px;
  font: inherit;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
}

.lang-toggle button:hover,
.lang-toggle button.active {
  color: var(--text);
}
