/* ==========================================================================
   BESTIARIUM STYLES
   ========================================================================== */
#view-creature-index {
  cursor: pointer;
}

#view-creature-index .sq-panel {
  cursor: default;
}

.sq-creature-index-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.sq-cindex-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Bestiarium Search & Filter Toolbar */
.sq-cindex-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(var(--bg-panel-rgb), 0.55);
  border: 1px solid rgba(var(--text-muted-rgb), 0.16);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.sq-cindex-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.sq-cindex-search-wrap .sq-search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text2);
  pointer-events: none;
}

.sq-cindex-search-wrap .sq-search-input {
  width: 100%;
  background: rgba(var(--bg-rgb), 0.85);
  border: 1px solid rgba(var(--text-muted-rgb), 0.24);
  color: var(--text-bright);
  padding: 8px 32px 8px 34px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sq-cindex-search-wrap .sq-search-input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 2px rgba(var(--accent-vivid-rgb), 0.2);
}

.sq-cindex-search-wrap .sq-search-clear {
  position: absolute;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.sq-cindex-search-wrap .sq-search-clear:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.sq-cindex-filters-wrap {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.sq-cindex-filter-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sq-cindex-filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text2);
  padding-left: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sq-cindex-select {
  width: 100%;
  background: rgba(var(--bg-rgb), 0.85);
  border: 1px solid rgba(var(--text-muted-rgb), 0.24);
  color: var(--text-bright);
  padding: 7px 22px 7px 8px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  transition: border-color 0.2s ease;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.sq-cindex-select:focus {
  border-color: var(--sky);
}

.sq-cindex-select option {
  background: var(--bg3);
  color: var(--text-bright);
}

/* Empty filter state */
.sq-cindex-empty-filter {
  text-align: center;
  padding: 32px 16px;
  background: rgba(var(--bg-panel-rgb), 0.45);
  border: 1px dashed rgba(var(--text-muted-rgb), 0.2);
  border-radius: 12px;
  color: var(--text2);
  margin-bottom: 20px;
}

.sq-cindex-empty-filter p {
  font-size: 0.85rem;
  margin: 0 0 12px;
  color: var(--text-soft);
}

.sq-cindex-section {
  background: rgba(var(--bg-panel-rgb), 0.55);
  border: 1px solid rgba(var(--text-muted-rgb), 0.16);
  border-radius: 16px;
  padding: 16px 18px 20px;
}

.sq-cindex-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(var(--text-muted-rgb), 0.12);
  margin-bottom: 14px;
  gap: 10px;
}

.sq-cindex-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.sq-cindex-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(var(--accent-vivid-rgb), 0.12);
  border: 1px solid rgba(var(--accent-vivid-rgb), 0.28);
  color: var(--sky);
  flex-shrink: 0;
}

.sq-cindex-type-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sq-cindex-rank-badge {
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--accent-vivid);
  background: rgba(var(--accent-vivid-rgb), 0.12);
  border: 1px solid rgba(var(--accent-vivid-rgb), 0.28);
  padding: 2px 7px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sq-cindex-section-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.sq-cindex-card {
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
  position: relative;
}

/* Uncaught state: dimmed & grayscale on thumbnail image (overlay badges keep full color), with border in rarity color */
.sq-cindex-card.is-uncaught {
  opacity: 0.72;
  background: rgba(var(--bg-panel-rgb), 0.6);
}

.sq-cindex-card.is-discovered {
  opacity: 0.88;
  background: rgba(var(--bg-panel-rgb), 0.72);
}

.sq-cindex-card.is-uncaught:not(.is-placeholder) .sq-cindex-thumb-img {
  filter: grayscale(1);
  opacity: 0.74;
}

.sq-cindex-card.is-placeholder .sq-cindex-thumb-img {
  opacity: 0.85;
}

.sq-cindex-card.is-uncaught .sq-cindex-card-desc {
  opacity: 0.65;
}

.sq-cindex-card.is-discovered .sq-cindex-card-desc {
  opacity: 0.85;
}

.sq-cindex-card.is-uncaught:hover {
  opacity: 0.95;
  transform: translateY(-2px);
}

/* Uncaught state: dashed border matching rarity color */
.sq-cindex-card.is-uncaught.sq-rarity-border-gewoehnlich {
  border: 1.5px dashed rgba(148, 163, 184, 0.65);
  box-shadow: 0 2px 10px rgba(148, 163, 184, 0.12);
}

.sq-cindex-card.is-uncaught.sq-rarity-border-selten {
  border: 1.5px dashed rgba(56, 189, 248, 0.8);
  box-shadow: 0 2px 14px rgba(56, 189, 248, 0.22);
}

.sq-cindex-card.is-uncaught.sq-rarity-border-episch {
  border: 1.5px dashed rgba(192, 132, 252, 0.85);
  box-shadow: 0 2px 16px rgba(192, 132, 252, 0.25);
}

