:root {
  --bg: #121214;
  --surface: #1c1c20;
  --surface-2: #26262c;
  --border: #33333a;
  --text: #ececf0;
  --muted: #9a9aa6;
  --accent: #ff7a45;
  --accent-ink: #1a0d06;
  --genre: #5aa9ff;
  --group: #b98cff;
  --danger: #ff5c6c;
  --ok: #4fd18b;
  --radius: 12px;
  --tabbar-h: 60px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
#view { max-width: 760px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 24px; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
input, select, textarea { width: 100%; min-width: 0; }
input[type="checkbox"] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--danger); background: transparent; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
label.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; gap: 12px; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
}
.item:active { background: var(--surface-2); }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex: none; }
.thumb.lg { width: 96px; height: 96px; }
.pos { color: var(--muted); font-variant-numeric: tabular-nums; width: 2.4em; flex: none; font-size: 13px; }
.bpm {
  font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.6em; text-align: right; flex: none;
}
.bpm.empty { color: var(--border); font-weight: 400; }
.dur { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; flex: none; }
.dur.src-musicbrainz::after { content: "ᴹᴮ"; margin-left: 2px; }
.dur.missing { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); line-height: 1.5;
}
.chip.genre { border-color: color-mix(in srgb, var(--genre) 50%, transparent); color: var(--genre); }
.chip.group { border-color: color-mix(in srgb, var(--group) 50%, transparent); color: var(--group); }
button.chip { padding: 5px 11px; font-size: 13px; }
button.chip.on.genre { background: var(--genre); color: #06121f; }
button.chip.on.group { background: var(--group); color: #140a22; }
.chip .x { margin-left: 4px; opacity: .7; }

.filters { display: grid; gap: 8px; margin-bottom: 12px; }
.filters .bpm-range input { width: 5.5em; text-align: center; }
.count { color: var(--muted); font-size: 13px; margin: 4px 2px 8px; }

.tap-pad {
  width: 100%; height: 140px; border-radius: 16px; border: 2px dashed var(--border);
  background: var(--surface); font-size: 18px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.tap-pad.hit { border-color: var(--accent); color: var(--text); }
.tap-pad .live { font-size: 40px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.bpm-input { font-size: 28px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 8px; margin-top: 20px; }
.actions button { flex: 1; padding: 12px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
.tabbar a {
  flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); gap: 2px;
}
.tabbar a .ico { font-size: 19px; line-height: 1; }
.tabbar a.active { color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  transition: .2s; max-width: calc(100% - 32px); z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }

.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }
.spinner { text-align: center; color: var(--muted); padding: 32px 0; }
.back { color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 6px; }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.kbd { font-size: 12px; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }

/* DJ項目 */
.item.colored { box-shadow: inset 4px 0 0 var(--track-color); }
.dj-mark {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .04em; vertical-align: 2px;
  background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 0 4px; margin-right: 6px;
}
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; font-size: 12px; }
.meta .stars { color: var(--accent); letter-spacing: -1px; }
.meta .rpm { color: var(--muted); }
.meta:empty { display: none; }

.dj-toggle {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.dj-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.dj-toggle .box {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--muted); flex: none;
  display: grid; place-items: center;
}
.dj-toggle input:checked + .box { background: var(--accent); border-color: var(--accent); }
.dj-toggle input:checked + .box::after { content: "✓"; color: var(--accent-ink); font-weight: 900; }
.dj-toggle:has(input:checked) { border-color: var(--accent); }
.dj-toggle input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }

.rating { display: flex; gap: 4px; }
.rating button { font-size: 28px; line-height: 1; padding: 4px 6px; background: transparent; border: none; color: var(--border); }
.rating button.on { color: var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; padding: 0; background: var(--c); border: 2px solid transparent;
}
.swatch.none { background: transparent; border: 2px dashed var(--border); }
.swatch.on { outline: 2px solid var(--text); outline-offset: 2px; }

details > summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: var(--accent-ink); font-size: 11px; font-weight: 700; text-align: center; margin-left: 4px;
}
label.check.strong { color: var(--text); font-weight: 600; }

