:root {
  --bg: #0a0a0d;
  --bg-soft: #111116;
  --panel: #16161c;
  --panel-2: #1c1c23;
  --border: rgba(255,255,255,0.09);
  --border-soft: rgba(255,255,255,0.06);
  --text-primary: #f3f2ef;
  --text-secondary: #9a9aa3;
  --text-muted: #5c5c66;
  --white: #ffffff;
  --success: #5fbf8f;
  --error: #e2707f;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --glass: rgba(255,255,255,0.045);
  --glass-strong: rgba(255,255,255,0.08);
  --glass-border: rgba(255,255,255,0.16);
  --glass-highlight: inset 0 1.5px 0 rgba(255,255,255,0.4), inset 0 -1px 0 rgba(255,255,255,0.04), inset 1px 0 0 rgba(255,255,255,0.12), inset -1px 0 0 rgba(0,0,0,0.2);
  --glass-sheen: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.02) 42%, rgba(255,255,255,0.07) 100%);
  --glass-sheen-strong: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.04) 42%, rgba(255,255,255,0.1) 100%);
  --blur-lg: blur(28px) saturate(180%);
  --blur-md: blur(18px) saturate(160%);
  --blur-sm: blur(12px) saturate(140%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Manrope', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
  position: relative;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: 'Manrope', sans-serif; }
a { color: inherit; text-decoration: none; }

.noise {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  opacity: 0.09;
  mix-blend-mode: overlay;
}
.glow {
  display: none;
}

.wrapper { position: relative; z-index: 1; width: 100%; max-width: 460px; margin: 0 auto; padding: 40px 20px 24px; flex: 1 0 auto; }

.brand { display: flex; align-items: center; justify-content: center; gap: 7px; margin-bottom: 56px; animation: fadeUp 1s cubic-bezier(0.19,1,0.22,1) both; }
.brand-mark { color: var(--text-primary); display: flex; align-items: center; }
.brand-mark svg { width: 17px; height: auto; max-height: 19px; display: block; }
.brand-name { font-family: 'Manrope', sans-serif; font-size: 0.95rem; font-weight: 800; letter-spacing: 0.2em; color: var(--text-primary); }
.brand-name-thin { color: var(--text-muted); font-weight: 500; }

.hero { text-align: center; }
.hero h1 {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: clamp(2.1rem, 9vw, 2.6rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 18px;
  text-shadow: 0 2px 24px rgba(0,0,0,0.4);
  animation: fadeUp 1.1s cubic-bezier(0.19,1,0.22,1) 0.15s both;
}

.hero h1 em { font-style: normal; font-weight: 700; color: var(--text-secondary); }
.hero-sub {
  font-size: 1rem; color: var(--text-secondary); font-weight: 400;
  margin-bottom: 30px; line-height: 1.6;
  animation: fadeUp 1.1s cubic-bezier(0.19,1,0.22,1) 0.32s both;
}

.input-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass-sheen);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 8px 30px rgba(0,0,0,0.35);
  border-radius: 999px;
  padding: 4px 6px 4px 18px;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  animation: fadeUp 1.1s cubic-bezier(0.19,1,0.22,1) 0.48s both;
}
.input-row:focus-within { border-color: rgba(255,255,255,0.32); }
.input-icon { flex-shrink: 0; color: var(--text-muted); }
.url-input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem; color: var(--text-primary);
  padding: 15px 0;
}
.url-input::placeholder { color: var(--text-muted); }
.paste-btn {
  flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--glass-sheen-strong);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.paste-btn:hover { background: rgba(255,255,255,0.16); color: var(--text-primary); }
.paste-btn:active { transform: scale(0.94); }
.spinner-sm {
  display: none;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--text-primary);
  animation: spin 0.7s linear infinite;
}
.paste-btn.loading #pasteIcon { display: none; }
.paste-btn.loading .spinner-sm { display: block; }

.options-row {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 16px;
  animation: fadeUp 1s cubic-bezier(0.19,1,0.22,1) 0.62s both;
}
.seg-group {
  display: flex; gap: 3px;
  background: var(--glass-sheen);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
  border-radius: 999px;
  padding: 3px;
  overflow: hidden;
}
.seg-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem; font-weight: 700;
  padding: 8px 16px; border-radius: 999px;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
}
.seg-btn.active { background: var(--text-primary); color: var(--bg); }