.sq-cindex-card.is-uncaught.sq-rarity-border-legendaer {
  border: 1.5px dashed rgba(251, 191, 36, 0.9);
  box-shadow: 0 2px 18px rgba(251, 191, 36, 0.28);
}

.sq-cindex-card.is-uncaught.sq-rarity-border-einzigartig {
  border: 1.5px dashed rgba(244, 63, 94, 0.95);
  box-shadow: 0 2px 20px rgba(244, 63, 94, 0.35);
}

/* Caught state: vivid, glowing border matching rarity */
.sq-cindex-card.is-caught {
  opacity: 1;
  filter: none;
  background: rgba(var(--bg-panel-rgb), 0.88);
  backdrop-filter: blur(8px);
}

.sq-cindex-card.is-caught:hover {
  transform: translateY(-3px);
}

.sq-cindex-card.is-caught.sq-rarity-border-gewoehnlich {
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 4px 16px rgba(148, 163, 184, 0.12);
}

.sq-cindex-card.is-caught.sq-rarity-border-selten {
  border: 1px solid rgba(56, 189, 248, 0.65);
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.24);
}

.sq-cindex-card.is-caught.sq-rarity-border-episch {
  border: 1px solid rgba(192, 132, 252, 0.7);
  box-shadow: 0 4px 22px rgba(192, 132, 252, 0.28);
}

.sq-cindex-card.is-caught.sq-rarity-border-legendaer {
  border: 1px solid rgba(251, 191, 36, 0.75);
  box-shadow: 0 4px 26px rgba(251, 191, 36, 0.32);
}

.sq-cindex-card.is-caught.sq-rarity-border-einzigartig {
  border: 1.5px solid rgba(244, 63, 94, 0.85);
  box-shadow: 0 4px 30px rgba(244, 63, 94, 0.4);
}

/* Thumbnail */
.sq-cindex-thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background: var(--bg);
}

.sq-cindex-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  display: block;
  transition: transform 0.35s ease;
}

.sq-cindex-card.is-caught:hover .sq-cindex-thumb-img {
  transform: scale(1.05);
}

.sq-cindex-thumb-overlay {
  position: absolute;
  inset: 0;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.65) 0%, transparent 55%);
}

