:root {
  --bg: #0f0f0f;
  --bg-raised: #1f1f1f;
  --bg-hover: #272727;
  --border: #303030;
  --text: #f1f1f1;
  --text-muted: #aaaaaa;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --danger: #f87171;
  --radius: 12px;
  --header-height: 56px;
  --bottom-bar-height: 56px;
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Header ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: rgba(15, 15, 15, 0.96);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
}

.brand-name {
  font-size: 20px;
  letter-spacing: -0.6px;
  font-weight: 500;
}

.brand-name b {
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search {
  justify-self: center;
  display: flex;
  width: min(640px, 100%);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 40px 0 0 40px;
  background: #121212;
  color: var(--text);
  font-size: 16px;
}

.search input:focus {
  outline: none;
  border-color: #1c62b9;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.search-button {
  width: 64px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 0 40px 40px 0;
  background: #222;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.search-button:hover { background: var(--bg-hover); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  font-weight: 500;
}

.nav-link:hover,
.nav-link[aria-current="page"] { background: var(--bg-hover); }

/* Language switch: the pill shows the code, an invisible native select on top opens the list. */
.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
}

.lang-switch::after {
  content: '';
  border: 4px solid transparent;
  border-top-color: var(--text-muted);
  margin-top: 4px;
}

.lang-switch:hover { background: var(--bg-hover); }
.lang-switch:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.lang-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font: inherit;
}

/* ---- Home -------------------------------------------------------------- */

.page {
  padding: 24px clamp(16px, 3vw, 40px) 48px;
  max-width: 2200px;
  margin: 0 auto;
}

.section-head { margin-bottom: 20px; }

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.section-hint {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 40px 16px;
}

.empty {
  margin: 48px auto;
  max-width: 480px;
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
}

