:root {
  --bg: #f5f0e8;
  --surface: #ffffff;
  --surface2: #fdf8f0;
  --ink: #1a1208;
  --ink2: #5a4e3a;
  --accent: #ff6b1a;
  --accent2: #ffd93d;
  --accent3: #4ecdc4;
  --bili: #fb7299;
  --yt: #ff0000;
  --shadow: 0 4px 24px rgba(26,18,8,0.12);
  --shadow-lg: 0 12px 48px rgba(26,18,8,0.18);
  --radius: 16px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 10% 20%, rgba(255,107,26,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(78,205,196,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(255,217,61,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 60px 20px 40px; }

header {
  padding: 36px 0 28px;
  text-align: center;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
}

.logo-icon {
  width: 52px; height: 52px;
  background: var(--ink);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.logo-icon svg { width: 28px; height: 28px; }

.logo-pip {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  top: -5px; right: -5px;
}
.logo-pip.bili { background: var(--bili); }
.logo-pip.yt   { background: var(--yt); }
.logo-pip.yt   { right: auto; left: -5px; top: auto; bottom: -5px; }

.site-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.site-title span {
  background: linear-gradient(120deg, var(--accent) 0%, #ffb347 50%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-sub {
  font-size: 0.95rem;
  color: var(--ink2);
  font-weight: 300;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 32px 28px;
  margin-bottom: 24px;
  border: 1.5px solid rgba(26,18,8,0.06);
}

.platform-row {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

.header-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.lang-btn {
  padding: 6px 12px;
  border: 1px solid rgba(26,18,8,0.1);
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ink3);
  transition: all 0.2s;
}

.lang-btn:hover {
  background: var(--surface2);
  color: var(--ink1);
}

.platform-btn {
  flex: 1;
  padding: 13px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: var(--surface2);
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--ink2);
  letter-spacing: 0.2px;
  position: relative;
  overflow: hidden;
}

.platform-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.platform-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.platform-btn.active-bili {
  background: #fff0f5;
  border-color: var(--bili);
  color: var(--bili);
  box-shadow: 0 4px 18px rgba(251,114,153,0.2);
}

.platform-btn.active-yt {
  background: #fff3f3;
  border-color: var(--yt);
  color: var(--yt);
  box-shadow: 0 4px 18px rgba(255,0,0,0.15);
}

.platform-icon { width: 22px; height: 22px; flex-shrink: 0; }
.platform-icon-yt { width: 38px; height: 20px; flex-shrink: 0; }

.input-row {
  display: flex;
  gap: 10px;
}

.url-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid rgba(26,18,8,0.1);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  background: var(--surface2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,107,26,0.1);
}

.url-input::placeholder { color: #b8a890; }

.extract-btn {
  padding: 14px 24px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
}

.extract-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 8px 24px rgba(26,18,8,0.25); }
.extract-btn:active { transform: scale(0.98); }

.extract-btn.loading {
  pointer-events: none;
  opacity: 0.75;
}

.extract-btn .btn-text { transition: opacity 0.15s; }
.extract-btn .spinner {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}

.extract-btn.loading .btn-text { opacity: 0; }
.extract-btn.loading .spinner { opacity: 1; }

.spinner-ring {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  margin-top: 12px;
  padding: 11px 16px;
  background: #fff3f0;
  border: 1.5px solid #ffc4b0;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: #c0442a;
  display: none;
}

.error-msg.show { display: block; animation: fadeSlide 0.2s ease; }

.result-section {
  display: none;
  animation: fadeSlide 0.35s ease;
}

.result-section.show { display: block; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.main-cover-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a1208;
  aspect-ratio: 16/9;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

.main-cover-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease, opacity 0.3s;
}

.main-cover-wrap:hover img { transform: scale(1.02); }

.cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(26,18,8,0.55) 0%, transparent 50%);
  pointer-events: none;
}

.cover-badge {
  position: absolute;
  top: 14px; left: 14px;
  padding: 5px 12px;
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: #fff;
}

.cover-badge.bili { background: var(--bili); }
.cover-badge.yt   { background: var(--yt); }

.cover-zoom-hint {
  position: absolute;
  bottom: 14px; right: 14px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border-radius: 50px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.9);
  display: flex; align-items: center; gap: 5px;
  pointer-events: none;
}

