:root {
  --nav-width: 200px;
  --player-width: 360px;
  --header-height: 64px;
  --bg: #101114;
  --nav: #0b0c0e;
  --content: #16181c;
  --player: #12141a;
  --panel: #1c1f26;
  --text: #f3f5f7;
  --muted: #8b919a;
  --line: #2a2e36;
  --accent: #6C7CFF;
  --accent-hover: #8593ff;
  --accent-soft: rgba(108, 124, 255, 0.16);
  --accent-border: rgba(108, 124, 255, 0.5);
  --accent-dim: var(--accent-soft);
  --accent-ink: #f4f6ff;
  --danger: #ff6b6b;
  --success: #3dd68c;
  --warning: #f5a524;
  --radius: 10px;
  --scroll-track: #16181c;
  --scroll-thumb: #3a3f4a;
  --scroll-thumb-hover: #525866;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
  font: 13px/1.45 "Segoe UI", "Malgun Gothic", sans-serif;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: var(--scroll-track);
}
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
  border: 2px solid var(--scroll-track);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}
*::-webkit-scrollbar-corner {
  background: var(--scroll-track);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.is-locked .app {
  visibility: hidden;
  pointer-events: none;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% 0%, #1a1e2c 0%, var(--bg) 55%);
  padding: 24px;
}
.login-gate[hidden] { display: none !important; }
.login-card {
  width: min(380px, 100%);
  background: #16181f;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.login-brand { margin-bottom: 18px; }
.login-card h1 {
  margin: 0 0 8px;
  font-size: 20px;
}
.login-card .muted { margin: 0 0 18px; }
.login-card .muted strong { color: var(--text); font-weight: 700; }
.login-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}
.login-card input,
.auth-settings-form input {
  width: 100%;
  height: 40px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #101114;
  color: var(--text);
  font: inherit;
}
.login-card input:focus,
.auth-settings-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-submit { width: 100%; margin-top: 6px; }
.auth-settings-form { max-width: 360px; margin: 10px 0 8px; }
.auth-settings-form .btn { margin-top: 4px; }

.app-header {
  height: var(--header-height);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: #0e1014;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 196px;
  flex: 0 0 auto;
}
.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-search {
  flex: 1;
  display: flex;
  align-items: center;
  max-width: 560px;
  height: 40px;
  background: #1a1d24;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.header-search:hover {
  border-color: #3a3f4a;
  background: #1d2128;
}
.header-search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-right: 10px;
  flex: 0 0 auto;
}
.header-search-icon svg {
  display: block;
}
.header-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
}
.header-username {
  display: inline-flex;
  align-items: center;
  height: 40px;
  max-width: 140px;
  padding: 0 12px;
  border-radius: 8px;
  background: #171a21;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-username[hidden] { display: none !important; }
.header-logout {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.header-logout:hover {
  background: #22252c;
  border-color: #3a3f4a;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn svg { display: block; }
.icon-btn:hover { background: #22252c; }
#nav-toggle, #player-toggle-mobile { display: none; }

.app-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--nav-width) 6px minmax(0, 1fr) 6px var(--player-width);
}
.resize-handle {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 3;
  touch-action: none;
}
.resize-handle::after {
  content: "";
  position: absolute;
  inset: 0 -3px;
}
.resize-handle:hover,
.resize-handle.is-dragging {
  background: var(--accent);
}
body.is-resizing {
  cursor: col-resize;
  user-select: none;
}
body.is-resizing * {
  user-select: none !important;
}
body.is-resizing video,
body.is-resizing audio,
body.is-resizing img {
  pointer-events: none;
}
body.is-video-window-dragging,
body.is-video-window-resizing {
  user-select: none;
}
body.is-video-window-dragging { cursor: move; }
body.is-video-window-resizing { cursor: nwse-resize; }

.nav {
  background: var(--nav);
  border-right: 1px solid var(--line);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.nav-scroll {
  overflow-y: auto;
  padding: 10px 10px 24px;
}
.nav-label {
  margin: 18px 12px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #6d737c;
  font-weight: 700;
}
.nav-scroll > .nav-label:first-child {
  margin-top: 4px;
}
.nav-item, .nav-pl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: #c8cdd4;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  gap: 8px;
}
.nav-item:hover, .nav-pl:hover { background: #1a1d24; color: #fff; }
.nav-item.is-active, .nav-pl.is-active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-create { color: var(--accent); }
.nav-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-pl-count { color: var(--muted); font-size: 11px; }

.content {
  min-width: 0;
  background: var(--content);
  overflow-y: auto;
  padding: 24px 28px 36px;
}

.view[hidden] { display: none !important; }
.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.view-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.view-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}
.view-head h2, .section-head h2 {
  margin: 0;
  font-size: 14px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 0 10px;
}
.view-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111318;
}
.view-toggle-btn {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.view-toggle-btn:hover {
  color: #fff;
  background: #22262e;
}
.view-toggle-btn.is-active {
  color: var(--accent);
  background: var(--accent-dim);
}
.select-all-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.select-all-wrap.is-compact span { display: none; }
.table-head .select-all-wrap {
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}
.muted { color: var(--muted); }

.search-form, .url-row, .library-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.search-form input,
.url-row input,
.library-toolbar input,
.library-toolbar select,
#playlist-name, #playlist-desc {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111318;
  color: var(--text);
  font: inherit;
}
.search-form input, .url-row input { flex: 1; min-width: 0; }
.search-form .btn,
.url-row .btn { height: 40px; }
.search-form input:focus, .url-row input:focus, .header-search:focus-within {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}
.url-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.url-form > label { display: block; margin-bottom: 6px; color: var(--muted); }
.library-toolbar { margin-bottom: 12px; }
.library-toolbar input { flex: 1 1 180px; }
.library-toolbar select { height: 40px; }

.btn {
  height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: #2a2e36; color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #353a44; }
.btn-ghost { background: transparent; color: #d0d4da; border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: #22252c; border-color: #3a3f4a; color: #fff; }
.btn-link {
  height: auto;
  padding: 4px 8px;
  background: transparent;
  color: var(--accent);
}
.btn-sm { height: 28px; font-size: 12px; padding: 0 10px; }
.btn-danger { background: #3a1717; color: #ffb4b4; }
.btn-danger:hover:not(:disabled) { background: #4a1c1c; color: #ffd0d0; }
.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-icon-text svg,
.btn-more svg { display: block; }
.btn-more {
  width: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  color: #c8cdd4;
  font: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip:hover {
  border-color: #3a3f4a;
  color: #fff;
}
.chip.is-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.chip.is-active:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.search-suggestions {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.search-suggestions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.search-suggestions-head h2 {
  margin: 0;
  font-size: 14px;
}
.search-suggestions-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.search-suggestions-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.search-suggestions-chips .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-error { margin: 8px 0 0; color: var(--danger); white-space: pre-line; }
.empty {
  color: var(--muted);
  padding: 36px 12px;
  text-align: center;
  line-height: 1.6;
}

.track-table {
  display: flex;
  flex-direction: column;
}
.table-head, .media-row, .track-row {
  display: grid;
  grid-template-columns: 28px 88px minmax(0, 2.2fr) minmax(90px, 1fr) 64px 72px auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #22252c;
}
.media-table .table-head,
.media-table .media-row {
  grid-template-columns: 32px minmax(140px, 1fr) minmax(88px, 150px) 52px 92px minmax(196px, 240px);
  gap: 8px 10px;
}
.media-table .media-row > .pick {
  justify-self: center;
}
.media-table .media-title-cell img {
  width: 80px;
  height: 45px;
  flex: 0 0 auto;
}
.media-table .col-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.media-table .col-title,
.media-table .media-title-cell {
  min-width: 0;
}
.media-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.media-title-text {
  min-width: 0;
  flex: 1;
}
.media-table .col-channel {
  min-width: 0;
}
.media-table .col-time {
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: visible;
  white-space: nowrap;
}
.media-table .col-format {
  overflow: visible;
  min-width: 0;
}
.format-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}
.media-table .col-actions,
.media-table .row-actions {
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.media-table .row-actions .btn-sm {
  padding: 0 8px;
}
.table-head {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--content);
  z-index: 1;
}
.media-row:hover, .track-row:hover { background: #1d2128; }
.media-row.is-playing, .track-row.is-playing {
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}
.media-row.is-selected {
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}
.media-row img, .track-row img {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 6px;
  background: #222;
  display: block;
}
.row-title {
  margin: 0;
  font-weight: 650;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.row-meta, .row-cell {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
}
.media-row:hover .row-actions, .media-row:focus-within .row-actions { opacity: 1; }
.media-table .row-actions {
  opacity: 0.72;
}
.media-table .media-row:hover .row-actions,
.media-table .media-row:focus-within .row-actions {
  opacity: 1;
}
.media-table .row-actions .btn {
  color: #b7bcc4;
}
.media-table .media-row:hover .row-actions .btn {
  color: #e8ebf0;
}
.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.badge-mp3 { background: var(--accent-soft); color: var(--accent); }
.badge-video { background: #2a2438; color: #c4b5fd; }
.saved-badge { color: var(--accent); font-size: 11px; font-weight: 700; }
.pick { accent-color: var(--accent); }
.now-playing { color: var(--accent); font-size: 11px; font-weight: 800; white-space: nowrap; }
.drag-handle {
  cursor: grab;
  color: #6b7280;
  user-select: none;
}
.media-row.is-dragging { opacity: 0.45; }
.media-row.drop-target { outline: 1px dashed var(--accent); }
.media-row.is-missing { opacity: 0.55; }
.media-title-cell .drag-handle {
  flex: 0 0 auto;
  color: #6b7280;
}

.playlist-tracks .table-head,
.playlist-tracks .track-row {
  grid-template-columns: 22px 88px minmax(0, 2fr) minmax(90px, 1fr) 64px auto;
}

.library-selection {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  background: var(--accent-dim);
}
.library-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.jobs-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
}
.job-stat {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #1a1d24;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
}
.job-stat.is-ok { color: var(--success); }
.job-stat.is-fail { color: var(--danger); }
.job-list { display: flex; flex-direction: column; gap: 8px; }
.job-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.job-card img {
  width: 96px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  background: #222;
}
.progress {
  height: 6px;
  background: #2a2e36;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 6px;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
}
.job-card.is-failed .progress > span { background: var(--danger); }
.job-card.is-completed .progress > span { background: var(--success); }
.job-ok { color: var(--success); font-weight: 700; }
.job-fail { color: var(--danger); font-weight: 700; white-space: pre-wrap; }
.job-card.is-compact { grid-template-columns: 1fr; }
.job-card.is-compact img, .job-card.is-compact .progress { display: none; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.home-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.12s ease;
}
.home-card:hover {
  border-color: var(--accent-border);
}
.home-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #222;
  display: block;
}
.home-card .row-title,
.home-card-actions {
  padding: 0 10px;
}
.home-card .row-title { margin: 8px 0 0; }
.home-section { margin-bottom: 28px; }
.home-section h2 { margin: 0 0 10px; font-size: 15px; }
.playlist-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.playlist-cover-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
}
.playlist-cover-card:hover {
  border-color: var(--accent-border);
}
.playlist-cover-art {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #171a22;
}
.playlist-cover-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.playlist-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
  font-size: 12px;
}
.playlist-cover-placeholder svg {
  width: 36px;
  height: 36px;
  color: #6d737c;
}
.playlist-cover-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.playlist-cover-card:hover .playlist-cover-play,
.playlist-cover-card:focus-within .playlist-cover-play {
  opacity: 1;
}
.playlist-cover-body { padding: 10px; }
.playlist-cover-body .row-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.playlist-cover-body .row-meta { margin: 4px 0 0; }

.player {
  background: var(--player);
  border-left: 1px solid var(--line);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.player-stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(42vh, 420px);
  background: #07080a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-empty {
  padding: 24px;
  text-align: center;
  color: var(--text);
}
.player-art {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  background: #000;
}
.player-video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}
.video-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(12, 14, 20, 0.72);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.82;
}
.video-expand:hover {
  opacity: 1;
  background: rgba(18, 22, 34, 0.92);
  color: var(--accent);
}
.player-now { padding: 14px 16px 6px; }
.player-title {
  margin: 0;
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.player-channel, .player-mode-label {
  margin: 4px 0 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-mode-label { color: var(--accent); font-size: 12px; }
.player.is-idle .player-transport { opacity: 0.35; pointer-events: none; }
.player.is-video .player-meter-row { display: none; }
.player.is-idle #player-toggle { display: none; }

.player-transport {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 0 6px;
}
.player-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 2px 10px 6px;
}
.player-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #22262e;
  color: #8b919a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.player-btn svg { display: block; }
svg[hidden] { display: none !important; }
.player-btn:hover {
  background: #2a2f3a;
  color: #fff;
}
.player-btn-main {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: var(--accent-ink);
}
.player-btn-main:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}
#player-toggle .ico-pause { display: none !important; }
#player-toggle.is-playing .ico-play { display: none !important; }
#player-toggle.is-playing .ico-pause { display: block !important; }
.player-btn.is-active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.player-btn.is-active:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.repeat-one-mark {
  display: none;
  position: absolute;
  right: 5px;
  bottom: 5px;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  color: currentColor;
}
.player-btn.is-repeat-one .repeat-one-mark { display: block; }
.player-meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 14px 6px;
}
.player-seek-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.player-seek-row input {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0;
  border: 0;
  outline: none;
  appearance: none;
  background: #2a2e36;
  border-radius: 99px;
  accent-color: var(--accent);
}
.player-seek-row input::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
  cursor: pointer;
}
.player-volume {
  display: flex;
  align-items: center;
  flex: 0 0 108px;
  width: 108px;
  max-width: 108px;
  margin: 0;
  padding: 0 0 0 8px;
  gap: 4px;
  color: var(--muted);
  border-left: 1px solid var(--line);
}
.player-mute {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.player-mute svg { display: block; }
.player-mute:hover { background: #22262e; color: #fff; }
.player-volume input {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0;
  border: 0;
  outline: none;
  appearance: none;
  background: #2a2e36;
  border-radius: 99px;
  accent-color: var(--accent);
}
.player-volume input::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
  cursor: pointer;
}
.player-status { margin: 0 14px 8px; color: #fbbf24; }

.resume-banner {
  margin: 8px 10px 0;
  padding: 10px;
  border-radius: 8px;
  background: #1d2430;
  border: 1px solid #2d3a4d;
}
.resume-label { margin: 0; font-size: 11px; color: var(--accent); }
.resume-title { margin: 4px 0 0; font-weight: 700; }
.resume-meta { margin: 2px 0 8px; color: var(--muted); }
.resume-actions { display: flex; gap: 6px; }

.player-tabs {
  display: flex;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.player-tab {
  flex: 1;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.player-tab:hover { color: var(--text); }
.player-tab.is-active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.player-tab-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}
.player-tab-panel[hidden] { display: none !important; }
.queue-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.queue-name { margin: 0; font-weight: 700; }
.queue-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.queue-list .empty { padding: 20px 8px; }
.queue-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.queue-row:hover { background: #1d2128; }
.queue-row.is-playing { background: var(--accent-dim); }
.queue-row img {
  width: 112px;
  height: 63px;
  object-fit: cover;
  border-radius: 8px;
  background: #1a1d24;
  display: block;
}
.queue-row .row-title {
  -webkit-line-clamp: 2;
}
.queue-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
  font-size: 16px;
  line-height: 1;
}
.queue-row:hover .queue-remove,
.queue-row:focus-within .queue-remove { opacity: 1; }
.queue-remove:hover { color: var(--text); background: #2a2e36; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  background: #1c1f26;
  color: var(--text);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: min(420px, 90vw);
}
.nav-group-label {
  margin: 10px 10px 4px;
  font-size: 10px;
  color: #6d737c;
  letter-spacing: 0.08em;
}

.info-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 10px;
}
.info-dl dt { color: var(--muted); font-size: 12px; }
.info-dl dd { margin: 0; word-break: break-word; }
.info-dl a { color: var(--accent); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden], .video-overlay[hidden], .video-window[hidden], .nav-backdrop[hidden], .player-backdrop[hidden], .row-menu[hidden] {
  display: none !important;
}
.modal-backdrop, .nav-backdrop, .player-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}
.modal-card {
  position: relative;
  width: min(420px, calc(100% - 32px));
  background: #1a1d24;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.modal-header {
  padding: 16px 16px 0;
  background: transparent;
  color: var(--text);
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
#delete-modal .modal-header {
  background: transparent;
  color: var(--danger);
}
.modal-body { padding: 12px 16px 16px; }
.modal-video-title { margin: 0 0 8px; font-weight: 700; }
.modal-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: none;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #111;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.field-label { display: block; margin: 8px 0 4px; color: var(--muted); }
#playlist-name, #playlist-desc { width: 100%; }
#playlist-desc { height: auto; padding: 8px 12px; }
.add-playlist-choices { max-height: 240px; overflow-y: auto; }

.video-window {
  position: fixed;
  z-index: 38;
  display: flex;
  flex-direction: column;
  background: #111318;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  min-width: 320px;
  min-height: 220px;
}
.video-window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  padding: 0 6px 0 14px;
  background: #171a22;
  border-bottom: 1px solid var(--line);
  cursor: move;
  user-select: none;
  flex: 0 0 auto;
  touch-action: none;
}
.video-window-head h2 {
  margin: 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-window-head .icon-btn { cursor: pointer; flex: 0 0 auto; }
.video-window-body {
  flex: 1;
  min-height: 0;
  background: #000;
  display: flex;
}
.video-window-body video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.video-window-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 55%, #6b7280 55%);
}

.row-menu {
  position: fixed;
  z-index: 39;
  min-width: 140px;
  background: #1c1f26;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.row-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
}
.row-menu button:hover { background: #2a2e36; }

.library-selection-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#library-selection-hint,
#playlist-selection-hint { width: 100%; margin: 0; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 16px 14px;
}
.media-grid > .empty {
  grid-column: 1 / -1;
}
@media (min-width: 1700px) {
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(248px, 100%), 1fr));
  }
}
.yt-card, .media-card {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.12s ease;
}
.yt-card { cursor: pointer; }
.yt-card:hover,
.media-card:hover {
  border-color: var(--accent-border);
}
.media-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.media-card.is-playing {
  box-shadow: inset 3px 0 0 var(--accent);
}
.yt-card-thumb, .media-card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #111;
}
.yt-card-thumb img, .media-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 1;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.yt-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.62));
  opacity: 0;
  transition: opacity 0.15s ease;
}
.yt-card:hover .yt-card-overlay,
.yt-card:focus-within .yt-card-overlay {
  opacity: 1;
}
.yt-card-overlay .btn-ghost {
  background: rgba(16, 18, 24, 0.88);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
}
.yt-card-body, .media-card-body {
  padding: 10px 10px 12px;
}
.yt-card-title, .media-card-title {
  margin: 0;
  font-weight: 650;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.9em;
  line-height: 1.45;
}
.yt-card-meta, .media-card-meta {
  margin: 4px 0 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
}
.media-card-formats {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  gap: 4px;
}
.media-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.media-card-actions .btn {
  color: #c5cad3;
}
.search-more-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0 8px;
}
.home-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.home-card-actions .btn { cursor: pointer; }
.home-dl {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-width: 640px;
}
.home-dl-item { margin-bottom: 10px; }
.home-dl-item:last-child { margin-bottom: 0; }
.settings-version {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.settings-lead { margin: 0 0 20px; max-width: 52ch; }
.settings-foot { margin: 8px 0 0; max-width: 52ch; }
.settings-body h2 { margin: 0 0 8px; font-size: 15px; }
.settings-card {
  margin: 0 0 14px;
  padding: 16px 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  max-width: 720px;
}
.settings-card .muted { margin-top: 0; }
.settings-keys {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}
.settings-keys li { margin: 6px 0; }
.suggest-admin {
  margin: 10px 0 8px;
}
.suggest-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.suggest-admin-toolbar input,
.suggest-admin-toolbar select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111318;
  color: var(--text);
  font: inherit;
}
.suggest-admin-toolbar input { flex: 1; min-width: 160px; }
#suggest-admin-status { white-space: pre-line; }
.suggest-admin-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: min(52vh, 560px);
  background: var(--panel);
}
.suggest-admin-head,
.suggest-admin-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 120px 128px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
}
.suggest-admin-toolbar .btn { height: 36px; }
.suggest-admin-head {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.suggest-admin-row {
  border-bottom: 1px solid #22252c;
}
.suggest-admin-row:last-child { border-bottom: 0; }
.suggest-admin-keyword {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest-admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
#suggest-edit-modal label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
}
#suggest-edit-modal select,
#suggest-edit-modal input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111318;
  color: var(--text);
  font: inherit;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #111318;
  color: var(--text);
  font: 12px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
  text-align: center;
}

