:root {
  --bg: #0b0b12;
  --bg-elevated: #14141f;
  --bg-card: #17171f;
  --border: #262636;
  --text: #f2f2f7;
  --text-dim: #9797ab;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
  --success: #34d399;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

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

/* --- Topbar ---------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(11, 11, 18, 0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 9px; }
.brand-mark { flex-shrink: 0; display: block; }
.topnav { display: flex; gap: 22px; flex: 1; }
.topnav a { color: var(--text-dim); font-size: 0.92rem; padding: 6px 0; border-bottom: 2px solid transparent; }
.topnav a:hover, .topnav a.active { color: var(--text); border-bottom-color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.credit-pill { background: var(--bg-elevated); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.user-name { color: var(--text-dim); font-size: 0.88rem; }

/* --- App shell (barre latérale pour les pages outil : générer, studio,
   bibliothèque, tarifs, admin) — la barre du haut ci-dessus reste utilisée
   pour les pages marketing (accueil, connexion, inscription). ------------*/
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.app-sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
}
.app-sidebar .brand { padding: 22px 22px 18px; }
.app-nav { flex: 1; padding: 8px 14px; display: flex; flex-direction: column; gap: 3px; }
.app-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-dim); font-size: 0.92rem; font-weight: 600; }
.app-nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.app-nav a.active { background: var(--accent-gradient); color: white; }
.app-nav .nav-icon { width: 20px; text-align: center; font-size: 1rem; }
.app-sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }

.upgrade-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.14), rgba(236, 72, 153, 0.08));
}
.upgrade-card:hover, .upgrade-card.active { border-color: var(--accent); }
.upgrade-card-icon { font-size: 1.1rem; }
.upgrade-card-title { font-weight: 700; font-size: 0.88rem; color: var(--text); }
.upgrade-card-text { font-size: 0.76rem; color: var(--text-dim); line-height: 1.4; }

.app-user-row { display: flex; align-items: center; gap: 10px; }
.app-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-gradient); color: white; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.app-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.app-user-info .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.app-user-info .user-credits { font-size: 0.75rem; color: var(--text-dim); }
.app-user-row .btn { flex-shrink: 0; padding: 7px 10px; font-size: 0.95rem; }
.app-content-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-main { flex: 1; }
.mobile-topbar { display: none; }

@media (max-width: 900px) {
  .app-sidebar { display: none; }
  .app-shell { display: block; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    border-bottom: 1px solid var(--border); position: sticky; top: 0;
    background: rgba(11, 11, 18, 0.9); backdrop-filter: blur(10px); z-index: 10;
  }
  .mobile-topbar .brand, .mobile-topbar .credit-pill { flex-shrink: 0; white-space: nowrap; }
  .mobile-topbar-links { display: flex; gap: 14px; overflow-x: auto; flex: 1; min-width: 0; }
  .mobile-topbar-links a { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; }
  .mobile-topbar-links a.active { color: var(--text); }
}

/* --- Buttons ----------------------------------------------------------*/
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: none; cursor: pointer;
  font-size: 0.95rem; font-weight: 600; font-family: inherit; transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-gradient); color: white; }
.btn-primary:hover { opacity: 0.92; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-elevated); }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- Layout helpers ---------------------------------------------------*/
.container { max-width: 1080px; margin: 0 auto; padding: 0 32px; }
.narrow { max-width: 480px; margin: 0 auto; padding: 64px 24px; }
.section { padding: 64px 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .container, .section { padding-left: 16px; padding-right: 16px; }
}

/* --- Cards / forms ------------------------------------------------------*/
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 0.95rem; font-family: inherit;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.help-text { font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; }
.error-box { background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.4); color: #fca5a5; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 0.88rem; }
.success-box { background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.4); color: #6ee7b7; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 0.88rem; }

/* --- Hero ---------------------------------------------------------------*/
.hero { text-align: center; padding: 96px 24px 64px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin: 0 0 18px; letter-spacing: -0.02em; }
.hero .highlight { background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-dim); font-size: 1.15rem; max-width: 620px; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; }