.wm-toggle { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.wm-toggle input { display: none; }
.wm-track {
  width: 30px; height: 17px; border-radius: 20px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  position: relative;
  transition: background var(--transition);
}
.wm-track::after {
  content: '';
  position: absolute; left: 2px; top: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
}
.wm-toggle input:checked + .wm-track { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); }
.wm-toggle input:checked + .wm-track::after { transform: translateX(13px); background: var(--text-primary); }
.wm-label { font-size: 0.84rem; color: var(--text-secondary); font-weight: 500; }

.btn-fetch {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 18px;
  background: var(--white);
  border: none; border-radius: var(--radius-md);
  color: #0a0a0d; font-family: 'Manrope', sans-serif;
  font-size: 1.02rem; font-weight: 700;
  min-height: 58px; cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
  animation: fadeUp 1s cubic-bezier(0.19,1,0.22,1) 0.74s both;
}
.btn-fetch:hover { opacity: 0.88; }
.btn-fetch:active { transform: scale(0.98); }
.btn-fetch:disabled { opacity: 0.5; cursor: not-allowed; }
.spinner {
  display: none;
  width: 17px; height: 17px; border-radius: 50%;
  border: 2.5px solid rgba(10,10,13,0.25);
  border-top-color: #0a0a0d;
  animation: spin 0.7s linear infinite;
}
.btn-fetch.loading .spinner { display: block; }
.btn-fetch.loading .btn-fetch-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(26px); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); filter: blur(10px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.progress-wrap {
  height: 2px; background: var(--panel); border-radius: 2px;
  overflow: hidden; margin-top: 12px; display: none;
}
.progress-wrap.visible { display: block; }
.progress-bar { height: 100%; width: 0%; background: var(--text-primary); transition: width 0.3s ease; }

.feature-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 28px; animation: fadeUp 1s cubic-bezier(0.19,1,0.22,1) 0.86s both; }
.feature-row-2 { margin-top: 10px; animation: fadeUp 1s cubic-bezier(0.19,1,0.22,1) 0.95s both; }
.feature { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--text-muted); font-weight: 500; }
.feature-icon { flex-shrink: 0; color: var(--text-muted); }