.shelf + .shelf {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.shelf-toggle {
  display: block;
  margin: 20px auto 0;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: transparent;
  font-weight: 500;
  cursor: pointer;
}

.shelf-toggle:hover { background: var(--bg-hover); }

.skeleton-title {
  width: 220px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(90deg, #1c1c1c 0%, #2a2a2a 50%, #1c1c1c 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* ---- Cards ------------------------------------------------------------- */

.card { display: block; min-width: 0; }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.card:hover .thumb img { transform: scale(1.03); }

.badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 12px;
  font-weight: 500;
}

.card-body {
  display: flex;
  gap: 12px;
  padding-top: 12px;
}

.card-text { min-width: 0; }

.card-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 500;
  line-height: 22px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-channel,
.card-meta {
  margin: 0;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card:hover .card-channel { color: var(--text); }

.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: var(--bg-hover);
}

.avatar-lg { width: 40px; height: 40px; font-size: 18px; }

.avatar-img { object-fit: cover; padding: 0; }

.card-compact {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 8px;
}

.card-compact .thumb { border-radius: 8px; }
.card-compact .card-body { padding-top: 0; }
.card-compact .card-title { font-size: 14px; line-height: 20px; }
.card-compact .card-channel { font-size: 12px; }

.skeleton .thumb,
.skeleton .avatar,
.skeleton .line {
  background: linear-gradient(90deg, #1c1c1c 0%, #2a2a2a 50%, #1c1c1c 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton .card-text { flex: 1; }
.skeleton .line { height: 16px; border-radius: 4px; margin-bottom: 8px; }
.skeleton .line.short { width: 60%; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* ---- Watch ------------------------------------------------------------- */

.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 402px;
  gap: 24px;
  max-width: 1754px;
  margin: 0 auto;
  padding: 24px clamp(16px, 2vw, 24px) 48px;
}

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 169px);
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.player video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
  padding: 24px;
}

.overlay-busy,
.overlay-error {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 460px;
}

.overlay-text { margin: 0; font-size: 16px; font-weight: 500; }

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  width: min(320px, 70vw);
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.progress.thin { width: 100%; height: 3px; }

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.error-title { margin: 0; font-size: 18px; font-weight: 600; color: var(--danger); }
.error-text { margin: 0; color: var(--text); }

.button {
  border: 0;
  border-radius: 18px;
  padding: 8px 16px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
}

.button:hover { background: #d9d9d9; }

.download-status { margin-top: 8px; }
.download-status[data-progress="none"] .progress { display: none; }

.download-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.download-row { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; }

.download-action {
  margin: 6px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.download-action:hover { text-decoration: underline; }
.download-action:disabled { opacity: 0.5; cursor: default; text-decoration: none; }

.video-title {
  margin: 12px 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 28px;
  overflow-wrap: anywhere;
}

.channel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.channel-text {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-right: auto;
}

.channel-name { font-size: 16px; font-weight: 500; }
a.channel-name[href]:hover { color: var(--accent); }

.quality { position: relative; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 18px;
  background: var(--bg-hover);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.pill:hover,
.pill[aria-expanded="true"] { background: #3f3f3f; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 230px;
  padding: 8px 0;
  border-radius: var(--radius);
  background: #282828;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.menu-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px 8px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible { background: #3a3a3a; outline: none; }

.menu-check { color: var(--accent); font-weight: 700; }

.menu-hint {
  color: var(--text-muted);
  font-size: 12px;
}

.chip {
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.description-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-hover);
}

.stats { margin: 0 0 6px; font-weight: 500; }

.description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.description.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.description a { color: #3ea6ff; }

.link-button {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 600;
  cursor: pointer;
}

.secondary-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.up-next {
  display: grid;
  gap: 8px;
}

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 1016px) {
  .watch { grid-template-columns: minmax(0, 1fr); }
  .player { max-height: none; }
}

@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .nav-link span { display: none; }
  .nav-link { padding: 0 6px; }
  .header-actions { gap: 6px; }
  .brand-name { display: none; }
  .search-button { width: 48px; }
  .lang-switch { padding: 0 8px 0 10px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .watch { padding: 0 0 32px; }
  .player { border-radius: 0; }
  .secondary { padding: 0 12px; }
}

/* ---- Buttons & form controls ------------------------------------------ */

.button:disabled { opacity: 0.5; cursor: default; }

.button-quiet {
  background: var(--bg-hover);
  color: var(--text);
  font-weight: 500;
}

.button-quiet:hover { background: #3f3f3f; }

.button-danger { background: #b91c1c; color: #fff; }
.button-danger:hover { background: #991b1b; }

.select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121212;
  color: var(--text);
  font: inherit;
}

.pill-small {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.pill[aria-pressed="true"] { color: var(--accent); }

.section-link {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #3ea6ff;
}

/* ---- Library ----------------------------------------------------------- */

.library-summary { margin: 6px 0 0; font-weight: 500; }

.add-form {
  display: flex;
  gap: 8px;
  max-width: 760px;
  margin: 8px 0 12px;
}

.add-form input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #121212;
  color: var(--text);
  font-size: 15px;
}

.add-form input:focus { outline: none; border-color: #1c62b9; }

.form-status { margin: 4px 0 12px; color: var(--text-muted); }
.form-status.is-error { color: var(--danger); }

.preview-card {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  max-width: 980px;
  margin-bottom: 24px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.preview-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-hover);
}

.preview-title { margin: 8px 0 4px; font-size: 18px; }

.preview-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin: 16px 0;
}

.field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  align-content: start;
}

.field-label {
  padding: 0;
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.option.is-disabled { opacity: 0.45; cursor: default; }
.option input[type="radio"] { accent-color: var(--accent); }

.count-input {
  width: 72px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #121212;
  color: var(--text);
  font: inherit;
}

.preview-actions { display: flex; gap: 8px; }

.notice {
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(234, 179, 8, 0.15);
  color: #fde68a;
}

.library-section { margin-top: 28px; }

.subscriptions {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.subscription {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.subscription-thumb {
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-hover);
}

.subscription-title { margin: 0 0 4px; font-size: 16px; }

.subscription-text .card-meta { white-space: normal; }

.subscription-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.videos-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.videos-head .section-title { margin-right: auto; }

.library-card { display: flex; flex-direction: column; min-width: 0; }

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-left: 48px;
}

.card-actions .button { padding: 6px 12px; font-size: 13px; }

.card-error { margin: 2px 0 0; color: var(--danger); font-size: 13px; }

.card-note { margin: 2px 0 0; color: #fbbf24; font-size: 13px; }

.empty-inline { color: var(--text-muted); margin: 0; }

.state-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 12px;
  font-weight: 600;
}

.state-downloading { color: var(--accent); }
.state-pending { color: var(--text-muted); }
.state-failed { color: var(--danger); }
.state-archived { color: #fbbf24; }

@media (max-width: 760px) {
  .preview-card { grid-template-columns: minmax(0, 1fr); }
  .subscription { grid-template-columns: 96px minmax(0, 1fr); }
  .subscription-thumb { width: 96px; }
  .subscription-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---- Sidebar ----------------------------------------------------------- */

:root { --sidebar-width: 240px; }

.topbar-start {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) { background: var(--bg-hover); }
.icon-button:disabled { opacity: 0.35; cursor: default; }

.sidebar {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  z-index: 9;
  width: var(--sidebar-width);
  padding: 8px 12px 24px;
  overflow-y: auto;
  background: var(--bg);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  scrollbar-width: thin;
}

body.sidebar-docked .sidebar,
body.drawer-open .sidebar { transform: none; }

body.drawer-open .sidebar { box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5); }

body.sidebar-docked main { margin-left: var(--sidebar-width); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--header-height) 0 0 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.5);
}

body.drawer-open .sidebar-backdrop { display: block; }

/* Phones: main pages at the bottom (below the menu drawer, which covers it when open). */
.bottom-bar { display: none; }

@media (max-width: 640px) {
  .bottom-bar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 7;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--border);
    background: rgba(15, 15, 15, 0.97);
  }

  body.has-bottom-bar { padding-bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom, 0px)); }

  .bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    color: var(--text-muted);
    font-size: 10px;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-link[aria-current="page"] { color: var(--text); font-weight: 600; }
  .bottom-link[aria-current="page"] svg { color: var(--accent); }
  .bottom-label { max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.side-group { padding: 4px 0 12px; }
.side-group + .side-section,
.side-section + .side-section,
.side-section + .side-group {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.side-section { padding-bottom: 12px; }

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 4px 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.side-item:hover { background: var(--bg-hover); }
.side-item[aria-current="page"] { background: var(--bg-hover); font-weight: 600; }
.side-item svg { flex: none; }

.side-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-count { color: var(--text-muted); font-size: 12px; }
.side-more { color: var(--text-muted); }
.side-empty { margin: 0; padding: 4px 12px; color: var(--text-muted); font-size: 13px; }

.side-avatar { width: 24px; height: 24px; font-size: 12px; }

.side-form {
  display: flex;
  gap: 6px;
  padding: 4px 4px 10px 12px;
}

.side-form input,
.menu-form input,
.rename-form input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121212;
  color: var(--text);
  font: inherit;
}

.side-form .button,
.menu-form .button { padding: 6px 12px; }

/* ---- Own playlists, saved playlists and channels ---------------------- */

.playlist-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.playlist-hero {
  position: sticky;
  top: calc(var(--header-height) + 16px);
  padding: 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.35), rgba(34, 211, 238, 0.08) 60%, var(--bg-raised));
}

.hero-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg-hover);
  color: var(--text-muted);
}

