.ig-downloader {
  max-width: 780px;
  margin: 0 auto;
}

.download-form {
  margin-bottom: 2rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

#igUrl {
  width: 100%;
  padding: 1rem 5.5rem 1rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

#igUrl:focus {
  outline: none;
  border-color: #E1306C;
}

.paste-btn,
.clear-btn {
  position: absolute;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.paste-btn {
  color: #C13584;
  background: rgba(225, 48, 108, 0.08);
  border: 1px solid rgba(225, 48, 108, 0.24);
}

.paste-btn:hover {
  background: rgba(225, 48, 108, 0.14);
  border-color: rgba(225, 48, 108, 0.42);
  color: #a1206a;
}

.clear-btn {
  color: #555555;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.clear-btn:hover {
  background: #e5e7eb;
  color: #111827;
}

[dir="rtl"] #igUrl {
  padding: 1rem 1rem 1rem 5.5rem;
}

[dir="rtl"] .paste-btn,
[dir="rtl"] .clear-btn {
  right: auto;
  left: 0.55rem;
}

.btn-primary {
  min-width: 132px;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #E1306C 0%, #C13584 50%, #833AB4 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(225, 48, 108, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.85;
  cursor: not-allowed;
  transform: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.hint {
  color: #666;
  font-size: 0.875rem;
  margin: 0;
}

.result-area {
  margin-top: 2rem;
  text-align: left;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-card {
  background: #ffffff;
  border: 1px solid rgba(225, 48, 108, 0.14);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 8px 28px rgba(17, 24, 39, 0.06);
}

.preview-card.result-highlight {
  animation: resultPulse 1s ease-out;
}

@keyframes resultPulse {
  0% {
    border-color: #E1306C;
    box-shadow: 0 0 0 4px rgba(225, 48, 108, 0.22), 0 8px 28px rgba(17, 24, 39, 0.08);
  }
  100% {
    border-color: rgba(225, 48, 108, 0.14);
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.06);
  }
}

.preview-main {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.media-preview-box {
  position: relative;
  background: #111111;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  display: flex;
  align-items: center;
  justify-content: center;
}

#thumbnail,
#videoPreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.download-options {
  min-width: 0;
}

.options-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.options-header svg {
  width: 20px;
  height: 20px;
  color: #E1306C;
  flex-shrink: 0;
}

.media-type-title {
  display: inline;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #262626;
  margin: 0;
}

#downloadLinks {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.download-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.35rem 0.35rem 1.1rem;
  border: 1.5px solid rgba(193, 53, 132, 0.35);
  border-radius: 999px;
  background: #ffffff;
}

.option-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #262626;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.35rem;
  background: linear-gradient(135deg, #E1306C 0%, #833AB4 100%);
  color: #ffffff;
  text-decoration: none;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}

.download-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.download-btn svg {
  width: 16px;
  height: 16px;
}

.media-meta-section {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid #f0f0f0;
}

.caption-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.caption-text {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #374151;
  margin: 0;
  word-break: break-word;
}

.caption-tag {
  color: #C13584;
  font-weight: 500;
}

.copy-caption-btn {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #A3245F;
  background: #fdf0f4;
  border: 1px solid #f3d6e1;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-caption-btn:hover {
  background: #f9dce7;
}

.meta-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  font-size: 0.8125rem;
  color: #6b7280;
}

.meta-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.meta-link {
  color: #A3245F;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(163, 36, 95, 0.3);
  transition: color 0.2s, border-color 0.2s;
}

.meta-link:hover {
  color: #E1306C;
  border-bottom-color: #E1306C;
}

.error-msg {
  margin-top: 1rem;
  padding: 1rem;
  background: #fee;
  border-left: 4px solid #c00;
  border-radius: 4px;
  color: #c00;
}

.loading {
  margin-top: 1.5rem;
  text-align: center;
  padding: 0.75rem 0 0.25rem;
}

.progress-track {
  max-width: 440px;
  height: 10px;
  margin: 0 auto 0.65rem;
  background: rgba(225, 48, 108, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #E1306C 0%, #833AB4 100%);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.loading p {
  font-size: 0.9rem;
  color: #555555;
  margin: 0;
}

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

@media (max-width: 680px) {
  .input-group {
    flex-direction: column;
  }

  .paste-btn,
  .clear-btn {
    min-height: 36px;
    padding: 0.45rem 0.85rem;
    font-size: 0.875rem;
  }

  .btn-primary {
    width: 100%;
  }

  .preview-main {
    grid-template-columns: 1fr;
  }

  .media-preview-box {
    max-width: 300px;
    margin: 0 auto;
    width: 100%;
  }

  .caption-box {
    flex-direction: column;
    gap: 0.6rem;
  }
}