:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d1c1a;
  --muted: #6d6a64;
  --line: #e4e1db;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --soft: #f3ece6;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --danger: #b42318;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --panel: #1f1e1c;
    --ink: #ece9e4;
    --muted: #a19d96;
    --line: #34322e;
    --accent: #e07a4b;
    --accent-ink: #1a1007;
    --soft: #2b2420;
    --ok: #5cbf86;
    --warn: #e0a84b;
    --danger: #f07167;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, system-ui, sans-serif;
}
[dir="auto"], textarea, .sent { font-family: "Noto Naskh Arabic", Inter, serif; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.top h1 { margin: 0; font-size: 18px; font-weight: 600; }
.top small { color: var(--muted); font-weight: 400; margin-inline-start: 8px; font-size: 13px; }
.credits { font-variant-numeric: tabular-nums; color: var(--muted); }
.credits b { color: var(--ink); }

.layout {
  display: grid; grid-template-columns: minmax(360px, 460px) 1fr; gap: 16px;
  padding: 16px 20px; align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 12px 16px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.form { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 900px) { .form { position: static; max-height: none; } }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; min-width: 0;
}
textarea { font-size: 19px; line-height: 1.8; resize: vertical; }
input:disabled { opacity: .5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.row { display: grid; gap: 10px; }
.row.two { grid-template-columns: 1fr 1fr; }
.row.four { grid-template-columns: 2fr 2fr 1fr 1fr auto; }
.row.voice { grid-template-columns: 2fr 1fr auto; align-items: end; }
@media (max-width: 560px) { .row.two, .row.voice, .row.four { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.chips button { font-size: 12px; padding: 3px 8px; border-radius: 999px; }

fieldset.settings {
  border: 1px solid var(--line); border-radius: var(--radius); margin: 0; padding: 10px 12px 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
}
fieldset legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
#stab3Wrap { grid-column: 1 / -1; }
.range output { color: var(--muted); font-weight: 400; margin-inline-start: 4px; font-variant-numeric: tabular-nums; }
input[type="range"] { padding: 0; accent-color: var(--accent); background: none; border: 0; }
.check { flex-direction: row; align-items: center; gap: 6px; }
.check input { width: auto; }
.inline { display: flex; gap: 6px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 7px 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
button:disabled { opacity: .5; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost:hover, .chips button:hover { background: var(--soft); }
button.link { border: 0; background: none; padding: 2px 0; color: var(--accent); }
button.link:hover { text-decoration: underline; }
button.danger { color: var(--danger); }
button.icon { padding: 4px 8px; }

.actions { display: flex; flex-direction: column; gap: 8px; }
.estimate { font-variant-numeric: tabular-nums; color: var(--muted); }
.estimate b { color: var(--ink); }
.estimate .warn { color: var(--warn); }
.btns { display: flex; gap: 8px; }
.btns .primary { flex: 1; }
.btns.small { justify-content: space-between; }
.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px -4px 12px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.take { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.take.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.take header { display: flex; align-items: baseline; gap: 10px; }
.take .meta { color: var(--muted); font-size: 12px; flex: 1; }
.take .fav { border: 0; background: none; font-size: 18px; color: var(--warn); }
.take .sent { margin: 0; font-size: 17px; line-height: 1.7; }
.take audio { width: 100%; height: 36px; }
.rate { grid-template-columns: auto 1fr; align-items: center; }
.stars button { border: 0; background: none; padding: 0 2px; font-size: 18px; color: var(--line); }
.stars button.on { color: var(--warn); }
.take footer { display: flex; gap: 16px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--soft); font-size: 12px; margin-inline-end: 4px; }
.qa { font-size: 12px; color: var(--muted); }
.qa .ok { color: var(--ok); }
.qa .bad { color: var(--warn); }
.qa .tr { font-family: "Noto Naskh Arabic", Inter, serif; font-size: 14px; color: var(--ink); }

.voice-card { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.voice-card p { margin: 0; color: var(--muted); font-size: 12px; grid-column: 1 / -1; }
.voice-card audio { grid-column: 1 / -1; width: 100%; height: 32px; }

.row.book-head { grid-template-columns: 2fr 2fr auto; align-items: end; }
@media (max-width: 560px) { .row.book-head { grid-template-columns: 1fr; } }
label.file { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-weight: 400; font-size: 14px; flex-direction: row; justify-content: center; }
label.file:hover { background: var(--soft); }
.chapter-bar { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 10px 0 12px; background: var(--soft); }
.progress { position: relative; height: 22px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--accent) 30%, transparent); transition: width .3s; }
.progress span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; }
.mix { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.mix audio { grid-column: 1 / -1; width: 100%; height: 34px; }
.paras { display: flex; flex-direction: column; gap: 2px; }
.para { font-family: "Noto Naskh Arabic", Inter, serif; font-size: 16px; line-height: 1.9; padding: 6px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; position: relative; }
.para:hover { background: var(--soft); }
.para.sel { border-color: var(--accent); background: var(--soft); }
.para.quote { font-style: italic; color: var(--muted); padding-inline-start: 28px; }
.para.attribution { font-size: 13px; color: var(--muted); text-align: end; }
.para.heading { font-weight: 600; }
.para.break { text-align: center; color: var(--muted); cursor: default; }
.para .n { font-family: Inter, sans-serif; font-size: 11px; color: var(--muted); margin-inline-end: 8px; }
.para .badge { font-family: Inter, sans-serif; margin-inline-start: 6px; }

/* Distribution (phase 3) */
.cast { margin: 12px 0; }
.cast h2 { font-size: 15px; margin: 0 0 8px; }
.cast-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.cast-card { border: 1px solid var(--line); border-inline-start: 4px solid var(--c); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.cast-card.ok { background: color-mix(in srgb, var(--ok) 7%, transparent); }
.cast-card header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cast-card header strong { font-family: "Noto Naskh Arabic", Inter, serif; font-size: 16px; color: var(--c); margin-inline-end: auto; }
.cast-card header button { padding: 4px 10px; font-size: 13px; }
.cast-card button.validated { color: var(--ok); border-color: var(--ok); }
.cast-card .role { margin: 0; font-size: 13px; }
.cast-card .hint { margin: 0; }
.cast-card audio { width: 100%; height: 32px; }
.cast-card .btns { flex-wrap: wrap; }
.cast-card .btns button { font-size: 13px; padding: 5px 10px; }
.cast-card details summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.cast-card .alt { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; margin-top: 6px; font-size: 13px; }
.cast-card .alt audio { grid-column: 1 / -1; }
.cast-card .sent { margin: 0; font-family: "Noto Naskh Arabic", Inter, serif; font-size: 15px; }
.assign { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border-radius: 8px; background: var(--soft); border: 1px solid var(--accent); }
.para .line { border-bottom: 2px solid var(--c); cursor: pointer; }
.para .line:hover { background: color-mix(in srgb, var(--c) 15%, transparent); }
.para .line.unset { border-bottom: 2px dashed var(--danger); }
.para .line .who { font-family: Inter, sans-serif; font-size: 10px; font-weight: 600; color: var(--c); margin-inline-end: 4px; vertical-align: super; }
.para .line.unset .who { color: var(--danger); }
.speaker-pick { width: auto; display: inline-block; font-family: Inter, sans-serif; font-size: 12px; padding: 2px 4px; margin-inline-end: 4px; }

@media (max-width: 560px) { .row.lex-row { grid-template-columns: 1fr; } }

/* Studio de correction (correct.js) */
.fx { display: flex; flex-direction: column; gap: 14px; }
.fx[hidden] { display: none; }
.fx-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.fx-title { display: flex; flex-direction: column; gap: 2px; margin-inline-end: auto; }
.fx-title h1 { margin: 0; font-size: 20px; }
.fx-ai { display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.fx-ai .hint { padding: 0 6px 0 10px; }
.fx-ai button { border: 0; border-radius: 999px; padding: 6px 14px; min-height: 32px; background: transparent; font-weight: 600; }
.fx-ai button.on { background: var(--ink); color: var(--bg); }
.fx-spent { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
.fx-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.fx-card h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }

.fx-deck { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; z-index: 5; box-shadow: 0 4px 14px rgb(0 0 0 / .06); }
.fx-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.fx-round { width: 44px; height: 44px; padding: 0; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.fx-play { width: 52px; height: 52px; border: 0; background: var(--accent); color: var(--accent-ink); }
.fx-play .i-pause, .fx-play.playing .i-play { display: none; }
.fx-play.playing .i-pause { display: block; }
.fx-time { font-variant-numeric: tabular-nums; font-size: 15px; min-width: 110px; }
.fx-stop { margin-inline-start: auto; min-height: 44px; padding: 0 16px; border: 1px solid var(--danger); color: var(--danger); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.fx-stop kbd { font: 11px Inter, sans-serif; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .8; }
.fx-toggle { min-height: 44px; padding: 0 16px; border-color: var(--ink); font-weight: 600; }
.fx-toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.fx-regen { min-height: 44px; border-color: var(--warn); color: var(--warn); font-weight: 600; }
.fx-remix { min-height: 44px; padding: 0 16px; border-color: var(--ok); color: var(--ok); font-weight: 600; }
.fx-remix.ready { background: var(--ok); color: #fff; }

.fx-overview { position: relative; height: 10px; border-radius: 999px; background: var(--soft); cursor: pointer; overflow: hidden; }
.fx-ov-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.fx-mark { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; }
.fx-mark.flag { background: var(--danger); }
.fx-mark.stale { background: var(--warn); }
.fx-mark.done { background: var(--ok); }

.fx-lanes { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 0 10px; }
.fx-ticks-pad, .fx-ticks { height: 20px; }
.fx-name, .fx-lane { height: 32px; border-bottom: 1px solid var(--line); }
.fx-name { display: flex; align-items: center; gap: 8px; font-family: "Noto Naskh Arabic", Inter, serif; font-weight: 600; font-size: 14px; overflow: hidden; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.fx-track { position: relative; overflow: hidden; cursor: pointer; direction: ltr; }
.fx-ticks { position: relative; border-bottom: 1px solid var(--line); }
.fx-tick { position: absolute; bottom: 3px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fx-lane { position: relative; background: color-mix(in srgb, var(--soft) 45%, transparent); }
.fx-block { position: absolute; top: 4px; height: 24px; padding: 0 5px; border: 1px solid rgb(0 0 0 / .1); border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; min-width: 6px; }
.fx-block.now { box-shadow: 0 0 0 2px var(--accent); }
.fx-block.sel { border: 3px solid var(--ink); }
.fx-block i { font-style: normal; background: #fff; border-radius: 4px; padding: 0 4px; }
.fx-block i.flag { color: var(--danger); }
.fx-block i.stale { color: var(--warn); }
.fx-block i.done { color: var(--ok); }
.fx-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; }

.fx-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px) minmax(340px, 420px); grid-template-areas: "text orig panel"; gap: 14px; align-items: start; }
.fx-cols.no-orig { grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); grid-template-areas: "text panel"; }
.fx-text { grid-area: text; }
.fx-orig { grid-area: orig; }
.fx-panel { grid-area: panel; }
@container main (max-width: 1180px) {
  .fx-cols, .fx-cols.no-orig { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); grid-template-areas: "text panel" "text orig"; }
  .fx-orig { position: static !important; max-height: none !important; }
}
@container main (max-width: 720px) { .fx-cols, .fx-cols.no-orig { grid-template-columns: 1fr; grid-template-areas: "panel" "orig" "text"; } }
.fx-orig { display: flex; flex-direction: column; gap: 10px; position: sticky; top: calc(var(--fx-deck, 300px) + 14px); max-height: calc(100vh - var(--fx-deck, 300px) - 28px); overflow-y: auto; }
.fx-orig[hidden] { display: none; }
.fx-panel { display: flex; flex-direction: column; gap: 14px; position: sticky; top: calc(var(--fx-deck, 300px) + 14px); max-height: calc(100vh - var(--fx-deck, 300px) - 28px); overflow-y: auto; }
.fx-panel.active { border-color: var(--accent); }
@media (max-width: 900px) { .fx-deck, .fx-orig, .fx-panel { position: static; max-height: none; } }

.fx-para { margin: 0 0 10px; font-family: "Noto Naskh Arabic", Inter, serif; font-size: 19px; line-height: 2; }
.fx-para.heading { font-weight: 600; font-size: 21px; }
.fx-seg { cursor: pointer; border-radius: 4px; padding: 2px 0; --p: 0%; }
.fx-seg:hover { background: var(--soft); }
.fx-seg.quote { border-bottom: 2px solid var(--c); }
/* Karaoké : la phrase lue se remplit de droite à gauche au fil de la lecture. */
.fx-seg.now { background: linear-gradient(to left, color-mix(in srgb, var(--accent) 30%, transparent) var(--p), color-mix(in srgb, var(--accent) 10%, transparent) var(--p)); }
.fx-seg.sel { outline: 2px solid var(--accent); }
.fx-seg.flagged { text-decoration: underline wavy var(--danger); text-underline-offset: 7px; }
.fx-seg.stale { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.fx-seg.redone::after { content: " ✓"; font-family: Inter, sans-serif; font-size: 11px; color: var(--ok); }

.fx-orig-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fx-orig-head h2 { margin: 0 auto 0 0; color: var(--ink); }
.fx-page { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 2px 10px rgb(0 0 0 / .08); background: #fff; }
.fx-ref-box { display: flex; flex-direction: column; gap: 4px; }
.fx-ref { margin: 0; font-family: "Noto Naskh Arabic", serif; font-size: 16px; line-height: 2; background: var(--bg); border-radius: 6px; padding: 8px 10px; }
.fx-ref mark, .fx-prop-text mark { background: #fde68a; color: #1d1c1a; border-radius: 3px; }

.fx-p-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fx-p-head b { font-family: "Noto Naskh Arabic", Inter, serif; font-size: 16px; }
.fx-p-head .link { margin-inline-start: auto; }
.badge.flag { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge.stale { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.fx-read { margin: 0; font-family: "Noto Naskh Arabic", Inter, serif; font-size: 20px; line-height: 1.9; background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.fx-tag { font: 12px Inter, sans-serif; background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); border-radius: 999px; padding: 1px 8px; margin-inline-start: 6px; }
.fx-ask { display: flex; flex-direction: column; gap: 8px; }
.fx-ask label { font-size: 13px; }
.fx-ask textarea { font-size: 15px; line-height: 1.5; }
.fx-ask .primary { min-height: 44px; }
.fx-ask .link { align-self: flex-start; }
.fx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-chips button { min-height: 38px; padding: 0 14px; border-radius: 999px; }
.fx-chips button.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.hint.warn { color: var(--warn); }
.fx-prop, .fx-tried, .fx-kept { display: flex; flex-direction: column; gap: 10px; border-radius: 10px; padding: 12px; }
.fx-prop { border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.fx-prop p { margin: 0; font-size: 13px; }
.fx-prop-text { font-family: "Noto Naskh Arabic", Inter, serif; font-size: 20px; line-height: 1.9; }
.fx-prop summary { cursor: pointer; font-size: 13px; color: var(--accent); }
.fx-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.fx-tried, .fx-kept { border: 1px solid var(--ok); background: color-mix(in srgb, var(--ok) 7%, transparent); }
.fx-kept b, .fx-tried > b { color: var(--ok); }
.btns.wrap { flex-wrap: wrap; align-items: center; }
.btns.wrap > * { flex: 0 0 auto; }
.fx-accept { min-height: 44px; padding: 0 16px; border: 0; background: var(--ok); color: #fff; font-weight: 600; }
.fx-lexoffer { display: flex; flex-direction: column; gap: 8px; font-size: 13px; border: 1px dashed var(--ok); border-radius: 8px; padding: 10px; }
.fx-lexoffer b { font-family: "Noto Naskh Arabic", serif; font-size: 16px; }
.fx-lexdone { margin: 0; font-size: 13px; color: var(--ok); }
.fx-takes summary, .fx-lex summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.fx-takes .take-row { margin-top: 6px; grid-template-columns: 1fr auto; }
.lex-item { display: flex; gap: 10px; align-items: center; font-family: "Noto Naskh Arabic", Inter, serif; font-size: 16px; }
.lex-item button { margin-inline-start: auto; font-family: Inter, sans-serif; font-size: 12px; }
.harakat { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.harakat button { font-family: "Noto Naskh Arabic", serif; font-size: 20px; line-height: 1; padding: 4px 10px; min-width: 40px; }
.take-row { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); }
.take-row.picked { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 7%, transparent); }
.fx-continue { min-height: 48px; border: 0; background: var(--ink); color: var(--bg); font-weight: 600; }
.fx-how { margin: 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.fx-how b { color: var(--ink); }

/* ---- V2 : Mes livres → studio du livre (app.js) ---- */
:root { --st-imported: var(--line); --st-analyzed: #e9c9a9; --st-ready: var(--accent); --st-generated: #8fbf9f; --st-mixed: var(--ok); }
@media (prefers-color-scheme: dark) { :root { --st-analyzed: #7a5a3c; --st-generated: #3f7a55; } }
.st-imported { background: var(--st-imported); } .st-analyzed { background: var(--st-analyzed); } .st-ready { background: var(--st-ready); }
.st-generated { background: var(--st-generated); } .st-mixed { background: var(--st-mixed); }

.toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 50; max-width: min(720px, calc(100vw - 32px)); box-shadow: 0 6px 20px rgb(0 0 0 / .15); background: var(--panel); border: 1px solid var(--danger); }
a.btn, label.file.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 600; text-decoration: none; }
a.btn.dark { background: var(--ink); color: var(--bg); }
label.file.primary { background: var(--accent); border: 0; color: var(--accent-ink); font-size: 14px; }
label.file { min-height: 44px; align-items: center; }
button { min-height: 36px; }
button.validated { color: var(--ok); border-color: var(--ok); font-weight: 600; }
button.ok-line { border-color: var(--ok); color: var(--ok); font-weight: 600; min-height: 44px; }
button.ok-fill { border-color: var(--ok); background: var(--ok); color: #fff; font-weight: 600; min-height: 44px; }

/* Accueil */
.home { max-width: 1440px; margin: 0 auto; padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.home-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.home-title { display: flex; flex-direction: column; gap: 2px; margin-inline-end: auto; }
.home-title h1 { margin: 0; font-size: 22px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters button { border-radius: 999px; padding: 6px 14px; }
.filters button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.book-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.book-card.new { border: 2px dashed var(--line); background: transparent; align-items: center; justify-content: center; text-align: center; min-height: 280px; }
.book-card.new label:not(.file) { width: min(260px, 100%); text-align: start; }
.bc-head { display: flex; align-items: flex-start; gap: 12px; }
.bc-cover { width: 56px; height: 76px; flex: none; border-radius: 6px; background: var(--soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); display: flex; align-items: center; justify-content: center; color: var(--accent); font: 600 22px "Noto Naskh Arabic", serif; }
.bc-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bc-id h2 { margin: 0; font: 600 22px/1.5 "Noto Naskh Arabic", Inter, serif; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.chip.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.bc-progress { display: flex; flex-direction: column; gap: 6px; }
.bc-line { display: flex; justify-content: space-between; font-size: 13px; }
.bc-bar { display: grid; gap: 2px; }
.bc-bar span { height: 10px; border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
dl.stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-variant-numeric: tabular-nums; }
dl.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 560px) { dl.stats, dl.stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
dl.stats div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
dl.stats dt { font-size: 12px; color: var(--muted); }
dl.stats dd { margin: 0; font-weight: 600; }
.bc-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bc-foot .hint { margin-inline-end: auto; }
details.menu { position: relative; flex: none; }
details.menu summary { list-style: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; inset-inline-end: 0; top: 48px; z-index: 10; min-width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .12); padding: 6px; display: flex; flex-direction: column; }
.menu-pop button, .menu-pop .menu-file { border: 0; background: none; text-align: start; padding: 10px 12px; border-radius: 8px; font: 400 14px Inter, sans-serif; cursor: pointer; flex-direction: row; }
.menu-pop button:hover, .menu-pop .menu-file:hover { background: var(--soft); }

/* Studio du livre */
.studio { padding: 14px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.st-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
a.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); text-decoration: none; font-weight: 600; }
.st-title { display: flex; flex-direction: column; margin-inline-end: auto; min-width: 0; }
#stTitle { font: 600 22px/1.4 "Noto Naskh Arabic", Inter, serif; }
.st-body { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.rail { flex: 1 1 230px; max-width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 14px; max-height: calc(100vh - 28px); }
@media (max-width: 900px) { .rail { max-width: none; position: static; max-height: 260px; } }
.rail-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 8px; font-size: 13px; }
.rail-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; min-height: 44px; color: var(--ink); text-decoration: none; }
.rail-item:hover { background: var(--bg); }
.rail-item.on { background: var(--soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.rail-item i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ri-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ri-text b { font-size: 13px; }
.ri-text span { font: 13px "Noto Naskh Arabic", serif; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.rail-item small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.st-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 14px; container: main / inline-size; }
.st-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.st-bar h1 { margin: 0 auto 0 0; font-size: 18px; }
.st-bar h1 span { font-family: "Noto Naskh Arabic", serif; font-weight: 600; }
.st-tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.st-tabs button { border: 0; border-radius: 9px; padding: 0 14px; min-height: 38px; background: transparent; font-weight: 600; }
.st-tabs button.on { background: var(--ink); color: var(--bg); }
#genProgress { display: flex; align-items: center; height: 32px; }
#genProgress[hidden] { display: none; }
#genProgress span { flex: 1; }
#genProgress .link { position: relative; margin-inline-end: 10px; min-height: 0; }
.notice { background: var(--soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.notice.warn { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.fx-seg.unset { border-bottom: 2px dashed var(--danger); }
.fx-who { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.fx-who select { width: auto; flex: 1; font-family: "Noto Naskh Arabic", Inter, serif; }
.fx-gen { min-height: 44px; }

.steps h2 { color: var(--ink); font-size: 16px; }
.steps ol { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.steps li.off { opacity: .55; }
.steps .num { width: 28px; height: 28px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.steps li.off .num { background: var(--line); color: var(--ink); }
.steps .grow { flex: 1; min-width: 200px; }
.steps button { min-height: 44px; padding: 0 18px; }
#chapterBox, #lexBox { display: flex; flex-direction: column; gap: 14px; }
#chapterBox audio { width: 100%; }
.steps-row { display: flex; flex-wrap: wrap; gap: 8px; }
.step { border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; }
.step.ok { border-color: var(--ok); color: var(--ok); }
#chapterBox .btns button, #chapterBox .btns a { min-height: 44px; }

.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; margin-top: 10px; }
.cast-card { background: var(--panel); border-inline-start-width: 1px; border-top: 4px solid var(--c); padding: 14px 16px; gap: 10px; }
.cast-card.ok { background: var(--panel); }
.voice-now { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.voice-now > div { flex: 1; min-width: 180px; font-size: 13px; }
.voice-now audio { flex: 1 1 200px; height: 34px; }
.picker { border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 5%, transparent); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.picker .alt { background: var(--panel); border-radius: 8px; padding: 6px 8px; margin: 0; }
.picker-search { display: flex; flex-wrap: wrap; gap: 6px; }
.picker-search input { flex: 1 1 140px; }
.settings-box summary { cursor: pointer; color: var(--accent); font-size: 13px; min-height: 28px; }
form.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding-top: 8px; }
form.settings .wide { grid-column: 1 / -1; }
form.settings output { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
form.settings input[type="range"] { padding: 0; }
@media (max-width: 560px) { form.settings { grid-template-columns: 1fr; } }
.lex-form { display: flex; flex-wrap: wrap; gap: 8px; }
.lex-form input { flex: 1 1 180px; min-height: 44px; font: 16px "Noto Naskh Arabic", serif; }
.lex-form button { min-height: 44px; }
.lex-list { display: flex; flex-direction: column; gap: 6px; }

/* ---- Préparation de lecture (étape 2) ---- */
button.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
button.danger-line { border-color: var(--danger); color: var(--danger); font-weight: 600; }
button.danger-fill { border-color: var(--danger); background: var(--danger); color: #fff; font-weight: 600; }
.prep { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 14px; align-items: start; margin-bottom: 14px; }
@container main (max-width: 900px) { .prep { grid-template-columns: 1fr; } }
.prep-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.prep-head { display: flex; flex-direction: column; gap: 8px; }
.prep-head h2 { color: var(--ink); font-size: 16px; margin: 0; }
.prep-head p { margin: 0; }
.prep-item { display: flex; flex-direction: column; gap: 8px; }
.prep-item.off { opacity: .55; }
.prep-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.prep-top .hint span { font-family: "Noto Naskh Arabic", Inter, serif; font-size: 13px; }
.prep-btns { margin-inline-start: auto; }
.prep-btns button { min-height: 36px; padding: 0 12px; }
.prep-kind { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.prep-kind.k-t { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.prep-kind.k-l { background: color-mix(in srgb, #2f6fb4 18%, transparent); color: #2f6fb4; }
.prep-kind.k-j { background: color-mix(in srgb, #7b3fa0 18%, transparent); color: #7b3fa0; }
@media (prefers-color-scheme: dark) { .prep-kind.k-l { color: #7fb0ea; } .prep-kind.k-j { color: #c79be6; } }
.prep-ctx { margin: 0; font-family: "Noto Naskh Arabic", Inter, serif; font-size: 18px; line-height: 1.9; }
.prep-ctx mark { background: #fde68a; color: #1d1c1a; border-radius: 3px; padding: 0 2px; }
.prep-change { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.prep-from { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 8px; padding: 2px 10px; font: 18px "Noto Naskh Arabic", Inter, serif; }
.prep-from b { color: var(--accent); }
.prep-change > .hint { flex: 1; min-width: 220px; font-size: 13px; }
.prep-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
.prep-edit label { flex: 1 1 220px; }
.prep-edit input { font: 17px "Noto Naskh Arabic", Inter, serif; min-height: 40px; }
.prep-edit .harakat { flex-basis: 100%; }
.prep-edit > .hint { flex-basis: 100%; }
.prep-side { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 14px; }
.prep-side dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.prep-side dd { margin: 0; font-weight: 600; }
.prep-side p { margin: 0; }
.prep-side button { min-height: 44px; }

/* ---- Panneau de correction : trois façons de corriger ---- */
.fx-modes { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; }
.fx-modes button { flex: 1 1 auto; border: 0; border-radius: 9px; padding: 0 10px; min-height: 38px; background: transparent; font-weight: 600; font-size: 13px; }
.fx-modes button.on { background: var(--ink); color: var(--bg); }
.fx-lib, .fx-rt { display: flex; flex-direction: column; gap: 10px; }
.fx-lib p, .fx-rt p { margin: 0; }
.fx-lib-voices { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fx-lib-voices button { border-radius: 999px; padding: 0 12px; font-family: "Noto Naskh Arabic", Inter, serif; font-weight: 600; }
.fx-lib-voices button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.fx-lib-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.fx-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.fx-lib-item { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 3px 4px; }
.fx-lib-item.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.fx-lib-play { width: 34px; height: 34px; min-height: 0; flex: none; padding: 0; border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 11px; }
.fx-lib-play.playing { background: var(--accent); color: var(--accent-ink); }
.fx-lib-play:disabled { opacity: .25; cursor: not-allowed; }
.fx-lib-pick { flex: 1; min-width: 0; border: 0; background: none; text-align: start; display: flex; flex-direction: column; padding: 2px 4px; min-height: 38px; justify-content: center; }
.fx-lib-pick b { font-size: 13px; }
.fx-lib-pick small { font-size: 11px; color: var(--muted); }
.fx-lib-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.fx-lib-foot .primary { margin-inline-start: auto; min-height: 44px; }
.fx-wave { width: 100%; height: 80px; background: var(--bg); border-radius: 8px; }
.fx-knobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 14px; }
.fx-knob { font-size: 13px; gap: 2px; }
.fx-knob > span { display: flex; justify-content: space-between; gap: 6px; }
.fx-knob b { font-variant-numeric: tabular-nums; font-weight: 600; }
.fx-knob small { font-size: 11px; }
.lib-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 13px; }
.lib-slot b { color: var(--ink); }

/* ---- Menu de l'appli (ABOOK-10) : Lire un livre / Écrire une histoire / Bibliothèque ---- */
.app { display: flex; align-items: stretch; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; }
.appnav {
  flex: 0 0 236px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: #1d1c1a; color: #e9e6e0; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
}
.an-brand { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 16px; }
.an-brand strong { color: #fff; font-size: 16px; }
.an-brand span, .an-label small { color: #9c978e; font-size: 12px; }
.appnav a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 10px; border-radius: 10px; color: inherit; text-decoration: none; }
.appnav a:hover { background: #2c2a27; }
.appnav a.on { background: #b4532a; color: #fff; }
.appnav a.on small { color: #fde9dc; }
.appnav svg { flex: none; }
.an-label { display: flex; flex-direction: column; gap: 1px; }
.an-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #34322e; font-size: 12px; color: #9c978e; font-variant-numeric: tabular-nums; }
.an-foot b { color: #fff; }
/* Sur les écrans de travail, le menu se réduit aux icônes (le nom reste au survol). */
.appnav.compact { flex-basis: 64px; padding: 14px 8px; }
.appnav.compact .an-brand, .appnav.compact .an-label, .appnav.compact .an-foot { display: none; }
.appnav.compact a { justify-content: center; padding: 8px 0; }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .appnav, .appnav.compact { flex: none; position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .appnav .an-brand, .appnav .an-foot, .appnav .an-label small { display: none; }
  .appnav .an-label { display: flex; }
  .appnav a { flex: 1 1 auto; min-height: 44px; justify-content: center; }
  /* Au téléphone, le pied du menu (crédits, langue, déconnexion) tient sur une ligne sous les liens. */
  .appnav .an-foot, .appnav.compact .an-foot { display: flex; flex: 1 0 100%; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 4px 0 0; padding: 6px 4px 0; }
  .appnav .an-foot .an-lang, .appnav .an-foot .an-out { margin: 0; }
  .appnav .an-out span { display: none; }
}
/* Langue de l'interface (ABOOK-13) */
.an-lang { display: block; margin-top: 10px; border: 1px solid #34322e; background: none; color: #e9c9a9; border-radius: 8px; padding: 6px 10px; min-height: 36px; font: 600 13px Inter, "Noto Naskh Arabic", sans-serif; cursor: pointer; }
.an-lang:hover { background: #34322e; }
.an-out { margin-top: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.an-out span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.an-out button { border: 0; background: none; color: #9c978e; text-decoration: underline; padding: 4px 0; min-height: 32px; font: inherit; cursor: pointer; }
.an-out button:hover { color: #fff; }
.an-lang[lang="ar"] { font-family: "Noto Naskh Arabic", serif; font-size: 15px; }
[dir="rtl"] body { font-family: "Noto Naskh Arabic", Inter, sans-serif; }
