:root {
  --primary: #fdda0d;
  --bg: #0b0b0d;
  --card: #16161a;
  --text: #ddd;
  --grid-size: 220px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* NAVIGATION */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(11, 11, 13, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #222;
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.nav-logo {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.2rem;
  white-space: nowrap;
}

.search-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  position: relative;
  max-width: 500px;
}

.search-input {
  padding: 10px 45px 10px 20px;
  width: 100%;
  background: #1a1a1f;
  border: 1px solid #333;
  border-radius: 8px;
  color: white;
  outline: none;
  transition: border-color 0.3s;
}

.search-input:focus {
  border-color: var(--primary);
}

.clear-search {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #666;
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  padding: 0;
  line-height: 1;
}

.search-input:not(:placeholder-shown) + .clear-search {
  display: block;
}

.nav-btn {
  background: #222;
  border: 1px solid #333;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  position: relative;
  z-index: 2001;
  transition: all 0.3s;
}

.nav-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

/* FLYOUT MENU */
#menuPerimeter {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1999;
}

.flyout-menu {
  display: block;
  position: fixed;
  top: 75px;
  right: 30px;
  width: 320px;
  background: rgba(26, 26, 31, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(253, 218, 13, 0.3);
  z-index: 2000;
  padding: 25px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  pointer-events: none;
  visibility: hidden;
}

.flyout-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  visibility: visible;
}

.setting-group {
  margin-bottom: 25px;
  width: 100%;
}

.setting-label {
  display: block;
  margin: 15px 0 8px;
  font-size: 0.7rem;
  color: #555;
  text-transform: uppercase;
  font-weight: 800;
}

.stats-footer {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #333;
  font-size: 0.75rem;
  color: #888;
}

.stats-footer b {
  color: var(--primary);
}

.stat-row {
  margin-bottom: 4px;
  display: block;
}

.common-tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

select,
input[type="range"] {
  width: 100%;
  background: #0b0b0d;
  color: white;
  border: 1px solid #333;
  padding: 10px;
  border-radius: 8px;
  outline: none;
}

input[type="range"]#gridRange {
  cursor: ew-resize;
  accent-color: var(--primary);
}

/* ASSET GRID */
.container {
  max-width: 1800px;
  margin: 40px auto;
  padding: 0 30px;
}

#assetList {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  list-style: none;
  padding: 0;
  justify-content: center;
}

.asset {
  background: #111114;
  border: 1px solid #252525;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease-out, transform 0.2s ease-out, border-color 0.2s
    ease-out;
  position: relative;
  contain: content;
  transform: translateZ(0);
  width: var(--grid-size);
  flex-shrink: 0;
  flex-grow: 0;
  will-change: width;
}

.asset:hover {
  border-color: var(--primary);
  transform: translateY(-5px);
}

.asset-id-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.hide-ids .asset-id-tag {
  opacity: 0;
}

/* ADULT OVERLAY */
.adult-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  color: rgba(255, 255, 255, 0.5);
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 1.8rem;
  letter-spacing: 1px;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.asset:hover .adult-badge {
  opacity: 0;
}

body.no-blur .adult-badge {
  display: none;
}

/* SKELETON & VISIBILITY */
.skeleton-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #111114 25%, #1a1a1f 50%, #111114 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  z-index: 1;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.image-thumbnail,
.image-backglow,
.content {
  opacity: 0;
}

.asset.is-visible .image-thumbnail,
.asset.is-visible .image-backglow,
.asset.is-visible .content {
  opacity: 1;
  transition: opacity 0.6s ease-in-out, filter 0.4s ease;
}

.asset.is-visible .skeleton-shimmer {
  display: none;
}

/* IMAGES */
.image-container {
  position: relative;
  width: 100%;
  padding-top: 100%;
  background: #000;
  flex-shrink: 0;
  z-index: 5;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
}

.image-thumbnail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 10;
}

.image-backglow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  pointer-events: none;
  transform: scale(1.6);
  will-change: transform;
}

.asset.is-visible .image-backglow {
  filter: blur(45px) saturate(5) contrast(1.5);
  opacity: 0.7;
}

.adult-content {
  filter: blur(50px);
}

.asset:hover .adult-content {
  filter: blur(0px);
}

body.no-blur .adult-content {
  filter: blur(0px) !important;
}

/* CARD CONTENT */
.content {
  padding: 15px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  z-index: 10;
  position: relative;
  background: rgba(18, 18, 22, 0.8) !important;
}

