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

:root {
  --bg: #fafafa;
  --text: #111;
  --muted: #666;
  --border: #e5e5e5;
  --surface: #fff;
  --input-bg: #fff;
  --badge-bg: rgba(0, 0, 0, 0.8);
  --badge-text: #fff;
  --thumb-placeholder: #eee;
  --shadow: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --border: #333;
  --surface: #171717;
  --input-bg: #171717;
  --badge-bg: rgba(255, 255, 255, 0.2);
  --badge-text: #fff;
  --thumb-placeholder: #262626;
  --shadow: rgba(255, 255, 255, 0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  text-align: center;
  margin-bottom: 3rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-top .language-switcher {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.lang-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lang-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.15), 0 4px 6px -2px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

.lang-btn:hover::before {
  opacity: 1;
}

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

.lang-btn .globe-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  left: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 1rem;
  padding: 0.5rem;
  min-width: 150px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.05);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-dropdown:not(.hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.875rem;
  background: transparent;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: all 0.2s ease;
  position: relative;
}

.lang-option:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.05));
  transform: translateX(4px);
}

.lang-option.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.2);
}

.lang-option .flag {
  font-size: 1.1rem;
  line-height: 1;
  filter: saturate(1.2);
}

.lang-option .lang-code {
  flex: 1;
}

[data-theme="dark"] .lang-btn {
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}

[data-theme="dark"] .lang-btn:hover {
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}

[data-theme="dark"] .lang-dropdown {
  background: linear-gradient(135deg, rgba(30,30,30,0.95), rgba(20,20,20,0.9));
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5), 0 10px 10px -5px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);
}

[data-theme="dark"] .lang-option:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.1));
}

[data-theme="dark"] .lang-option.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(139,92,246,0.15));
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.3);
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
}

header p {
  color: var(--muted);
  margin-top: 0.5rem;
}
  color: var(--muted);
  margin-top: 0.5rem;
}

.input-section {
  margin-bottom: 2rem;
}

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

.input-group input {
  flex: 1;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 1rem;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.input-group input:focus {
  border-color: var(--text);
}

#btnGo {
  padding: 0.85rem 1.5rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.25s ease, color 0.25s ease;
}

#btnGo:hover {
  opacity: 0.85;
}

.hidden {
  display: none !important;
}

.logo-link {
  text-decoration: none;
  color: inherit;
}

.error-msg {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

#loading {
  text-align: center;
  padding: 3rem 0;
}

#loading p {
  color: var(--muted);
  margin-top: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}

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

.card {
  display: flex;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.thumbnail-wrap {
  position: relative;
  width: 200px;
  min-width: 140px;
}

.thumbnail-wrap img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 0.5rem;
  background: var(--thumb-placeholder);
}

.badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.7rem;
  font-family: ui-monospace, monospace;
  padding: 2px 6px;
  border-radius: 4px;
}

.meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

#videoTitle {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#videoAuthor {
  color: var(--muted);
  margin-top: 0.35rem;
  font-size: 0.95rem;
}

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

.actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.download-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.download-timer.hidden {
  display: none !important;
}

