:root {
  --bg: #0f1115;
  --card: #191c22;
  --card-2: #21252d;
  --text: #e8eaed;
  --muted: #9aa0aa;
  --accent: #ff0033;
  --accent-2: #ff3355;
  --ok: #37d67a;
  --err: #ff5d5d;
  --border: #2a2f38;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b1f27 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 20px;
}
.brand { font-weight: 700; font-size: 1.1rem; }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.hero { text-align: center; margin: 18px 0 26px; }
.hero h1 { font-size: 1.7rem; margin: 0 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.url-row { display: flex; gap: 10px; }
.url-row input { flex: 1; }

input, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--card-2);
  transition: transform 0.05s ease, opacity 0.2s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.btn.block { display: block; width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.video { display: flex; gap: 16px; margin-bottom: 20px; }
.thumb {
  width: 160px; height: 90px; object-fit: cover;
  border-radius: 10px; background: var(--card-2); flex-shrink: 0;
}
.video-title { font-size: 1.1rem; margin: 0 0 6px; }
.video-meta { min-width: 0; }

.options { display: flex; flex-direction: column; gap: 18px; margin-bottom: 20px; }
.opt-group { display: flex; flex-direction: column; gap: 8px; }
#videoOpts, #playlistVideoOpts { flex-direction: row; gap: 14px; }
#videoOpts > div, #playlistVideoOpts > div { flex: 1; }

.segmented { display: flex; gap: 8px; }
.seg {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); border-radius: 10px;
  cursor: pointer; font-weight: 600;
}
.seg.active { border-color: var(--accent); background: rgba(255, 0, 51, 0.12); }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.toggle:hover { border-color: var(--accent); }
.toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.progress {
  height: 12px; background: var(--card-2); border-radius: 999px;
  overflow: hidden; margin: 12px 0 6px;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.3s ease;
}

.result { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.ok { color: var(--ok); font-weight: 700; margin: 0 0 6px; }
.error { color: var(--err); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.disclaimer { text-align: center; margin-top: 24px; }

.playlist-entries {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-2);
}

.playlist-entry {
  display: flex;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.playlist-entry:last-child {
  border-bottom: none;
}

.playlist-entry:hover {
  background: rgba(255, 255, 255, 0.04);
}

.playlist-entry.selected {
  background: rgba(255, 0, 51, 0.12);
}

.playlist-entry input[type="checkbox"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.playlist-entry .entry-info {
  flex: 1;
  min-width: 0;
  margin-left: 12px;
}

.playlist-entry .entry-thumb {
  width: 60px;
  height: 34px;
  border-radius: 4px;
  object-fit: cover;
  background: #222;
  flex-shrink: 0;
}

.playlist-entry .entry-title {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-entry .entry-duration {
  font-size: 0.85rem;
  color: var(--muted);
}

.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.small-btn { padding: 8px 12px; font-size: 0.8rem; }

#sessionNewTokenValue { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

#sessionEntries {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-2);
}
#sessionEntries:empty { display: none; }

.session-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.session-entry:last-child { border-bottom: none; }
.session-entry .entry-info { flex: 1; min-width: 0; }
.session-entry .entry-title { font-size: 0.95rem; overflow-wrap: anywhere; }
.session-entry .muted { overflow-wrap: anywhere; font-size: 0.75rem; }

.session-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .video { flex-direction: column; }
  .thumb { width: 100%; height: auto; aspect-ratio: 16/9; }
  #videoOpts { flex-direction: column; }
  .url-row { flex-direction: column; }
  .session-entry { flex-direction: column; align-items: stretch; }
  .session-actions { justify-content: flex-start; }
}
