.header-nav-bar {
  padding-top: 12px;
}

.header-nav {
  margin-top: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.header-nav-toggle {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  line-height: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-nav-toggle-line {
  width: 20px;
  height: 2.5px;
  border-radius: 2px;
  background-color: #f4f4f4;
  display: block;
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid #303030;
  color: #d9d9d9;
  font-size: 14px;
  text-decoration: none;
  background: #1c1d1e;
  line-height: 1;
}

.header-nav-label {
  white-space: nowrap;
}

.header-nav-icon {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.92;
}

.header-nav-icon-viewer {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s4-6 10-6 10 6 10 6-4 6-10 6-10-6-10-6z'/%3E%3Ccircle cx='12' cy='12' r='2.5'/%3E%3C/svg%3E");
}

.header-nav-icon-photo {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='3'/%3E%3Ccircle cx='9' cy='10' r='1.7'/%3E%3Cpath d='M4.5 17l5-5 3 3 3-2.5L19.5 17'/%3E%3C/svg%3E");
}

.header-nav-icon-video {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='3'/%3E%3Cpath d='M10 9l6 3-6 3V9z' fill='white' stroke='none'/%3E%3C/svg%3E");
}

.header-nav-icon-reel {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M3 10h18M8 5l-2 5M13 5l-2 5M18 5l-2 5'/%3E%3C/svg%3E");
}

.header-nav-icon-story {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-3-6.7'/%3E%3Cpath d='M21 3v6h-6'/%3E%3C/svg%3E");
}

.header-nav-link:hover,
.header-nav-link.active {
  background: #E1306C;
  color: #fff;
  border-color: #E1306C;
  text-decoration: none;
}

.stories-profile-link {
  max-width: 1030px;
  margin: 12px auto 0;
  display: flex;
  justify-content: center;
}

.stories-profile-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #fff;
}

.stories-profile-link-name {
  font-size: clamp(24px, 3.4vw, 44px);
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.stories-profile-link-out {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  flex: none;
}

.stories-profile-link-out:hover {
  color: #fff;
  opacity: 0.88;
  text-decoration: none;
}

.stories-profile-link-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex: none;
}

.stories-profile-link-icon svg {
  width: 100%;
  height: 100%;
}

.source-row {
  margin: 14px auto 0;
  max-width: 1030px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.source-row label {
  color: #d9d9d9;
  font-size: 14px;
}

.source-select {
  min-width: 260px;
  border: 1px solid #303030;
  background: #1c1d1e;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.source-select:focus {
  border-color: #E1306C;
}

.progress-bar-container {
  width: 100%;
  max-width: 520px;
  height: 8px;
  background-color: rgba(217, 217, 217, 0.2);
  border-radius: 4px;
  margin: 0 auto 15px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #E1306C, #C13584);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 14px;
  color: #d9d9d9;
  margin-top: 10px;
}

#media-results {
  max-width: 1170px;
  padding: 0 35px;
  margin: 10px auto 0;
}

.media-results-wrapper {
  display: flex;
  flex-direction: column;
  gap: 30px;
  max-width: 1170px;
  margin: 0 auto;
  padding: 0;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  width: 100%;
  align-items: start;
}

.media-item {
  background: #151617;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  border: 1px solid #242526;
  width: 100%;
  min-width: 0;
}

.media-preview-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 12px;
  --preview-ratio: 1 / 1;
}

.media-preview-wrap.ratio-1x1 {
  --preview-ratio: 1 / 1;
}

.media-preview-wrap.ratio-4x5 {
  --preview-ratio: 4 / 5;
}

.media-preview-wrap.ratio-9x16 {
  --preview-ratio: 9 / 16;
}

.media-preview-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  background: linear-gradient(105deg, #1a1b1d 22%, #2a2c2f 42%, #1a1b1d 62%);
  background-size: 220% 100%;
}

.media-preview-wrap.is-loading::before {
  opacity: 1;
  animation: media-skeleton-shimmer 1.1s linear infinite;
}