.feature-card { padding: 28px; }
.feature-card .icon { font-size: 1.8rem; margin-bottom: 12px; }
.feature-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.feature-card p { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

/* --- Pricing --------------------------------------------------------------*/
.price-card { text-align: center; display: flex; flex-direction: column; }
.price-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.price-card .badge { background: var(--accent-gradient); color: white; font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; align-self: center; margin-bottom: 12px; }
.price-card h3 { margin: 0 0 4px; }
.price-card .price { font-size: 2.2rem; font-weight: 800; margin: 12px 0 4px; }
.price-card .credits { color: var(--text-dim); margin-bottom: 20px; }

/* --- Dashboard / generator ------------------------------------------------*/
.generator-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .generator-layout { grid-template-columns: 1fr; } }

/* --- Accueil : hero + générateur rapide ------------------------------- */
.home-hero { padding: 8px 0 28px; }
.home-hero h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); margin: 0 0 10px; letter-spacing: -0.02em; }
.home-hero .highlight { background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-hero p { color: var(--text-dim); font-size: 1.02rem; max-width: 560px; margin: 0; }

.generator-card { margin-top: 8px; margin-bottom: 40px; }
.generator-tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg-elevated); border-radius: 999px; padding: 4px; width: fit-content; }
.tab-btn { border: none; background: transparent; color: var(--text-dim); font-family: inherit; font-size: 0.86rem; font-weight: 600; padding: 8px 18px; border-radius: 999px; cursor: pointer; transition: background .12s ease, color .12s ease; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--accent-gradient); color: white; }

.quick-generate-row { display: flex; gap: 10px; }
.quick-generate-row input[type=text] { flex: 1; }
.quick-generate-row .btn { flex-shrink: 0; }
.quick-dropdowns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.quick-dropdowns select { width: auto; min-width: 160px; padding: 9px 12px; font-size: 0.86rem; }
.instrumental-toggle { font-size: 0.86rem; color: var(--text-dim); white-space: nowrap; }
#custom-panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 560px) {
  .quick-generate-row { flex-direction: column; }
  .quick-generate-row .btn { width: 100%; }
}

.section-header { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 16px; }
.section-header h2 { margin: 0; font-size: 1.25rem; }

.featured-grid { margin-bottom: 8px; }
.featured-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.featured-cover { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; }
.featured-play { width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); color: white; display: flex; align-items: center; justify-content: center; font-size: 1rem; opacity: 0; transition: opacity .15s ease, transform .15s ease; transform: scale(0.9); }
.featured-cover:hover .featured-play { opacity: 1; transform: scale(1); }
.featured-title { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.featured-meta { font-size: 0.78rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.style-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.style-tag { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 0.8rem; cursor: pointer; color: var(--text-dim); }
.style-tag:hover { border-color: var(--accent); color: var(--text); }
.style-tag.selected { background: var(--accent-gradient); border-color: transparent; color: white; }
.style-tag[data-add-section] { cursor: pointer; }
#sections-list { margin-top: 4px; margin-bottom: 12px; }
#sections-list .section-lyrics { min-height: 70px; }

.job-card { display: flex; align-items: center; gap: 14px; padding: 16px; }
.job-card .job-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.job-card .job-info { flex: 1; min-width: 0; }
.job-card .job-title { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-card .job-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.status-badge { font-size: 0.72rem; padding: 3px 10px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.status-badge.queued, .status-badge.processing { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
.status-badge.completed { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; }
.status-badge.failed { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }

/* --- Track / player ---------------------------------------------------- */
.track-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.track-cover { width: 100%; aspect-ratio: 1; border-radius: 10px; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.track-title { font-weight: 600; font-size: 0.92rem; }
.track-meta { font-size: 0.78rem; color: var(--text-dim); }
audio { width: 100%; height: 34px; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.25); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

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

table.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.admin-table th, table.admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.admin-table th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.footer { text-align: center; padding: 32px; color: var(--text-dim); font-size: 0.82rem; border-top: 1px solid var(--border); margin-top: 48px; }

/* --- Import audio / enregistrement micro / voix clonées ---------------- */
#record-btn[data-recording="1"] { border-color: #f87171; color: #fca5a5; animation: recordPulse 1.4s ease-in-out infinite; }
@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
}
#record-timer { font-variant-numeric: tabular-nums; }

.upload-item, .persona-item { border: 1px solid var(--border); }
.upload-item audio { margin-bottom: 4px; }

#cover-form { border: 1px solid var(--accent); }
