.turnstile-hint,
#turnstileHint {
  text-align: center;
}

:root {
  --bg-a: #02030a;
  --bg-b: #0a1324;
  --ink: #ffffff;
  --ink-soft: #bac7e6;
  --panel: rgba(13, 20, 36, 0.85);
  --panel-strong: rgba(8, 14, 26, 0.98);
  --surface-a: rgba(255, 255, 255, 0.08);
  --surface-b: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.14);

  --accent: #915BFE;
  --accent-glow: rgba(145, 91, 254, 0.35);
  --accent-hover: #7b46e4;
  --live: #ef4444;

  --font-sans: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 20px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --header-height: 103px;
  --header-height-mobile: 84px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  caret-color: transparent;

  input,
  textarea,
  [contenteditable="true"],
  [contenteditable=""] {
    caret-color: auto;
  }

  background-color: var(--bg-a);
  background-image: radial-gradient(circle at 15% 15%, rgba(145, 91, 254, 0.14), transparent 45%),
  radial-gradient(circle at 85% 85%, rgba(239, 68, 68, 0.05), transparent 45%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 1.5rem 2.75rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  line-height: 0;
}

.brand img {
  height: 54px;
  width: auto;
  object-fit: contain;
  transition: var(--transition);
}

.brand img:hover {
  transform: scale(1.02);
}

.nav-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.8rem 1.5rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-a);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  transition: var(--transition);
  user-select: none;
  text-decoration: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#historyBtn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  border-radius: 10px;
}

.app-layout {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

main {
  flex: 1;
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 4.5rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-section {
  text-align: center;
  max-width: 720px;
  margin-bottom: 6rem;
  padding: 2.5rem 1rem;
  animation: fadeIn 0.6s ease;
}

.hero-section h1 {
  font-size: 2.2rem;
  margin-bottom: 1.2rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-section p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.view-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 3.5rem 3.5rem;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: none;
}

.view-card.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.form-group {
  margin-bottom: 2.5rem;
  position: relative;
  width: 100%;
}

#view-form.lyrics-mode #mainPrompt {
  min-height: 280px;
}

.label-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  user-select: none;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  user-select: none;
}

.char-counter {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  user-select: none;
}

.field-hint {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  opacity: 0.9;
}

.field-hint.warning {
  color: #f8c26a;
}

textarea,
select,
input[type="text"] {
  caret-color: var(--ink);
  width: 100%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: var(--transition);
}

textarea {
  resize: vertical;
}

textarea:focus,
select:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(0, 0, 0, 0.7);
}

select option {
  background: var(--bg-b);
  color: var(--ink);
}

.mode-toggle {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
}

.mode-btn {
  flex: 1;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

select {
  cursor: pointer;
  user-select: none;
}

.mode-btn:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.mode-btn.active {
  color: #fff;
  border-color: transparent;
  background: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
  font-weight: 600;
}

.style-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.2rem;
  width: 100%;
  user-select: none;
  max-height: 5.4rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.2rem 0.4rem 0.2rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(145, 91, 254, 0.45) rgba(255, 255, 255, 0.06);
}

.style-tags::-webkit-scrollbar {
  width: 6px;
}

.style-tags::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.style-tags::-webkit-scrollbar-thumb {
  background: rgba(145, 91, 254, 0.45);
  border-radius: 999px;
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface-b);
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  border-radius: 20px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  flex: 0 0 auto;
  white-space: nowrap;
}

.tag:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.captcha-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 1.5rem;
}

.captcha-wrap .cf-turnstile {
  margin: 0 auto;
}

.status-box {
  text-align: center;
  padding: 5rem 0;
}

.spinner {
  width: 54px;
  height: 54px;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 2.5rem;
  animation: spin 1s linear infinite;
}

.status-msg {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.status-sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
  transition: opacity 0.25s ease;
}

#generateBtn {
  width: 80%;
  display: flex;
  justify-content: center;
  margin: 1.5rem auto 0;
  padding: 1rem;
  font-size: 1rem;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.result-header>div:first-child {
  .result-actions .btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
    max-width: 120px;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 0.8rem;
    padding: 0.62rem 0.9rem;
    border-radius: 11px;
    gap: 0.4rem;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 0 0 auto;
  }
}

.result-actions .btn {
  font-size: 0.8rem;
  padding: 0.62rem 0.9rem;
  border-radius: 11px;
  gap: 0.4rem;
}

#view-results h2 {
  margin-bottom: 0.5rem;
  font-size: 1.45rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

#newSongBtn {
  flex-shrink: 0;
}

.share-link-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.track-card {
  background: var(--surface-b);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin-top: 2rem;
}

.track-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.track-title {
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.summary-title {
  margin-bottom: 0.85rem;
}

.summary-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.summary-card-header-variant {
  margin-top: 0.4rem;
}

.summary-card-header .summary-title,
.summary-card-header .variant-label {
  margin: 0;
}

.summary-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.summary-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.summary-action-btn:hover {
  color: var(--ink);
  border-color: rgba(145, 91, 254, 0.7);
  background: rgba(145, 91, 254, 0.2);
  transform: translateY(-1px);
}

.summary-action-btn .material-symbols-rounded {
  font-size: 0.95rem;
}

.summary-meta {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 1.2rem;
}

.variant-label {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0.85rem 0 0.6rem;
}

.empty-history {
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-align: center;
  padding-top: 2rem;
}

.track-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.24rem 0.52rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  white-space: nowrap;
}