button:focus-visible,
.chip:focus-visible,
.nav-item:focus-visible,
.nav-pl:focus-visible,
.player-tab:focus-visible,
.player-btn:focus-visible,
.icon-btn:focus-visible,
.header-logout:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  :root { --nav-width: 160px; }
}

@media (min-width: 901px) {
  .player-backdrop { display: none !important; }
}

@media (max-width: 900px) {
  #nav-toggle, #player-toggle-mobile { display: inline-flex; }
  .app-body { grid-template-columns: 1fr; }
  .resize-handle { display: none; }
  .nav {
    position: fixed;
    z-index: 25;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: min(240px, 84vw);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  body.nav-open .nav { transform: none; }
  .player {
    position: fixed;
    z-index: 26;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: min(360px, 100vw);
    transform: translateX(105%);
    transition: transform 0.18s ease;
  }
  body.player-open .player { transform: none; }
  .nav-backdrop, .player-backdrop { z-index: 24; }
  .player-stage { max-height: 28vh; }
}

@media (max-width: 720px) {
  .table-head { display: none; }
  .media-row, .track-row, .playlist-tracks .track-row {
    grid-template-columns: 28px 80px 1fr auto;
  }
  .row-cell { display: none; }
  .row-actions { opacity: 1; }
  .media-table .table-head { display: none; }
  .media-table .media-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }
  .media-table .col-channel,
  .media-table .col-time,
  .media-table .col-format { display: none; }
  .media-table .row-actions { opacity: 1; }
  .header-search { max-width: none; }
  .brand { min-width: 0; }
  .brand-name { display: none; }
  .header-username { display: none !important; }
  .app-header { gap: 10px; padding: 0 12px; }
}