#timerCountdown {
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.dl-btn {
  flex: 1;
  padding: 0.85rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.25s ease, color 0.25s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.size-estimate {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.8;
}

.download-progress {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar div {
  height: 100%;
  background: var(--text);
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s ease;
}

.dl-btn:hover {
  opacity: 0.85;
}

.reset-btn {
  display: block;
  margin: 0 auto;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.reset-btn:hover {
  color: var(--text);
}

.cookies-section {
  margin-bottom: 2rem;
}

.cookies-section label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.cookies-section .optional {
  font-weight: 400;
  color: var(--muted);
}

.cookie-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 0.95rem;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background-color 0.25s ease, color 0.25s ease;
}

.cookie-input:focus {
  border-color: var(--text);
}

.cookies-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

footer {
  margin-top: auto;
  text-align: center;
  padding-top: 2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

footer a {
  text-decoration: none;
  color: inherit;
}

.faq {
  margin-top: 3rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.faq h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  margin-bottom: 1rem;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
}

.faq-item:hover {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 10px 15px -3px rgba(99,102,241,0.1), 0 4px 6px -4px rgba(99,102,241,0.1), 0 0 0 1px rgba(99,102,241,0.05);
  transform: translateY(-2px);
}

.faq-item[open] {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 20px 25px -5px rgba(99,102,241,0.15), 0 8px 10px -6px rgba(99,102,241,0.1), 0 0 0 1px rgba(99,102,241,0.1);
}

.faq-item summary {
  padding: 1.25rem 1.5rem;
  padding-right: 4.5rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  position: relative;
  transition: all 0.2s ease;
}

.faq-item summary > span {
  flex: 1;
  padding-right: 1rem;
  line-height: 1.4;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item summary::before {
  content: '+';
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 400;
  color: rgba(99,102,241,0.8);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.faq-item[open] summary::before {
  content: '−';
  color: rgba(99,102,241,1);
  transform: translateY(-50%) rotate(180deg);
}

.faq-item summary::before {
  content: '+';
  position: absolute;
  right: 1.5rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 400;
  color: rgba(99,102,241,0.8);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.faq-item[open] summary::before {
  content: '−';
  color: rgba(99,102,241,1);
  transform: rotate(180deg);
}

.faq-item[open] summary::after {
  background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(139,92,246,0.2));
  transform: rotate(90deg);
}

.faq-item p {
  padding: 0 1.5rem 1.25rem 1.5rem;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

[data-theme="dark"] .faq-item {
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.3), 0 1px 2px -1px rgba(0,0,0,0.3);
}

[data-theme="dark"] .faq-item:hover {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 10px 15px -3px rgba(99,102,241,0.2), 0 4px 6px -4px rgba(99,102,241,0.15), 0 0 0 1px rgba(99,102,241,0.1);
}

[data-theme="dark"] .faq-item[open] {
  border-color: rgba(99,102,241,0.6);
  box-shadow: 0 20px 25px -5px rgba(99,102,241,0.25), 0 8px 10px -6px rgba(99,102,241,0.2), 0 0 0 1px rgba(99,102,241,0.15);
}

@media (max-width: 560px) {
  .card {
    flex-direction: column;
  }
  .thumbnail-wrap {
    width: 100%;
  }
  .actions {
    flex-direction: column;
  }
  .dl-btn {
    width: 100%;
  }
}

.download-timer {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.download-timer.hidden {
  display: none;
}

#timerCountdown {
  display: inline-block;
  min-width: 1.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.theme-toggle {
  padding: 0.5rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) rotate(15deg);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.15), 0 4px 6px -2px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

.theme-toggle:hover::before {
  opacity: 1;
}

.theme-toggle:active {
  transform: translateY(0) rotate(15deg);
}

[data-theme="dark"] .theme-toggle {
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}

[data-theme="dark"] .theme-toggle:hover {
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}

.toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 9999px;
  background: var(--muted);
  position: relative;
  transition: background-color 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg);
  transition: transform 0.2s ease;
  display: block;
}

[data-theme="dark"] .toggle-track {
  background: var(--surface);
}

[data-theme="dark"] .toggle-thumb {
  transform: translateX(20px);
  background: var(--text);
  color: var(--bg);
}

.cookie-consent {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 90vw;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 100;
}

.cookie-consent p {
  font-size: 0.875rem;
  color: var(--text);
  margin: 0;
}

.cookie-btn {
  padding: 0.5rem 1rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.seo-content {
  max-width: 720px;
  margin: 3rem auto;
  padding: 0 1rem;
  line-height: 1.75;
  color: var(--text);
}

.seo-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  line-height: 1.35;
}

.seo-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 1.75rem 0 0.6rem;
  line-height: 1.4;
}

.seo-content p {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--text);
}

.seo-content ul {
  margin: 0.75rem 0 1.25rem 1.25rem;
  padding: 0;
  list-style: disc;
}

.seo-content li {
  margin-bottom: 0.5rem;
  font-size: 1rem;
  line-height: 1.65;
}

.seo-content strong {
  font-weight: 700;
}

@media (max-width: 560px) {
  .seo-content {
    padding: 0 1rem;
  }
  .seo-content h2 {
    font-size: 1.3rem;
  }
  .seo-content h3 {
    font-size: 1.1rem;
  }
}
