:root {
  --ink: #0c1a1f;
  --ink-2: #14303a;
  --foam: #e8f4f2;
  --mist: #a8c5c0;
  --line: rgba(232, 244, 242, 0.12);
  --accent: #ff6b4a;
  --accent-2: #ff8f75;
  --ok: #3dcc9c;
  --danger: #ff5c7a;
  --panel: rgba(12, 26, 31, 0.72);
  --radius: 14px;
  --font-display: "Syne", sans-serif;
  --font-body: "DM Sans", sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--foam);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1d4f4a 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #3a1f2a 0%, transparent 50%),
    linear-gradient(165deg, #071215 0%, var(--ink) 45%, #0a2228 100%);
  background-attachment: fixed;
  line-height: 1.5;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top,
main,
.foot {
  position: relative;
  z-index: 1;
}

.top {
  padding: 1.25rem clamp(1.25rem, 4vw, 3rem) 0;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--mist);
  opacity: 0;
  animation: rise 0.7s ease forwards 0.05s;
}

.hero {
  min-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 4rem;
  max-width: 920px;
}

.brand-hero {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.2rem, 10vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, var(--foam) 20%, var(--accent-2) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  animation: rise 0.8s ease forwards 0.12s;
}

.lede {
  margin: 0 0 2rem;
  max-width: 34rem;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--mist);
  opacity: 0;
  animation: rise 0.8s ease forwards 0.22s;
}

.fetch-form {
  display: grid;
  gap: 1rem;
  opacity: 0;
  animation: rise 0.8s ease forwards 0.32s;
}

#url {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  color: var(--foam);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  font: inherit;
  font-size: 1.05rem;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

#url:focus {
  border-color: rgba(255, 107, 74, 0.7);
  transform: translateY(-1px);
}

.controls {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 20, 24, 0.55);
}

.meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.9rem;
  align-items: center;
}

.meta img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--ink-2);
}

#video-title {
  margin: 0;
  font-weight: 600;
}

.muted {
  color: var(--mist);
  font-size: 0.92rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}

.segmented {
  margin: 0;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 0.15rem;
  background: rgba(0, 0, 0, 0.25);
}

.segmented label {
  cursor: pointer;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--mist);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked) {
  background: var(--accent);
  color: #1a0b08;
}

.quality-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--mist);
}

.quality-label select {
  min-width: 10rem;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--foam);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font: inherit;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--foam);
  font: inherit;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #ff3d6e);
  border-color: transparent;
  color: #1a0808;
  box-shadow: 0 10px 30px rgba(255, 107, 74, 0.28);
}

.btn.ghost:hover:not(:disabled) {
  border-color: rgba(232, 244, 242, 0.35);
  background: rgba(255, 255, 255, 0.04);
}

.btn.small {
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
}

.progress {
  margin-top: 1.25rem;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ok), var(--accent));
  transition: width 0.25s ease;
}

.error {
  margin-top: 1rem;
  color: var(--danger);
}

.library {
  padding: 0 clamp(1.25rem, 4vw, 3rem) 4rem;
  max-width: 920px;
}

.library-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.library h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.library-actions {
  display: flex;
  gap: 0.5rem;
}

.library-note {
  margin: 0 0 1.25rem;
}

.file-list {
  display: grid;
  gap: 0.55rem;
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  animation: rise 0.45s ease both;
}

.file-row input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.file-name {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
}

.file-meta {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--mist);
}

.file-actions {
  display: flex;
  gap: 0.4rem;
}

.empty {
  padding: 1.5rem 0;
  color: var(--mist);
}

.foot {
  padding: 0 clamp(1.25rem, 4vw, 3rem) 2rem;
  color: var(--mist);
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .meta {
    grid-template-columns: 1fr;
  }

  .file-row {
    grid-template-columns: auto 1fr;
  }

  .file-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
