﻿:root {
  --bg: #f8f7f3;
  --panel: #ffffff;
  --ink: #141414;
  --muted: #3f3f3f;
  --line: #1f1f1f;
  --accent: #0c8b56;
  --accent-soft: #d9efe4;
  --warn: #b92f2f;
  --pigeon: #ff4fa3;
  --crow: #2f2f34;
  --gull: #2c8cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(135deg, #f5f3ed 0, #f5f3ed 16px, #f0eee8 16px, #f0eee8 32px),
    radial-gradient(circle at 20% 0%, #e7f4ed 0%, transparent 45%),
    radial-gradient(circle at 100% 20%, #f8efde 0%, transparent 35%),
    var(--bg);
}

.app-header {
  padding: 1.25rem 1rem 0.5rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw + 1rem, 2.2rem);
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.container {
  padding: 0.9rem;
  max-width: 1200px;
  margin: 0 auto 2rem;
}

.site-footer {
  max-width: 1200px;
  margin: 0 auto 2.4rem;
  padding: 0 0.9rem;
  color: #4a5563;
  font-size: 0.88rem;
}

.controls {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
}

.controls label,
.controls button {
  font-size: 0.95rem;
}

.controls select,
.controls button,
.controls input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.55rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

.controls button {
  cursor: pointer;
  border-color: #0d6b45;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.controls button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: #8fa49a;
  border-color: #6f8479;
}

.controls .btn-locate {
  background: linear-gradient(180deg, #0f9a62 0%, #0b804f 100%);
  border-color: #0a6f44;
}

.controls .btn-meme {
  background: linear-gradient(180deg, #10866d 0%, #0d6a56 100%);
  border-color: #0b5848;
}

.controls .btn-share {
  background: linear-gradient(180deg, #2470c9 0%, #1c5ca5 100%);
  border-color: #174e8a;
}

.controls .btn-example {
  background: #f2f6fb;
  color: #1f3148;
  border-color: #9db3cb;
}

.controls .btn-compact {
  width: auto;
  min-width: 140px;
  justify-self: end;
  text-transform: none;
  letter-spacing: 0;
  background: #e7eef7;
  color: #1c2d44;
  border-color: #9eb2c7;
}

.controls input {
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.small-inline {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  white-space: nowrap;
}

.toggle-label input {
  margin: 0;
  width: auto;
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateY(1px);
}

.meta {
  margin: 0.8rem 0;
}

#statusText {
  margin: 0;
  font-weight: 700;
  color: #1d2c3b;
}

.taxa-info {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.meta-card {
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #c7d3e2;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 2px 0 rgba(13, 23, 34, 0.08);
}

.meta-card .taxa-info {
  margin-top: 0.35rem;
  line-height: 1.35;
}

.map-wrap {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  margin: 0 0 0.8rem;
  box-shadow: 0 4px 0 #131313;
  position: relative;
}

.map-loading-overlay {
  position: absolute;
  inset: 0.75rem;
  z-index: 12;
  display: grid;
  place-items: center;
  background: rgba(245, 249, 255, 0.7);
  border-radius: 8px;
  backdrop-filter: blur(1px);
}

.map-loading-overlay[hidden] {
  display: none !important;
}

.map-loading-card {
  min-width: min(420px, 92%);
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #1e2d3f;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.map-loading-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #cfd7e4;
  border-top-color: #1f69c5;
  animation: spin 0.85s linear infinite;
}

.map-loading-text {
  margin: 0.45rem 0 0.45rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #223246;
}

.map-loading-bar-wrap {
  height: 10px;
  border-radius: 999px;
  background: #d7e5f7;
  border: 1px solid #9ab4d1;
  overflow: hidden;
}

.map-loading-bar {
  width: 20%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2c8cff, #0cb96f);
  transition: width 180ms ease;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.map-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}

.map-title {
  margin: 0;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.map-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.bias-map {
  width: 100%;
  height: auto;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #eef7ff 0%, #e8f2ff 100%);
}

.map-region {
  stroke: #fff;
  stroke-width: 2.2;
  cursor: pointer;
  filter: drop-shadow(0 0 0.8px rgba(0, 0, 0, 0.35));
  transition: opacity 120ms ease, stroke-width 120ms ease, filter 120ms ease;
}

.map-region:hover {
  stroke: #000;
  stroke-width: 2.8;
  filter: drop-shadow(0 0 1.2px rgba(0, 0, 0, 0.45));
}

.map-region.is-focused {
  stroke: #ffe400;
  stroke-width: 4.7;
  filter: drop-shadow(0 0 2.6px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 5px rgba(255, 228, 0, 0.4));
}

.map-region.is-dim {
  opacity: 0.7;
}

.map-region.is-below-threshold {
  opacity: 0.55;
}

.map-tint {
  pointer-events: none;
}

.map-legend-panel {
  position: absolute;
  left: 14px;
  top: 62px;
  z-index: 6;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #b8c4d3;
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
}

.map-legend-panel summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: #2a3542;
  user-select: none;
}

@media (max-width: 700px) {
  .map-legend-panel {
    left: 10px;
    top: 92px;
  }
}

.legend-list {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.45rem;
  align-items: center;
  font-size: 0.76rem;
  color: #2e3946;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.map-legend span {
  white-space: nowrap;
}

.legend-gradient {
  width: 150px;
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #d64040 0%, #f8efef 50%, #1c9b62 100%);
  border: 2px solid #242424;
}

.legend-gradient-seq {
  width: 150px;
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e7f1ff 0%, #2c8cff 100%);
  border: 2px solid #242424;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid #242424;
  display: inline-block;
}

.map-status {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.map-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(12px, 12px);
  pointer-events: none;
  max-width: 280px;
  background: rgba(18, 23, 31, 0.93);
  color: #f5f8fc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.78rem;
  line-height: 1.35;
  z-index: 10;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  white-space: normal;
}

.map-tooltip strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.84rem;
}

.map-tooltip .tip-line {
  display: block;
}

.table-controls {
  margin: 0 0 0.5rem;
  display: flex;
  justify-content: flex-start;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
}

.table-controls label {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 600;
}

.table-info-btn {
  margin-left: auto;
  padding: 0.4rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #f1f5fb;
  color: #213247;
  font-weight: 700;
  cursor: pointer;
}

.table-controls select {
  display: block;
  margin-top: 0.25rem;
  padding: 0.4rem 0.55rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  min-width: 220px;
}

.control-attn {
  outline: 3px solid #ffcf3f;
  box-shadow: 0 0 0 4px rgba(255, 207, 63, 0.28);
}
.table-wrap {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  box-shadow: 0 4px 0 #131313;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid #dadada;
  padding: 0.45rem 0.5rem;
  text-align: left;
  font-size: 0.88rem;
}

th {
  position: sticky;
  top: 0;
  background: #111111;
  color: #fff;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 0.8rem;
}

tr:hover {
  background: #ffeef7;
}

tbody tr:nth-child(even) {
  background: #faf9f6;
}

tr.focused-row {
  background: #fff8cb !important;
  outline: 2px solid #ffd53e;
}

tr.low-sample-row {
  opacity: 0.62;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bias.negative {
  color: var(--warn);
}

.bias.positive {
  color: #0b8e51;
}

.bars {
  width: 150px;
  display: flex;
  gap: 3px;
  height: 10px;
}

.bar {
  height: 100%;
  border-radius: 3px;
}

.bar.pigeon {
  background: var(--pigeon);
}

.bar.crow {
  background: var(--crow);
}

.bar.gull {
  background: var(--gull);
}

.loading {
  opacity: 0.7;
}

.info-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid #1f5c42;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(20, 44, 34, 0.2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 26, 21, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 36px rgba(17, 26, 21, 0.25);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.close-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.modal-body {
  padding: 0.9rem 1rem 1rem;
  color: #243129;
  line-height: 1.4;
}

.modal-body p {
  margin: 0 0 0.65rem;
}

.png-example-image {
  display: block;
  width: 100%;
  max-width: 540px;
  height: auto;
  margin: 0 auto;
  border: 2px solid #1d2c3b;
  border-radius: 10px;
}

.meme-help {
  font-size: 0.9rem;
}

.meme-section {
  margin: 0.8rem 0 1rem;
}

.meme-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.meme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}

.meme-option {
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  padding: 0.25rem;
  background: #fafafa;
  cursor: pointer;
}

.meme-option.selected {
  border-color: #0c8b56;
  box-shadow: 0 0 0 2px rgba(12, 139, 86, 0.2);
}

.meme-option input {
  display: none;
}

.meme-option img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.meme-option .small {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.meme-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.meme-actions button {
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-weight: 700;
}

.meme-actions .secondary-btn {
  background: #fff;
  color: var(--ink);
}

.meme-actions #saveMemeBtn {
  background: var(--accent);
  color: #fff;
  border-color: #0d6b45;
}

.share-stage {
  position: fixed;
  left: -10000px;
  top: -10000px;
  width: 1080px;
  height: 1350px;
  pointer-events: none;
}

.share-card {
  width: 1080px;
  height: 1350px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 36%),
    linear-gradient(165deg, #f6f7ef 0%, #e5eef9 52%, #cfdcf5 100%);
  border: 10px solid #111;
  border-radius: 26px;
  box-shadow: 0 18px 0 #111;
  padding: 38px 40px;
  font-family: "Trebuchet MS", "Avenir Next", "Gill Sans", sans-serif;
  color: #151515;
  position: relative;
  overflow: hidden;
  --gang-accent: #ff4fa3;
  --gang-accent-soft: #ffc2df;
}

.share-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  border: 8px solid var(--gang-accent);
  pointer-events: none;
  opacity: 0.55;
}

.share-card::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 14px;
  border: 2px dashed rgba(17, 17, 17, 0.28);
  pointer-events: none;
}

.share-top {
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  align-items: start;
  position: relative;
  z-index: 2;
}

.share-header-left {
  max-width: 640px;
  min-width: 0;
}

.share-header-right {
  min-width: 280px;
  justify-self: end;
  text-align: right;
  display: grid;
  gap: 6px;
}

.share-card h2 {
  margin: 0;
  font-size: 74px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 0.95;
  text-shadow: 3px 3px 0 rgba(255, 255, 255, 0.65);
}

.share-filters {
  margin: 12px 0 0;
  font-size: 17px;
  font-weight: 700;
  color: #2c3648;
  white-space: nowrap;
  line-height: 1.1;
}

.share-holo {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, 0.45) 48%, rgba(255, 255, 255, 0) 61%),
    radial-gradient(circle at 82% 20%, color-mix(in srgb, var(--gang-accent) 20%, #fff 80%) 0%, rgba(255, 255, 255, 0) 52%);
  mix-blend-mode: screen;
  pointer-events: none;
  opacity: 0.72;
}

.share-badge {
  position: static;
  justify-self: end;
  background: linear-gradient(180deg, #111 0%, #333 100%);
  color: #fff;
  border: 3px solid var(--gang-accent-soft);
  border-radius: 999px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 10px 18px 8px;
}

.share-strength-row {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.share-rarity {
  position: static;
  font-size: 26px;
  font-weight: 900;
  color: var(--gang-accent);
  text-shadow: 0 1px 0 #fff, 0 0 12px color-mix(in srgb, var(--gang-accent) 60%, #fff 40%);
}

.share-rarity-label {
  position: static;
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #495362;
}

.share-rarity-legend {
  position: static;
  justify-self: end;
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  color: rgba(78, 86, 98, 0.7);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  padding: 3px 7px;
  max-width: 320px;
  opacity: 0.7;
}

.share-main {
  display: grid;
  grid-template-columns: 1fr 470px;
  gap: 24px;
  height: calc(100% - 236px);
}

.share-left {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.55));
  border: 5px solid #111;
  border-radius: 22px;
  padding: 26px 24px;
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--gang-accent-soft) 58%, #fff 42%);
}

.share-left p {
  margin: 0 0 14px;
}

.share-province {
  font-size: 44px;
  font-weight: 900;
  line-height: 1.1;
}

.share-bird {
  font-size: 36px;
  font-weight: 700;
}

.share-bias {
  font-size: 58px;
  font-weight: 900;
  line-height: 1.05;
  color: color-mix(in srgb, var(--gang-accent) 65%, #14385e 35%);
  margin-bottom: 8px !important;
}

.share-bias-interpretation {
  font-size: 20px;
  font-weight: 700;
  color: #324055;
  margin-bottom: 14px !important;
}

.share-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.share-stat {
  border: 3px solid #111;
  border-radius: 14px;
  background: #fff;
  padding: 10px 10px 8px;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--gang-accent) 55%, #111 45%);
}

.share-stat .label {
  display: block;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #3f4a5c;
}

.share-stat .value {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  font-weight: 900;
}

.share-right {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 18px;
}

.share-note {
  margin-top: 4px !important;
  font-size: 20px !important;
  font-weight: 600;
  color: #666;
}

.share-confidence {
  display: inline-block;
  margin: 0 0 12px !important;
  font-size: 18px !important;
  font-weight: 900;
  color: #1c2f44;
  border: 2px solid #1c2f44;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.7);
}

.share-cta {
  margin: 10px 0 0 !important;
  font-size: 19px !important;
  font-weight: 800;
  color: #223752;
}

.share-footer {
  position: absolute;
  left: 40px;
  right: auto;
  bottom: 12px;
  font-size: 22px !important;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #1b1b1b;
  padding: 2px 8px 1px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
  z-index: 6;
  opacity: 0.85;
}

.share-map-preview {
  border: 5px solid #111;
  border-radius: 16px;
  background: #d2deed;
  box-shadow: inset 0 0 0 4px #ffffff96, 0 5px 0 color-mix(in srgb, var(--gang-accent) 40%, #111 60%);
  overflow: hidden;
}

.share-map-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.share-map-preview .map-region {
  opacity: 0.56;
}

.share-map-preview .share-map-focus {
  stroke: #ffe45c;
  stroke-width: 9;
  stroke-linejoin: round;
  opacity: 1 !important;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 6px rgba(255, 228, 92, 0.7));
}

.share-map-label {
  position: absolute;
  top: 14px;
  left: 14px;
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #16283f;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 3px 8px;
  z-index: 3;
}

.share-photo-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

#shareBirdImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 5px solid #111;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--gang-accent) 40%, #111 60%);
}

.share-photo-caption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: rgba(14, 18, 24, 0.7);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.share-card.share-qa-debug .share-header-left {
  outline: 2px dashed #e23370;
  background: rgba(226, 51, 112, 0.08);
}

.share-card.share-qa-debug .share-header-right {
  outline: 2px dashed #2f73e2;
  background: rgba(47, 115, 226, 0.08);
}

@media (max-width: 760px) {
  .container {
    padding: 0.7rem;
  }

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

  .map-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .toggle-label {
    margin-top: 0;
  }

  .info-btn {
    right: 10px;
    bottom: 10px;
  }

  .meme-actions {
    flex-direction: column;
  }

  .table-info-btn {
    margin-left: 0;
  }

  .png-example-image {
    max-width: 100%;
  }
}

