* { margin: 0; padding: 0; box-sizing: border-box; }
html { width: 100%; max-width: 100%; overflow-x: hidden; overscroll-behavior-x: none; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #111; color: #eee; width: 100%; max-width: 100%; min-height: 100vh; overflow-x: hidden; }
#app { width: 100%; max-width: 1700px; min-width: 0; margin: 0 auto; padding: 0.5rem; display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; }
h1 { font-size: 1rem; color: #aaa; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.4rem; }
h3 { font-size: 0.8rem; color: #999; margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.05em; }
#sync-indicator { width: 8px; height: 8px; border-radius: 50%; background: #4e8; display: none; flex-shrink: 0; }
#sync-indicator.visible { display: inline-block; }
#sync-indicator.disconnected { background: #e44; }

/* Header */
#header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
#auth-section { display: flex; gap: 0.4rem; align-items: center; }
#auth-section .user-info { display: flex; align-items: center; gap: 0.4rem; }
#auth-section .username { color: #4e8; font-weight: 600; font-size: 0.85rem; }
#auth-section .admin-badge { background: #c4f; color: #111; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.65rem; }
#btn-logout { background: none; border: none; color: #e44; font-size: 0.65rem; cursor: pointer; padding: 0; opacity: 0.7; }
#btn-logout:hover { opacity: 1; text-decoration: underline; }
#btn-logout.guest-signin { background: #4e8; color: #111; font-size: 0.85rem; font-weight: 600; padding: 0.4rem 1rem; border-radius: 4px; opacity: 1; }
#btn-logout.guest-signin:hover { background: #5fa; text-decoration: none; }
#btn-kick-others { background: none; border: none; color: #ea4; font-size: 0.65rem; cursor: pointer; padding: 0; opacity: 0.7; }
#btn-kick-others:hover { opacity: 1; text-decoration: underline; }
#site-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 0.5rem; }
#site-header h1 { margin: 0; }
#btn-report-bug { color: #4e8; font-size: 0.8rem; text-decoration: none; padding: 0.3rem 0.6rem; border: 1px solid #4e8; border-radius: 4px; }
#btn-report-bug:hover { background: #4e8; color: #111; }
#stream-select select { background: #222; color: #eee; border: 1px solid #333; padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.85rem; }

/* Main content - library and queue */
#main-content { display: flex; gap: 0.5rem; flex: 1; width: 100%; min-width: 0; min-height: 0; margin-bottom: 0.5rem; max-width: 1600px; margin-left: auto; margin-right: auto; overflow-x: hidden; }
#channels-panel { order: 1; flex: 0 0 160px; min-width: 0; background: #1a1a1a; border-radius: 6px; padding: 0.4rem; display: flex; flex-direction: column; min-height: 250px; max-height: 60vh; }
#channels-list { flex: 1; overflow-y: auto; }
#channels-list .channel-item { padding: 0.2rem 0.4rem; border-radius: 3px; font-size: 0.8rem; display: flex; flex-direction: column; gap: 0.1rem; }
#channels-list .channel-item.active { background: #2a4a3a; color: #4e8; }
#channels-list .channel-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 0.1rem 0; border-radius: 3px; }
#channels-list .channel-header:hover { background: #222; }
#channels-list .channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
#channels-list .channel-name-input { flex: 1; font-size: 0.8rem; background: #111; color: #eee; border: 1px solid #4e8; border-radius: 3px; padding: 0.1rem 0.3rem; outline: none; min-width: 0; }
#channels-list .listener-count { font-size: 0.65rem; color: #aaa; flex-shrink: 0; margin-left: 0.3rem; }
#channels-list .btn-delete-channel { background: none; border: none; color: #666; font-size: 0.9rem; cursor: pointer; padding: 0 0.2rem; line-height: 1; opacity: 0; transition: opacity 0.15s; }
#channels-list .channel-header:hover .btn-delete-channel { opacity: 1; }
#channels-list .btn-delete-channel:hover { color: #e44; }
#channels-list .btn-rename-channel { background: none; border: none; color: #666; font-size: 0.7rem; cursor: pointer; padding: 0 0.2rem; line-height: 1; opacity: 0; transition: opacity 0.15s; }
#channels-list .channel-header:hover .btn-rename-channel { opacity: 1; }
#channels-list .btn-rename-channel:hover { color: #4e8; }
#channels-list .channel-listeners { display: flex; flex-direction: column; margin-left: 0.5rem; border-left: 1px solid #333; padding-left: 0.3rem; }
#channels-list .listener { font-size: 0.65rem; color: #aaa; padding: 0.05rem 0; position: relative; }
#channels-list .listener::before { content: ""; position: absolute; left: -0.3rem; top: 50%; width: 0.2rem; height: 1px; background: #333; }
#channels-list .listener-mult { color: #999; font-size: 0.55rem; }
#library-panel, #queue-panel { flex: 1 1 0; min-width: 0; max-width: 100%; overflow: hidden; background: #1a1a1a; border-radius: 6px; padding: 0.5rem; display: flex; flex-direction: column; min-height: 250px; max-height: 60vh; position: relative; }
#library-panel { order: 2; }
#queue-panel { order: 3; }
.panel-tabs { display: flex; gap: 0; margin-bottom: 0; flex-shrink: 0; }
.panel-tab { background: #252525; border: none; color: #999; font-family: inherit; font-size: 0.8rem; font-weight: bold; padding: 0.3rem 0.6rem; cursor: pointer; border-radius: 4px 4px 0 0; text-transform: uppercase; letter-spacing: 0.05em; margin-right: 2px; }
.panel-tab:hover { color: #aaa; background: #2a2a2a; }
.panel-tab.active { color: #eee; background: #222; }
.panel-views { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative; background: #222; border-radius: 0 4px 4px 4px; }
.panel-view { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; position: relative; padding: 0.4rem; }
.panel-view.active { display: flex; }
.tasks-empty { color: #666; font-size: 0.85rem; padding: 1rem; text-align: center; }
.tasks-empty.hidden { display: none; }
#tasks-list { display: flex; flex-direction: column; gap: 0.3rem; overflow-y: auto; flex: 1; }
.task-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; background: #2a2a1a; border-radius: 4px; font-size: 0.8rem; color: #ea4; position: relative; overflow: hidden; }
.task-item.complete { background: #1a2a1a; color: #4e8; }
.task-item.error { background: #2a1a1a; color: #e44; }
.task-item .task-spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid #ea4; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
.task-item.complete .task-spinner { display: none; }
.task-item.error .task-spinner { display: none; }
.task-item .task-icon { flex-shrink: 0; }
.task-item.complete .task-icon::before { content: "✓"; }
.task-item.error .task-icon::before { content: "✗"; }
.task-item .task-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item .task-progress { font-size: 0.7rem; color: #888; flex-shrink: 0; }
.task-item .task-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: #ea4; transition: width 0.2s; }
.task-item.complete .task-bar { background: #4e8; }
.slow-queue-section { margin-top: 0.5rem; border-top: 1px solid #333; padding-top: 0.5rem; }
.slow-queue-section.hidden { display: none; }
.slow-queue-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; padding: 0 0.2rem; gap: 0.5rem; }
.slow-queue-title { font-size: 0.75rem; color: #888; font-weight: 500; }
.slow-queue-timer { font-size: 0.7rem; color: #6af; flex: 1; }
.slow-queue-cancel-all { background: none; border: 1px solid #633; color: #a66; font-size: 0.65rem; padding: 0.15rem 0.4rem; border-radius: 3px; cursor: pointer; transition: all 0.15s; }
.slow-queue-cancel-all:hover { background: #422; border-color: #844; color: #e88; }
.slow-queue-list { display: flex; flex-direction: column; gap: 0.15rem; max-height: 200px; overflow-y: auto; }
.slow-queue-playlist-header { font-size: 0.7rem; color: #888; padding: 0.3rem 0.2rem 0.15rem; margin-top: 0.2rem; border-top: 1px solid #2a2a2a; }
.slow-queue-playlist-header:first-child { border-top: none; margin-top: 0; }
.slow-queue-item { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.4rem; background: #1a1a2a; border-radius: 3px; font-size: 0.75rem; color: #6af; }
.slow-queue-item.next { background: #1a2a2a; color: #4cf; }
.slow-queue-item-icon { flex-shrink: 0; font-size: 0.7rem; }
.slow-queue-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slow-queue-cancel { background: none; border: none; color: #666; cursor: pointer; padding: 0 0.2rem; font-size: 0.7rem; opacity: 0; transition: opacity 0.15s; }
.slow-queue-item:hover .slow-queue-cancel { opacity: 1; }
.slow-queue-cancel:hover { color: #e44; }
.slow-queue-show-toggle { background: none; border: none; color: #68a; font-size: 0.7rem; padding: 0.3rem; cursor: pointer; width: 100%; text-align: center; }
.slow-queue-show-toggle:hover { color: #8af; text-decoration: underline; }
.scan-progress { font-size: 0.7rem; color: #ea4; padding: 0.2rem 0.4rem; background: #2a2a1a; border-radius: 3px; margin-bottom: 0.3rem; display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.scan-progress.hidden { display: none; }
.scan-progress.complete { color: #4e8; background: #1a2a1a; }
.scan-progress .spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid #ea4; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.upload-btn { width: 100%; padding: 0.5rem; background: #2a3a2a; border: 1px dashed #4e8; border-radius: 4px; color: #4e8; font-size: 0.85rem; cursor: pointer; margin-top: 0.3rem; flex-shrink: 0; }
.upload-btn:hover { background: #3a4a3a; }
.add-btn { width: 100%; padding: 0.5rem; background: #252525; border: 1px solid #444; border-radius: 4px; color: #888; font-size: 0.85rem; cursor: pointer; margin-top: 0.3rem; flex-shrink: 0; transition: all 0.2s; }
.add-btn:hover { background: #2a2a2a; border-color: #666; color: #aaa; }
.add-btn.hidden { display: none; }
.fetch-dialog { position: absolute; bottom: 0; left: 0; right: 0; background: #1a1a1a; border-top: 1px solid #333; border-radius: 0 0 6px 6px; display: flex; flex-direction: column; animation: panelSlideUp 0.2s ease-out; }
.fetch-dialog.hidden { display: none; }
.fetch-dialog.closing { animation: panelSlideDown 0.2s ease-in forwards; }
.fetch-dialog-header { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.5rem; border-bottom: 1px solid #333; }
.fetch-dialog-header span { font-size: 0.8rem; color: #aaa; }
.fetch-dialog-close { background: none; border: none; color: #666; font-size: 1.2rem; cursor: pointer; padding: 0 0.3rem; line-height: 1; }
.fetch-dialog-close:hover { color: #aaa; }
.fetch-dialog-content { padding: 0.5rem; display: flex; gap: 0.4rem; }
.fetch-url-input { flex: 1; padding: 0.4rem 0.6rem; background: #222; border: 1px solid #444; border-radius: 4px; color: #eee; font-size: 0.85rem; font-family: inherit; }
.fetch-url-input:focus { outline: none; border-color: #4e8; }
.fetch-submit-btn { padding: 0.4rem 0.8rem; background: #2a3a2a; border: 1px solid #4e8; border-radius: 4px; color: #4e8; font-size: 0.85rem; cursor: pointer; font-family: inherit; }
.fetch-submit-btn:hover { background: #3a4a3a; }
.add-panel { position: absolute; bottom: 0; left: 0; right: 0; background: #1a1a1a; border-top: 1px solid #333; border-radius: 0 0 6px 6px; display: flex; flex-direction: column; height: 50%; overflow: hidden; animation: panelSlideUp 0.2s ease-out; }
.add-panel.hidden { display: none; }
.add-panel.closing { animation: panelSlideDown 0.2s ease-in forwards; }
@keyframes panelSlideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes panelSlideDown { from { transform: translateY(0); opacity: 1; } to { transform: translateY(100%); opacity: 0; } }
.add-panel-close { width: calc(100% - 1rem); margin: 0.5rem; padding: 0.5rem; background: #252525; border: 1px solid #444; border-radius: 4px; color: #888; font-size: 0.85rem; cursor: pointer; flex-shrink: 0; }
.add-panel-close:hover { background: #2a2a2a; border-color: #666; color: #aaa; }
.add-panel-content { flex: 1; overflow-y: auto; padding: 0 0.5rem 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; }
.add-option { width: 100%; padding: 0.6rem 0.8rem; background: #222; border: 1px solid #333; border-radius: 4px; color: #aaa; font-size: 0.85rem; cursor: pointer; text-align: left; transition: all 0.15s; }
.add-option:hover { background: #2a3a2a; border-color: #4e8; color: #4e8; }
.upload-progress { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem; background: #2a2a1a; border-radius: 4px; margin-top: 0.3rem; flex-shrink: 0; position: relative; overflow: hidden; }
.upload-progress.hidden { display: none; }
.upload-progress-bar { position: absolute; left: 0; top: 0; bottom: 0; background: #4a6a4a; transition: width 0.2s; }
.upload-progress-text { position: relative; z-index: 1; font-size: 0.75rem; color: #4e8; }
.upload-dropzone { position: absolute; inset: 0; background: rgba(42, 74, 58, 0.95); display: flex; align-items: center; justify-content: center; border-radius: 6px; border: 2px dashed #4e8; z-index: 10; }
.upload-dropzone.hidden { display: none; }
.dropzone-content { color: #4e8; font-size: 1.2rem; font-weight: 600; }
#queue-title { margin: 0 0 0.3rem 0; }
#queue-duration { font-size: 0.75rem; color: #888; font-weight: normal; }
.now-playing-bar { font-size: 0.75rem; color: #4e8; padding: 0.3rem 0.5rem; background: #1a2a1a; border: 1px solid #2a4a3a; border-radius: 4px; margin-bottom: 0.3rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-playing-bar:hover { background: #2a3a2a; }
.now-playing-bar.hidden { display: none; }
.now-playing-bar .label { color: #aaa; }
.panel-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.3rem; }
.panel-header h3 { margin: 0; flex-shrink: 0; }
.panel-header select { flex: 1; background: #222; color: #eee; border: 1px solid #333; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.75rem; }
.panel-header button { background: #333; color: #eee; border: 1px solid #444; width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: 0.9rem; line-height: 1; padding: 0; }
.panel-header button:hover { background: #444; }
.new-channel-input { flex: 1; background: #222; color: #eee; border: 1px solid #333; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.75rem; }
.btn-submit-channel { background: #2a4a3a; color: #4e8; border: 1px solid #3a5a4a; width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.btn-submit-channel:hover { background: #3a5a4a; }
.search-input { flex: 1; background: #222; color: #eee; border: 1px solid #333; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.75rem; }
.search-input::placeholder { color: #666; }
#library, #queue { flex: 1; overflow-y: auto; overflow-x: hidden; min-width: 0; }
#library .track, #queue .track, #playlist-tracks .track { padding: 0.3rem 0.5rem; border-radius: 4px; cursor: pointer; font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; position: relative; user-select: none; min-width: 0; }
#library .track[title], #queue .track[title], #playlist-tracks .track[title] { cursor: pointer; }
#library .track:hover, #queue .track:hover, #playlist-tracks .track:hover { background: #222; }
#queue .track.active { background: #2a4a3a; color: #4e8; }
.cache-indicator { width: 3px; height: 100%; position: absolute; left: 0; top: 0; border-radius: 4px 0 0 4px; }
.track.cached .cache-indicator { background: #4e8; }
.track.not-cached .cache-indicator { background: #ea4; }
.track-number { color: #888; font-size: 0.7rem; min-width: 1.3rem; margin-right: 0.2rem; }
.track-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.track-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.track-actions .duration { color: #999; font-size: 0.75rem; }
#queue .track.active .track-number,
#queue .track.active .duration { color: #d6e6dc; }
.track-actions .track-play-btn { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; background: #333; border: none; border-radius: 3px; font-size: 0.7rem; color: #aaa; cursor: pointer; transition: background 0.2s, color 0.2s; }
.track-actions .track-play-btn:hover { background: #48f; color: #fff; }
.track-actions .track-preview-btn { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; background: #333; border: none; border-radius: 3px; font-size: 0.7rem; color: #aaa; cursor: pointer; transition: background 0.2s, color 0.2s; }
.track-actions .track-preview-btn:hover { background: #4a4; color: #fff; }
.track-actions .track-add, .track-actions .track-remove { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; background: #333; border: none; border-radius: 3px; font-size: 0.85rem; color: #ccc; cursor: pointer; opacity: 0; transition: opacity 0.2s; }
.track:hover .track-add, .track:hover .track-remove { opacity: 0.6; }
.track-actions .track-add:hover, .track-actions .track-remove:hover { opacity: 1; background: #444; }
.track-actions .track-remove { color: #e44; }
.track-actions .track-add { color: #4e4; }
.track-actions .track-menu-btn { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: #333; border: none; border-radius: 3px; color: #ccc; cursor: pointer; opacity: 0; font-size: 1rem; line-height: 1; padding: 0; transition: opacity 0.2s, background 0.2s; }
.track-actions .track-menu-btn::before { content: "..."; }
.track:hover .track-menu-btn, .track-menu-btn:focus-visible { opacity: 0.75; }
.track-actions .track-menu-btn:hover { opacity: 1; background: #444; }

/* Track selection */
.track-checkmark { color: #4e8; font-weight: bold; margin-right: 0.4rem; font-size: 0.85rem; }
.track.selected { background: #2a3a4a; }
.track.dragging { opacity: 0.5; }
/* Allow drop events to pass through to parent track element */
.track > * { pointer-events: none; }
.track > .track-actions { pointer-events: auto; }
.track > .track-actions > * { pointer-events: auto; }
.track.drop-above::before { content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 2px; background: #4e8; border-radius: 2px; }
.track.drop-below::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: #4e8; border-radius: 2px; }
#queue.drop-target, #queue .drop-zone, #playlist-tracks.drop-target { border: 2px dashed #4e8; border-radius: 4px; }
#queue .drop-zone { padding: 1.5rem; text-align: center; color: #4e8; }

/* Context menu */
.context-menu { position: fixed; background: #222; border: 1px solid #444; border-radius: 5px; padding: 0.2rem 0; z-index: 1000; min-width: 130px; box-shadow: 0 4px 12px rgba(0,0,0,0.6); }
.context-menu-item { padding: 0.4rem 0.75rem; cursor: pointer; font-size: 0.8rem; display: flex; align-items: center; gap: 0.4rem; }
.context-menu-item:hover { background: #333; }
.context-menu-item.danger { color: #e44; }
.context-menu-item.danger:hover { background: #3a2a2a; }

/* Player bar */
#player-bar { background: #1a1a1a; border-radius: 6px; padding: 0.5rem 0.75rem; display: flex; gap: 0.75rem; align-items: center; min-width: 0; max-width: 100%; overflow-x: hidden; }
#now-playing { width: 180px; flex: 0 1 180px; min-width: 0; }
#channel-name { font-size: 0.7rem; color: #666; margin-bottom: 0.1rem; }
#track-name { font-size: 0.9rem; font-weight: 600; overflow: hidden; position: relative; min-width: 0; }
#track-name .marquee-inner { display: inline-block; white-space: nowrap; }
#track-name.scrolling .marquee-inner { animation: scroll-marquee 8s linear infinite; }
@keyframes scroll-marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
#player-controls { flex: 1 1 auto; min-width: 0; }
#progress-row { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.2rem; }
#progress-row.denied { animation: flash-red 0.5s ease-out; }
@keyframes flash-red { 0% { background: #e44; } 100% { background: transparent; } }
#btn-sync { font-size: 0.7rem; cursor: pointer; color: #666; transition: color 0.2s, text-shadow 0.2s; letter-spacing: 0.05em; }
#btn-sync:hover { color: #888; }
#btn-sync.synced { color: #eb0; text-shadow: 0 0 8px #eb0, 0 0 12px #eb0; }
#btn-sync.synced.connected { color: #4e8; text-shadow: 0 0 8px #4e8, 0 0 12px #4e8; }
#btn-prev, #btn-next { font-size: 0.75rem; cursor: pointer; opacity: 0.6; transition: opacity 0.2s; }
#btn-prev:hover, #btn-next:hover { opacity: 1; }
#btn-mode { font-size: 0.7rem; cursor: pointer; transition: color 0.2s, text-shadow 0.2s; letter-spacing: 0.05em; padding: 0.1rem 0.3rem; border-radius: 3px; }
#btn-mode.mode-once { color: #888; text-shadow: none; }
#btn-mode.mode-repeat-all { color: #4e8; text-shadow: 0 0 6px #4e8; }
#btn-mode.mode-repeat-one { color: #eb0; text-shadow: 0 0 6px #eb0; }
#btn-mode.mode-shuffle { color: #c4f; text-shadow: 0 0 6px #c4f; }
#btn-mode:hover { opacity: 0.8; }
#status-icon { font-size: 0.85rem; width: 1rem; text-align: center; cursor: pointer; }
.control-disabled { opacity: 0.45 !important; cursor: not-allowed !important; }
#progress-container { background: #222; border-radius: 4px; height: 5px; cursor: pointer; position: relative; flex: 1; min-width: 0; }
#progress-bar { background: #555; height: 100%; border-radius: 4px; width: 0%; transition: width 0.3s linear; pointer-events: none; }
#progress-bar.playing.synced { background: #4e8; }
#progress-bar.playing.local { background: #c4f; }
#progress-bar.muted { background: #555 !important; }
#seek-tooltip { position: absolute; bottom: 10px; background: #333; color: #eee; padding: 2px 5px; border-radius: 3px; font-size: 0.7rem; pointer-events: none; display: none; transform: translateX(-50%); }
#time { font-size: 0.75rem; color: #aaa; margin: 0; line-height: 1; white-space: nowrap; }
#buffer-bar { display: flex; gap: 1px; margin-bottom: 0.2rem; }
#buffer-bar .segment { flex: 1; height: 2px; background: #333; border-radius: 1px; }
#buffer-bar .segment.available { background: #396; }
#buffer-bar .segment.loading { background: #666; animation: throb 0.6s ease-in-out infinite alternate; }
@keyframes throb { from { background: #444; } to { background: #888; } }
#download-speed { font-size: 0.6rem; color: #888; text-align: right; }
#volume-controls { display: flex; gap: 0.4rem; align-items: center; min-width: 0; }
#btn-stream-only { font-size: 0.7rem; cursor: pointer; color: #666; transition: color 0.2s, text-shadow 0.2s; letter-spacing: 0.05em; }
#btn-stream-only:hover { color: #888; }
#btn-stream-only.active { color: #4af; text-shadow: 0 0 6px #4af; }
#btn-mute { font-size: 1rem; cursor: pointer; opacity: 0.8; transition: opacity 0.2s; }
#btn-mute:hover { opacity: 1; }
#volume { width: 120px; accent-color: #4e8; }

/* Common */
button { background: #222; color: #eee; border: 1px solid #333; padding: 0.4rem 1rem; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
button:hover { background: #333; }
.hidden { display: none !important; }
#status { margin-top: 0.3rem; font-size: 0.75rem; color: #888; text-align: center; }
.empty { color: #999; font-style: italic; font-size: 0.85rem; }

/* Login panel */
#login-panel { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.5rem; background: #1a1a1a; border-radius: 6px; border: 1px solid #333; max-width: 360px; margin: auto; }
#login-panel.hidden { display: none; }
#login-panel h2 { font-size: 1rem; color: #888; margin-bottom: 0.3rem; }
#login-panel .tabs { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
#login-panel .tabs button { background: none; border: none; color: #666; font-size: 0.9rem; cursor: pointer; padding: 0.4rem 0; border-bottom: 2px solid transparent; }
#login-panel .tabs button.active { color: #4e8; border-bottom-color: #4e8; }
#login-panel input { background: #222; color: #eee; border: 1px solid #333; padding: 0.5rem; border-radius: 4px; font-size: 0.9rem; }
#login-panel .form-group { display: flex; flex-direction: column; gap: 0.4rem; }
#login-panel .form-group.hidden { display: none; }
#login-panel .submit-btn { background: #4e8; color: #111; border: none; padding: 0.5rem; border-radius: 4px; font-size: 0.9rem; cursor: pointer; font-weight: 600; }
#login-panel .submit-btn:hover { background: #5fa; }
#auth-error, #signup-error { color: #e44; font-size: 0.75rem; }
#guest-section { margin-top: 0.75rem; }
#guest-section.hidden { display: none; }
#guest-section .divider { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; color: #666; font-size: 0.8rem; }
#guest-section .divider::before, #guest-section .divider::after { content: ""; flex: 1; height: 1px; background: #333; }
#guest-section .guest-btn { width: 100%; background: #333; color: #eee; border: 1px solid #444; padding: 0.5rem; border-radius: 4px; font-size: 0.9rem; cursor: pointer; }
#guest-section .guest-btn:hover { background: #444; }

#player-content { display: none; flex-direction: column; flex: 1; }
#player-content.visible { display: flex; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background-color: #111; border-radius: 3px; }
::-webkit-scrollbar-thumb { background-color: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background-color: #555; }

/* Toast notifications */
#toast-container { position: fixed; top: 0.5rem; right: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; z-index: 1000; pointer-events: none; max-width: 320px; max-height: 50vh; overflow-y: auto; }
.toast { background: #1a3a2a; color: #4e8; padding: 0.5rem 0.75rem; border-radius: 5px; border: 1px solid #4e8; box-shadow: 0 4px 12px rgba(0,0,0,0.4); font-size: 0.8rem; animation: toast-in 0.3s ease-out; max-width: 280px; }
.toast.toast-warning { background: #3a3a1a; color: #ea4; border-color: #ea4; }
.toast.toast-error { background: #3a1a1a; color: #e44; border-color: #e44; }
.toast-confirm { pointer-events: auto; color: #eee; max-width: 320px; }
.toast-confirm-message { display: block; margin-bottom: 0.5rem; line-height: 1.35; }
.toast-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.toast-actions button { padding: 0.3rem 0.65rem; font-size: 0.75rem; min-height: 32px; }
.toast-action-confirm { background: #4e8; border-color: #4e8; color: #111; font-weight: 600; }
.toast-action-cancel { background: #222; border-color: #555; color: #ddd; }
.toast.fade-out { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-20px); } }

/* Toast history panel */
#btn-history { position: fixed; bottom: 0.5rem; left: 0.5rem; background: #222; border: 1px solid #333; color: #888; padding: 0.3rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.7rem; z-index: 999; }
#btn-history:hover { background: #333; color: #ccc; }
#toast-history { position: fixed; bottom: 3rem; left: 0.5rem; width: 320px; max-height: 400px; background: #1a1a1a; border: 1px solid #333; border-radius: 6px; z-index: 1001; display: flex; flex-direction: column; }
#toast-history.hidden { display: none; }
.history-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; border-bottom: 1px solid #333; color: #888; font-size: 0.8rem; }
.history-header button { background: none; border: none; color: #888; cursor: pointer; font-size: 1rem; padding: 0; width: 20px; height: 20px; }
.history-header button:hover { color: #ccc; }
#toast-history-list { flex: 1; overflow-y: auto; padding: 0.3rem; max-height: 350px; }
.history-item { padding: 0.3rem 0.5rem; font-size: 0.75rem; border-radius: 3px; margin-bottom: 0.2rem; color: #4e8; background: #1a2a1a; }
.history-item.history-warning { color: #ea4; background: #2a2a1a; }
.history-item.history-error { color: #e44; background: #2a1a1a; }
.history-time { color: #666; margin-right: 0.4rem; }

/* Playlists UI */
.playlists-container { display: flex; flex: 1; min-height: 0; gap: 0.5rem; }
#playlists-list-panel { width: 180px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; }
#playlist-contents-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.playlists-section { margin-bottom: 0.5rem; }
.playlists-section h4 { color: #666; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; padding: 0 0.3rem; }
.playlist-item { padding: 0.3rem 0.5rem; border-radius: 4px; cursor: pointer; font-size: 0.8rem; display: flex; align-items: center; gap: 0.3rem; }
.playlist-item:hover { background: #2a2a2a; }
.playlist-item.selected { background: #2a4a3a; }
.playlist-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-owner { color: #666; font-size: 0.7rem; }
.playlist-count { color: #666; font-size: 0.7rem; background: #333; padding: 0.1rem 0.3rem; border-radius: 3px; }
.empty-playlists { color: #555; font-size: 0.75rem; padding: 0.5rem; font-style: italic; }
.new-playlist-btn { width: 100%; padding: 0.4rem 0.5rem; background: #252525; border: 1px dashed #444; border-radius: 4px; color: #888; font-size: 0.8rem; cursor: pointer; margin-top: auto; }
.new-playlist-btn:hover { background: #2a2a2a; border-color: #4e8; color: #4e8; }
.new-playlist-input, .playlist-rename-input { width: 100%; padding: 0.3rem 0.5rem; background: #222; border: 1px solid #4e8; border-radius: 4px; color: #eee; font-size: 0.8rem; margin-bottom: 0.3rem; outline: none; }
#playlist-contents-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; padding: 0.3rem; background: #252525; border-radius: 4px; }
#selected-playlist-name { font-size: 0.9rem; font-weight: 600; color: #eee; }
#playlist-actions { display: flex; gap: 0.3rem; }
#playlist-actions.hidden { display: none; }
#playlist-actions button { padding: 0.2rem 0.5rem; font-size: 0.75rem; background: #333; border: 1px solid #444; border-radius: 3px; color: #aaa; cursor: pointer; }
#playlist-actions button:hover { background: #444; color: #eee; }
#playlist-tracks { flex: 1; overflow-y: auto; }
.playlist-track { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 0.8rem; cursor: pointer; }
.playlist-track:hover { background: #2a2a2a; }
.playlist-track .track-number { color: #555; font-size: 0.7rem; min-width: 1.5rem; }
.playlist-track .track-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-track .track-duration { color: #666; font-size: 0.75rem; }
.empty-playlist-tracks { color: #555; font-size: 0.8rem; padding: 1rem; text-align: center; font-style: italic; }
.context-menu-separator { height: 1px; background: #333; margin: 0.2rem 0; }
.context-menu-item.has-submenu { position: relative; }
.context-submenu { position: absolute; display: none; top: -4px; left: calc(100% - 8px); padding-left: 8px; background: transparent; min-width: 120px; z-index: 1001; }
.context-submenu-inner { background: #222; border: 1px solid #444; border-radius: 4px; padding: 0.2rem 0; }
.context-menu-item.has-submenu:hover > .context-submenu { display: block; }
.context-submenu .context-menu-item { padding: 0.4rem 0.75rem; }
.context-menu-item.disabled { color: #666; cursor: default; }
.context-menu-item.disabled:hover { background: transparent; }

/* Mobile tab bar - hidden on desktop */
#mobile-tabs { display: none; }

/* Medium-width layout: keep the queue closer to the user's hand */
@media (max-width: 1180px) {
  #main-content {
    max-width: 100%;
  }

  #channels-panel {
    flex-basis: 145px;
  }

  #queue-panel {
    order: 2;
    flex-grow: 1.12;
  }

  #library-panel {
    order: 3;
  }

  #player-bar {
    flex-wrap: wrap;
  }

  #now-playing {
    flex: 1 1 180px;
  }

  #player-controls {
    flex: 999 1 420px;
  }

  #volume-controls {
    flex: 0 1 180px;
    margin-left: auto;
  }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  html, body { 
    height: 100%; 
    overflow: hidden; 
  }
  #app { 
    padding: 0.3rem; 
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }
  #player-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  
  /* Header */
  #site-header { margin-bottom: 0.3rem; flex-shrink: 0; }
  #site-header h1 { font-size: 0.9rem; }
  #btn-report-bug { font-size: 0.7rem; padding: 0.2rem 0.4rem; }
  #btn-logout.guest-signin { min-height: 44px; }
  
  #header-row { flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.3rem; flex-shrink: 0; }
  #auth-section .user-info { flex-wrap: wrap; gap: 0.3rem; }
  #btn-kick-others { display: none; }
  
  /* Mobile tab bar */
  #mobile-tabs { 
    display: flex; 
    gap: 2px; 
    margin-bottom: 0.3rem;
    background: #1a1a1a;
    border-radius: 6px;
    padding: 3px;
    flex-shrink: 0;
  }
  .mobile-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #666;
    font-size: 0.8rem;
    font-weight: 600;
    min-height: 44px;
    padding: 0.65rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
  }
  .mobile-tab:hover { color: #888; }
  .mobile-tab.active { 
    background: #4e8; 
    color: #111; 
  }
  
  /* Main content - single column, fixed height for scroll */
  #main-content { 
    flex-direction: column; 
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    margin: 0;
  }
  
  /* Panels - only show active one on mobile */
  #channels-panel, #library-panel, #queue-panel { 
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: none;
    min-height: 0;
    display: none;
    overflow: hidden;
  }
  #channels-panel.mobile-active,
  #library-panel.mobile-active,
  #queue-panel.mobile-active { 
    display: flex; 
  }
  
  /* Library panel - fixed header, scrollable content */
  #library-panel .panel-tabs {
    flex-shrink: 0;
  }
  #library-panel .panel-tab {
    min-height: 44px;
  }
  #library-panel .panel-views {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    width: 100%;
  }
  #library-panel .panel-view.active {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    width: 100%;
  }
  #library-panel .panel-header {
    flex-shrink: 0;
  }
  #library {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    width: 100%;
  }
  .add-btn {
    flex-shrink: 0;
    width: auto;
    align-self: stretch;
  }
  
  /* Queue panel - fixed header, scrollable content */
  #queue-panel #queue-title,
  #queue-panel #now-playing-bar {
    flex-shrink: 0;
  }
  #queue {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  
  /* Channels panel - scrollable list */
  #channels-panel #channels-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  
  /* Channel list - larger touch targets */
  #channels-list .channel-item { padding: 0.4rem; }
  #channels-list .channel-header { padding: 0.3rem 0; min-height: 44px; }
  #channels-list .channel-name { font-size: 0.9rem; }
  #channels-list .btn-rename-channel,
  #channels-list .btn-delete-channel { 
    opacity: 0.7; 
    font-size: 1rem;
    padding: 0.3rem;
  }
  
  /* Library/Queue - larger items */
  .track { padding: 0.5rem 0.4rem; min-height: 44px; }
  .track-title { font-size: 0.85rem; }
  
  /* Player bar - stacked layout */
  #player-bar { 
    flex-direction: column; 
    gap: 0.4rem; 
    padding: 0.4rem;
    position: sticky;
    bottom: 0;
    z-index: 100;
    margin: 0 -0.3rem -0.3rem -0.3rem;
    border-radius: 6px 6px 0 0;
  }
  #now-playing { 
    width: 100%; 
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  #channel-name { display: none; }
  #track-name { 
    flex: 1; 
    font-size: 0.85rem;
  }
  #player-controls { width: 100%; flex: 0 0 auto; }
  #progress-row {
    display: grid;
    grid-template-columns: minmax(42px, auto) 44px 44px 44px minmax(58px, auto);
    grid-template-areas:
      "sync prev play next mode"
      "progress progress progress progress time";
    gap: 0.25rem 0.35rem;
    align-items: center;
  }
  #btn-sync {
    grid-area: sync;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  #btn-prev { grid-area: prev; }
  #status-icon { grid-area: play; }
  #btn-next { grid-area: next; }
  #btn-mode {
    grid-area: mode;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #progress-container {
    grid-area: progress;
    width: 100%;
    min-width: 0;
    height: 8px;
  }
  #time {
    grid-area: time;
    text-align: right;
  }
  #status-icon { 
    font-size: 1.2rem; 
    width: 44px; 
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #btn-prev, #btn-next { 
    font-size: 1rem; 
    padding: 0.3rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #btn-sync, #btn-mode { 
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
  }
  #volume-controls { 
    flex: 0 0 auto;
    justify-content: center;
    gap: 0.3rem;
    width: 100%;
    margin-left: 0;
  }
  #btn-stream-only { display: none; }
  #btn-mute {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #volume { width: min(160px, 55vw); height: 44px; }
  .track-actions .track-menu-btn {
    opacity: 1;
    width: 44px;
    height: 44px;
    font-size: 1rem;
    background: #2a2a2a;
  }
  
  /* Hide history button on mobile */
  #btn-history { display: none; }
  
  /* Toast positioning */
  #toast-container { 
    top: auto;
    bottom: calc(9.25rem + env(safe-area-inset-bottom));
    left: 0.3rem;
    right: 0.3rem;
    max-width: none;
    max-height: 30vh;
  }
  .toast { max-width: none; }
  
  /* Login panel */
  #login-panel { padding: 1rem; }
}

/* Theme selector */
#stream-select { margin-left: auto; }
#theme-select { min-width: 170px; }

/* Shared theme surfaces */
body[data-ui-theme]:not([data-ui-theme="default"]) #channels-panel,
body[data-ui-theme]:not([data-ui-theme="default"]) #library-panel,
body[data-ui-theme]:not([data-ui-theme="default"]) #queue-panel,
body[data-ui-theme]:not([data-ui-theme="default"]) #player-bar,
body[data-ui-theme]:not([data-ui-theme="default"]) #login-panel,
body[data-ui-theme]:not([data-ui-theme="default"]) .panel-views,
body[data-ui-theme]:not([data-ui-theme="default"]) #playlist-contents-header,
body[data-ui-theme]:not([data-ui-theme="default"]) .context-menu,
body[data-ui-theme]:not([data-ui-theme="default"]) #toast-history {
  background: var(--panel-bg, #1a1a1a);
  border-color: var(--panel-border, #333);
  color: var(--text-color, #eee);
}

body[data-ui-theme]:not([data-ui-theme="default"]) #site-header h1,
body[data-ui-theme]:not([data-ui-theme="default"]) h3,
body[data-ui-theme]:not([data-ui-theme="default"]) .panel-tab.active,
body[data-ui-theme]:not([data-ui-theme="default"]) #selected-playlist-name {
  color: var(--heading-color, var(--text-color, #eee));
}

body[data-ui-theme]:not([data-ui-theme="default"]) button,
body[data-ui-theme]:not([data-ui-theme="default"]) select,
body[data-ui-theme]:not([data-ui-theme="default"]) input,
body[data-ui-theme]:not([data-ui-theme="default"]) .panel-tab,
body[data-ui-theme]:not([data-ui-theme="default"]) .track-actions .track-menu-btn,
body[data-ui-theme]:not([data-ui-theme="default"]) .track-actions .track-play-btn,
body[data-ui-theme]:not([data-ui-theme="default"]) .track-actions .track-preview-btn {
  background: var(--control-bg, #222);
  border-color: var(--control-border, #444);
  color: var(--control-color, var(--text-color, #eee));
}

body[data-ui-theme]:not([data-ui-theme="default"]) .track:hover,
body[data-ui-theme]:not([data-ui-theme="default"]) .playlist-item:hover,
body[data-ui-theme]:not([data-ui-theme="default"]) .context-menu-item:hover {
  background: var(--hover-bg, #222);
}

body[data-ui-theme]:not([data-ui-theme="default"]) #queue .track.active,
body[data-ui-theme]:not([data-ui-theme="default"]) .playlist-item.selected,
body[data-ui-theme]:not([data-ui-theme="default"]) .mobile-tab.active,
body[data-ui-theme]:not([data-ui-theme="default"]) .now-playing-bar,
body[data-ui-theme]:not([data-ui-theme="default"]) .toast {
  background: var(--active-bg, #2a4a3a);
  border-color: var(--accent, #4e8);
  color: var(--active-color, var(--accent, #4e8));
}

body[data-ui-theme]:not([data-ui-theme="default"]) .track.cached .cache-indicator,
body[data-ui-theme]:not([data-ui-theme="default"]) #progress-bar.playing.synced,
body[data-ui-theme]:not([data-ui-theme="default"]) #buffer-bar .segment.available,
body[data-ui-theme]:not([data-ui-theme="default"]) #sync-indicator.visible {
  background: var(--accent, #4e8);
}

body[data-ui-theme]:not([data-ui-theme="default"]) .track.not-cached .cache-indicator,
body[data-ui-theme]:not([data-ui-theme="default"]) #btn-sync.synced,
body[data-ui-theme]:not([data-ui-theme="default"]) .toast.toast-warning {
  color: var(--warning, #ea4);
}

body[data-ui-theme="phosphor"] {
  --panel-bg: #07140f;
  --panel-border: #1f7a48;
  --text-color: #caf7d9;
  --heading-color: #73ff9c;
  --control-bg: #0b1f17;
  --control-border: #24965a;
  --control-color: #dfffe8;
  --hover-bg: #123321;
  --active-bg: #123d29;
  --active-color: #8cffad;
  --accent: #51f080;
  --warning: #f5de72;
  background: #020806;
  color: var(--text-color);
}

body[data-ui-theme="phosphor"] #app { filter: drop-shadow(0 0 8px rgba(81, 240, 128, 0.12)); }
body[data-ui-theme="phosphor"] #track-name,
body[data-ui-theme="phosphor"] #btn-sync.synced.connected { text-shadow: 0 0 10px rgba(81, 240, 128, 0.55); }

body[data-ui-theme="vaporwave"] {
  --panel-bg: #21123a;
  --panel-border: #ff71ce;
  --text-color: #f8d7ff;
  --heading-color: #05ffa1;
  --control-bg: #351a54;
  --control-border: #b967ff;
  --control-color: #ffffff;
  --hover-bg: #46206d;
  --active-bg: #2d567a;
  --active-color: #05ffa1;
  --accent: #01cdfe;
  --warning: #fffb96;
  background: linear-gradient(135deg, #12091f 0%, #2f1856 46%, #0b4857 100%);
  color: var(--text-color);
}

body[data-ui-theme="vaporwave"] #main-content { gap: 0.8rem; }
body[data-ui-theme="vaporwave"] #channels-panel,
body[data-ui-theme="vaporwave"] #library-panel,
body[data-ui-theme="vaporwave"] #queue-panel,
body[data-ui-theme="vaporwave"] #player-bar { box-shadow: 0 0 22px rgba(1, 205, 254, 0.2), inset 0 0 0 1px rgba(255, 113, 206, 0.22); }

body[data-ui-theme="sunrise"] {
  --panel-bg: #241b2d;
  --panel-border: #f18f01;
  --text-color: #fff0d4;
  --heading-color: #ffcf56;
  --control-bg: #3a2340;
  --control-border: #f45d48;
  --control-color: #fff7e8;
  --hover-bg: #50314f;
  --active-bg: #5f342e;
  --active-color: #ffd166;
  --accent: #ff9f1c;
  --warning: #2ec4b6;
  background: radial-gradient(circle at 20% 0%, #7a2f5c 0, #2b1838 45%, #101018 100%);
  color: var(--text-color);
}

body[data-ui-theme="paper"] {
  --panel-bg: #f4efe3;
  --panel-border: #3b3327;
  --text-color: #1d1a17;
  --heading-color: #0b0b0b;
  --control-bg: #fffaf0;
  --control-border: #5a4a36;
  --control-color: #1d1a17;
  --hover-bg: #e5d8bd;
  --active-bg: #d9c69f;
  --active-color: #1d1a17;
  --accent: #285f47;
  --warning: #a75a00;
  background: #d7c9aa;
  color: var(--text-color);
}

body[data-ui-theme="paper"] #channels-panel,
body[data-ui-theme="paper"] #library-panel,
body[data-ui-theme="paper"] #queue-panel,
body[data-ui-theme="paper"] #player-bar {
  border: 1px solid var(--panel-border);
  box-shadow: 4px 4px 0 #3b3327;
}

body[data-ui-theme="contrast"] {
  --panel-bg: #000;
  --panel-border: #fff;
  --text-color: #fff;
  --heading-color: #ffff00;
  --control-bg: #000;
  --control-border: #fff;
  --control-color: #fff;
  --hover-bg: #202020;
  --active-bg: #ffff00;
  --active-color: #000;
  --accent: #00ffff;
  --warning: #ff00ff;
  background: #000;
  color: #fff;
}

body[data-ui-theme="contrast"] #channels-panel,
body[data-ui-theme="contrast"] #library-panel,
body[data-ui-theme="contrast"] #queue-panel,
body[data-ui-theme="contrast"] #player-bar { border: 2px solid #fff; border-radius: 0; }

body[data-ui-theme="aquarium"] {
  --panel-bg: rgba(8, 42, 58, 0.86);
  --panel-border: #52e0c4;
  --text-color: #d7fff8;
  --heading-color: #a3fff1;
  --control-bg: #10394d;
  --control-border: #59bde0;
  --control-color: #ebfffb;
  --hover-bg: #174d62;
  --active-bg: #0d5f65;
  --active-color: #adfff0;
  --accent: #52e0c4;
  --warning: #ffd166;
  background: linear-gradient(180deg, #062c45, #03161d);
  color: var(--text-color);
}

body[data-ui-theme="aquarium"] #app { backdrop-filter: blur(2px); }
body[data-ui-theme="aquarium"] #channels-panel,
body[data-ui-theme="aquarium"] #library-panel,
body[data-ui-theme="aquarium"] #queue-panel,
body[data-ui-theme="aquarium"] #player-bar { border: 1px solid rgba(163, 255, 241, 0.42); }

body[data-ui-theme="amber"] {
  --panel-bg: #1b1204;
  --panel-border: #8c5d13;
  --text-color: #ffd98a;
  --heading-color: #ffb000;
  --control-bg: #2a1b06;
  --control-border: #b97919;
  --control-color: #ffe8ad;
  --hover-bg: #3a2508;
  --active-bg: #4c3109;
  --active-color: #ffc857;
  --accent: #ffb000;
  --warning: #f77f00;
  background: #080502;
  color: var(--text-color);
  font-family: "Cascadia Mono", "Consolas", monospace;
}

body[data-ui-theme="amber"] * { letter-spacing: 0; }
body[data-ui-theme="amber"] #track-name { text-transform: uppercase; }

body[data-ui-theme="compact"] {
  --panel-bg: #15181b;
  --panel-border: #35414a;
  --text-color: #e6edf3;
  --heading-color: #9fc7ff;
  --control-bg: #20262c;
  --control-border: #3e4d58;
  --control-color: #edf4fb;
  --hover-bg: #242c33;
  --active-bg: #22364b;
  --active-color: #9fc7ff;
  --accent: #79c0ff;
  --warning: #e3b341;
  background: #0d1117;
  color: var(--text-color);
}

body[data-ui-theme="compact"] #app { max-width: 1200px; padding: 0.25rem; }
body[data-ui-theme="compact"] #main-content { gap: 0.25rem; }
body[data-ui-theme="compact"] #channels-panel { flex-basis: 130px; }
body[data-ui-theme="compact"] #library-panel,
body[data-ui-theme="compact"] #queue-panel { padding: 0.25rem; max-height: 66vh; }
body[data-ui-theme="compact"] #library .track,
body[data-ui-theme="compact"] #queue .track,
body[data-ui-theme="compact"] #playlist-tracks .track { padding: 0.16rem 0.35rem; font-size: 0.78rem; }
body[data-ui-theme="compact"] #player-bar { padding: 0.35rem 0.5rem; }

body[data-ui-theme="cinema"] {
  --panel-bg: #101010;
  --panel-border: #41362a;
  --text-color: #e8dfcc;
  --heading-color: #f6c65b;
  --control-bg: #1f1a15;
  --control-border: #6d5735;
  --control-color: #f3ead7;
  --hover-bg: #292118;
  --active-bg: #3d2b18;
  --active-color: #f6c65b;
  --accent: #f6c65b;
  --warning: #db5461;
  background: #050505;
  color: var(--text-color);
}

body[data-ui-theme="cinema"] #main-content { display: grid; grid-template-columns: 150px minmax(280px, 0.8fr) minmax(420px, 1.45fr); }
body[data-ui-theme="cinema"] #queue-panel { order: 3; max-height: 70vh; }
body[data-ui-theme="cinema"] #queue .track.active { font-size: 1rem; padding: 0.65rem 0.75rem; }
body[data-ui-theme="cinema"] #player-bar { border-top: 4px solid var(--accent); }

body[data-ui-theme="hotdog"] {
  --panel-bg: #ffff00;
  --panel-border: #000000;
  --text-color: #000000;
  --heading-color: #ffff00;
  --control-bg: #ffffff;
  --control-border: #000000;
  --control-color: #000000;
  --hover-bg: #ff0000;
  --active-bg: #ff0000;
  --active-color: #ffffff;
  --accent: #ff0000;
  --warning: #000000;
  background: #ff0000;
  color: #000000;
  font-family: "MS Sans Serif", "Arial", sans-serif;
}

body[data-ui-theme="hotdog"] #site-header h1,
body[data-ui-theme="hotdog"] h3,
body[data-ui-theme="hotdog"] .panel-tab.active {
  background: #ff0000;
  color: #ffff00;
  padding: 0.1rem 0.25rem;
}

body[data-ui-theme="hotdog"] #channels-panel,
body[data-ui-theme="hotdog"] #library-panel,
body[data-ui-theme="hotdog"] #queue-panel,
body[data-ui-theme="hotdog"] #player-bar,
body[data-ui-theme="hotdog"] #login-panel,
body[data-ui-theme="hotdog"] .panel-views,
body[data-ui-theme="hotdog"] #toast-history,
body[data-ui-theme="hotdog"] .context-menu {
  border: 3px solid #000000;
  border-radius: 0;
  box-shadow: 5px 5px 0 #000000;
}

body[data-ui-theme="hotdog"] button,
body[data-ui-theme="hotdog"] select,
body[data-ui-theme="hotdog"] input,
body[data-ui-theme="hotdog"] .panel-tab,
body[data-ui-theme="hotdog"] .track-actions .track-menu-btn,
body[data-ui-theme="hotdog"] .track-actions .track-play-btn,
body[data-ui-theme="hotdog"] .track-actions .track-preview-btn {
  border: 2px outset #ffffff;
  border-radius: 0;
  font-weight: 700;
}

body[data-ui-theme="hotdog"] button:active,
body[data-ui-theme="hotdog"] .panel-tab.active {
  border-style: inset;
}

body[data-ui-theme="hotdog"] .panel-tab,
body[data-ui-theme="hotdog"] .track,
body[data-ui-theme="hotdog"] .playlist-item,
body[data-ui-theme="hotdog"] .context-menu-item,
body[data-ui-theme="hotdog"] .channel-item {
  border-radius: 0;
}

body[data-ui-theme="hotdog"] .track:hover,
body[data-ui-theme="hotdog"] .context-menu-item:hover,
body[data-ui-theme="hotdog"] .playlist-item:hover {
  color: #ffff00;
}

body[data-ui-theme="hotdog"] #queue .track.active,
body[data-ui-theme="hotdog"] .now-playing-bar,
body[data-ui-theme="hotdog"] .mobile-tab.active,
body[data-ui-theme="hotdog"] .toast {
  border: 2px solid #000000;
  text-transform: uppercase;
}

body[data-ui-theme="hotdog"] #progress-container,
body[data-ui-theme="hotdog"] #buffer-bar .segment {
  background: #ffffff;
  border: 1px solid #000000;
  border-radius: 0;
}

body[data-ui-theme="hotdog"] #progress-bar.playing.synced,
body[data-ui-theme="hotdog"] #buffer-bar .segment.available,
body[data-ui-theme="hotdog"] .track.cached .cache-indicator {
  background: #ff0000;
}

html[data-ui-theme="spreadsheet"],
html[data-ui-theme="myspace"],
html[data-ui-theme="sideways"] {
  max-width: none;
  overflow-x: auto;
  overscroll-behavior-x: auto;
}

html[data-ui-theme="spreadsheet"] { min-width: 2100px; }
html[data-ui-theme="myspace"] { min-width: 1850px; }
html[data-ui-theme="sideways"] { min-width: 2600px; }

body[data-ui-theme="spreadsheet"],
body[data-ui-theme="myspace"],
body[data-ui-theme="sideways"] {
  max-width: none;
  overflow-x: auto;
}

body[data-ui-theme="spreadsheet"] {
  --panel-bg: #ffffff;
  --panel-border: #8b8b8b;
  --text-color: #000000;
  --heading-color: #008000;
  --control-bg: #efefef;
  --control-border: #777777;
  --control-color: #000000;
  --hover-bg: #ffffcc;
  --active-bg: #00ff00;
  --active-color: #000000;
  --accent: #0000ff;
  --warning: #ff0000;
  background: #fff;
  color: #000;
  font-family: "Times New Roman", serif;
}

body[data-ui-theme="spreadsheet"] #app { width: 2100px; max-width: none; overflow-x: visible; }
body[data-ui-theme="spreadsheet"] #main-content { width: 2050px; max-width: none; overflow-x: visible; gap: 0; }
body[data-ui-theme="spreadsheet"] #channels-panel,
body[data-ui-theme="spreadsheet"] #library-panel,
body[data-ui-theme="spreadsheet"] #queue-panel,
body[data-ui-theme="spreadsheet"] #player-bar {
  border: 1px solid #000;
  border-radius: 0;
  box-shadow: none;
}
body[data-ui-theme="spreadsheet"] .track { border-bottom: 1px solid #999; border-radius: 0; }
body[data-ui-theme="spreadsheet"] #library,
body[data-ui-theme="spreadsheet"] #queue { overflow-x: scroll; }

body[data-ui-theme="myspace"] {
  --panel-bg: #220044;
  --panel-border: #00ff66;
  --text-color: #ffff00;
  --heading-color: #ff00ff;
  --control-bg: #0000cc;
  --control-border: #ffff00;
  --control-color: #ffffff;
  --hover-bg: #ff00ff;
  --active-bg: #00ffff;
  --active-color: #000000;
  --accent: #00ff66;
  --warning: #ff6600;
  background: repeating-linear-gradient(45deg, #ff00ff 0 18px, #00ffff 18px 36px, #ffff00 36px 54px);
  color: var(--text-color);
  font-family: Impact, "Arial Black", sans-serif;
}

body[data-ui-theme="myspace"] #app { width: 1850px; max-width: none; overflow-x: visible; transform: rotate(-0.35deg); }
body[data-ui-theme="myspace"] #main-content { width: 1780px; max-width: none; overflow-x: visible; gap: 1.25rem; }
body[data-ui-theme="myspace"] #channels-panel,
body[data-ui-theme="myspace"] #library-panel,
body[data-ui-theme="myspace"] #queue-panel,
body[data-ui-theme="myspace"] #player-bar {
  border: 6px ridge #00ff66;
  border-radius: 22px;
  box-shadow: 12px 12px 0 #ff00ff, -9px -7px 0 #00ffff;
}
body[data-ui-theme="myspace"] .track:nth-child(odd) { transform: rotate(0.45deg); }
body[data-ui-theme="myspace"] .track:nth-child(even) { transform: rotate(-0.45deg); }
body[data-ui-theme="myspace"] #track-name { font-size: 1.25rem; color: #00ff66; text-shadow: 2px 2px #ff00ff; }

body[data-ui-theme="sideways"] {
  --panel-bg: #241313;
  --panel-border: #cc3333;
  --text-color: #f8dcdc;
  --heading-color: #ff6b35;
  --control-bg: #351b1b;
  --control-border: #8c2f39;
  --control-color: #fff1f1;
  --hover-bg: #482121;
  --active-bg: #5a231f;
  --active-color: #ffb199;
  --accent: #ff6b35;
  --warning: #ffd166;
  background: #190b0b;
  color: var(--text-color);
}

body[data-ui-theme="sideways"] #app { width: 2600px; max-width: none; overflow-x: visible; }
body[data-ui-theme="sideways"] #main-content {
  width: 2480px;
  max-width: none;
  display: grid;
  grid-template-columns: 260px 1060px 1060px;
  overflow-x: visible;
}
body[data-ui-theme="sideways"] #channels-panel,
body[data-ui-theme="sideways"] #library-panel,
body[data-ui-theme="sideways"] #queue-panel { max-height: 42vh; }
body[data-ui-theme="sideways"] #player-bar { width: 2480px; max-width: none; }

@media (max-width: 768px) {
  #stream-select { width: 100%; margin-left: 0; }
  #theme-select { width: 100%; min-height: 44px; }

  body[data-ui-theme="compact"] #app,
  body[data-ui-theme="cinema"] #app {
    max-width: 100%;
  }

  body[data-ui-theme="cinema"] #main-content {
    display: flex;
    grid-template-columns: none;
  }
}