.hero-thumb img { width: 100%; height: 100%; object-fit: cover; }

.hero-title {
  margin: 16px 0 6px;
  font-size: 26px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

a.button { display: inline-flex; align-items: center; }

.rename-form { display: flex; gap: 8px; margin: 16px 0 6px; }

.playlist-items { margin: 0; padding: 0; list-style: none; }

.playlist-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 10px;
}

.playlist-row:hover { background: var(--bg-raised); }

.row-index { color: var(--text-muted); text-align: center; font-size: 14px; }

.row-link {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.row-thumb { border-radius: 8px; }
.row-actions { display: flex; gap: 2px; }

.collection-head {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 28px;
}

.collection-avatar { width: 128px; height: 128px; font-size: 52px; }

.collection-cover {
  display: grid;
  place-items: center;
  flex: none;
  width: 256px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg-hover);
}

.collection-cover img { width: 100%; height: 100%; object-fit: cover; }
.collection-text .hero-title { margin-top: 0; }

/* ---- Watch page: playlist menu and panel ------------------------------ */

.playlist-add { position: relative; }

.menu-separator { height: 1px; margin: 6px 0; background: #3a3a3a; }

.menu-form { display: flex; gap: 6px; padding: 6px 12px; }

.playlist-panel {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-head { padding: 12px 16px; background: var(--bg-raised); }
.panel-title { font-size: 18px; font-weight: 700; }
.panel-title:hover { color: var(--accent); }
.panel-head .card-meta { margin-top: 4px; }

.panel-items {
  max-height: 420px;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  list-style: none;
}

.panel-item {
  display: grid;
  grid-template-columns: 24px 100px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
}

.panel-item:hover { background: var(--bg-hover); }
.panel-item[aria-current="true"] { background: rgba(99, 102, 241, 0.22); }
.panel-item .row-index { font-size: 12px; }
.panel-thumb { border-radius: 6px; }
.panel-item .card-title { font-size: 13px; line-height: 18px; }
.panel-item .card-channel { font-size: 12px; }

/* ---- Settings ---------------------------------------------------------- */

.settings-card {
  max-width: 1000px;
  margin-bottom: 20px;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.settings-heading { margin: 0 0 4px; font-size: 18px; }

.settings-group { margin: 20px 0 0; padding: 0; border: 0; }

.settings-subheading {
  margin-bottom: 12px;
  padding: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* One setting per row: name and hint on the left, the control on the right. */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 8px;
}

.settings-grid > .setting {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 24px;
  row-gap: 4px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.settings-grid > .setting:first-child { border-top: 0; padding-top: 6px; }
.settings-grid > .setting > .setting-label,
.settings-grid > .setting > .setting-hint,
.settings-grid > .setting > .setting-error { grid-column: 1; }
.settings-grid > .setting > :not(.setting-label, .setting-hint, .setting-error) {
  grid-column: 2;
  grid-row: 1 / span 3;
  justify-self: end;
}
.settings-grid > .setting > .select { min-width: 180px; }

/* Long values (lists, secrets) take the whole width below their name. */
.settings-grid > .setting-wide,
.settings-grid > .setting:has(> textarea) { grid-template-columns: minmax(0, 1fr); }
.settings-grid > .setting-wide > :not(.setting-label, .setting-hint, .setting-error),
.settings-grid > .setting:has(> textarea) > :not(.setting-label, .setting-hint, .setting-error) {
  grid-column: 1;
  grid-row: auto;
  justify-self: stretch;
}

/* Switches instead of check boxes, on the right like the other controls. */
.settings-grid > .setting-check input[type="checkbox"] {
  position: relative;
  width: 40px;
  height: 22px;
  margin: 0;
  border-radius: 11px;
  background: #555;
  cursor: pointer;
  appearance: none;
  transition: background 0.2s;
}

.settings-grid > .setting-check input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.settings-grid > .setting-check input[type="checkbox"]:checked { background: var(--accent); }
.settings-grid > .setting-check input[type="checkbox"]:checked::before { transform: translateX(18px); }
.settings-grid > .setting-check { cursor: pointer; }

/* Pages: a readable column; personal and server settings as titled groups of cards. */
.page.settings .settings-card { max-width: 820px; }
.page.settings .section-head { max-width: 820px; }

.settings-section-head { max-width: 820px; margin: 32px 0 12px; }
.settings-section-title { margin: 0; font-size: 20px; }
.settings-form > .settings-section-title { margin: 32px 0 0; }
.settings-form > .section-hint { max-width: 820px; margin-bottom: 12px; }
.page.settings .settings-card .settings-heading { margin-bottom: 4px; }

/* The server settings are long: Save stays reachable at the bottom of the screen. */
.settings-savebar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  max-width: 820px;
  margin: 0 0 20px;
  padding: 12px 24px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.45);
}

.settings-status { max-width: 820px; }

.setting { display: grid; gap: 6px; align-content: start; }

.setting-check {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
}

.setting-check .setting-hint,
.setting-check .setting-error { grid-column: 2; }
.setting-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.setting-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.setting-hint { color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.setting-error { color: var(--danger); font-size: 12px; }
.has-error .input,
.has-error .textarea,
.has-error .select { border-color: var(--danger); }

.input,
.textarea {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121212;
  color: var(--text);
  font: inherit;
}

.input-number { max-width: 160px; }
.input-short { width: 64px; text-transform: uppercase; }
.textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.region-field { display: flex; align-items: center; gap: 10px; }
.region-name { color: var(--text-muted); }

.chip-accent { color: var(--accent); }

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.settings-actions .form-status { margin: 0; }

.environment {
  display: grid;
  grid-template-columns: minmax(200px, auto) minmax(0, 1fr);
  gap: 10px 24px;
  margin: 16px 0 0;
}

.environment dt { color: var(--text-muted); }
.environment dd { margin: 0; overflow-wrap: anywhere; }
.env-set { color: #4ade80; font-weight: 600; }
.env-unset { color: var(--text-muted); }

@media (max-width: 900px) {
  .playlist-layout { grid-template-columns: minmax(0, 1fr); }
  .playlist-hero { position: static; }
  .collection-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .row-link { grid-template-columns: 120px minmax(0, 1fr); }
  .environment { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .environment dd { margin-bottom: 10px; }
}

/* ---- Admin: storage and downloads ------------------------------------- */

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  max-width: 1000px;
}

.disk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin-bottom: 20px;
}

.disk-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.disk-card .settings-heading { margin: 0; }
.disk-path { margin: 0; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.disk-usage { margin: 0; font-weight: 500; }

.disk-bar {
  position: relative;
  display: flex;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.disk-yourod,
.swatch-yourod { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.disk-other,
.swatch-other { background: #6b7280; }
.swatch-free { background: rgba(255, 255, 255, 0.12); }
.disk-bar.is-full .disk-other { background: #b45309; }

.disk-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fbbf24;
}

.disk-legend { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.disk-legend li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.disk-legend-label { color: var(--text-muted); }
.disk-legend-detail { flex-basis: 100%; padding-left: 18px; color: var(--text-muted); font-size: 12px; }
.swatch { flex: none; align-self: center; width: 10px; height: 10px; border-radius: 3px; }
.disk-low { margin: 0; color: #fde68a; }

.admin-card { max-width: 1000px; }

.admin-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 12px;
}

.admin-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-sort { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }

.admin-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 12px 0 0; padding: 0; list-style: none; }

.admin-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border-radius: 10px;
}

.admin-row:hover { background: var(--bg-hover); }
.admin-row .thumb { border-radius: 8px; }
/* One column that never grows past the row, so long titles end in an ellipsis. */
.admin-row-text { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.admin-row-text > * { min-width: 0; }
.admin-row-title { display: block; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
a:hover > .admin-row-title { color: var(--accent); }
.admin-row-meta { color: var(--text-muted); font-size: 12px; }
.admin-row-meta.is-error { color: var(--danger); }
.admin-row .progress { margin-top: 4px; }
.admin-row-side { display: grid; justify-items: end; gap: 4px; text-align: right; }
.admin-size { font-size: 13px; }
.admin-more { display: flex; justify-content: center; margin-top: 12px; }

@media (max-width: 600px) {
  .admin-head { flex-direction: column; }
  .admin-row { grid-template-columns: 88px minmax(0, 1fr); }
  .admin-row-side { grid-column: 2; justify-items: start; grid-auto-flow: column; justify-content: start; align-items: center; text-align: left; }
}

/* ---- Watch layout: default and theater mode -------------------------- */

.watch {
  grid-template-areas: "player side" "info side";
  grid-template-rows: auto 1fr;
  row-gap: 0;
}

.player-area { grid-area: player; min-width: 0; }
.watch > .primary { grid-area: info; min-width: 0; }
.watch > .secondary { grid-area: side; min-width: 0; }

/* Theater: the player spans the whole width, the content stays centred below it. */
.watch.theater {
  max-width: none;
  padding: 0 0 48px;
  column-gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1280px) 402px minmax(0, 1fr);
  grid-template-areas: "player player player player" ". info side .";
}

.watch.theater .player {
  height: min(56.25vw, calc(100vh - 169px));
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}

.watch.theater .download-status { max-width: 1706px; margin: 8px auto 0; padding: 0 24px; }
.watch.theater > .primary,
.watch.theater > .secondary { padding-top: 16px; }

@media (max-width: 1016px) {
  .watch,
  .watch.theater {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "player" "info" "side";
  }

  .watch.theater { padding: 0 0 32px; }
  .watch.theater > .primary,
  .watch.theater > .secondary { padding: 16px 16px 0; }
}

@media (max-width: 640px) {
  .watch > .primary { padding: 0 12px; }
  .player-area .download-status { margin-left: 12px; margin-right: 12px; }
}

/* ---- Player controls ------------------------------------------------- */

.player.has-custom-controls { user-select: none; -webkit-user-select: none; }
.player .player-overlay { z-index: 6; }

.player-gradient {
  position: absolute;
  inset: auto 0 0 0;
  height: 140px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  pointer-events: none;
  transition: opacity 0.25s;
}

.player-controls {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 3;
  padding: 0 12px 4px;
  transition: opacity 0.25s;
}

.player.is-inactive .player-controls,
.player.is-inactive .player-gradient { visibility: hidden; opacity: 0; }

.player.is-idle .player-controls,
.player.is-idle .player-gradient { opacity: 0; }
.player.is-idle { cursor: none; }
/* No double-tap zoom on the picture: double taps jump 15 s there. */
.player.has-custom-controls video { touch-action: manipulation; }

/* Touch: play/pause in the middle while the controls are shown. */
.center-play { display: none; }

@media (hover: none) and (pointer: coarse) {
  .player.has-custom-controls .center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    transition: opacity 0.25s;
  }

  /* Hidden ones must not catch taps meant for the picture. */
  .player.is-idle .center-play,
  .player.is-inactive .center-play,
  .player.is-buffering .center-play { opacity: 0; pointer-events: none; }
}

/* Double-tap jump: a half-round flash on that side with the seconds jumped so far. */
.tap-seek {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 38%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.tap-seek svg { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7)); }

.tap-seek-back { left: 0; border-radius: 0 50% 50% 0 / 0 50% 50% 0; }
.tap-seek-forward { right: 0; border-radius: 50% 0 0 50% / 50% 0 0 50%; }
.tap-seek.is-pulse svg { animation: tap-pulse 0.35s ease-out; }

@keyframes tap-pulse {
  from { opacity: 0.3; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.seekbar {
  position: relative;
  display: flex;
  align-items: center;
  height: 18px;
  cursor: pointer;
  touch-action: none;
}

.seekbar:focus-visible { outline: none; }

.seek-rail {
  position: relative;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  transition: height 0.1s;
}

.seekbar:hover .seek-rail,
.seekbar.is-dragging .seek-rail,
.seekbar:focus-visible .seek-rail { height: 5px; }

.seek-rail > div { position: absolute; inset: 0 auto 0 0; width: 0; }
.seek-available {
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.16) 0 4px, rgba(255, 255, 255, 0.24) 4px 8px);
}
.seek-buffered { background: rgba(255, 255, 255, 0.42); }
.seek-hover { background: rgba(255, 255, 255, 0.55); }
.seek-played { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.seek-knob {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.1s;
  pointer-events: none;
}

.seekbar:hover .seek-knob,
.seekbar.is-dragging .seek-knob,
.seekbar:focus-visible .seek-knob { transform: translate(-50%, -50%) scale(1); }

.seek-preview {
  position: absolute;
  bottom: 24px;
  display: grid;
  justify-items: center;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

.preview-image {
  border: 2px solid #fff;
  border-radius: 6px;
  background-color: #000;
  background-repeat: no-repeat;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.preview-time {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 46px;
}

.ctl {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.92;
}

.ctl:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.ctl[hidden] { display: none; }

.ctl-captions { position: relative; }
.ctl-captions.is-disabled { opacity: 0.4; }
.ctl-captions.is-on::after {
  content: "";
  position: absolute;
  inset: auto 10px 7px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.volume { display: flex; align-items: center; }

.volume-slider {
  width: 0;
  height: 4px;
  margin: 0;
  opacity: 0;
  appearance: none;
  border-radius: 2px;
  background: linear-gradient(90deg, #fff var(--fill, 100%), rgba(255, 255, 255, 0.3) var(--fill, 100%));
  cursor: pointer;
  transition: width 0.15s, opacity 0.15s, margin 0.15s;
}

.volume-slider::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.volume-slider::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }

.volume:hover .volume-slider,
.volume:focus-within .volume-slider { width: 72px; margin: 0 10px 0 4px; opacity: 1; }

.time {
  margin-left: 6px;
  color: #eee;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.control-spacer { flex: 1; }

.player-menu {
  position: absolute;
  right: 12px;
  bottom: 62px;
  z-index: 5;
  min-width: 270px;
  max-height: calc(100% - 80px);
  padding: 8px 0;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(28, 28, 28, 0.95);
  backdrop-filter: blur(6px);
  scrollbar-width: thin;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px 10px 16px;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-row:hover,
.menu-row:focus-visible { background: rgba(255, 255, 255, 0.1); outline: none; }
.menu-row .menu-label { flex: 1; }
.menu-value { color: #bbb; font-size: 13px; }

.menu-back {
  margin-bottom: 6px;
  padding-left: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  font-weight: 600;
}

.player-menu .menu-item { color: #fff; }

.player-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 5;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.82);
  font-size: 14px;
  transform: translateX(-50%);
}

.player-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  pointer-events: none;
}

.player.is-fullscreen,
.player:fullscreen {
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}

/* Subtitles like YouTube; lifted above the controls while they are shown (Chromium). */
.player video::cue {
  background: rgba(8, 8, 8, 0.75);
  color: #fff;
  font-family: Roboto, "Segoe UI", system-ui, sans-serif;
}

.player.has-custom-controls video::-webkit-media-text-track-container {
  transform: translateY(-68px);
  transition: transform 0.25s;
}

.player.is-idle video::-webkit-media-text-track-container,
.player.is-inactive video::-webkit-media-text-track-container { transform: none; }

/* ---- Subscription import --------------------------------------------- */

.import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 4px 0 12px;
}

.import-panel {
  max-width: 980px;
  margin-bottom: 24px;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.import-tools { display: flex; gap: 16px; margin: 12px 0 6px; }
.import-tools .link-button { margin: 0; color: #3ea6ff; font-weight: 500; }

.import-list {
  max-height: 340px;
  margin: 0 0 16px;
  padding: 4px 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  list-style: none;
}

.import-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
}

.import-item:hover { background: var(--bg-hover); }
.import-item.is-disabled label { cursor: default; color: var(--text-muted); }
.import-item input { width: 16px; height: 16px; accent-color: var(--accent); }
.import-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-error { color: var(--danger); }

/* ---- Subscribing without downloads ----------------------------------- */

.follow-only .download-field { display: none; }

.subscribe-button {
  height: 36px;
  padding: 0 16px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.subscribe-button:hover { background: #d9d9d9; }
.subscribe-button.is-subscribed { background: var(--bg-hover); color: var(--text); }
.subscribe-button.is-subscribed:hover { background: #3f3f3f; }

/* ---- SponsorBlock and Return YouTube Dislike --------------------------- */

.seek-rail > .seek-segments { position: absolute; inset: 0; width: auto; pointer-events: none; }
.seek-segment { position: absolute; top: 0; bottom: 0; opacity: 0.9; }

.skip-notice {
  position: absolute;
  right: 16px;
  bottom: 76px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 6px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.82);
  font-size: 14px;
}

.skip-undo {
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.skip-undo:hover { background: rgba(255, 255, 255, 0.28); }

.votes {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 6px;
  border-radius: 18px;
  background: var(--bg-hover);
}

.vote {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-weight: 500;
}

.vote-divider { width: 1px; height: 22px; background: #555; }

.vote-bar {
  position: absolute;
  inset: auto 16px 4px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.vote-bar > div { height: 100%; background: var(--text); }

.sponsor-categories { display: grid; margin-top: 0; }

.sponsor-category {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 180px;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.sponsor-category.is-disabled { opacity: 0.5; }
.sponsor-category label { display: grid; gap: 2px; }
.sponsor-swatch { width: 14px; height: 14px; border-radius: 3px; }

/* ---- Subscriptions page ----------------------------------------------- */

.subs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.subs-actions { display: flex; gap: 8px; }

.channel-strip {
  display: flex;
  gap: 8px;
  margin: 0 0 24px;
  padding-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.channel-strip:empty { display: none; }

.strip-channel {
  display: grid;
  justify-items: center;
  flex: none;
  gap: 6px;
  width: 96px;
  padding: 8px 4px;
  border-radius: 12px;
  text-align: center;
}

.strip-channel:hover { background: var(--bg-hover); }
.strip-avatar { width: 56px; height: 56px; font-size: 22px; }

.strip-name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.strip-channel:hover .strip-name { color: var(--text); }

/* ---- Accounts ------------------------------------------------------------ */

.account-slot { position: relative; display: flex; align-items: center; }

.account-button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.account-avatar { width: 32px; height: 32px; font-size: 15px; }
.account-button[aria-expanded="true"] .account-avatar { box-shadow: 0 0 0 2px var(--accent); }

.account-menu { min-width: 260px; }
.account-menu .menu-item { grid-template-columns: 20px 1fr; gap: 14px; padding-left: 16px; }
.account-language {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 4px 16px;
}
.account-lang-switch { min-width: 72px; justify-content: center; }

.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 12px;
}

.account-head > div,
.account-summary-text { display: grid; gap: 2px; min-width: 0; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.account-role { color: var(--text-muted); font-size: 13px; }

.signin-pill {
  padding: 0 14px 0 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
}

.signin-pill:hover { background: rgba(34, 211, 238, 0.12); }

.side-guest { padding: 12px; }
.side-guest-text { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; }

.signin-prompt {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 460px;
  margin: 64px auto;
  text-align: center;
}

.signin-icon { color: var(--text-muted); }
.signin-title { margin: 8px 0 0; font-size: 22px; }
.signin-text { margin: 0 0 8px; color: var(--text-muted); }
.signin-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.settings-card .signin-prompt { margin: 16px auto 8px; }

/* Login and registration */

.auth-page { display: grid; place-items: start center; }

.auth-card {
  width: min(420px, 100%);
  margin-top: 6vh;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.auth-title { margin: 0 0 8px; font-size: 22px; }
.auth-note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: rgba(34, 211, 238, 0.08);
}
.auth-form { display: grid; gap: 16px; margin-top: 20px; }
.auth-form .form-status { margin: 0; }
.auth-submit { justify-self: stretch; padding: 10px 16px; }
.auth-links { margin-top: 20px; color: var(--text-muted); }
.auth-links p { margin: 6px 0 0; }
.auth-links a { color: var(--accent); }
.auth-links a:hover { text-decoration: underline; }

/* Settings: own account, invite link, account list */

.account-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

.account-summary-text { flex: 1; }
.account-avatar-large { width: 48px; height: 48px; font-size: 22px; }

.avatar-form { display: grid; gap: 12px; margin-top: 20px; }
.avatar-form .input[type="file"] { max-width: 420px; }
.avatar-form .settings-actions { margin-top: 0; }

.password-form { margin-top: 24px; }
.password-form .settings-actions { margin-top: 16px; }

.setting-wide { grid-column: 1 / -1; }
.secret-field { display: grid; gap: 10px; max-width: 720px; }
.secret-row,
.invite-row { display: flex; align-items: center; gap: 8px; }
.secret-row .input { flex: 1; }
.input-secret,
.invite-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.invite-link { display: grid; gap: 6px; }
.invite-link:empty { display: none; }
.invite-url {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #121212;
  overflow-wrap: anywhere;
  user-select: all;
}

.user-list { display: grid; margin-top: 12px; }

.user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.user-row:first-child { border-top: 0; }
.user-text { display: grid; gap: 4px; }
.user-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.user-reset { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.user-reset .input { flex: 1; min-width: 200px; }

@media (max-width: 760px) {
  .user-row { grid-template-columns: auto minmax(0, 1fr); }
  .user-actions { grid-column: 2; justify-content: flex-start; }
  .signin-pill span { display: none; }
  .signin-pill { padding: 0 8px; }
}

/* Login and registration have no search field that pushes the actions to the right. */
body[data-auth-page] .header-actions { grid-column: 3; }

/* ---- Personal home page ---------------------------------------------------- */

.thumb-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
}

.thumb-progress > span { display: block; height: 100%; background: var(--accent); }

/* Cards with a "⋮" menu are a <div>: the thumbnail and the text are separate links. */
.card-thumb-link { display: block; }
.card-body { position: relative; }
.card-body > .card-text { flex: 1; }

.card-menu-button {
  flex: none;
  align-self: flex-start;
  width: 32px;
  height: 32px;
  margin: -4px -8px 0 0;
}

@media (hover: hover) {
  .card .card-menu-button { opacity: 0; }
  .card:hover .card-menu-button,
  .card-menu-button:focus-visible,
  .card-menu-button[aria-expanded="true"] { opacity: 1; }
}

.card-menu { top: 32px; min-width: 260px; }
.menu-note { margin: 0; padding: 6px 16px 10px; color: var(--text-muted); font-size: 13px; }
.menu-note + .menu-item { border-top: 1px solid #3a3a3a; padding-top: 10px; }

.card-dismissed {
  aspect-ratio: 16 / 9;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text-muted);
  text-align: center;
}

.card-dismissed p { margin: 0; }

.section-head-row { display: flex; align-items: center; gap: 8px; }
.is-spinning svg { animation: spin 0.9s linear infinite; }

.recs-note {
  max-width: 640px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.recs-note p { margin: 0; }
.recs-note p + p { margin-top: 6px; }

/* History */

.history-page .section-hint { margin-bottom: 20px; }
.history-day + .history-day { margin-top: 36px; }
.history-day-title { margin: 0 0 16px; font-size: 18px; }
.hidden-card { margin-top: 48px; }

/* ---- Playlists page ---------------------------------------------------- */

.playlists-page .section-hint { margin-bottom: 16px; }
.playlist-forms { display: grid; gap: 10px; max-width: 720px; margin-bottom: 12px; }
.playlist-forms .add-form { margin: 0; }

.playlist-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 24px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip-button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--bg-hover);
  font-weight: 500;
  cursor: pointer;
}

.chip-button:hover { background: #3f3f3f; }
.chip-button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* A stack edge above the cover marks a playlist, as on YouTube. */
.playlist-card .card-thumb-link { position: relative; display: block; padding-top: 6px; }
.playlist-card .card-thumb-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 10px;
  border-radius: 8px 8px 0 0;
  background: #3a3a3a;
}

.playlist-thumb { display: grid; place-items: center; background: var(--bg-raised); }
.playlist-thumb-empty { color: var(--text-muted); }

.playlist-count {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 12px;
  font-weight: 500;
}

.playlist-saved-text { flex: 1; min-width: 0; display: grid; gap: 8px; }
.playlist-rename { flex: 1; display: grid; gap: 8px; }
.playlist-rename .card-actions { margin-top: 0; }

.side-title-link:hover { text-decoration: underline; }
.playlist-card .card-actions { flex-wrap: wrap; padding-left: 0; }

/* ---- Channel page ------------------------------------------------------- */

.channel-banner {
  aspect-ratio: 6.2 / 1;
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
}

.channel-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }

.channel-header { display: flex; align-items: flex-start; gap: 24px; margin-bottom: 20px; }

.channel-avatar {
  flex: none;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-raised);
}

.channel-avatar-empty { display: grid; place-items: center; color: var(--text-muted); }
.channel-headtext { min-width: 0; display: grid; gap: 8px; justify-items: start; }
.channel-title { margin: 0; font-size: 34px; line-height: 1.15; }
.channel-facts { margin: 0; color: var(--text-muted); }

.channel-description {
  max-width: 760px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  text-align: left;
  white-space: pre-line;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.channel-description.is-open { display: block; }
.channel-description:hover { color: var(--text); }
.channel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.channel-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.channel-tab {
  padding: 12px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.channel-tab:hover { color: var(--text); }
.channel-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }

/* Shorts: upright cards, no avatar (it is the same channel everywhere). */
.grid-shorts { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 28px 12px; }
.grid-shorts .thumb { aspect-ratio: 9 / 16; }
.grid-shorts .card-avatar-link,
.grid-shorts .card-body > .avatar { display: none; }

/* Cards whose channel name is its own link (see videoCard). */
.card-title-link { display: block; }
.card-channel-link { display: block; }
.card-channel-link:hover { color: var(--text); text-decoration: underline; }
.card-avatar-link { flex: none; align-self: flex-start; }
.channel-name[href]:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .channel-header { gap: 16px; }
  .channel-avatar { width: 72px; height: 72px; }
  .channel-title { font-size: 24px; }
}

/* ---- Watch together ------------------------------------------------------ */

.together-add { position: relative; }

.together-create {
  width: min(360px, 90vw);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.together-create-title { margin: 0; font-size: 16px; font-weight: 700; }
.together-create .button { justify-self: start; }
.together-note { margin: 0; color: var(--text-muted); font-size: 13px; }

.together-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.together-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.together-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.together-count { color: var(--text-muted); font-size: 13px; }
.together-start { justify-self: stretch; }

.together-invite { display: flex; align-items: center; gap: 8px; }
.together-invite .invite-url { flex: 1; font-size: 12px; }
.together-guests { font-size: 13px; }

.together-members { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }

.together-member {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border-radius: 16px;
  background: var(--bg-hover);
  font-size: 13px;
}

.together-member.is-away { opacity: 0.5; }
.together-avatar { width: 24px; height: 24px; font-size: 12px; }

.together-messages {
  max-height: 240px;
  min-height: 60px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 4px;
  font-size: 13px;
}

.together-message { overflow-wrap: anywhere; }
.together-event { color: var(--text-muted); font-style: italic; }
.together-row { display: flex; gap: 8px; }
.together-row .input { flex: 1; min-width: 0; }
.together-join { display: grid; gap: 10px; }
.together-join p { margin: 0; }
.together-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Offline page (progressive web app) ----------------------------------- */

.offline-page {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.offline-page h1 { margin: 8px 0 0; font-size: 24px; }
.offline-page p { max-width: 420px; margin: 0 0 8px; color: var(--text-muted); }

@media (max-width: 640px) {
  .settings-grid > .setting:not(.setting-check) { grid-template-columns: minmax(0, 1fr); }
  .settings-grid > .setting:not(.setting-check) > :not(.setting-label, .setting-hint, .setting-error) {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
  }
  .sponsor-category { grid-template-columns: 14px minmax(0, 1fr); }
  .sponsor-category .select { grid-column: 2; }
  .settings-savebar { padding: 10px 16px; }
  body.has-bottom-bar .settings-savebar { bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom, 0px)); }
}
