:root {
  --bg: #fafafa;
  --surface: #fff;
  --fg: #1f2024;
  --muted: #8b8e95;
  --line: #e6e7eb;
  --accent: #2b7d5e;
  --accent-soft: #d8efe4;
  --missing: #d9534f;
  --missing-soft: #fce8e7;
  --owned: #2b7d5e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "PingFang SC", "Hiragino Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
a.muted, .muted a { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
       background: #eef0f3; padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.85em; }

.topbar {
  display: flex; align-items: center; gap: 1.5em;
  padding: 0.6em 1.5em;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar .brand { font-weight: 600; text-decoration: none; }
.topbar nav a {
  margin-right: 1em; text-decoration: none; color: var(--muted);
  padding: 0.25em 0; border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--fg); }
.topbar .grow { flex: 1; }
.logout-btn { background: transparent; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; font-size: 0.85em; }
.logout-btn:hover { color: var(--fg); }

/* ── login page ─────────────────────────── */
body.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 2.5em 2em; width: 320px; max-width: 90vw; text-align: center;
  box-shadow: 0 4px 30px rgba(0,0,0,0.06);
}
.login-card h1 { margin: 0 0 1.5em; font-weight: 600; }
.login-card form { display: flex; flex-direction: column; gap: 0.75em; }
.login-card input[type=password] {
  font: inherit; padding: 0.6em 0.8em; border: 1px solid var(--line); border-radius: 6px;
}
.login-card button {
  font: inherit; padding: 0.6em 1em; border: 0; border-radius: 6px;
  background: var(--accent); color: white; cursor: pointer;
}
.login-card button:hover { opacity: 0.9; }
.login-error { color: var(--missing); margin: 0 0 0.5em; font-size: 0.9em; }

main { max-width: 960px; margin: 1.5em auto; padding: 0 1.5em; }

h1 { font-weight: 600; font-size: 1.6em; margin: 0 0 0.3em; }
h2 { font-weight: 600; font-size: 1.15em; margin: 1.5em 0 0.6em; }

.badge {
  display: inline-block; padding: 1px 6px; font-size: 0.7em; font-weight: 500;
  background: var(--line); border-radius: 3px; color: var(--muted);
  vertical-align: middle; margin-left: 0.4em;
}
.empty { padding: 2em; text-align: center; color: var(--muted); }

/* ── artists list ─────────────────────────── */
.page-head { display: flex; align-items: flex-end; gap: 2em; flex-wrap: wrap; }
.filter-bar { display: flex; gap: 1em; align-items: center; }
.filter-bar label { font-size: 0.85em; color: var(--muted); }
.filter-bar select {
  font: inherit; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--surface);
  margin-left: 0.4em;
}