.thumb-section {
  margin-top: 18px;
}

.thumb-label {
  font-family: 'Syne', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink2);
  margin-bottom: 10px;
}

.thumb-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.thumb-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: #1a1208;
  flex-shrink: 0;
}

.thumb-item img {
  width: 120px; height: 68px;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.thumb-item:hover { transform: translateY(-3px) scale(1.04); box-shadow: var(--shadow); }

.thumb-item.active {
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(255,107,26,0.3);
}

.thumb-quality {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(26,18,8,0.75);
  color: #fff;
  font-size: 0.62rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.thumb-item .thumb-error-badge {
  position: absolute;
  inset: 0;
  background: rgba(26,18,8,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.6);
  font-size: 0.7rem;
}

.thumb-item.has-error .thumb-error-badge { display: flex; }

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.action-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.3px;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.action-btn:active { transform: scale(0.97); }

.btn-dl-png { background: var(--ink); color: #fff; }
.btn-dl-jpg { background: var(--surface2); color: var(--ink); border-color: rgba(26,18,8,0.12); }
.btn-copy   { background: var(--surface2); color: var(--ink); border-color: rgba(26,18,8,0.12); }

.btn-copy.copied { background: #e8faf2; border-color: #4ecdc4; color: #1a7a6e; }

.action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.url-display {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1.5px solid rgba(26,18,8,0.08);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.url-display-text {
  flex: 1;
  font-size: 0.82rem;
  color: var(--ink2);
  font-family: 'DM Sans', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(26,18,8,0.9);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
  backdrop-filter: blur(6px);
}

.lightbox.show { display: flex; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

.lightbox-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.25); }

footer {
  text-align: center;
  padding: 36px 0 44px;
  color: var(--ink2);
  font-size: 0.88rem;
}

.footer-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 50px;
  padding: 10px 22px;
  box-shadow: var(--shadow);
  border: 1.5px solid rgba(26,18,8,0.06);
  font-weight: 500;
}

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }

.copyright {
  margin-top: 16px;
  font-size: 0.78rem;
  opacity: 0.7;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.history-section {
  margin-top: 20px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.history-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink2);
}

.clear-history-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink2);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-history-btn:hover {
  background: rgba(26,18,8,0.05);
  color: var(--accent);
}

.clear-history-btn svg {
  width: 14px;
  height: 14px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.history-item:hover {
  background: rgba(255,107,26,0.08);
  transform: translateX(4px);
}

.history-item .platform-badge {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-item .platform-badge.yt {
  background: rgba(255,0,0,0.15);
  color: #ff0000;
}

.history-item .platform-badge.bili {
  background: rgba(251,114,153,0.15);
  color: #fb7299;
}

.history-item .platform-badge svg {
  width: 14px;
  height: 14px;
}

.history-item .history-info {
  flex: 1;
  min-width: 0;
}

.history-item .history-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .history-url {
  font-size: 0.75rem;
  color: var(--ink2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.history-item .history-time {
  font-size: 0.7rem;
  color: var(--ink2);
  opacity: 0.7;
  flex-shrink: 0;
}

.history-item .remove-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink2);
  opacity: 0;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-item:hover .remove-btn {
  opacity: 0.5;
}

.history-item .remove-btn:hover {
  opacity: 1;
  background: rgba(26,18,8,0.1);
  color: var(--accent);
}

.history-item .remove-btn svg {
  width: 12px;
  height: 12px;
}

.history-empty {
  text-align: center;
  padding: 30px 0;
  color: var(--ink2);
  opacity: 0.7;
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .card { padding: 22px 18px; }
  .input-row { flex-direction: column; }
  .extract-btn { width: 100%; }
  .platform-btn { font-size: 0.85rem; padding: 11px 6px; }
  .thumb-item img { width: 90px; height: 51px; }
  .action-row { gap: 8px; }
  .action-btn { padding: 10px 14px; font-size: 0.8rem; }
  .history-item .history-time { display: none; }
}