:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1c1e22; --muted: #6a707b; --line: #dde0e6;
  --accent: #5b4bdb; --accent-text: #fff; --danger: #c93a3a; --sel: #5b4bdb33;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14151a; --surface: #1d1f26; --text: #e8e9ee; --muted: #9298a5; --line: #2e313b; --accent: #8b7dff; --accent-text: #11111a; --danger: #ef6b6b; --sel: #8b7dff33; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input, select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); min-height: 1.4em; }

header { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
header h1 { font-size: 17px; margin: 0 8px 0 0; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { border: none; background: none; border-radius: 8px; }
nav button.active { background: var(--sel); font-weight: 600; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.center { max-width: 360px; margin: 12vh auto; display: grid; gap: 12px; }
.center input { width: 100%; }

.library { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
@media (max-width: 760px) { .library { grid-template-columns: 1fr; } }
.albums { display: grid; gap: 4px; align-content: start; }
.albums button { text-align: left; display: flex; justify-content: space-between; gap: 8px; }
.albums button.active { background: var(--sel); border-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.tile.selected { border-color: var(--accent); }
.tile.dragover { border-color: var(--danger); }
.tile img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: var(--line); }
.tile .cap { padding: 4px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile input[type=checkbox] { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 24px; text-align: center; color: var(--muted); margin-bottom: 12px; }
.drop.over { border-color: var(--accent); color: var(--text); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td img { height: 48px; border-radius: 6px; vertical-align: middle; margin-right: 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 20px; max-width: min(92vw, 520px); }
dialog::backdrop { background: #0008; }
dialog img.preview { width: 100%; max-height: 50vh; object-fit: contain; background: var(--bg); border-radius: 8px; }
dialog .form { display: grid; gap: 10px; margin-top: 12px; }
dialog label { display: flex; gap: 8px; align-items: center; }
.code { font: 700 28px/1 ui-monospace, monospace; letter-spacing: 2px; text-align: center; padding: 16px; background: var(--bg); border-radius: 10px; }
