/* Shared tokens and primitives for the public site and the admin backend.
   Visual language follows Apple Music / NetEase Cloud Music: red accent,
   light and dark themes that follow the system setting. */
:root {
  color-scheme: light dark;
  --accent: #fa2d48;
  --accent-hover: #e81d3a;
  --accent-ink: #fff;
  --accent-soft: rgba(250, 45, 72, .1);
  --accent-line: rgba(250, 45, 72, .35);

  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --sidebar: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --surface-3: #e6e6ea;
  --zebra: rgba(0, 0, 0, .028);
  --hover: rgba(0, 0, 0, .055);
  --line: rgba(0, 0, 0, .08);
  --line-2: rgba(0, 0, 0, .14);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --wave: rgba(0, 0, 0, .16);
  --wave-hover: rgba(0, 0, 0, .32);
  --glass: rgba(250, 250, 252, .86);
  --scrim: rgba(0, 0, 0, .32);
  --danger: #e5302d;
  --danger-soft: rgba(229, 48, 45, .1);
  --shadow: 0 12px 32px rgba(0, 0, 0, .14);
  --shadow-art: 0 8px 24px rgba(0, 0, 0, .16);

  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --cat-bgm: #af52de;
  --cat-sfx: #ff9500;
  --cat-voice: #0a84ff;
  --cat-ambience: #30b158;
  --cat-song: #ff2d55;
  --cat-instrumental: #30a8c7;
  --cat-other: #8e8e93;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #fa2d48;
    --accent-hover: #ff4a62;
    --accent-soft: rgba(250, 45, 72, .16);
    --accent-line: rgba(250, 45, 72, .45);

    --bg: #161618;
    --bg-2: #232326;
    --sidebar: #1e1e21;
    --surface: #1f1f22;
    --surface-2: #2a2a2e;
    --surface-3: #37373c;
    --zebra: rgba(255, 255, 255, .03);
    --hover: rgba(255, 255, 255, .07);
    --line: rgba(255, 255, 255, .08);
    --line-2: rgba(255, 255, 255, .15);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --wave: rgba(255, 255, 255, .2);
    --wave-hover: rgba(255, 255, 255, .4);
    --glass: rgba(32, 32, 35, .86);
    --scrim: rgba(0, 0, 0, .5);
    --danger: #ff5f57;
    --danger-soft: rgba(255, 95, 87, .14);
    --shadow: 0 16px 40px rgba(0, 0, 0, .5);
    --shadow-art: 0 10px 28px rgba(0, 0, 0, .45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.icon-sm { width: 16px; height: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13px; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-tinted { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-tinted:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-lg { height: 40px; padding: 0 22px; font-size: 14px; }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12px; gap: 4px; }
.btn-sm .icon { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.is-on { color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Form controls */
.input, .select {
  height: 34px; padding: 0 12px; width: 100%;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%238e8e93' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 20px; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }

/* Chips, segmented control and badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 14px;
  border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--text);
  font-size: 13px; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s;
}
.chip:hover { background: var(--surface-3); }
.chip.is-active { background: var(--accent); color: var(--accent-ink); }
.chip .count { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.chip.is-active .count { color: inherit; opacity: .75; }
.chip-sm { height: 26px; padding: 0 10px; font-size: 12px; }

.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-2); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 14px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.segmented .is-active { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 0 0 .5px var(--line); }
@media (prefers-color-scheme: dark) { .segmented .is-active { background: var(--surface-3); } }

.cat-badge {
  --c: var(--cat-other);
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 5px; font-size: 11px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
[data-cat="bgm"] { --c: var(--cat-bgm); }
[data-cat="sfx"] { --c: var(--cat-sfx); }
[data-cat="voice"] { --c: var(--cat-voice); }
[data-cat="ambience"] { --c: var(--cat-ambience); }
[data-cat="song"] { --c: var(--cat-song); }
[data-cat="instrumental"] { --c: var(--cat-instrumental); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--cat-other)); }

/* Covers: an image, or a generated gradient with the first character of the name. */
.cover { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 20% 10%, hsl(var(--h) 75% 62% / .6), transparent 60%),
    linear-gradient(135deg, hsl(var(--h) 60% 42%), hsl(calc(var(--h) + 50) 65% 22%));
  color: rgba(255, 255, 255, .92); font-weight: 700; font-size: 40px;
  container-type: size;
}
.cover-fallback span { font-size: clamp(12px, 42cqmin, 96px); line-height: 1; }

/* Toasts */
.toasts { position: fixed; z-index: 300; left: 50%; top: 20px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  padding: 9px 16px; border-radius: 999px; max-width: min(90vw, 480px);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500;
  animation: toast-in .2s ease-out;
}
.toast-error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 120px 0; }

.empty { padding: 64px 24px; text-align: center; color: var(--text-2); }
.empty .icon { width: 44px; height: 44px; color: var(--text-3); margin: 0 auto 12px; display: block; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
