:root {
  --bg: #12131a;
  --card: #1b1d27;
  --card-2: #232635;
  --border: #2e3244;
  --text: #e8e9f0;
  --muted: #9297ab;
  --accent: #ff8c42;
  --accent-2: #4ec9b0;
  --danger: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 820px; margin: 0 auto; }

header { margin-bottom: 1.75rem; }
h1 { margin: 0 0 .25rem; font-size: 1.7rem; letter-spacing: -.02em; }
.sub { margin: 0; color: var(--muted); }

h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* --- Formulaire --------------------------------------------------------- */
.field { display: block; margin-bottom: 1rem; }
.field span {
  display: block;
  margin-bottom: .4rem;
  font-size: .82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

input[type="text"], input[type="url"] {
  width: 100%;
  padding: .7rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.sep {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.1rem 0;
  color: var(--muted);
  font-size: .85rem;
}
.sep::before, .sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1rem;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: rgba(255, 140, 66, .07); }
.drop-main { margin: 0 0 .3rem; font-weight: 500; }
.drop-sub { margin: 0; font-size: .87rem; color: var(--muted); }
.filename {
  margin: .8rem 0 0;
  padding: .45rem .7rem;
  display: inline-block;
  background: var(--card-2);
  border-radius: 6px;
  font-size: .87rem;
  color: var(--accent-2);
}

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.primary {
  width: 100%;
  margin-top: 1.25rem;
  padding: .85rem;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #1a1206;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { opacity: .5; cursor: not-allowed; }

.error {
  margin: 1rem 0 0;
  padding: .7rem .85rem;
  background: rgba(255, 107, 107, .12);
  border: 1px solid rgba(255, 107, 107, .35);
  border-radius: 8px;
  color: var(--danger);
  font-size: .9rem;
}
.error p { margin: 0; }

/* Message brut de yt-dlp, conservé pour le debug. */
.tech {
  margin-top: .6rem !important;
  padding-top: .55rem;
  border-top: 1px solid rgba(255, 107, 107, .22);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  line-height: 1.45;
  word-break: break-word;
}

.fallback {
  margin-top: .8rem;
  padding: .55rem .9rem;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #1a1206;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
}
.fallback:hover { filter: brightness(1.08); }

/* Mise en évidence de la zone d'upload après clic sur le bouton de repli. */
.drop.highlight {
  border-color: var(--accent);
  animation: pulse 1.1s ease-out 2;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 140, 66, .5); }
  100% { box-shadow: 0 0 0 14px rgba(255, 140, 66, 0); }
}

/* --- Chargement --------------------------------------------------------- */
.loading { text-align: center; }
.spinner {
  width: 34px;
  height: 34px;
  margin: .25rem auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hint { margin: .4rem 0 0; font-size: .85rem; color: var(--muted); }

/* --- Résultats ---------------------------------------------------------- */
.bpm-card { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; }
.bpm { display: flex; align-items: baseline; gap: .5rem; }
.bpm-value {
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -.03em;
}
.bpm-unit { font-size: 1rem; color: var(--muted); letter-spacing: .1em; }

.meta { display: flex; gap: 2rem; margin: 0; flex-wrap: wrap; }
.meta dt {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.meta dd { margin: .15rem 0 0; font-size: 1.05rem; font-weight: 500; }

.timeline {
  display: flex;
  width: 100%;
  height: 62px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.seg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid rgba(0, 0, 0, .35);
  color: #10121a;
  font-size: .72rem;
  font-weight: 600;
  overflow: hidden;
  cursor: default;
}
.seg:last-child { border-right: none; }
.seg small { font-weight: 500; opacity: .75; }

.legend {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .5rem;
}
.legend li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .65rem;
  background: var(--card-2);
  border-radius: 8px;
  font-size: .85rem;
}
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.legend .times { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

textarea {
  width: 100%;
  padding: .9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88rem;
  line-height: 1.6;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.copy {
  padding: .45rem .9rem;
  background: var(--accent-2);
  border: none;
  border-radius: 6px;
  color: #08201c;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.copy:hover { filter: brightness(1.08); }

@media (max-width: 560px) {
  .bpm-value { font-size: 2.8rem; }
  .meta { gap: 1.2rem; }
}