.result-section {
  opacity: 0; transform: translateY(14px); pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  margin-top: 28px;
}
.result-section.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.result-card {
  background: var(--glass-sheen-strong);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 24px 60px rgba(0,0,0,0.45);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: scaleIn 0.8s cubic-bezier(0.19,1,0.22,1) both;
}
.result-meta { display: flex; align-items: center; gap: 8px 10px; padding: 13px 16px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.result-meta-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.result-platform-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 20px; text-transform: uppercase;
  background: var(--glass-strong); backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid var(--glass-border); color: var(--text-secondary);
}
.content-type-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--glass-strong); backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid var(--glass-border); color: var(--text-secondary);
}
.result-username { order: 3; width: 100%; font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-caption { order: 4; width: 100%; font-size: 0.76rem; color: var(--text-primary); line-height: 1.5; margin-top: 6px; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.result-caption.expanded { -webkit-line-clamp: unset; }
.result-duration { font-family: 'JetBrains Mono', monospace; font-size: 0.66rem; color: var(--text-muted); margin-left: auto; display: flex; align-items: center; gap: 5px; }

.preview-wrap { position: relative; background: #050506; max-height: 380px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.video-el { width: 100%; max-height: 380px; object-fit: contain; display: block; }
.thumb-img { width: 100%; max-height: 320px; object-fit: cover; display: block; }

.photo-carousel { position: relative; width: 100%; aspect-ratio: 4/5; max-height: 420px; overflow: hidden; background: #050506; touch-action: pan-y; }
.photo-carousel-track { display: flex; height: 100%; transition: transform 0.32s cubic-bezier(0.4,0,0.2,1); }
.photo-carousel-track.dragging { transition: none; }
.photo-slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #050506; }
.photo-slide img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; user-select: none; }
.carousel-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18);
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); transition: background var(--transition), transform var(--transition); z-index: 5;
}
.carousel-nav:hover { background: rgba(255,255,255,0.18); }
.carousel-nav:active { transform: translateY(-50%) scale(0.92); }
.carousel-nav.prev { left: 10px; }
.carousel-nav.next { right: 10px; }
.carousel-nav:disabled { opacity: 0.25; cursor: default; }
.carousel-counter {
  position: absolute; top: 10px; right: 10px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; font-weight: 700;
  background: rgba(0,0,0,0.55); color: #fff; padding: 3px 9px; border-radius: 20px;
  backdrop-filter: blur(6px); z-index: 5;
}
.carousel-photo-dl {
  position: absolute; bottom: 10px; right: 10px;
  display: flex; align-items: center; gap: 5px;
  font-size: 0.66rem; font-weight: 700;
  padding: 6px 12px; border-radius: 20px;
  background: rgba(255,255,255,0.9); color: #0a0a0d;
  border: none; cursor: pointer;
  transition: background var(--transition), transform var(--transition); z-index: 5;
}
.carousel-photo-dl:hover { background: #fff; transform: translateY(-1px); }
.carousel-dots { position: absolute; bottom: 10px; left: 10px; display: flex; align-items: center; gap: 5px; z-index: 5; }
.carousel-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.35); border: none; cursor: pointer; padding: 0; transition: all var(--transition); }
.carousel-dot.active { background: #fff; width: 15px; border-radius: 4px; }

.dl-options { padding: 14px 16px; display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.dl-title { font-size: 0.68rem; color: var(--text-muted); font-weight: 700; margin-right: 4px; width: 100%; }
.dl-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: 'Manrope', sans-serif;
  font-size: 0.9rem; font-weight: 700;
  padding: 13px 18px; border-radius: var(--radius-sm);
  border: 1px solid; cursor: pointer; transition: all var(--transition);
}
.dl-btn.video, .dl-btn.sd { flex: 1 1 auto; border-color: var(--white); color: #0a0a0d; background: var(--white); }
.dl-btn.video:hover, .dl-btn.sd:hover { opacity: 0.88; }
.dl-btn.audio { flex: 0 1 auto; border-color: var(--glass-border); color: var(--text-secondary); background: var(--glass); backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm); }
.dl-btn.audio:hover { background: var(--glass-strong); color: var(--text-primary); }

.history-section { margin-top: 26px; animation: fadeUp 0.9s cubic-bezier(0.19,1,0.22,1) both; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; color: var(--text-muted); text-transform: uppercase; }
.clear-hist { font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; color: var(--text-muted); background: none; border: none; cursor: pointer; transition: color var(--transition); }
.clear-hist:hover { color: var(--error); }
.hist-list { display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.hist-list::-webkit-scrollbar { height: 3px; }
.hist-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  flex: 0 0 168px; padding: 14px 15px;
  background: var(--glass-sheen); backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
  border-radius: var(--radius-md); cursor: pointer; position: relative;
  overflow: hidden;
  transition: all var(--transition); scroll-snap-align: start;
  opacity: 0; animation: fadeUp 0.8s cubic-bezier(0.19,1,0.22,1) forwards;
}
.hist-item:hover { background: var(--glass-strong); border-color: rgba(255,255,255,0.26); }
.hist-icon { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.64rem; font-weight: 700; flex-shrink: 0; background: var(--glass-strong); color: var(--text-secondary); border: 1px solid var(--glass-border); }
.hist-info { width: 100%; }
.hist-url { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; line-height: 1.4; }
.hist-time { font-size: 0.68rem; color: var(--text-muted); margin-top: 5px; }
.hist-redo { position: absolute; top: 10px; right: 10px; color: var(--text-muted); transition: color var(--transition), transform var(--transition); }
.hist-item:hover .hist-redo { color: var(--text-primary); transform: translateX(1px); }

footer {
  position: relative; z-index: 1;
  text-align: center; padding: 24px 22px 32px;
  color: var(--text-muted); font-size: 0.78rem; line-height: 1.7;
  flex-shrink: 0;
  margin-top: auto;
}

.notif-stack { position: fixed; bottom: 20px; right: 20px; left: 20px; z-index: 999; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.notif {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius-md);
  font-size: 0.78rem; font-weight: 600;
  background: var(--glass-sheen-strong);
  backdrop-filter: var(--blur-lg); -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 12px 30px rgba(0,0,0,0.4);
  pointer-events: auto; animation: slideIn 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
  max-width: 320px; color: var(--text-primary);
  overflow: hidden;
}
.notif.success { border-color: rgba(95,191,143,0.3); }
.notif.success svg { color: var(--success); }
.notif.error { border-color: rgba(226,112,127,0.3); }
.notif.error svg { color: var(--error); }
.notif.info svg { color: var(--text-secondary); }
.notif.hide { animation: slideOut 0.25s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(10px); } }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; white-space: nowrap;
  background: var(--glass-sheen-strong); backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  color: var(--text-primary);
  border: 1px solid var(--glass-border); border-radius: 6px; padding: 4px 9px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 10;
}
[data-tip]:hover::after { opacity: 1; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a2a32; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #38383f; }

@media (max-width: 380px) {
  .wrapper { padding: 30px 14px 20px; }
  .hero h1 { font-size: 2.1rem; }
}