.media-preview-wrap.is-loading {
  aspect-ratio: var(--preview-ratio);
  min-height: clamp(220px, 24vw, 420px);
  border-radius: 8px;
  overflow: hidden;
  background: #101112;
}

.media-preview-wrap.ratio-1x1.is-loading {
  min-height: clamp(200px, 20vw, 340px);
}

.media-preview-wrap.ratio-4x5.is-loading {
  min-height: clamp(220px, 24vw, 400px);
}

.media-preview-wrap.ratio-9x16.is-loading {
  min-height: clamp(280px, 36vw, 520px);
}

.media-preview-wrap.is-loading .media-preview {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  opacity: 0;
}

.media-preview {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  object-fit: initial;
  border-radius: 8px;
  margin-bottom: 0;
  background: #0e0f10;
  z-index: 2;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.media-preview-fallback {
  background: linear-gradient(180deg, #121314 0%, #191b1d 100%);
  min-height: 180px;
}

.media-preview-wrap.ratio-4x5 .media-preview-fallback {
  min-height: clamp(220px, 24vw, 400px);
}

.media-preview-wrap.ratio-9x16 .media-preview-fallback {
  min-height: clamp(280px, 36vw, 520px);
}

@keyframes media-skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -20% 0;
  }
}

.media-date {
  font-size: 12px;
  color: #a5a5a5;
  margin-bottom: 10px;
}

.media-expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 999px;
  background: rgba(16, 16, 16, 0.58);
  cursor: pointer;
  z-index: 3;
}

.media-expand-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22' fill='none'%3E%3Cpath d='M2.75 8.25V4.583a1.833 1.833 0 0 1 1.833-1.833H8.25M13.75 2.75h3.667a1.833 1.833 0 0 1 1.833 1.833V8.25M19.25 13.75v3.667a1.833 1.833 0 0 1-1.833 1.833H13.75M8.25 19.25H4.583a1.833 1.833 0 0 1-1.833-1.833V13.75' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

.media-expand-btn:hover {
  background: rgba(16, 16, 16, 0.72);
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #E1306C;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.download-btn:hover {
  background: rgb(1 143 235);
  text-decoration: none;
}

.media-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1200;
  padding: 24px;
}

.media-lightbox.open {
  display: flex;
}

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

.media-lightbox-frame {
  max-width: min(94vw, 1600px);
  max-height: 90vh;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-lightbox-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  background: #0e0f10;
}

.media-lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(16, 16, 16, 0.68);
  color: #fff;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

body.media-lightbox-open {
  overflow: hidden;
}

.result-summary {
  color: #d9d9d9;
  margin: 0 0 12px;
  font-size: 14px;
}

.content .music-info.right.error-message {
  margin-top: 0;
}

@media (max-width: 1199px) {
  .media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-row {
    justify-content: flex-start;
  }

  .source-select {
    min-width: 220px;
  }
}

@media (max-width: 640px) {
  .header-nav-bar {
    padding-top: 8px;
  }

  .header-nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid #303030;
    background: #1c1d1e;
    margin: 0;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  }

  .header-controls {
    gap: 16px;
  }

  .header-nav {
    display: none;
    margin-top: 10px;
    flex-direction: column;
    gap: 8px;
  }

  .header-nav-bar.is-open .header-nav {
    display: flex;
  }

  .header-nav-link {
    width: 100%;
    justify-content: flex-start;
    min-height: 44px;
  }

  .stories-profile-row {
    gap: 12px;
  }

  .stories-profile-link-name {
    font-size: clamp(22px, 7.2vw, 32px);
  }

  .stories-profile-link-icon {
    width: 34px;
    height: 34px;
  }

  #media-results {
    padding: 0 20px;
  }

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

  .source-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .source-select {
    width: 100%;
  }

  .content .input-form form input {
    padding-right: 124px;
  }

  .media-expand-btn {
    width: 50px;
    height: 50px;
  }

  .download-btn {
    min-height: 52px;
    padding: 14px 16px;
    font-size: 16px;
  }
}
