* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  height: 100vh; overflow: hidden;
  background: #0a0a0a; color: #e8e3d9;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px; display: flex; flex-direction: column;
}

/* HEADER */
header {
  border-bottom: 1px solid #1e1e1e; padding: 10px 24px;
  display: grid; grid-template-columns: 1fr 3fr 1fr;
  align-items: center; gap: 16px;
  flex-shrink: 0; background: #0a0a0a; z-index: 50;
}
.header-left { display: flex; align-items: center; }
.header-right { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.yt-badge { font-size: 13px; letter-spacing: 4px; color: #ff3b30; font-family: monospace; text-transform: uppercase; }
#ytSearchInput { background: #000; border: 1px solid #222; color: #e8e3d9; padding: 7px 14px; font-size: 15px; font-family: inherit; outline: none; flex: 1; min-width: 0; }
#ytSearchInput:focus { border-color: #333; }
#ytSearchInput::placeholder { color: #555; }
.btn-search { background: #000 !important; border: 1px solid #ff3b30 !important; color: #ff3b30 !important; }
.btn-search:hover { background: #ff3b30 !important; color: #fff !important; }
.header-center { display: flex; gap: 8px; align-items: stretch; justify-content: center; flex: 2; }

/* CRED PANEL */
#credPanel { background: #0d0d0d; border-bottom: 1px solid #1e1e1e; padding: 18px 24px; flex-shrink: 0; display: none; }
.cred-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.cred-label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #555; font-family: monospace; margin-bottom: 4px; }
.cred-input { width: 100%; background: #111; border: 1px solid #1e1e1e; color: #e8e3d9; padding: 8px 10px; font-size: 14px; font-family: monospace; outline: none; -webkit-text-security: disc; }
.cred-input:focus { border-color: #2a2a2a; }
.cred-row { display: flex; gap: 10px; align-items: center; }
.cred-note { font-size: 13px; color: #555; font-family: monospace; }

/* LAYOUT */
#body { display: flex; flex: 1; overflow: hidden; }

/* SIDEBAR */
#sidebar { width: 220px; flex-shrink: 0; border-right: 1px solid #1e1e1e; display: flex; flex-direction: column; overflow: hidden; background: #080808; }
#sidebarHeader { height: 54px; padding: 0 16px; border-bottom: 1px solid #1e1e1e; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.sidebar-title { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: #555; font-family: monospace; }
#sidebarList { flex: 1; overflow-y: auto; padding: 6px 0; }
#sidebarList::-webkit-scrollbar { width: 2px; }
#sidebarList::-webkit-scrollbar-thumb { background: #1e1e1e; }
.pl-item { padding: 8px 14px; cursor: pointer; display: flex; align-items: center; border-left: 2px solid transparent; font-size: 15px; color: #777; white-space: nowrap; overflow: hidden; transition: all 0.1s; }
.pl-item:hover { background: #0f0f0f; color: #bbb; }
.pl-item.active { background: #0f0f0f; color: #e8e3d9; border-left-color: #ff3b30; }
.pl-item .pl-count { font-size: 12px; color: #555; font-family: monospace; margin-left: auto; flex-shrink: 0; padding-left: 6px; }
.pl-sep { height: 1px; background: #161616; margin: 5px 0; }
#sidebarFooter { height: 46px; padding: 0 14px; border-top: 1px solid #161616; flex-shrink: 0; display: flex; align-items: center; }
#sidebarFooter .btn { flex: 1; }

/* MAIN */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* TABS */
#tabs { display: flex; border-bottom: 1px solid #1e1e1e; flex-shrink: 0; height: 54px; align-items: center; }
.tab { padding: 0 22px; height: 54px; display: flex; align-items: center; cursor: pointer; font-size: 14px; font-family: monospace; letter-spacing: 1px; text-transform: uppercase; color: #555; border-bottom: 2px solid transparent; transition: all 0.15s; }
.tab:hover { color: #bbb; }
.tab.active { color: #e8e3d9; border-bottom-color: #ff3b30; }

/* TOOLBAR */
#mainToolbar { height: 54px; padding: 0 20px; border-bottom: 1px solid #1e1e1e; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
#mainTitle { font-size: 17px; color: #bbb; flex-shrink: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mainCount { font-size: 13px; color: #555; font-family: monospace; white-space: nowrap; }
#searchPlaylistInput { background: #111; border: 1px solid #1e1e1e; color: #e8e3d9; padding: 0 12px; font-size: 15px; font-family: inherit; outline: none; width: 400px; height: 34px; }
#searchPlaylistInput:focus { border-color: #2a2a2a; }
#filterWrap { display: flex; align-items: center; margin-left: auto; }
#filterClear { background: none; border: 1px solid #1e1e1e; border-left: none; color: #555; font-size: 15px; font-family: monospace; cursor: pointer; width: 34px; height: 34px; padding: 0; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
#filterClear:hover { color: #ff3b30; border-color: #ff3b30; border-left: 1px solid #ff3b30; }

/* SEARCH TAB */
#searchTab { flex: 1; display: none; flex-direction: column; overflow: hidden; }
#searchResults { flex: 1; overflow-y: auto; }
#searchResults::-webkit-scrollbar { width: 2px; }
#searchResults::-webkit-scrollbar-thumb { background: #1e1e1e; }

/* PLAYLIST TAB */
#playlistTab { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#listWrap { flex: 1; overflow-y: auto; }
#listWrap::-webkit-scrollbar { width: 2px; }
#listWrap::-webkit-scrollbar-thumb { background: #1e1e1e; }

/* VIDEO ROWS */
.video-row { display: flex; gap: 12px; align-items: center; padding: 7px 20px; border-left: 2px solid transparent; transition: border-color 0.1s, background 0.1s; }
.video-row:nth-child(odd) { background: #0c0c0c; }
.video-row:nth-child(even) { background: #0a0a0a; }
.video-row:hover { border-left-color: #ff3b30; background: #111 !important; }
.video-row.playing { border-left-color: #ff3b30; background: #120a0a !important; }
.v-thumb { width: 88px; height: 49px; object-fit: cover; flex-shrink: 0; background: #111; cursor: pointer; }
.v-thumb-ph { width: 88px; height: 49px; background: #111; flex-shrink: 0; }
.v-info { flex: 1; min-width: 0; }
.v-title { font-size: 15px; color: #bbb; display: block; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; cursor: pointer; }
.v-title:hover { color: #ff3b30; }
.v-age { color: #664; }
.v-age:hover { color: #996; }
.v-meta { font-size: 13px; color: #777; font-family: monospace; }
.v-actions { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }

/* MOVE/ADD DROPDOWN */
.dd-wrap { position: relative; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 3px); background: #111; border: 1px solid #222; min-width: 190px; max-height: 480px; overflow-y: auto; z-index: 400; display: none; }
.dd-menu.open { display: block; }
.dd-menu::-webkit-scrollbar { width: 2px; }
.dd-opt { padding: 8px 12px; cursor: pointer; font-size: 14px; font-family: monospace; color: #777; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: all 0.1s; }
.dd-opt:hover { background: #1a1a1a; color: #e8e3d9; }
.dd-opt-active { color: #ff3b30 !important; }
.dd-sep { height: 1px; background: #1a1a1a; }

/* PLAYER PANEL */
#playerPanel {
  width: 0; flex-shrink: 0; border-left: 1px solid transparent;
  display: flex; flex-direction: column; overflow: hidden;
  background: #080808; transition: width 0.25s ease; position: relative;
}
#playerPanel.open { width: 50vw; border-left-color: #1e1e1e; min-width: 432px; max-width: 75vw; }
#playerResizer {
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  cursor: col-resize; z-index: 10; transition: background 0.15s;
}
#playerResizer:hover, #playerResizer.dragging { background: rgba(255,59,48,0.35); }
#playerHeader { height: 54px; padding: 0 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #1a1a1a; flex-shrink: 0; }
#playerHeaderTitle { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #555; font-family: monospace; }
#playerEmbed { width: 100%; aspect-ratio: 16/9; background: #000; flex-shrink: 0; }
#playerEmbed iframe, #playerEmbed > div { width: 100%; height: 100%; border: none; }
.btn-active { border-color: #777 !important; color: #bbb !important; }
.btn-active:hover { border-color: #ff3b30 !important; color: #ff3b30 !important; }
#playerInfo { padding: 12px 14px; border-bottom: 1px solid #1a1a1a; flex-shrink: 0; }
#playerTitle { font-size: 15px; color: #e8e3d9; line-height: 1.5; margin-bottom: 4px; }
#playerChannel { font-size: 13px; color: #555; font-family: monospace; text-decoration: none; display: block; transition: color 0.15s; }
#playerChannel:hover { color: #bbb; }
#playerControls { padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #1a1a1a; flex-shrink: 0; }
#playerQueue { font-size: 13px; color: #555; font-family: monospace; }
#playerAdd { padding: 10px 14px; flex-shrink: 0; }
#playerAdd .dd-menu { bottom: calc(100% + 3px); top: auto; }
#mainToolbar .dd-menu { left: 0; right: auto; }

/* BUTTONS */
.btn { background: none; border: 1px solid #1e1e1e; color: #777; padding: 5px 11px; cursor: pointer; font-size: 13px; font-family: monospace; transition: all 0.15s; white-space: nowrap; }
.btn:hover { border-color: #ff3b30; color: #ff3b30; }
.btn-red { background: #ff3b30; border-color: #ff3b30; color: #fff; }
.btn-red:hover { background: #d93328; border-color: #d93328; color: #fff; }
.btn-play { border-color: #ff3b30; color: #ff3b30; }
.btn-play:hover { background: #ff3b30; color: #fff; }
.btn:disabled { opacity: 0.25; cursor: not-allowed; pointer-events: none; }
.btn-sq { padding: 5px !important; min-width: 29px; display: inline-flex; align-items: center; justify-content: center; }

/* STATUS */
#statusBar { height: 46px; background: #060606; border-top: 1px solid #161616; padding: 0 14px; font-family: monospace; font-size: 13px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
#statusMsg { color: #555; transition: color 0.2s; flex: 1; }
#statusMsg.ok { color: #3a6e3a; }
#statusMsg.err { color: #8c3a3a; }

/* DIALOG */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.88); display: none; align-items: center; justify-content: center; z-index: 999; }
#overlay.open { display: flex; }
#dialog { background: #0f0f0f; border: 1px solid #222; padding: 28px; max-width: 380px; width: 90%; }
#dialogMsg { font-size: 16px; color: #bbb; margin-bottom: 20px; line-height: 1.7; }
#dialogBtns { display: flex; gap: 10px; justify-content: flex-end; }

.state-msg { padding: 48px 20px; text-align: center; font-family: monospace; font-size: 14px; color: #555; }

/* SEARCH FILTER BAR */
#searchFilterBar { padding: 8px 12px; border-bottom: 1px solid #1e1e1e; display: flex; gap: 6px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.sf-group { display: flex; gap: 3px; }
.sf-sep { width: 1px; background: #222; align-self: stretch; margin: 0 4px; }
.sf-btn { background: none; border: 1px solid #222; color: #555; padding: 3px 9px; cursor: pointer; font-size: 12px; font-family: monospace; transition: all 0.15s; }
.sf-btn:hover { border-color: #444; color: #999; }
.sf-btn.active { border-color: #ff3b30; color: #ff3b30; }
select.sf-sel { background: #000; border: 1px solid #222; color: #555; padding: 3px 6px; font-size: 12px; font-family: monospace; outline: none; cursor: pointer; }
select.sf-sel:hover { border-color: #444; color: #999; }
#showMoreWrap { padding: 10px 20px; text-align: center; flex-shrink: 0; display: none; border-top: 1px solid #1e1e1e; }

/* PLAYLIST GROUPS */
.pl-group-hdr { padding: 7px 10px 4px; display: flex; align-items: center; gap: 3px; color: #444; font-size: 11px; font-family: monospace; letter-spacing: 1.5px; text-transform: uppercase; user-select: none; }
.pl-group-hdr:hover { color: #666; }
.pl-group-toggle { cursor: pointer; flex: 1; display: flex; align-items: center; gap: 5px; overflow: hidden; min-width: 0; }
.pl-group-arrow { font-size: 9px; flex-shrink: 0; }
.pl-group-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-group-btn { background: none; border: none; color: #333; cursor: pointer; font-size: 13px; font-family: monospace; padding: 0 3px; flex-shrink: 0; }
.pl-group-btn:hover { color: #bbb; }
.pl-ungrouped-lbl { padding: 5px 14px 2px; font-size: 10px; font-family: monospace; letter-spacing: 2px; text-transform: uppercase; color: #2a2a2a; }
.pl-item-ctx { display: none; background: none; border: none; color: #333; font-size: 12px; font-family: monospace; cursor: pointer; padding: 0 2px; margin-left: 2px; flex-shrink: 0; line-height: 1; }
.pl-item:hover .pl-item-ctx { display: inline; }
.pl-item-ctx:hover { color: #999; }

/* PLAYLIST CONTEXT MENU */
#plCtxMenu { position: fixed; background: #111; border: 1px solid #222; z-index: 700; display: none; min-width: 170px; }
#plCtxMenu.open { display: block; }
.ctx-opt { padding: 8px 14px; cursor: pointer; font-size: 13px; font-family: monospace; color: #777; white-space: nowrap; }
.ctx-opt:hover { background: #1a1a1a; color: #e8e3d9; }
.ctx-sep { height: 1px; background: #1e1e1e; }
.ctx-sub-opt { padding: 6px 14px 6px 22px; cursor: pointer; font-size: 13px; font-family: monospace; color: #666; white-space: nowrap; }
.ctx-sub-opt:hover { background: #1a1a1a; color: #e8e3d9; }
.ctx-label { padding: 6px 14px 2px; font-size: 11px; font-family: monospace; color: #444; letter-spacing: 1px; text-transform: uppercase; }

/* PLAYER EXTRA CONTROLS */
#playerExtraCtrl { padding: 8px 14px; display: flex; gap: 5px; border-bottom: 1px solid #1a1a1a; flex-shrink: 0; }
#playerExtraCtrl .btn { flex: 1; text-align: center; padding: 5px 4px; }

/* CRED ACTIONS */
.cred-actions { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid #1e1e1e; align-items: center; }

/* CHANNEL LINK IN ROWS */
.v-ch-link { cursor: pointer; }
.v-ch-link:hover { color: #bbb; }

/* BULK SELECT */
#bulkBar { display: none; padding: 0 20px; height: 46px; border-top: 1px solid #1e1e1e; background: #0d0d0d; align-items: center; gap: 8px; flex-shrink: 0; }
.v-bulk-check { flex-shrink: 0; width: 15px; height: 15px; cursor: pointer; accent-color: #ff3b30; margin-right: 2px; }
