*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-bright: #4ade4a;
  --green-mid: #2d8a2d;
  --green-dark: #0d2818;
  --green-card: #142e1f;
  --green-border: #1e4d2e;
  --orange: #f97316;
  --red: #ef4444;
  --text: #e8f5e9;
  --text-muted: #8fbc8f;
  --shadow: rgba(0, 0, 0, 0.4);
}

html {
  font-size: 16px;
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% 20%, #1a4d2e 0%, var(--green-dark) 60%, #061a0e 100%);
  min-height: 100vh;
  color: var(--text);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(74, 222, 74, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

.logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 32px var(--shadow);
  border: 3px solid var(--green-mid);
}

.header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green-bright), #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.25rem;
}

.container {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--green-card);
  border: 1px solid var(--green-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px var(--shadow);
}

.input-card {
  margin-bottom: 1.5rem;
}

.label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

input[type="url"] {
  flex: 1;
  background: var(--green-dark);
  border: 2px solid var(--green-border);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="url"]::placeholder {
  color: #4a7a5a;
}

input[type="url"]:focus {
  border-color: var(--green-bright);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 12px;
  padding: 0.875rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-bright), var(--green-mid));
  color: var(--green-dark);
  box-shadow: 0 4px 16px rgba(74, 222, 74, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(74, 222, 74, 0.45);
}

.btn-download {
  width: 100%;
  margin-top: 1.25rem;
  background: linear-gradient(135deg, var(--orange), var(--red));
  color: white;
  padding: 1rem;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
}

.btn-download:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(249, 115, 22, 0.5);
}

.btn-loader {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.hidden {
  display: none !important;
}

.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.platform-badge {
  background: var(--green-dark);
  border: 1px solid var(--green-border);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cookies-block {
  margin-top: 1rem;
  text-align: left;
}

.cookies-block summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.cookies-block summary:hover {
  color: var(--green-bright);
}

.cookies-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--green-bright);
  font-weight: 600;
  text-align: left;
}

.cookies-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.6rem 0;
  line-height: 1.5;
}

#cookies-input {
  width: 100%;
  background: var(--green-dark);
  border: 1.5px solid var(--green-border);
  border-radius: 10px;
  padding: 0.75rem;
  color: var(--text);
  font-family: monospace;
  font-size: 0.75rem;
  resize: vertical;
  outline: none;
}

#cookies-input:focus {
  border-color: var(--green-bright);
}

.error-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: #fca5a5;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.error-box.status-info {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.35);
  color: #86efac;
}

.local-banner {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  color: #fde68a;
  font-size: 0.92rem;
  line-height: 1.5;
}

.local-banner a {
  color: var(--green-bright);
  font-weight: 700;
}

.local-banner.local-active {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.35);
  color: #86efac;
}

.ext-hint-strong {
  margin-top: 0.75rem;
  color: var(--green-bright);
}

.video-card {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}

.video-preview {
  flex-shrink: 0;
}

.thumbnail {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--green-border);
  display: block;
  background: var(--green-dark);
}

.thumbnail-placeholder {
  width: 160px;
  height: 90px;
  background: var(--green-dark);
  border-radius: 10px;
  border: 2px solid var(--green-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.video-info h2 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.dot {
  opacity: 0.5;
}

.formats-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.formats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.formats-count {
  font-size: 0.85rem;
  color: var(--green-bright);
  font-weight: 600;
}

.formats-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 480px;
  overflow-y: auto;
}

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

.formats-list::-webkit-scrollbar-thumb {
  background: var(--green-border);
  border-radius: 3px;
}

.format-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--green-dark);
  border: 2px solid var(--green-border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.format-item:hover {
  border-color: var(--green-mid);
}

.format-item.selected {
  border-color: var(--green-bright);
  background: rgba(74, 222, 74, 0.08);
}

.format-item input[type="radio"] {
  accent-color: var(--green-bright);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.format-label {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.format-size {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.format-badge {
  display: inline-block;
  margin-left: 0.5rem;
  background: rgba(74, 222, 74, 0.2);
  color: var(--green-bright);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  vertical-align: middle;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}

.footer a {
  color: var(--green-bright);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.legal-notice {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.legal-page {
  max-width: 760px;
  margin: 0 auto 2rem;
}

.legal-card {
  padding: 1.75rem;
  line-height: 1.65;
}

.legal-card h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--green-bright);
}

.legal-card h2:first-of-type {
  margin-top: 0;
}

.legal-card p,
.legal-card li {
  margin-bottom: 0.65rem;
  color: var(--text);
}

.legal-card ul {
  padding-left: 1.25rem;
}

.legal-card a {
  color: var(--green-bright);
}

.legal-updated,
.legal-note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legal-contact {
  font-weight: 700;
}

.legal-back {
  margin-top: 1.5rem;
}

.ext-install-btn {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--green-card);
  border: 1.5px solid var(--green-border);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  color: var(--green-bright);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.ext-install-btn:hover {
  border-color: var(--green-bright);
  box-shadow: 0 6px 28px rgba(74, 222, 74, 0.2);
  transform: translateY(-1px);
}

.ext-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.ext-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.ext-modal-content {
  position: relative;
  background: var(--green-card);
  border: 1px solid var(--green-border);
  border-radius: 20px;
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px var(--shadow);
  text-align: center;
}

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

.ext-modal-content::-webkit-scrollbar-thumb {
  background: var(--green-border);
  border-radius: 3px;
}

.ext-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.ext-modal-close:hover {
  color: var(--text);
}

.ext-modal-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--green-mid);
  margin-bottom: 1rem;
}

.ext-modal-content h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--green-bright);
  margin-bottom: 0.5rem;
}

.ext-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: left;
}

.ext-hint code {
  background: var(--green-dark);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--green-bright);
}

.ext-download-btn {
  text-decoration: none;
  display: flex;
  width: 100%;
  padding: 0.875rem;
  margin-bottom: 1rem;
  justify-content: center;
}

@media (max-width: 600px) {
  .logo-wrap {
    flex-direction: column;
    gap: 0.75rem;
  }

  .header h1 {
    font-size: 1.6rem;
  }

  .input-row {
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
  }

  .video-card {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .video-preview {
    width: 100%;
  }

  .thumbnail,
  .thumbnail-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    min-height: 180px;
    max-height: 220px;
  }

  .meta {
    justify-content: flex-start;
  }

  .formats-list {
    max-height: none;
  }

  .format-item {
    flex-wrap: wrap;
  }

  .format-size {
    width: 100%;
    padding-left: 2rem;
  }

  .ext-install-btn {
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  .ext-install-btn svg {
    display: none;
  }
}
