:root {
  --bg: #f7f7f9;
  --panel: #ffffff;
  --side: #f0f0f4;
  --text: #1c1c22;
  --muted: #6b6b78;
  --line: #e2e2e8;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --hover: #e8e8f0;
  --error-bg: #fdecec;
  --error: #b42318;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15151a;
    --panel: #1d1d24;
    --side: #18181e;
    --text: #ececf1;
    --muted: #9a9aa8;
    --line: #2e2e38;
    --accent: #818cf8;
    --accent-text: #0f0f14;
    --hover: #262630;
    --error-bg: #3a1d1d;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.45rem; margin: 0 0 1rem; line-height: 1.25; word-break: break-word; }
h2 { font-size: 1.05rem; margin: 2rem 0 .4rem; }
code { background: var(--hover); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .9rem; }

.layout { display: grid; grid-template-columns: 290px 1fr; min-height: 100%; }
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 1.1rem .9rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
#quitBtn { margin-top: auto; flex: none; }
.btn-quiet { background: none; color: var(--muted); }
.btn-quiet:hover { color: var(--text); }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 2rem 1.6rem; text-align: center;
}
.login-box h1 { margin: .6rem 0 1.4rem; }
.login-box form { display: flex; flex-direction: column; gap: .6rem; text-align: left; }
.login-box label { font-weight: 600; }
.login-box input {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
.login-box input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.stopped { max-width: 520px; margin: 18vh auto; padding: 0 16px; text-align: center; }
.brand { font-weight: 700; font-size: 1.1rem; margin: 0 .3rem 1rem; }
.side-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem .3rem .4rem; }
main { padding: 2rem clamp(1rem, 4vw, 3rem) 7rem; max-width: 980px; width: 100%; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-block { width: 100%; }
.icon-btn {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .95rem;
  width: 28px; height: 28px; border-radius: 6px; display: inline-grid; place-items: center; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; border-radius: 8px; }
.history li:hover, .history li.active { background: var(--hover); }
.history li.empty { padding: .4rem .3rem; }
.h-main { flex: 1; min-width: 0; padding: .45rem .5rem; color: inherit; text-decoration: none; display: flex; flex-direction: column; }
.h-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .92rem; }
.h-sub { font-size: .76rem; color: var(--muted); }
.h-actions { display: flex; padding-right: .25rem; }
.badge { background: var(--line); border-radius: 99px; padding: 0 .45rem; font-size: .72rem; }
.badge-err { background: var(--error-bg); color: var(--error); }
#totalCost { margin: 1rem .3rem 0; }

.banner { background: var(--error-bg); color: var(--error); padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  min-height: 220px; padding: 2rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--panel);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--accent); outline: none; }
.drop.busy { opacity: .6; pointer-events: none; }
.drop-title { font-size: 1.15rem; font-weight: 600; }
.model-label { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
select { font: inherit; padding: .4rem .5rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); max-width: 100%; }
.settings { display: flex; flex-direction: column; gap: .35rem; margin-top: 1rem; }
.settings label { font-weight: 600; }
.settings .check { display: flex; align-items: center; gap: .5rem; font-weight: 400; cursor: pointer; }
.settings .check input { width: 16px; height: 16px; accent-color: var(--accent); }
.settings textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); resize: vertical; min-height: 2.6rem;
}
.settings :disabled, .settings .disabled { opacity: .5; }
.upload-progress { margin-top: 1rem; display: flex; flex-direction: column; gap: .3rem; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.error-text { color: var(--error); }
#uploadError { margin-top: 1rem; }
#saveState { font-weight: 400; margin-left: .5rem; }

.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.job-titles { min-width: 0; flex: 1; }
.job-titles h1 { margin-bottom: .2rem; }
.job-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .5rem; }
.date-btn { border: 0; background: none; color: inherit; font: inherit; padding: 0; cursor: pointer; text-align: left; }
.date-btn:hover { color: var(--accent); text-decoration: underline; }
.date-btn .warn { color: var(--error); }
.date-edit { display: inline-flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.date-edit input { font: inherit; padding: .2rem .35rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.btn-small { padding: .2rem .55rem; font-size: .82rem; }
.actions { display: flex; gap: .5rem; }
.actions .btn-primary { font-size: 1rem; padding: .6rem 1.1rem; }

#statusBox:not(:empty) { margin-top: 1.5rem; }
.status-box {
  display: grid; grid-template-columns: auto 1fr; gap: .6rem 1rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
}
.status-box progress, .status-box .muted { grid-column: 1 / -1; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--error-bg); color: var(--error); border-radius: var(--radius); padding: 1rem 1.2rem; }
.error-box .muted { color: inherit; opacity: .8; }
.error-box pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; max-height: 260px; overflow: auto; color: var(--text); background: var(--panel); padding: .6rem; border-radius: 6px; }

