:root {
  --bg: #0e0e12;
  --bg-elevated: #17171d;
  --bg-card: #1c1c24;
  --bg-card-hover: #232330;
  --border: #2a2a35;
  --text: #f2f2f5;
  --text-dim: #9a9aa8;
  --text-faint: #67677a;
  --accent: #a855f7;
  --accent-2: #ec4899;
  --accent-grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --success: #22c55e;
  --danger: #f43f5e;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at 20% -10%, #241a33 0%, var(--bg) 45%) fixed;
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

/* ---------- Navbar ---------- */
.navbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(14, 14, 18, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.navbar .logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.navbar .search-wrap {
  flex: 1;
  max-width: 480px;
}

.navbar input[type="search"] {
  width: 100%;
}

.navbar .spacer {
  flex: 1;
}

.navbar .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar .username {
  color: var(--text-dim);
  font-size: 14px;
}

/* ---------- Inputs / buttons ---------- */
input,
select,
textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #3a3a4a;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-grad);
  border: none;
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.btn-danger {
  color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

.hero {
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 28px;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}

.hero p {
  color: var(--text-dim);
  margin: 0;
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
  align-items: center;
}

.filters input[type="number"] {
  width: 90px;
}

.filters .tag-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.filters .tag-chip.active {
  background: var(--accent-grad);
  color: white;
  border-color: transparent;
}

/* ---------- Sample grid ---------- */
.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.sample-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.sample-card:hover {
  border-color: #3a3a4a;
  box-shadow: var(--shadow);
}

.sample-card .row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.sample-card .title {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-card .owner {
  color: var(--text-faint);
  font-size: 12px;
}

.sample-card .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
}

.sample-card .meta span {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
}

.sample-card .tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sample-card .tag {
  font-size: 11px;
  color: var(--accent);
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.25);
  padding: 2px 8px;
  border-radius: 999px;
}

.sample-card audio {
  width: 100%;
  height: 34px;
  filter: invert(0.88) hue-rotate(180deg);
  border-radius: 999px;
}

.category-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: white;
  background: var(--accent-grad);
  padding: 3px 10px;
  border-radius: 999px;
}

.midi-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
}

.sample-card .card-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.modal .field {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal .field label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.modal .field-row {
  display: flex;
  gap: 10px;
}

.modal .field-row .field {
  flex: 1;
}

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(168, 85, 247, 0.08);
}

.dropzone .file-name {
  color: var(--text);
  font-weight: 600;
  margin-top: 6px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 16px;
}

.hint {
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------- Auth pages ---------- */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-card .logo {
  display: block;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-card .field label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.auth-card .switch-link {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-dim);
}

.auth-card .switch-link a {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Misc ---------- */
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-top: 10px;
  display: none;
}

.progress-bar .fill {
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  transition: width 0.2s;
}

footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  padding: 24px;
}

@media (max-width: 640px) {
  .navbar {
    flex-wrap: wrap;
  }
  .navbar .search-wrap {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
}

/* ---------- Bannière de téléchargement du client bureau ---------- */
/* display:flex est posé par le script au moment où l'on sait qu'un client existe :
   la règle ci-dessous ne décrit donc que la mise en forme, pas la visibilité. */
.client-banner {
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 0 0 24px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.14), rgba(236, 72, 153, 0.1));
}

.client-banner .client-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 240px;
}

.client-banner .client-text strong {
  font-size: 15px;
}

.client-banner .client-text span {
  color: var(--text-dim);
  font-size: 13px;
}

.client-banner .btn {
  white-space: nowrap;
}
