:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #eeeff1;
  --text: #16181d;
  --muted: #646a75;
  --border: #dcdee3;
  --accent: #1a9c93;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --gutter: 16px;

  --t-original: #2f9e44;
  --t-cover: #1c7ed6;
  --t-remix: #ae3ec9;
  --t-remaster: #0c8599;
  --t-arrangement: #e67700;
  --t-instrumental: #5c7cfa;
  --t-mashup: #d6336c;
  --t-pv: #f08c00;
  --t-other: #868e96;
  --vdb: var(--accent);
  --vdb-text: var(--accent-text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #232730;
    --text: #e8eaef;
    --muted: #9aa1ad;
    --border: #2c313b;
    --accent: #39c5bb;
    --accent-text: #0b1312;
    --danger: #ff6b5b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px var(--gutter);
  max-width: 1800px; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; line-height: 1;
}
.brand img { display: block; flex: none; }
.unread-pill {
  background: var(--accent); color: var(--accent-text);
  font-size: 12px; font-weight: 700; padding: 2px 8px;
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  background: none; border: 0; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg {
  display: inline-flex; background: var(--surface-2); padding: 3px;
}
.seg button {
  border: 0; background: none; cursor: pointer;
  padding: 6px 10px; color: var(--muted);
  display: inline-grid; place-items: center;
}
.seg-text button { font-size: 13px; font-weight: 600; padding: 5px 12px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.filters { padding-top: 0; }

.sync-progress { max-width: 1800px; margin: 0 auto; padding: 0 var(--gutter) 8px; }
.sync-bar { height: 3px; background: var(--surface-2); overflow: hidden; }
.sync-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.sync-bar.indeterminate span { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.sync-text { font-size: 12px; color: var(--text); margin-top: 4px; font-variant-numeric: tabular-nums; }
.chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  flex: 1; min-width: 0; padding: 2px 0;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  padding: 5px 12px; cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--t-other)); }
.chip .n { color: var(--muted); font-weight: 500; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on .n { color: inherit; opacity: .7; }

.selbar { padding-top: 0; font-size: 14px; }
.sel-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.sel-all input, .pick input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.btn {
  border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  padding: 7px 14px; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-ghost { background: var(--surface-2); color: var(--text); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: 44px; min-width: 230px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 8px; display: grid; gap: 4px;
}
.menu-user { font-weight: 700; padding: 6px 8px 0; }
.menu-meta { font-size: 12px; color: var(--muted); padding: 0 8px 6px; }
.menu-check { display: flex; gap: 8px; align-items: center; padding: 8px; font-size: 14px; cursor: pointer; }
.menu-item {
  text-align: left; background: none; border: 0; padding: 8px; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }

/* ---------- Main ---------- */
main { max-width: 1800px; margin: 0 auto; padding: 16px var(--gutter) 64px; }
.banner {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}
.empty { text-align: center; padding: 48px 0; }

.login { display: grid; place-items: center; padding: 32px 0; }
.login-card {
  width: 100%; max-width: 380px; display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 24px; box-shadow: var(--shadow);
}
.login-card h2 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; font-size: 13px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login-card input {
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.login-card .btn { justify-content: center; padding: 10px; font-size: 15px; }
.error { color: var(--danger); }

/* ---------- Feed: shared ---------- */
.item { position: relative; min-width: 0; }
.item .thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--surface-2); cursor: pointer;
}
.item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item .thumb .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 28px; }
.dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 600;
  padding: 1px 5px;
}
.pick {
  position: absolute; left: 6px; top: 6px; z-index: 2;
  display: grid; place-items: center; width: 32px; height: 32px;
  background: rgba(0,0,0,.55); cursor: pointer;
}
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 1px 7px; color: #fff; background: var(--c, var(--t-other));
  vertical-align: 1px; white-space: nowrap;
}
.info { display: flex; gap: 10px; padding: 10px 2px 0; min-width: 0; }
.info-text { min-width: 0; flex: 1; }
.title {
  margin: 0; font-size: 15px; font-weight: 650; line-height: 1.3; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.artist, .meta { font-size: 13px; color: var(--text); margin-top: 2px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.vdb-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--vdb); color: var(--vdb-text) !important; text-decoration: none;
  font-size: 11px; font-weight: 700; padding: 1px 6px;
}
.vdb-chip:hover { filter: brightness(1.15); }
.btn-vdb { background: var(--vdb); color: var(--vdb-text); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }
.item.read .unread-dot { visibility: hidden; }
.item.read:not(.expanded) .thumb img { opacity: .55; }
.item.read:not(.expanded) .title { color: var(--muted); }
.item.selected .thumb { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Grid ---------- */
.feed.grid {
  display: grid; gap: 24px 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

/* ---------- List ---------- */
.feed.list, .feed.compact { display: grid; gap: 0; }
.feed.list .item:not(.expanded) {
  display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: start;
  padding: 12px 8px; border-bottom: 1px solid var(--border);
}
.feed.list .item:not(.expanded):first-child, .feed.compact .item:not(.expanded):first-child { border-top: 1px solid var(--border); }
.feed.list .item:not(.expanded):hover, .feed.compact .item:not(.expanded):hover { background: var(--surface); }
.feed .item:not(.expanded) { cursor: pointer; }
.item.expanded { cursor: auto; user-select: text; }
.feed.list .item.expanded, .feed.compact .item.expanded { margin: 12px 0; }

/* ---------- Compact ---------- */
.feed.compact .item:not(.expanded) {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--c, var(--t-other));
}
.feed.compact .pick { position: static; width: auto; height: auto; background: none; opacity: 1 !important; flex: none; }
.feed.compact .unread-dot { margin-top: 0; }
.compact-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.compact-badge { flex: none; min-width: 84px; text-align: center; }
.compact-producer {
  flex: 0 1 auto; max-width: 30%; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Phones: two lines — [✓ • type title] / [producer date] */
@media (max-width: 560px) {
  .feed.compact .item:not(.expanded) {
    display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    column-gap: 8px; row-gap: 3px;
  }
  .feed.compact .pick, .feed.compact .unread-dot { grid-row: 1; }
  .compact-badge { grid-row: 1; grid-column: 3; min-width: 0; }
  .compact-title { grid-row: 1; grid-column: 4 / 6; }
  .compact-producer { grid-row: 2; grid-column: 3 / 5; max-width: none; }
  .compact-date { grid-row: 2; grid-column: 5; }
}
@media (max-width: 420px) {
  .topbar-row { gap: 4px; }
  .brand { font-size: 0; gap: 0; }
  .icon-btn { width: 34px; height: 34px; }
  .seg button { padding: 6px 7px; }
}
.compact-date { flex: none; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.item.read:not(.expanded) .compact-title { color: var(--muted); font-weight: 500; }
.feed.compact .item.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.feed.list .item:not(.expanded) .info { padding: 0; }
.feed.list .item:not(.expanded) .pick { width: 28px; height: 28px; left: 4px; top: 4px; }
@media (max-width: 480px) {
  .feed.list .item:not(.expanded) { grid-template-columns: 120px 1fr; gap: 10px; padding: 6px 0; }
  .feed.list .title { font-size: 14px; }
}

/* ---------- Expanded ---------- */
.item.expanded {
  grid-column: 1 / -1;
  background: var(--surface); border: 1px solid var(--border);
  padding: 12px; box-shadow: var(--shadow);
  display: grid; gap: 12px; scroll-margin-top: 140px;
}
.item.expanded > .thumb { display: none; }
.item.expanded .info { padding: 0; }
.item.expanded .title { -webkit-line-clamp: unset; font-size: 18px; }
.player {
  position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .fallback {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: #fff; padding: 16px; background-size: cover; background-position: center;
}
.player .fallback::before { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.player .fallback > * { position: relative; }
.pv-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-tabs button {
  border: 1px solid var(--border); background: var(--bg);
  padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.pv-tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rate {
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
  padding: 7px 14px; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.rate svg { width: 16px; height: 16px; }
.rate.on[data-rating="Like"] { background: #1c7ed6; border-color: #1c7ed6; color: #fff; }
.rate.on[data-rating="Favorite"] { background: #e8590c; border-color: #e8590c; color: #fff; }
.rate:disabled { opacity: .5; cursor: progress; }

/* Every action button shares one size, whatever its variant or icon. */
.actions > .rate, .actions > .btn {
  height: 34px; padding: 0 14px; border: 1px solid transparent;
  font-size: 13px; font-weight: 700; line-height: 1; gap: 6px;
}
.actions > .rate { border-color: var(--border); }
.actions svg { width: 15px; height: 15px; flex: none; }
.item.expanded .unread-dot { display: none; }
.producers { font-size: 13px; color: var(--text); }
.producers a { color: inherit; }
.details {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px;
  margin: 10px 0 0; font-size: 13px;
}
.details dt { color: var(--muted); font-weight: 600; white-space: nowrap; }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.details a { color: var(--text); }
.details a:hover { color: var(--accent); }
.muted-inline { color: var(--muted); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 12px; padding: 2px 7px; text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--border);
}
.tag:hover { border-color: var(--accent); }

@media (min-width: 900px) {
  .item.expanded { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); grid-template-rows: auto 1fr; padding: 16px; gap: 16px 20px; }
  .item.expanded .player-wrap { grid-row: span 2; }
  .item.expanded .info { align-self: start; }
  .item.expanded .actions { align-self: start; }
}
@media (hover: hover) {
  .item:not(.selected):not(:hover) .pick { opacity: 0; }
  .feed.selecting .item .pick { opacity: 1 !important; }
}
.item.expanded .pick { display: none; }

/* ---------- Player (inline over the open card, or docked mini player) ---------- */
.player-placeholder { aspect-ratio: 16 / 9; background: #000; }
.player-host { position: absolute; z-index: 5; }
.player-host .mini-bar { display: none; }
.player-host.docked {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  width: min(400px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
}
.player-host.docked .mini-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; }
.mini-meta {
  flex: 1; min-width: 0; display: grid; gap: 1px; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--text);
}
.mini-title, .mini-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-title { font-weight: 700; font-size: 14px; }
.mini-artist { font-size: 12px; }
.mini-meta:hover .mini-title { color: var(--accent); }
.mini-actions { display: flex; gap: 6px; flex: none; }
.mini-actions > button {
  width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer;
}
.mini-actions svg { width: 16px; height: 16px; }
.mini-close:hover { border-color: var(--text); }
body.has-mini main { padding-bottom: 300px; }

/* Phones: full-width bar, video on the left */
@media (max-width: 600px) {
  .player-host.docked {
    left: 0; right: 0; bottom: 0; width: auto;
    display: flex; align-items: stretch;
    border-width: 1px 0 0; padding-bottom: env(safe-area-inset-bottom);
  }
  .player-host.docked .player { width: 44%; flex: none; }
  .player-host.docked .mini-bar {
    flex: 1; min-width: 0; flex-direction: column; align-items: stretch; justify-content: space-between;
    gap: 4px; padding: 6px 8px;
  }
  .player-host.docked .mini-actions { justify-content: flex-end; }
  .player-host.docked .mini-actions > button { width: 32px; height: 32px; }
  body.has-mini main { padding-bottom: 140px; }
}
