:root {
  --bg: #0b0e14;
  --bg-elev: #121621;
  --bg-card: #151a26;
  --bg-hover: #1c2230;
  --border: #232a3a;
  --border-strong: #313a4f;
  --text: #e8edf6;
  --muted: #8a93a3;
  --muted-2: #5e6776;
  --accent: #1db954;
  --accent-2: #1ed760;
  --accent-glow: rgba(29, 185, 84, 0.18);
  --danger: #ff5c5c;
  --warn: #ffb547;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.55);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(29, 185, 84, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(30, 215, 96, 0.05), transparent 50%),
    var(--bg);
}

a { color: var(--accent-2); }
code { font-family: var(--mono); font-size: 0.85em; color: var(--muted); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: #042617;
  border-radius: 10px;
  box-shadow: 0 4px 14px -4px var(--accent-glow);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__text strong { font-size: 16px; letter-spacing: 0.2px; }
.brand__sub { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}

/* Login */
.login-card {
  max-width: 380px;
  margin: 8vh auto 0;
  text-align: left;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .muted { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input, button {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms, background 120ms;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-card);
}
input::placeholder { color: var(--muted-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 80ms, background 120ms, border-color 120ms;
  font-weight: 500;
  user-select: none;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: #03110a;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 6px 18px -8px var(--accent-glow);
}
.btn--primary:hover { filter: brightness(1.05); background: linear-gradient(160deg, var(--accent), var(--accent-2)); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.w-100 { width: 100%; }

.error { color: var(--danger); font-size: 13px; margin-top: 10px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

/* Search */
.searchbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.searchbar input { flex: 1; }
.searchbar .btn { white-space: nowrap; }
.hint { font-size: 12px; margin: 2px 2px 18px; line-height: 1.45; }

/* Results */
.results { display: flex; flex-direction: column; gap: 10px; }
.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 56px 16px;
  font-size: 13px;
}
.placeholder__icon { font-size: 36px; margin-bottom: 10px; opacity: 0.6; }

.result-card {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 140ms, background 140ms;
}
.result-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }

.thumb {
  position: relative;
  width: 120px;
  height: 68px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__dur {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
}

.result-card__main { min-width: 0; }
.result-card__title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.result-card__channel {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-card__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 130px;
}
.result-card__actions .btn { padding: 7px 10px; font-size: 12.5px; }
.btn--play { background: var(--bg-elev); border-color: var(--border-strong); }
.btn--play:hover { border-color: var(--accent); color: var(--accent-2); }
.btn--dl[data-state="done"] { background: var(--accent-glow); border-color: var(--accent); color: var(--accent-2); }

.progress {
  height: 4px;
  width: 100%;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
}
.progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 120ms linear;
}

@media (max-width: 560px) {
  .result-card {
    grid-template-columns: 96px 1fr;
    grid-template-rows: auto auto;
  }
  .thumb { width: 96px; height: 54px; }
  .result-card__actions { grid-column: 1 / -1; flex-direction: row; }
  .result-card__actions .btn { flex: 1; }
  .searchbar { flex-direction: column; }
  .searchbar .btn { width: 100%; }
}

/* Modal player */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(4px);
}
.modal__panel {
  position: relative;
  width: min(560px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
}
.modal__close:hover { background: rgba(255, 80, 80, 0.18); color: var(--danger); }
.player-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.player-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 99px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--ok { border-color: var(--accent); color: var(--accent-2); }

.muted { color: var(--muted); }