:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #5b6475;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --border: #dde1e8;
  --error-bg: #fdecec;
  --error-text: #a51d1d;
  --ok-bg: #e8f6ee;
  --ok-text: #1b6b3a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1d2129;
    --text: #e7e9ee;
    --muted: #9aa3b3;
    --accent: #6d8bff;
    --accent-text: #0e1220;
    --border: #2d3340;
    --error-bg: #3a1a1a;
    --error-text: #ffb3b3;
    --ok-bg: #16301f;
    --ok-text: #9fe0b5;
  }
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar form { margin: 0; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }

.container { max-width: 760px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
}
.card.narrow { max-width: 420px; margin: 24px auto; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }

label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 0.95rem; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.link { background: none; border: 0; color: var(--accent); font-size: 0.95rem; cursor: pointer; padding: 4px; }

.msg { padding: 10px 12px; border-radius: 8px; }
.msg-error { background: var(--error-bg); color: var(--error-text); }
.msg-success, .msg-info { background: var(--ok-bg); color: var(--ok-text); }

/* --- Comptes et sécurité (Lot 2) --- */
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.card + .card { margin-top: 16px; }
a { color: var(--accent); }
a.btn { text-align: center; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-danger { background: var(--error-text); color: var(--surface); }
.btn-small { display: inline-block; width: auto; margin-top: 8px; padding: 8px 14px; font-size: 0.95rem; }
.help { color: var(--muted); font-size: 0.92rem; margin: 6px 0; }
.field-error { color: var(--error-text); font-size: 0.92rem; margin: 6px 0 0; }
.separator { text-align: center; color: var(--muted); margin: 20px 0 0; }
.msg-warning { background: var(--error-bg); color: var(--error-text); }
.topnav { display: flex; align-items: center; gap: 12px; }
.topnav a { text-decoration: none; font-size: 0.95rem; }
.qr-box { display: flex; justify-content: center; margin: 16px 0; }
.qr-box img { background: #fff; padding: 8px; border-radius: 8px; }
code.secret { word-break: break-all; font-size: 1rem; }
.backup-codes {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  list-style: none; padding: 0; margin: 16px 0; font-size: 1.05rem;
}
.backup-codes li { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; text-align: center; }
.item-list { list-style: none; padding: 0; margin: 12px 0; }
.item-list li { border-top: 1px solid var(--border); padding: 12px 0; }
.item-list .help { display: block; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; }
summary { cursor: pointer; color: var(--accent); margin-top: 6px; }
[hidden] { display: none !important; }

/* --- Dossiers, enregistrements, dépôt (Lot 3) --- */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; font-size: 0.95rem; }
.breadcrumb span { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.toolbar > .btn, .toolbar summary.btn { display: inline-block; width: auto; margin-top: 0; padding: 11px 16px; }
.dropdown { flex: 1 1 auto; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown[open] .inline-form { margin-top: 10px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-title { font-weight: 600; word-break: break-word; }
.folder-link { display: block; color: var(--text); text-decoration: none; padding: 4px 0; }
.item-list details form { margin-top: 8px; }
.badge { flex: none; font-size: 0.8rem; padding: 3px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.badge-processing { color: var(--accent); border-color: var(--accent); }
.badge-done { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.badge-error { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
select, input[type="file"] {
  width: 100%; padding: 11px; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.inline-form select { flex: 1; min-width: 160px; width: auto; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  margin: 8px 0 0; padding: 28px 16px; border: 2px dashed var(--border); border-radius: 12px;
  color: var(--text); cursor: pointer;
}
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-over { border-color: var(--accent); background: var(--bg); }
.dropzone-text { font-weight: 600; }
@media (hover: none) { .desktop-only { display: none; } }
.file-list { list-style: none; padding: 0; margin: 12px 0; }
.file-item { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--border); }
.file-name { word-break: break-all; }
.file-item progress { width: 100%; height: 8px; }
.file-status { font-size: 0.9rem; color: var(--muted); }
.file-ok .file-status { color: var(--ok-text); }
.file-error .file-status { color: var(--error-text); }
.btn:disabled { opacity: 0.5; cursor: default; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two-cols { grid-template-columns: 1fr; } }

/* --- Transcription (Lot 4) --- */
.rec-progress { width: 100%; height: 6px; margin: 6px 0 2px; }
.rec-error { margin: 8px 0 0; font-size: 0.92rem; }
.excerpt { margin: 6px 0 0; font-size: 0.95rem; color: var(--text); }

/* --- Lecture, correction, recherche (Lot 6) --- */
.search-form { display: flex; gap: 8px; margin-bottom: 14px; }
.search-form input[type="search"] {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.search-form .btn-small { margin-top: 0; }
a.item-title { color: var(--text); text-decoration: none; }
a.item-title:hover { color: var(--accent); }
.zip-bar { align-items: center; }
.zip-bar .btn-small { margin-top: 0; }
.rec-title { word-break: break-word; margin-bottom: 4px; }
.player-bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 8px 0; margin: 8px 0 12px;
}
.player-bar audio { width: 100%; display: block; }
.transcript { padding: 8px; }
.segment {
  display: flex; gap: 10px; width: 100%; text-align: left; align-items: baseline;
  padding: 8px; border: 0; border-radius: 8px; background: none;
  color: var(--text); font: inherit; line-height: 1.5; cursor: pointer;
}
.segment:hover { background: var(--bg); }
.segment.active { background: var(--ok-bg); }
.seg-time { flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg-text { flex: 1; }
.correct-row { padding: 10px 0; border-top: 1px solid var(--border); }
.correct-row.corrected textarea { border-color: var(--accent); }
.correct-row.active { background: var(--ok-bg); }
.correct-head { display: flex; justify-content: space-between; align-items: center; }
.seg-play { font-variant-numeric: tabular-nums; }
textarea {
  width: 100%; padding: 10px; font: inherit; color: var(--text); resize: vertical;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.sticky-actions {
  position: sticky; bottom: 0; display: flex; gap: 16px; align-items: center;
  padding: 10px 0; background: var(--bg);
}
.sticky-actions .btn { width: auto; margin-top: 0; padding: 12px 20px; }