.sq-cindex-rarity-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sq-cindex-pill {
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sq-cindex-pill.is-caught {
  background: rgba(52, 211, 153, 0.9);
  color: #022c22;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

.sq-cindex-pill.is-discovered {
  background: rgba(56, 189, 248, 0.22);
  color: #bae6fd;
  border: 1px solid rgba(125, 211, 252, 0.42);
  backdrop-filter: blur(4px);
}

.sq-cindex-pill.is-uncaught {
  background: rgba(var(--bg-elevated-rgb), 0.9);
  color: var(--text2);
  border: 1px solid rgba(var(--text-muted-rgb), 0.3);
}

/* Info body */
.sq-cindex-card-info {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.sq-cindex-card-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
  line-height: 1.3;
}

.sq-cindex-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 600;
}

.sq-cindex-spawn {
  color: var(--accent-vivid);
  font-weight: 700;
}

.sq-cindex-kp {
  color: #fde047;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
}

.sq-cindex-dot {
  color: var(--text3);
}

.sq-cindex-card-desc {
  font-size: 0.74rem;
  color: var(--text-soft);
  line-height: 1.35;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sq-cindex-card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(var(--text-muted-rgb), 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
}

.sq-cindex-count-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.sq-cindex-count-tag.is-dimmed {
  color: var(--text3);
}

.sq-cindex-count-tag.is-discovered-tag {
  color: #7dd3fc;
}

.sq-cindex-loading {
  text-align: center;
  padding: 36px 14px;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

@media (max-width: 640px) {

  /* Toolbar & Filter controls in Smartphone mode */
  .sq-cindex-toolbar {
    padding: 9px 10px;
    gap: 8px;
    margin-bottom: 12px;
    border-radius: 11px;
  }

  .sq-cindex-search-wrap .sq-search-input {
    font-size: 0.78rem;
    padding: 6px 28px 6px 30px;
  }

  .sq-cindex-search-wrap .sq-search-icon {
    width: 14px;
    height: 14px;
    left: 9px;
  }

  .sq-cindex-filters-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .sq-cindex-filter-label {
    font-size: 0.62rem;
  }

  .sq-cindex-select {
    font-size: 0.72rem;
    padding: 5px 16px 5px 6px;
    border-radius: 6px;
    background-position: right 4px center;
  }

  /* Container & Section Header adjustments in Smartphone mode */
  .sq-cindex-section {
    padding: 10px 8px 12px;
    border-radius: 12px;
  }

  .sq-cindex-section-header {
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    align-items: center;
  }

  .sq-cindex-section-title {
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    flex: 1 1 auto;
  }

  .sq-cindex-type-icon {
    width: 20px;
    height: 20px;
    border-radius: 5px;
  }

  .sq-cindex-type-icon svg {
    width: 12px;
    height: 12px;
  }

  .sq-cindex-type-name {
    font-size: 0.80rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .sq-cindex-rank-badge {
    font-size: 0.58rem;
    padding: 1px 5px;
    gap: 2px;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .sq-cindex-rank-badge svg {
    width: 9px;
    height: 9px;
  }

  .sq-cindex-section-badge {
    font-size: 0.62rem;
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
  }

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

  .sq-cindex-card-title {
    font-size: 0.85rem;
  }

  .sq-cindex-card-desc {
    display: none;
  }

  .sq-cindex-thumb-wrapper {
    aspect-ratio: 1 / 1;
  }

  .sq-cindex-pill .sq-cindex-pill-text {
    display: none;
  }

  .sq-cindex-pill {
    padding: 3px 6px;
    gap: 0;
    min-width: 22px;
    justify-content: center;
  }
}

@media (max-width: 440px) {
  .sq-cindex-filters-wrap {
    gap: 4px;
  }

  .sq-cindex-select {
    font-size: 0.68rem;
    padding: 5px 14px 5px 4px;
  }

  .sq-cindex-section-header {
    gap: 4px;
  }

  .sq-cindex-type-name {
    font-size: 0.74rem;
  }

  .sq-cindex-rank-badge {
    font-size: 0.54rem;
    padding: 1px 4px;
  }

  .sq-cindex-section-badge {
    font-size: 0.58rem;
    padding: 2px 5px;
  }
}

/* Placeholder card for uncaught creatures (non-admin) */
.sq-cindex-card.is-placeholder {
  opacity: 0.85;
  filter: none;
  cursor: default;
}

.sq-cindex-card.is-placeholder .sq-cindex-thumb-img {
  object-fit: cover;
  padding: 0;
  background: radial-gradient(circle at center, var(--bg4), var(--bg) 75%);
}

.sq-cindex-card.is-placeholder:hover {
  transform: none;
  opacity: 0.72;
  border-color: rgba(var(--text-muted-rgb), 0.32);
}

.sq-cindex-card.is-clickable {
  cursor: pointer;
}

.sq-cindex-card.is-clickable:hover {
  cursor: pointer;
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   BESTIARIUM LIGHTBOX MODAL
   ========================================================================== */
.sq-creature-lightbox-modal {
  max-width: 660px;
  width: 92%;
  background: rgba(var(--bg-panel-rgb), 0.96);
  border: 1px solid rgba(var(--text-muted-rgb), 0.24);
  border-radius: 20px;
  padding: 18px 20px 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: sq-lightbox-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sq-lightbox-pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.sq-creature-lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(var(--text-muted-rgb), 0.14);
}

.sq-creature-lightbox-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sq-creature-lightbox-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}

.sq-creature-lightbox-body {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  border-radius: 14px;
  border: 1px solid rgba(var(--text-muted-rgb), 0.14);
  overflow: hidden;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.6);
  padding: 8px;
}

.sq-creature-lightbox-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 10px;
  display: block;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.sq-creature-lightbox-image.is-greyed-out {
  filter: grayscale(1);
}

.sq-creature-lightbox-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

.sq-creature-lightbox-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text2);
}

.sq-creature-lightbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.sq-creature-lightbox-spawn {
  color: #a7f3d0;
}

.sq-creature-lightbox-habitat {
  color: #93c5fd;
}

.sq-cindex-location-val {
  font-weight: 700;
  color: var(--text-bright);
}

.sq-creature-lightbox-desc {
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.42;
  margin: 0;
}

/* ==========================================================================
   SCROLL TO TOP BUTTON (BESTIARIUM)
   ========================================================================== */
.sq-scroll-top-btn {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--sky);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(var(--accent-rgb), 0.25);
  z-index: 900;
  transition: all 0.25s var(--silk);
  opacity: 1;
  transform: translateY(0);
}

.sq-scroll-top-btn.hidden {
  display: none !important;
}

.sq-scroll-top-btn:hover {
  background: var(--sky);
  color: var(--text-on-accent);
  border-color: var(--sky2);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 28px rgba(var(--accent-rgb), 0.45);
}

.sq-scroll-top-btn:active {
  transform: translateY(0) scale(0.96);
}

.sq-scroll-top-btn svg,
.sq-scroll-top-btn .lucide {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.4;
}

@media (max-width: 768px) {
  .sq-scroll-top-btn {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 40px;
    height: 40px;
  }

  .sq-scroll-top-btn svg,
  .sq-scroll-top-btn .lucide {
    width: 20px;
    height: 20px;
  }
}