.track-status-live {
  background: rgba(239, 68, 68, 0.2);
  color: #ff9e9e;
  border-color: rgba(239, 68, 68, 0.45);
  animation: pulse 1.5s infinite;
}

.track-status-pending {
  background: rgba(248, 194, 106, 0.16);
  color: #f8c26a;
  border-color: rgba(248, 194, 106, 0.4);
}

.track-status-complete {
  background: rgba(119, 227, 169, 0.16);
  color: #88e8b4;
  border-color: rgba(119, 227, 169, 0.4);
}

.track-header .btn {
  font-size: 0.8rem;
  padding: 0.6rem 0.88rem;
  border-radius: 11px;
  gap: 0.4rem;
  flex-shrink: 0;
}

.app-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 90;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  border: 1px solid rgba(119, 227, 169, 0.35);
  background: rgba(9, 24, 16, 0.9);
  color: #c9ffe0;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 0.25rem;
  width: 100%;
}

.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: var(--transition);
  flex-shrink: 0;
}

.play-btn:hover {
  transform: scale(1.06);
  background: var(--accent-hover);
}

.play-btn-icon {
  font-size: 1.7rem;
  line-height: 1;
  display: block;
  transform: translateX(1px);
  pointer-events: none;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.timeline-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--ink-soft);
  min-width: 0;
}

.seek-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.18);
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  min-width: 40px;
}

.seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.1s ease;
}

.seek-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.lyrics-area {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink-soft);
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(145, 91, 254, 0.45) rgba(255, 255, 255, 0.06);
  white-space: pre-wrap;
}

.lyrics-area::-webkit-scrollbar {
  width: 8px;
}

.lyrics-area::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.lyrics-area::-webkit-scrollbar-thumb {
  background: rgba(145, 91, 254, 0.45);
  border-radius: 999px;
}

aside {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: 400px;
  background: var(--panel-strong);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 40;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
}

aside.open {
  transform: translateX(0);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.history-title {
  font-size: 1.2rem;
}

.btn-icon {
  padding: 0.5rem 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon .material-symbols-rounded {
  font-size: 1.05rem;
}

.history-sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 1.75rem;
  line-height: 1.6;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.site-footer {
  padding: 0 1rem 2rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.history-item {
  background: var(--surface-b);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.history-item:hover {
  background: var(--surface-a);
  border-color: rgba(255, 255, 255, 0.22);
}

.hist-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}

.history-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.18rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
}

.history-status .material-symbols-rounded {
  font-size: 0.92rem;
}

.history-status-complete {
  color: #77e3a9;
  background: rgba(42, 141, 91, 0.2);
  border-color: rgba(119, 227, 169, 0.35);
}

.history-status-pending {
  color: #f8c26a;
  background: rgba(148, 110, 43, 0.2);
  border-color: rgba(248, 194, 106, 0.35);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@media (max-width: 768px) {
  header {
    min-height: var(--header-height-mobile);
    padding: 1.15rem 1.25rem;
  }

  .brand img {
    height: 46px;
  }

  .btn-mobile-compact {
    font-size: 0.8rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    gap: 0.35rem;
    min-width: 2.5rem;
    justify-content: center;
  }

  aside {
    width: 100%;
    top: var(--header-height-mobile);
    padding: 1.5rem;
  }

  main {
    padding: 2rem 1rem 4rem;
  }

  .hero-section {
    margin-bottom: 3rem;
  }

  .hero-section h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
  }

  .hero-section p {
    font-size: 0.95rem;
  }

  .view-card {
    padding: 2rem 1.5rem;
    border-radius: 20px;
    background: rgba(13, 20, 36, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.18);
  }

  h2 {
    font-size: 1.35rem;
    margin-bottom: 1.5rem;
  }

  .form-group {
    margin-bottom: 2rem;
  }

  textarea,
  select,
  input[type="text"] {
    padding: 1rem;
    font-size: 0.95rem;
  }

  .style-tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .style-tags::-webkit-scrollbar {
    display: none;
  }

  .tag {
    flex: 0 0 auto;
  }

  /* Ajustement critique pour garder le bouton télécharger sur la même ligne */
  .track-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .track-header .btn {
    width: auto;
    justify-content: center;
  }

  .track-header .btn.btn-mobile-compact {
    width: auto;
  }

  .track-card {
    padding: 1.5rem;
    margin-top: 1.5rem;
  }

  .audio-controls {
    gap: 1rem;
  }

  #generateBtn {
    width: 100%;
  }

  .result-header {
    align-items: stretch;
  }

  .result-actions {
    width: 100%;
    justify-content: stretch;
  }

  .result-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .app-toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    text-align: center;
  }
}