.speakers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; margin-top: .6rem; }
.speaker {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--radius); padding: .75rem;
}
.play {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--c); color: #fff; font-size: .8rem;
}
.play:hover { filter: brightness(1.1); }
.speaker-body { flex: 1; min-width: 0; }
.speaker input {
  width: 100%; font: inherit; font-weight: 600; padding: .35rem .5rem; margin-bottom: .2rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text);
}
.speaker input:focus { outline: 2px solid var(--c); outline-offset: -1px; }
.excerpt { font-size: .85rem; font-style: italic; margin-top: .3rem; color: var(--muted); }

.transcript { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1.2rem; margin-top: .6rem; }
.turn { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.turn:last-child { border-bottom: 0; }
.turn-head { display: flex; align-items: baseline; gap: .6rem; }
.turn-name { font-weight: 700; color: var(--c); }
.ts { border: 0; background: none; color: var(--muted); font: .8rem ui-monospace, monospace; cursor: pointer; padding: 0; }
.ts:hover { color: var(--accent); text-decoration: underline; }
.turn p { margin: .15rem 0 0; white-space: pre-wrap; }

.player-bar {
  position: fixed; bottom: 0; left: 290px; right: 0; padding: .6rem 1rem;
  background: var(--panel); border-top: 1px solid var(--line);
}
.player-bar audio { width: 100%; display: block; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .history { max-height: 240px; overflow-y: auto; }
  .player-bar { left: 0; }
}

/* ---------- Dictionnaire ---------- */
.nav-btn { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; text-decoration: none; }
.nav-btn.active { border-color: var(--accent); color: var(--accent); }
.nav-btn .badge:empty { display: none; }
.dict-summary { margin: .2rem 0 0; font-size: .92rem; }
.dict-summary a { color: var(--accent); }

.dict-add { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1.2rem 0 .8rem; }
.dict-add input { flex: 1 1 320px; }
.dict-add input, .dict-tools input {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text);
}
.dict-add input:focus, .dict-tools input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.dict-tools { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dict-tools input { flex: 0 1 260px; padding: .4rem .6rem; }
.dict-tools .btn { margin-left: auto; }

.dict-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .9rem; }
.dict-cat {
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--radius);
  padding: .6rem .8rem .9rem; transition: opacity .15s, box-shadow .15s;
}
.dict-cat.inactive { opacity: .55; }
.dict-cat.drop-target { box-shadow: 0 0 0 2px var(--c); }
.dict-cat-head { display: flex; align-items: center; gap: .45rem; margin-bottom: .55rem; }
.dict-cat-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.cat-name {
  flex: 1; min-width: 0; font: inherit; font-weight: 700; border: 1px solid transparent; border-radius: 6px;
  padding: .2rem .35rem; background: none; color: var(--text);
}
.cat-name:hover { border-color: var(--line); }
.cat-name:focus { border-color: var(--c); outline: none; background: var(--bg); }
.cat-count { font-size: .78rem; color: var(--muted); background: var(--hover); border-radius: 99px; padding: 0 .5rem; }
.cat-toggle { display: flex; align-items: center; gap: .25rem; font-size: .8rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.cat-toggle input { accent-color: var(--c); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 2rem; align-items: flex-start; }
.chip {
  display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 99px; background: var(--bg);
  font-size: .9rem; max-width: 100%;
}
.chip:hover { border-color: var(--c); }
.chip.dragging { opacity: .4; }
.chip.beyond { opacity: .45; border-style: dashed; }
.warn-text { color: #b45309; }
.dict-cat-head .icon-btn:disabled { opacity: .25; cursor: default; }
.chip-text {
  border: 0; background: none; color: var(--text); font: inherit; cursor: grab; padding: .2rem .15rem .2rem .7rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-del { border: 0; background: none; color: var(--muted); cursor: pointer; padding: .2rem .55rem .2rem .3rem; font-size: .75rem; }
.chip-del:hover { color: var(--error); }
.chip mark { background: color-mix(in srgb, var(--c) 30%, transparent); color: inherit; border-radius: 3px; }
.chip.editing { padding: .15rem .3rem; gap: .25rem; border-color: var(--c); border-radius: 10px; }
.chip.editing input, .chip.editing select {
  font: inherit; font-size: .88rem; padding: .15rem .35rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text);
}
.chip.editing input { width: 11rem; }