.asset.is-visible .content {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.name {
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 4px;
  font-size: 0.9rem;
  height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.author-label {
  font-size: 0.7rem;
  color: #777;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author-label b {
  color: var(--primary);
  font-weight: 600;
}

.stats {
  color: #aaa;
  font-size: 0.75rem;
  display: flex;
  gap: 10px;
  margin-top: auto;
  font-weight: 600;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
  height: 18px;
  overflow: hidden;
}

.tag-pill {
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.4);
  height: 18px;
  line-height: 18px;
  padding: 0 8px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.tag-pill.clickable {
  cursor: pointer;
}

.tag-pill.clickable:hover {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  transition: 0.3s;
  padding: 20px;
  box-sizing: border-box;
}

.modal.visible {
  display: flex;
}

.modal.active {
  background: rgba(0, 0, 0, 0.95);
}

.modal-card {
  background: #1a1a1f;
  width: 100%;
  max-width: 1000px;
  height: 500px;
  border: 1px solid var(--primary);
  border-radius: 16px;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9);
  transition: 0.3s;
  position: relative;
}

.modal.active .modal-card {
  opacity: 1;
  transform: scale(1);
}

.modal-carousel {
  flex: 0 0 500px;
  height: 500px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* CAROUSEL TRACKS */
.carousel-track, .carousel-blur-track {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  will-change: transform;
}

.carousel-track {
  z-index: 2;
}

.carousel-blur-track {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  filter: blur(40px) brightness(0.5);
  opacity: 0.8;
}

.carousel-slide, .carousel-blur-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.carousel-blur-slide img {
  width: 120%;
  height: 120%;
  object-fit: cover;
  transform: scale(1.1);
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 15px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1.2rem;
  transition: 0.2s;
}

.carousel-btn:hover {
  background: var(--primary);
  color: #000;
}

.btn-prev {
  left: 15px;
}

.btn-next {
  right: 15px;
}

.carousel-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 1);
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.modal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #16161a;
  overflow: hidden;
  height: 500px;
}

.modal-header-fixed {
  padding: 20px 20px 0;
  background: #16161a;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.modal-name {
  font-size: 1.15rem;
  line-height: 1.2;
  margin-bottom: 4px;
  color: var(--primary);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-subtitle {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 15px;
}

.modal-author-link {
  color: #888;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-author-link:hover {
  color: var(--primary);
}

.modal-author-link b {
  color: inherit;
}

/* TAB SYSTEM */
.modal-tabs {
  display: flex;
  gap: 15px;
  border-bottom: 1px solid #333;
  padding: 0 20px;
  background: #16161a;
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 0;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab-btn:hover {
  color: #aaa;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

/* TAB CONTENT AREAS */
.tab-content-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px 20px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Metadata */
.modal-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-pill {
  background: #222;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: #ccc;
  border: 1px solid #333;
}

.modal-section-title {
  font-size: 0.6rem;
  font-weight: 800;
  color: #555;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
}

/* File List */
.file-list {
  background: #0b0b0d;
  border-radius: 8px;
  border: 1px solid #222;
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-item {
  padding: 8px 12px;
  border-bottom: 1px solid #1a1a1f;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.file-link {
  color: #fff;
  text-decoration: none;
  word-break: break-all;
  flex: 1;
}

.file-link:hover {
  color: var(--primary);
}

/* Relationships */
.asset-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}

.asset-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1f1f23;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: 0.2s;
}

.asset-link-item:hover {
  background: #2a2a2f;
  border-color: var(--primary);
}

.asset-link-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
}

.asset-link-name {
  font-size: 0.65rem;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Description Area */
.desc-content {
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.5;
  white-space: pre-wrap;
}

.desc-content a {
  color: var(--primary);
}

.delisted-warning {
  background: rgba(255, 68, 68, 0.15);
  border: 1px solid #ff4444;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  color: #ff8888;
  font-size: 0.75rem;
  line-height: 1.3;
  display: none;
}

/* FOOTER */
.modal-footer {
  margin-top: auto;
  padding: 24px 20px;
  background: #16161a;
  border-top: 1px solid #222;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-id-display {
  color: #444;
  font-size: 0.7rem;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  gap: 20px;
}

.discrete-link {
  color: #666;
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}

.discrete-link:hover {
  color: var(--primary);
}

#filterNotice {
  display: none;
  background: #1a1a1f;
  border: 2px dashed var(--primary);
  border-radius: 12px;
  padding: 20px;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--primary);
  font-weight: 800;
  font-size: 0.9rem;
  width: 100%;
}

@media (max-width: 800px) {
  .modal-card {
    flex-direction: column;
    height: 95vh;
    max-width: 500px;
  }
  .modal-carousel {
    flex: 0 0 400px;
    width: 100%;
    height: 400px;
  }
  .modal-info {
    height: auto;
    flex: 1;
  }
}