:root {
  color-scheme: dark;
  --bg: #10121a;
  --panel: #181b25;
  --text: #e7e9f0;
  --muted: #9aa0b4;
  --accent: #5b8cff;
  --error: #ff7a7a;
  --ok: #6bd39a;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] {
  display: none !important;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  align-self: flex-start;
}

.player-wrap {
  position: relative;
  width: 100%;
  max-width: 1280px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.player-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 700ms ease;
  background: #000;
}

.prompt-form {
  width: 100%;
  max-width: 1280px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.prompt-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.prompt-row {
  display: flex;
  gap: 0.5rem;
}

.prompt-input {
  flex: 1;

  min-width: 0;
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
}

.prompt-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.prompt-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--accent);
  color: #0b0d13;
  border: none;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
}

.prompt-submit-icon {
  display: block;
}

.prompt-submit:hover,
.prompt-submit:focus-visible {
  filter: brightness(1.1);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pending {
  width: 100%;
  max-width: 1280px;
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

.message {
  width: 100%;
  max-width: 1280px;
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--error);
  background: rgba(255, 122, 122, 0.1);
  border: 1px solid rgba(255, 122, 122, 0.3);
  border-radius: 6px;
}

.debug,
.stats {
  width: 100%;
  max-width: 1280px;
  margin: 0;
  padding: 0.75rem 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.stats {
  max-width: none;
}

.debug-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.debug-block + .debug-block {
  margin-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 0.75rem;
}

.debug-block-title {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.debug-kv {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: 0.15rem 0.9rem;
  margin: 0 0 0.5rem;
}

.debug-kv dt {
  color: var(--muted);
}

.debug-kv dd {
  margin: 0;

  white-space: pre-wrap;
  word-break: break-word;
}

.debug-verdict {
  margin: 0 0 0.5rem;
  padding: 0.35rem 0.5rem;
  background: rgba(91, 140, 255, 0.12);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
}

.debug-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.25rem 0;
}

.debug-table th,
.debug-table td {
  text-align: left;
  padding: 0.2rem 0.5rem 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  vertical-align: top;
  word-break: break-word;
}

.debug-table th {
  color: var(--muted);
  font-weight: 500;
}

.debug-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.debug-win {
  color: var(--accent);
}

.debug-out {
  color: var(--muted);
  opacity: 0.75;
}

.debug-ok {
  color: var(--ok);
}

.debug-ko {
  color: var(--error);
}

.debug-more,
.debug-note {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.debug-body {
  margin-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 0.75rem;
}

.debug-current-file {
  color: var(--accent);
  font-weight: 600;
}

.stats-entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stats-card {
  padding: 0.6rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.stats-card-value {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stats-card-label {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.stats-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-toc a,
.stats-retour {
  color: var(--accent);
  text-decoration: none;
}

.stats-toc a:hover,
.stats-retour:hover {
  text-decoration: underline;
}

.stats-retour {
  margin-left: auto;
}

.stats-sous-titre {
  margin: 0.9rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.stats-periodes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.stats-periodes-label {
  color: var(--muted);
}

.stats-bouton {
  padding: 0.2rem 0.55rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
}

.stats-bouton:hover {
  border-color: var(--accent);
}

.stats-bouton-actif {
  background: rgba(91, 140, 255, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

.stats-bar-cell {
  width: 22%;
  min-width: 4rem;
}

.stats-bar {
  height: 0.55rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.stats-nuage {
  margin: 0.2rem 0 0;
  color: var(--muted);
  word-break: break-word;
}

.stats-coller {
  margin: 0.4rem 0 0;
  padding: 0.5rem 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre;
}

@media (max-width: 720px) {
  .debug,
  .stats {
    overflow-x: auto;
  }

  .debug-kv {
    grid-template-columns: 1fr;
    gap: 0 0;
  }

  .debug-kv dt {
    margin-top: 0.3rem;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 1rem;
  }
}
