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

:root {
  --bg:      #111111;
  --surface: #1e1e1e;
  --border:  #2e2e2e;
  --accent:  #7c3aed;
  --accent2: #9d5bf0;
  --text:    #e8e8e8;
  --muted:   #888888;
  --error:   #f87171;
  --radius:  8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 80px;
}

.container {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

header { text-align: center; }

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

h1 span { color: var(--accent); }

header p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.88rem;
}

/* Input row */
.input-row { display: flex; gap: 10px; }

input[type="url"] {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="url"]:focus { border-color: var(--accent); }
input[type="url"]::placeholder { color: var(--muted); }

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

#fetch-btn {
  background: var(--accent);
  color: #fff;
  padding: 12px 22px;
  white-space: nowrap;
}

#fetch-btn:hover:not(:disabled) { background: var(--accent2); }

.error {
  color: var(--error);
  font-size: 0.88rem;
  text-align: center;
}

.hidden { display: none !important; }

/* Result card */
.media-info {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

#thumbnail {
  width: 140px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--border);
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

#title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

#meta-line {
  color: var(--muted);
  font-size: 0.82rem;
}

/* Format picker */
.format-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.format-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.group-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 42px;
}

.format-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fmt-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--radius);
}

.fmt-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent2);
}

.fmt-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Progress */
#progress-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

#progress-text {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Download button */
#download-btn {
  background: var(--accent);
  color: #fff;
  padding: 13px;
  width: 100%;
  font-size: 1rem;
  letter-spacing: 0.2px;
}

#download-btn:hover:not(:disabled) { background: var(--accent2); }

/* Mobile */
@media (max-width: 480px) {
  body { padding: 32px 12px 60px; }
  h1 { font-size: 1.8rem; }
  #thumbnail { width: 100px; height: 60px; }
  .format-group { flex-wrap: wrap; }
}
