@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  --ink: #f3f8fb;
  --muted: #92a9b8;
  --muted-strong: #b8c8d2;
  --bg: #06111c;
  --panel: #081725;
  --panel-soft: #0c2030;
  --panel-raised: #10293a;
  --line: rgba(153, 190, 207, 0.18);
  --line-strong: rgba(153, 190, 207, 0.32);
  --aqua: #52d6d1;
  --aqua-soft: rgba(82, 214, 209, 0.14);
  --amber: #ffb454;
  --amber-soft: rgba(255, 180, 84, 0.16);
  --danger: #ff8d83;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --control-width: 400px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-width: 320px;
}

/* Critical Leaflet layout fallback. The CDN stylesheet supplies the complete
   component skin; these rules keep tiles, vector layers and controls aligned
   if a browser delays or blocks that external stylesheet. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }

.leaflet-map-pane canvas {
  z-index: 100;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: var(--aqua);
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 2000;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--control-width) minmax(0, 1fr);
  height: 100dvh;
  min-height: 680px;
  overflow: hidden;
}

.control-panel {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-width: 0;
  padding: 24px 26px 20px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 18% 0%, rgba(82, 214, 209, 0.09), transparent 30%),
    linear-gradient(180deg, #091a29 0%, #071521 100%);
  border-right: 1px solid var(--line);
  scrollbar-color: var(--line-strong) transparent;
}

.topbar,
.brand,
.species-card-heading,
.timeline-heading,
.timeline-actions,
.range-row,
.science-note {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
}

.brand {
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 1px solid rgba(82, 214, 209, 0.38);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(82, 214, 209, 0.22), rgba(82, 214, 209, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.brand-mark svg {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg .wave {
  stroke: var(--aqua);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.language-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(8, 23, 37, 0.82);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.language-button:hover,
.language-button:focus-visible {
  border-color: var(--aqua);
  background: var(--aqua-soft);
}

.language-button:active,
button:active {
  transform: translateY(1px);
}

.intro {
  max-width: 340px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--aqua);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0;
  max-width: 330px;
  font-family: "Manrope", sans-serif;
  font-size: clamp(2rem, 3vw, 2.65rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.intro > p:last-child {
  margin: 14px 0 0;
  color: var(--muted-strong);
  font-size: 0.96rem;
  line-height: 1.55;
}

.species-search {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(12, 32, 48, 0.72);
}

.species-search > label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 50px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #071520;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-row:focus-within {
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(82, 214, 209, 0.1);
}

.search-icon {
  display: grid;
  place-items: center;
  padding-left: 8px;
  color: var(--muted);
}

.search-icon svg,
.search-row button svg,
.external-link svg,
.play-button svg,
.science-note svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-row input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.93rem;
  font-style: italic;
}

.search-row input::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.55;
}

.search-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: stretch;
  min-width: 102px;
  padding: 0 13px;
  border: 0;
  background: var(--amber);
  color: #162131;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.search-row button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.species-search > small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.4;
}

.status {
  display: none;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted-strong);
  font-size: 0.87rem;
  line-height: 1.45;
}

.status:not(:empty) {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status.loading::before {
  content: "";
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--aqua);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.status.error {
  border-color: rgba(255, 141, 131, 0.34);
  color: #ffc1ba;
  background: rgba(255, 141, 131, 0.06);
}

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

.species-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(16, 41, 58, 0.96), rgba(9, 28, 42, 0.96));
  box-shadow: var(--shadow);
}

.species-card[hidden],
.species-photo[hidden] {
  display: none;
}

.species-card-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.species-card-heading h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 1.28rem;
  line-height: 1.15;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.authority {
  min-height: 1.2em;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.external-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  text-decoration: none;
}

.species-photo {
  position: relative;
  margin: 15px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg);
}

.species-photo img {
  display: block;
  width: 100%;
  height: 132px;
  object-fit: cover;
}

.species-photo figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 18px 10px 8px;
  overflow: hidden;
  background: linear-gradient(transparent, rgba(2, 11, 17, 0.88));
  color: #d8e5eb;
  font-size: 0.66rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 16px;
}

.stat {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(6, 17, 28, 0.36);
}

.stat span,
.stat strong {
  display: block;
}

.stat span {
  color: var(--muted);
  font-size: 0.71rem;
}

.stat strong {
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-quality {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(6, 17, 28, 0.28);
}

.data-quality[hidden] {
  display: none;
}

.data-quality summary {
  color: var(--aqua);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.data-quality dl {
  display: grid;
  gap: 7px;
  margin: 11px 0 0;
}

.data-quality dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.data-quality dt,
.data-quality dd,
.data-quality p {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
}

.data-quality dt,
.data-quality p {
  color: var(--muted);
}

.data-quality dd {
  color: var(--ink);
  font-weight: 700;
}

.data-quality p {
  margin-top: 10px;
}

.data-sources {
  margin-top: auto;
  padding-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.data-sources p {
  margin: 0;
}

.data-sources .prototype-note {
  margin-top: 8px;
  padding-left: 9px;
  border-left: 2px solid var(--amber);
  color: var(--muted-strong);
}

.data-sources a {
  font-weight: 700;
  text-underline-offset: 3px;
}

.visual-panel {
  display: grid;
  grid-template-rows: minmax(300px, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: #0a1721;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #b8c5c8;
  touch-action: none;
  transition: filter 0.18s ease, opacity 0.18s ease;
}

.map-wrap.map-is-loading #map {
  filter: blur(2px) saturate(0.65);
  opacity: 0.72;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 550;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 11px;
  padding: 24px;
  background: rgba(6, 17, 28, 0.2);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

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

.map-loading > span:last-child {
  max-width: 290px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(6, 17, 28, 0.9);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

.map-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(82, 214, 209, 0.25);
  border-top-color: var(--aqua);
  border-radius: 50%;
  animation: map-loading-spin 0.75s linear infinite;
}

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

.leaflet-container {
  font-family: "DM Sans", sans-serif;
}

.leaflet-control-zoom a {
  border-color: rgba(255, 255, 255, 0.1) !important;
  background: #0a1d2b !important;
  color: var(--ink) !important;
}

.leaflet-control-attribution {
  background: rgba(6, 17, 28, 0.8) !important;
  color: #aec1cb;
}

.leaflet-control-attribution a {
  color: #72e3dd;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #081b29;
  color: var(--ink);
}

.leaflet-popup-content-wrapper {
  border: 1px solid rgba(82, 214, 209, 0.3);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.leaflet-popup-content {
  width: min(280px, calc(100vw - 80px)) !important;
  margin: 15px 16px;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--muted-strong);
}

.occurrence-popup h3 {
  margin: 0 22px 10px 0;
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  line-height: 1.25;
}

.occurrence-popup-loading,
.occurrence-popup-error {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.78rem;
  line-height: 1.4;
}

.occurrence-popup-details {
  display: grid;
  gap: 7px;
}

.occurrence-popup-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.occurrence-popup-row span {
  color: var(--muted);
  font-size: 0.7rem;
}

.occurrence-popup-row strong {
  overflow-wrap: anywhere;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
}

.occurrence-popup > a {
  display: inline-block;
  margin-top: 11px;
  color: var(--aqua);
  font-size: 0.75rem;
  font-weight: 700;
  text-underline-offset: 3px;
}

.map-overlay {
  position: absolute;
  z-index: 500;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(6, 17, 28, 0.88);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.map-legend {
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 11px;
  color: #d7e5eb;
  font-size: 0.75rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border: 2px solid #fff3d8;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(255, 180, 84, 0.2);
}

.period-badge {
  top: 18px;
  left: 18px;
  padding: 10px 13px;
  border-radius: 12px;
}

.period-badge span,
.period-badge strong {
  display: block;
}

.period-badge span {
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.period-badge strong {
  margin-top: 2px;
  color: var(--amber);
  font-family: "Manrope", sans-serif;
  font-size: 0.95rem;
}

.timeline-panel {
  position: relative;
  z-index: 5;
  min-height: 278px;
  padding: 22px 26px 19px;
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 100%, rgba(255, 180, 84, 0.06), transparent 32%),
    #081725;
}

.timeline-heading {
  justify-content: space-between;
  gap: 20px;
}

.timeline-heading h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.timeline-actions {
  gap: 9px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.speed-control select {
  min-height: 40px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #0a1d2b;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.secondary-button,
.play-button {
  min-height: 40px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted-strong);
}

.secondary-button.active {
  border-color: rgba(82, 214, 209, 0.5);
  background: var(--aqua-soft);
  color: var(--aqua);
}

.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 112px;
  padding: 0 14px;
  border: 0;
  background: var(--amber);
  color: #14202d;
}

.play-button .pause-icon,
.play-button.playing .play-icon {
  display: none;
}

.play-button.playing .pause-icon {
  display: block;
}

.play-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.timeline-chart {
  display: flex;
  align-items: end;
  gap: clamp(3px, 0.55vw, 8px);
  height: 92px;
  margin-top: 16px;
  padding: 0 1px 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.timeline-bar {
  position: relative;
  min-width: 14px;
  flex: 1 0 14px;
  height: max(5px, var(--bar-height));
  padding: 0;
  border: 0;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, rgba(82, 214, 209, 0.92), rgba(82, 214, 209, 0.3));
  cursor: pointer;
  transition: height 0.25s ease, background 0.2s ease, transform 0.2s ease;
}

.timeline-bar:hover,
.timeline-bar:focus-visible {
  background: linear-gradient(180deg, #89eeea, #38aaa8);
  outline: 0;
  transform: translateY(-2px);
}

.timeline-bar:disabled {
  cursor: wait;
  opacity: 0.55;
}

.timeline-bar:disabled:hover {
  background: linear-gradient(180deg, rgba(82, 214, 209, 0.92), rgba(82, 214, 209, 0.3));
  transform: none;
}

.timeline-bar.active {
  background: linear-gradient(180deg, #ffd18f, var(--amber));
  box-shadow: 0 0 0 3px rgba(255, 180, 84, 0.12);
}

.timeline-bar::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  z-index: 10;
  width: max-content;
  max-width: 140px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #06111c;
  color: var(--ink);
  font-size: 0.68rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.timeline-bar:hover::after,
.timeline-bar:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.range-row {
  gap: 13px;
  margin-top: 11px;
}

.range-row > span {
  min-width: 34px;
  color: var(--muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
}

.range-row > span:last-child {
  text-align: right;
}

.range-row input {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--amber);
  cursor: pointer;
}

.range-row input:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.timeline-footer {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(280px, 1fr);
  align-items: center;
  gap: 24px;
  margin-top: 7px;
}

.period-summary {
  margin: 0;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.period-breakdown {
  margin: 3px 0 0;
  color: var(--muted-strong);
  font-size: 0.72rem;
  line-height: 1.35;
}

.period-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-width: 0;
}

.science-note {
  justify-self: end;
  gap: 7px;
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.science-note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--amber);
}

:focus-visible {
  outline: 3px solid rgba(82, 214, 209, 0.7);
  outline-offset: 3px;
}

@media (max-width: 1050px) {
  :root { --control-width: 350px; }

  .control-panel {
    gap: 20px;
    padding: 20px;
  }

  .intro h1 {
    font-size: 2rem;
  }

  .search-row {
    grid-template-columns: 32px minmax(0, 1fr) 48px;
  }

  .search-row button {
    min-width: 48px;
    padding: 0;
  }

  .search-row button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .timeline-footer {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .science-note {
    justify-self: start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: flex;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    flex-direction: column;
  }

  .control-panel {
    order: 1;
    max-height: none;
    overflow: visible;
    padding: max(17px, env(safe-area-inset-top)) 17px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand small {
    display: none;
  }

  .intro {
    max-width: none;
  }

  .intro h1 {
    max-width: 430px;
    font-size: clamp(1.9rem, 9vw, 2.55rem);
  }

  .species-search {
    padding: 14px;
  }

  .search-row {
    grid-template-columns: 34px minmax(0, 1fr) 52px;
  }

  .species-card {
    padding: 16px;
  }

  .species-photo img {
    height: clamp(150px, 42vw, 230px);
  }

  .data-sources {
    margin-top: 0;
  }

  .visual-panel {
    order: 2;
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .map-wrap {
    height: 58dvh;
    min-height: 390px;
  }

  #map {
    touch-action: none;
  }

  .period-badge {
    top: 12px;
    left: 12px;
  }

  .map-legend {
    right: 12px;
    bottom: 12px;
  }

  .timeline-panel {
    min-height: 0;
    padding: 20px 17px calc(22px + env(safe-area-inset-bottom));
  }

  .timeline-heading {
    align-items: flex-end;
  }

  .timeline-actions {
    flex-shrink: 0;
  }

  .speed-control {
    gap: 4px;
  }

  .speed-control > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .speed-control select {
    min-height: 42px;
    padding-left: 8px;
  }

  .secondary-button {
    width: 42px;
    padding: 0;
    font-size: 0;
  }

  .secondary-button::before {
    content: "∞";
    font-size: 1.1rem;
  }

  .play-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .play-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .timeline-chart {
    gap: 5px;
    height: 108px;
    margin-top: 19px;
  }

  .timeline-bar {
    min-width: 17px;
    flex-basis: 17px;
  }

  .timeline-footer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .period-result {
    grid-template-columns: 1fr;
  }

  .science-note {
    max-width: none;
  }
}

@media (max-width: 430px) {
  .control-panel {
    gap: 18px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .brand strong {
    font-size: 0.92rem;
  }

  .intro > p:last-child {
    font-size: 0.9rem;
  }

  .stats-grid {
    gap: 7px;
  }

  .stat {
    padding: 10px;
  }

  .map-wrap {
    min-height: 360px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
