:root { color-scheme: light dark; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #0f0f0f; color: #f1f1f1; }
.topbar { display: flex; gap: 1rem; align-items: center; padding: 0.8rem 1rem; background: #212121; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.2rem; white-space: nowrap; }
.brand span { color: #3ea6ff; }
.search { display: flex; flex: 1; min-width: 240px; max-width: 720px; }
.search input { flex: 1; padding: 0.6rem 0.8rem; border-radius: 20px 0 0 20px; border: 1px solid #444; background: #121212; color: inherit; outline: none; }
.search button { padding: 0 1.2rem; border: 1px solid #444; border-left: 0; background: #3d3d3d; color: inherit; cursor: pointer; white-space: nowrap; }
.search button[type="submit"] { border-radius: 0; }
.search button:last-child { border-radius: 0 20px 20px 0; }
.search button:hover { background: #4d4d4d; }
.hint { font-size: 0.85rem; opacity: 0.8; }
.hint code { background: #111; padding: 0.1rem 0.4rem; border-radius: 4px; }
.layout { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.player.hidden { display: none; }
.player-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.player-wrap iframe { width: 100%; height: 100%; border: 0; }
.now-playing { display: flex; justify-content: space-between; gap: 1rem; margin: 0.8rem 0 1.2rem; flex-wrap: wrap; }
.now-playing h2 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.now-playing p { margin: 0; opacity: 0.75; font-size: 0.9rem; }
.player-actions { display: flex; gap: 0.6rem; align-items: start; }
.player-actions a, .player-actions button { padding: 0.5rem 0.9rem; border-radius: 20px; border: 1px solid #444; background: #212121; color: inherit; cursor: pointer; text-decoration: none; font-size: 0.9rem; }
.status { margin: 0.6rem 0; opacity: 0.85; min-height: 1.4em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card { background: #212121; border-radius: 12px; overflow: hidden; cursor: pointer; border: 1px solid transparent; text-align: left; padding: 0; color: inherit; font: inherit; }
.card:hover, .card:focus-visible { border-color: #3ea6ff; outline: none; }
.thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.85); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.78rem; }
.card-body { padding: 0.7rem 0.8rem 0.9rem; }
.card-body h3 { margin: 0 0 0.35rem; font-size: 0.95rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-body p { margin: 0; font-size: 0.82rem; opacity: 0.75; }
.footer { text-align: center; padding: 1.5rem 1rem 2rem; opacity: 0.7; font-size: 0.85rem; }
.footer a { color: #3ea6ff; }
@media (max-width: 600px) { .hint { display: none; } }

/* Tabs */
.tabs { display: flex; gap: 0.5rem; padding: 0.6rem 1rem 0; background: #0f0f0f; max-width: 1200px; margin: 0 auto; }
.tab { padding: 0.5rem 1.1rem; border-radius: 20px; border: 1px solid #444; background: #212121; color: inherit; cursor: pointer; font-size: 0.95rem; }
.tab.active { background: #3ea6ff; border-color: #3ea6ff; color: #06121f; font-weight: 700; }
.pill { display: inline-block; min-width: 1.4em; text-align: center; background: rgba(127,127,127,.35); border-radius: 10px; padding: 0 0.4em; font-size: 0.8em; margin-left: 0.3em; }
.tab.active .pill { background: rgba(0,0,0,.25); }

/* Save button on result thumbnails */
.save-btn { position: absolute; top: 6px; right: 6px; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid #666; background: rgba(0,0,0,.72); color: #ffd60a; font-size: 1rem; line-height: 1; cursor: pointer; }
.save-btn:hover { background: rgba(0,0,0,.9); border-color: #ffd60a; }

/* Favorites manager */
.hidden { display: none !important; }
.fav-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 760px) { .fav-layout { grid-template-columns: 1fr; } }
.fav-lists { background: #212121; border-radius: 12px; padding: 0.9rem; }
.fav-lists h2, .fav-items-pane h2 { margin: 0 0 0.7rem; font-size: 1.05rem; }
.fav-list-ul { list-style: none; margin: 0 0 0.9rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.fav-list-row { display: flex; gap: 0.3rem; align-items: center; border-radius: 8px; padding: 0.15rem; }
.fav-list-row.active { background: #333; }
.fav-list-open { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; background: none; border: 0; color: inherit; cursor: pointer; padding: 0.45rem 0.5rem; border-radius: 8px; font-size: 0.95rem; text-align: left; }
.fav-list-open:hover { background: #2c2c2c; }
.fav-list-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 1px solid transparent; color: inherit; cursor: pointer; border-radius: 6px; padding: 0.25rem 0.4rem; font-size: 0.95rem; opacity: 0.8; }
.icon-btn:hover { opacity: 1; border-color: #555; background: #2c2c2c; }
.icon-btn.danger:hover { border-color: #e5534b; color: #ff7b72; }
.icon-btn.lock { cursor: default; opacity: 0.6; }
.rename-input { flex: 1; min-width: 0; padding: 0.35rem 0.5rem; border-radius: 6px; border: 1px solid #3ea6ff; background: #121212; color: inherit; }
.new-list-form { display: flex; gap: 0.4rem; }
.new-list-form input { flex: 1; min-width: 0; padding: 0.5rem 0.6rem; border-radius: 8px; border: 1px solid #444; background: #121212; color: inherit; }
.new-list-form button { padding: 0 0.9rem; border-radius: 8px; border: 1px solid #444; background: #3d3d3d; color: inherit; cursor: pointer; }
.new-list-form button:hover { background: #4d4d4d; }
.fav-item-actions { display: flex; gap: 0.4rem; align-items: center; padding: 0 0.8rem 0.8rem; }
.move-select { flex: 1; min-width: 0; padding: 0.35rem; border-radius: 6px; border: 1px solid #444; background: #121212; color: inherit; font-size: 0.85rem; }

/* Save-to-list picker popup */
.picker { position: absolute; z-index: 50; width: 220px; background: #262626; border: 1px solid #555; border-radius: 10px; padding: 0.4rem; box-shadow: 0 8px 24px rgba(0,0,0,.6); }
.picker-title { font-size: 0.8rem; opacity: 0.7; padding: 0.3rem 0.5rem; }
.picker-status { padding: 0.5rem; font-size: 0.85rem; opacity: 0.8; }
.picker-item { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; width: 100%; background: none; border: 0; color: inherit; cursor: pointer; padding: 0.55rem 0.5rem; border-radius: 6px; font-size: 0.9rem; text-align: left; }
.picker-item:hover { background: #3a3a3a; }

/* Toast */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #333; border: 1px solid #555; color: #f1f1f1; padding: 0.6rem 1.1rem; border-radius: 20px; z-index: 100; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
