:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2933;
  background: #eef2f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef2f5;
  overflow: hidden;
}

button {
  font: inherit;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 8px;
  gap: 10px;
  overflow: hidden;
}

.site-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1;
}

.identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  margin-left: auto;
  margin-right: 28px;
  text-align: right;
}

.signature {
  color: #334e68;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.contact {
  font-size: 13px;
  color: #718096;
  line-height: 1.2;
}

.categories,
.animal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.cat-pill,
.animal-filter,
.page-btn,
.bird-index-item {
  border: 1px solid #d9e2ec;
  background: #fff;
  color: #334e68;
  border-radius: 999px;
  cursor: pointer;
}

.cat-pill {
  padding: 4px 12px;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.cat-pill.active,
.animal-filter.active,
.bird-index-item.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.layout.no-index {
  grid-template-columns: minmax(0, 1fr);
}

.card,
.bird-index {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .10);
}

.content {
  padding: 12px 14px 14px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bird-index {
  height: auto;
  max-height: none;
  padding: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bird-index-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bird-index-title {
  font-weight: 700;
  font-size: 14px;
}

.bird-index-count {
  color: #718096;
  font-size: 12px;
  white-space: nowrap;
}

.bird-index-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
  padding-right: 4px;
  padding-bottom: 20px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.bird-index-list::-webkit-scrollbar {
  width: 6px;
}

.bird-index-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.bird-branch {
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
}

.bird-order,
.bird-family {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bird-order .bird-branch {
  background: #ecfdf3;
  color: #2f6846;
}

.bird-family .bird-branch {
  margin-left: 6px;
  background: #eaf6fb;
  color: #2a5b72;
}

.bird-index-item {
  width: 100%;
  min-height: 18px;
  padding: 1px 5px;
  display: flex;
  align-items: center;
  text-align: left;
  font-size: 10.5px;
  line-height: 1.2;
  border-radius: 5px;
  background: #f3f5f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bird-index-item.recent {
  min-height: 22px;
  font-weight: 700;
}

.bird-index-item.species {
  margin-left: 10px;
  width: calc(100% - 10px);
}

.bird-index-item:hover,
.cat-pill:hover,
.animal-filter:hover,
.page-btn:hover:not(:disabled) {
  background: #e8eef3;
}

.animal-filters {
  flex: 0 0 auto;
}

.animal-filter {
  padding: 4px 12px;
  font-size: 12px;
}

.groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}

.content-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.content-scroll::-webkit-scrollbar {
  width: 6px;
}

.content-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.content-pagination {
  flex: 0 0 auto;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-footer {
  flex: 0 0 auto;
  min-height: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #718096;
  font-size: 12px;
  line-height: 1.2;
}

.site-footer a {
  color: #718096;
  text-decoration: none;
}

.site-footer a:hover {
  color: #334e68;
  text-decoration: underline;
}

.group {
  background: #fbfcfd;
  border: 1px solid #e6edf3;
  border-radius: 8px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.group-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #334e68;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 5), minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.item {
  margin: 0;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(245, 158, 11, .18);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
  display: flex;
  flex-direction: column;
}

.thumb {
  background: #111827;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

.thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.caption {
  min-height: 30px;
  padding: 6px 9px;
  color: #44546a;
  font-size: 12px;
  line-height: 1.45;
  background: #fff;
  border-top: 1px solid #eef2f5;
}

.empty {
  color: #718096;
  padding: 18px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.page-btn {
  padding: 5px 14px;
}

.page-btn:disabled {
  opacity: .45;
  cursor: default;
}

.page-jump {
  width: 44px;
  padding: 4px 7px;
  border: 1px solid #d9e2ec;
  border-radius: 999px;
  color: #334e68;
  background: #fff;
  font: inherit;
  font-size: 12px;
  text-align: center;
}

.page-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #718096;
  font-size: 12px;
}

.page-jump::-webkit-outer-spin-button,
.page-jump::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .82);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow: hidden;
}

.lightbox.open {
  display: flex;
  touch-action: none;
}

.lightbox-inner {
  max-width: 100vw;
  max-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img {
  max-width: 100vw;
  max-height: 96vh;
  object-fit: contain;
  border-radius: 8px;
  transition: transform .12s ease-out;
  cursor: default;
  touch-action: none;
  user-select: none;
}

.lightbox-caption {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(900px, 96vw);
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(20, 25, 31, .38);
  backdrop-filter: blur(14px) saturate(1.18);
  color: #fff;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .24);
  pointer-events: none;
}

.lightbox-info-line {
  min-height: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 981px) {
  .content-scroll {
    overflow: hidden;
  }

  .groups {
    height: 100%;
  }

  .group {
    overflow: hidden;
  }

  .grid {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: repeat(var(--grid-rows, 3), var(--card-height, auto));
  }

  .item {
    height: var(--card-height, auto);
  }

  .thumb {
    height: var(--thumb-height, auto);
  }

  .caption {
    flex: 0 0 42px;
    min-height: 42px;
    max-height: 42px;
    overflow: hidden;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .layout {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .bird-index {
    position: static;
    height: auto;
    max-height: none;
  }

  .bird-index-list {
    max-height: 260px;
  }

  .content {
    max-height: none;
  }

  .content-scroll {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 10px;
  }

  .brand-row {
    align-items: flex-start;
    gap: 10px;
  }

  .identity {
    max-width: 48vw;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .item {
    display: flex;
    flex-direction: column;
  }

  .thumb {
    aspect-ratio: 4 / 3;
    flex: 0 0 auto;
  }

  .caption {
    font-size: 10px;
    line-height: 1.35;
    padding: 5px 7px;
    min-height: 36px;
    max-height: 36px;
    overflow: hidden;
  }
}
