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

:root {
  --red:    #0077FF;
  --red-dk: #005ecc;
  --bg:     #0f0f0f;
  --surface:#1a1a1a;
  --border: #2e2e2e;
  --text:   #f1f1f1;
  --sub:    #aaaaaa;
  --radius: 14px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ── */
.page { display: flex; flex-direction: column; min-height: 100dvh; }

.header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.logo-icon { width: 38px; height: 38px; flex-shrink: 0; border-radius: 8px; }
.logo-text  { display: flex; flex-direction: column; gap: 1px; }
.logo-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.3px; line-height: 1.2; }
.logo-sub   { font-size: 0.7rem; color: #0077FF; font-weight: 500; letter-spacing: 0.2px; }

.main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.footer {
  text-align: center;
  padding: 16px;
  font-size: 0.75rem;
  color: var(--sub);
  border-top: 1px solid var(--border);
}
.footer a { color: #0077FF; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Search card ── */
.search-card { display: flex; flex-direction: column; gap: 12px; }

.label { font-size: 0.8rem; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.6px; }

.input-row {
  display: flex;
  gap: 8px;
}

input[type="url"] {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s;
  min-width: 0;
}
input[type="url"]:focus { border-color: var(--red); }
input[type="url"]::placeholder { color: #555; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  padding: 12px 20px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-dk); }

.btn-download {
  width: 100%;
  background: var(--red);
  color: #fff;
  font-size: 1rem;
  padding: 15px;
  border-radius: 12px;
  margin-top: 4px;
}
.btn-download:hover:not(:disabled) { background: var(--red-dk); }

.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ── Spinner ── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Video card ── */
.video-card { display: flex; flex-direction: column; gap: 16px; }

.thumb-row { display: flex; gap: 14px; align-items: flex-start; }

.thumbnail {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--border);
}

.meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.video-title { font-size: 0.95rem; font-weight: 600; line-height: 1.35; word-break: break-word; }
.video-sub   { font-size: 0.78rem; color: var(--sub); }

/* ── Quality select ── */
.quality-row { display: flex; flex-direction: column; gap: 8px; }

.select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 12px 14px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  transition: border-color 0.18s;
}
.select:focus { border-color: var(--red); }

/* ── Error & notes ── */
.error-msg {
  background: rgba(255, 60, 60, 0.12);
  border: 1px solid rgba(255, 60, 60, 0.35);
  color: #ff6b6b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.4;
}

.note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--sub);
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Mobile tweaks ── */
@media (max-width: 400px) {
  .main { padding: 16px 12px 28px; }
  .card { padding: 16px; }
  .thumbnail { width: 100px; height: 56px; }
  .btn { padding: 11px 16px; }
  .btn-download { padding: 14px; }
}