.artist-list { margin-top: 1em; background: var(--surface);
               border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.artist-row {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.5em;
  padding: 0.75em 1em; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--fg);
}
.artist-row:last-child { border-bottom: 0; }
.artist-row:hover { background: #f4f6f8; }
.artist-row__name { display: flex; align-items: center; gap: 0.4em; min-width: 0; }
.artist-row__name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artist-row__name .mbid { font-family: ui-monospace, Menlo, monospace; font-size: 0.75em; color: var(--muted); }
.artist-row__stats { display: grid; grid-template-columns: 50px 1fr 40px 80px;
                     gap: 0.75em; align-items: center; }
.artist-row__stats .ratio { font-variant-numeric: tabular-nums; text-align: right; }
.artist-row__stats .pct { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.artist-row__stats .items { text-align: right; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* ── artist detail ────────────────────────── */
.artist-head { margin-bottom: 1em; }
.artist-head .back { text-decoration: none; color: var(--muted); font-size: 0.9em; }
.artist-head .back:hover { color: var(--fg); }

.discography { margin-top: 1em; }
.rg-list { list-style: none; margin: 0; padding: 0;
           background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
           overflow: hidden; }
.rg {
  display: grid; grid-template-columns: 70px 30px 1fr 180px 70px;
  gap: 0.75em; align-items: center;
  padding: 0.55em 1em; border-bottom: 1px solid var(--line);
}
.rg:last-child { border-bottom: 0; }
.rg__year { font-variant-numeric: tabular-nums; color: var(--muted); }
.rg__icon { text-align: center; }
.rg__title a { text-decoration: none; }
.rg__title a:hover { text-decoration: underline; }
.rg--owned { background: var(--accent-soft); }
.rg--missing .rg__title { color: var(--muted); }
.rg__items { text-align: right; font-variant-numeric: tabular-nums; }

/* ── duplicates ────────────────────────── */
.dup-list { margin-top: 1em; display: flex; flex-direction: column; gap: 1em; }
.dup-group { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dup-group__head {
  display: flex; align-items: center; gap: 0.75em; flex-wrap: wrap;
  padding: 0.6em 1em; background: #f4f6f8; border-bottom: 1px solid var(--line);
}
.dup-group__title { font-weight: 600; }
.dup-files { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.dup-files th, .dup-files td {
  text-align: left; padding: 0.5em 1em; border-top: 1px solid var(--line);
}
.dup-files th { font-weight: 500; color: var(--muted); font-size: 0.85em; }
.dup-files .path-col { word-break: break-all; }
.dup-files .ok { color: var(--owned); font-weight: 600; }
.dup-files .warn { color: var(--missing); font-weight: 600; }
.dup-file--keep { background: var(--accent-soft); }
.dup-file--drop { background: var(--missing-soft); }

/* ── organize ────────────────────────── */
.org-list { display: flex; flex-direction: column; gap: 0.6em; margin-top: 1em; }
.org-group { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.org-group--done { opacity: 0.6; }
.org-group__head {
  display: flex; align-items: center; gap: 1em; padding: 0.6em 1em;
  background: #f4f6f8; flex-wrap: wrap;
}
.org-group__title { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; flex: 1; min-width: 0; }
.org-group__title strong { word-break: break-all; }
.org-group__actions { display: flex; gap: 0.6em; }
.link-btn { background: transparent; border: 0; color: var(--accent); cursor: pointer; font: inherit; }
.apply-btn { font: inherit; padding: 0.35em 0.9em; border: 1px solid var(--accent);
             background: var(--surface); color: var(--accent); border-radius: 5px; cursor: pointer; }
.apply-btn:hover:not(:disabled) { background: var(--accent-soft); }
.apply-btn:disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; background: transparent; }

.badge--recording { background: var(--accent-soft); color: var(--accent); }
.badge--album { background: #fff2dd; color: #b86c00; }
.badge--artist { background: #ffeaea; color: var(--missing); }
.badge--tag-only { background: var(--line); color: var(--muted); }
.badge--mixed { background: var(--line); color: var(--muted); }

.org-group__body { padding: 0.75em 1em; border-top: 1px solid var(--line); }
.org-paths { margin-bottom: 0.75em; line-height: 1.8; font-size: 0.9em; }

.org-moves { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.org-moves th, .org-moves td { padding: 0.3em 0.5em; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.org-moves th { font-weight: 500; color: var(--muted); font-size: 0.8em; }
.org-moves .path-col { word-break: break-all; }
.org-moves .row--noop { color: var(--muted); }
.org-moves .row--sidecar { background: #fafbfc; }

.org-leftovers { margin-top: 0.75em; padding: 0.6em; background: var(--missing-soft); border-radius: 5px; }
.org-leftovers ul { margin: 0.3em 0 0 1em; padding: 0; }

.ok { color: var(--owned); font-weight: 600; }

/* ── admin ─────────────────────────────── */
.admin-actions { display: flex; flex-wrap: wrap; gap: 0.5em; margin: 1em 0; }
.admin-actions button {
  font: inherit; padding: 0.5em 1em;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface); color: var(--fg); cursor: pointer;
}
.admin-actions button:hover { background: #f4f6f8; }
.admin-out {
  background: #1f2024; color: #e6e7eb; padding: 1em; border-radius: 8px;
  font-family: ui-monospace, Menlo, monospace; font-size: 0.85em;
  white-space: pre-wrap; word-break: break-all; overflow-x: auto;
}
