/* Démonstrateur Arbiter : charte du Manager Wizidee (bleu #1f3a8a, Barlow) */
:root {
  /* charte Everial (wizidee-sandbox) */
  --bg: #fbfbff;
  --panel: #ffffff;
  --soft: #f4f6fd;
  --text: #001849;
  --text-2: #253141;
  --muted: #535f70;
  --border: #dae1ff;
  --border-strong: #b3c5ff;
  --accent: #1a3d8a;
  --accent-2: #21428f;
  --accent-soft: #eef0ff;
  --brand-light: #a5b9f5;
  --on-brand: #f0f5ff;
  --choice: #21428f;
  --bool: #0d8c48;
  --score: #7a3e00;
  --ok: #0d6b39;
  --ok-soft: #dff6e9;
  --warn: #7a3e00;
  --warn-soft: #fdecd2;
  --err: #ba1a1a;
  --err-soft: #ffdad6;
  --bar: #b3c5ff;
  --code-bg: #001849;
  --code-fg: #eef0ff;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 'Blinker', system-ui, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
code, .mono, pre { font-family: 'JetBrains Mono', ui-monospace, monospace; }
code { font-size: 0.88em; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ---------- bandeau (charte Everial) ---------- */
.topbar { margin: 3px; border-radius: 6px; min-height: 64px; background: var(--accent-2); color: var(--on-brand); display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 0.75rem; height: 2rem; }
.sparkle { height: 100%; aspect-ratio: 1; fill: var(--brand-light); transition: transform 0.6s ease-in-out; }
.brand:hover .sparkle { transform: rotate(360deg); }
.brand-name { font-weight: 700; font-size: 1.35rem; line-height: 1; letter-spacing: 0.01em; }
.topbar-divider { width: 1px; height: 40px; background: var(--brand-light); }
.topnav { display: flex; align-self: stretch; }
.topnav a { position: relative; display: flex; align-items: center; padding: 0 1.4rem; color: var(--on-brand); text-decoration: none; font-weight: 600; font-size: 1.1rem; }
.topnav a.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 10px; height: 2px; background: var(--brand-light); }

/* ---------- deux volets ---------- */
.volets { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; padding: 20px; max-width: 1680px; margin: 0 auto; align-items: start; }
@media (max-width: 1080px) { .volets { grid-template-columns: minmax(0, 1fr); padding: 16px; } }
.volet { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* grand écran : chaque volet défile seul, l'exécution reste visible pendant le paramétrage */
@media (min-width: 1081px) {
  body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  .topbar { flex: none; }
  .volets { flex: 1; min-height: 0; width: 100%; align-items: stretch; }
  .volet { overflow-y: auto; min-height: 0; padding: 0 6px 24px 0; }
}
.volet-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- cas d'usage ---------- */
.scenario-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.scenario { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 92px; }
.scenario:hover { border-color: var(--accent); }
.scenario.active { border: 2px solid var(--accent); padding: 9px 11px; background: var(--accent-soft); }
.scenario .s-name { font-weight: 700; font-size: 15px; }
.scenario .s-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.qtag { font-size: 11px; font-weight: 600; color: #fff; border-radius: 4px; padding: 1px 6px; }
.qtag.choice { background: var(--choice); }
.qtag.check { background: var(--bool); }
.qtag.score { background: var(--score); }
.qtag.meta { background: #eef2f9; color: var(--text-2); border: 1px solid var(--border); }

/* ---------- éditeur ---------- */
.editor-head { display: flex; align-items: center; gap: 10px; }
.title-input { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; background: transparent; }
.title-input:hover, .title-input:focus { border-color: var(--border-strong); background: #fff; }
.desc-input { border: 1px solid transparent; background: transparent; padding: 4px 6px; resize: vertical; color: var(--text-2); }
.desc-input:hover, .desc-input:focus { border-color: var(--border-strong); background: #fff; }
.badge { font-size: 13px; font-weight: 600; border-radius: 12px; padding: 3px 10px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.dirty { color: var(--warn); background: var(--warn-soft); }

.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid #c9d3e6; }
.tabs button { height: 42px; padding: 0 18px; border: 0; background: transparent; color: var(--text-2); font-weight: 500; cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab-panel { display: flex; flex-direction: column; gap: 14px; }
.block { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.block:last-child { border-bottom: 0; padding-bottom: 0; }
.block-head { display: flex; align-items: baseline; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.editor-foot { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

input[type=text], input[type=password], textarea, select { width: 100%; border: 1px solid var(--border-strong); border-radius: 4px; padding: 7px 10px; background: #fff; }
textarea { resize: vertical; line-height: 1.45; }
textarea.mono, pre { font-size: 12.5px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.label-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.check, .switch-row { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input, .switch-row input { margin-top: 4px; }
.inline { display: flex; flex-wrap: wrap; gap: 16px; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.item { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--soft); display: flex; flex-direction: column; gap: 8px; }
.item.invalid { border-color: var(--err); background: var(--err-soft); }
.item-row { display: flex; gap: 8px; }
.item-row .t-label { flex: 2; font-weight: 600; }
.item-row .t-key, .item-row .q-id { flex: 1; min-width: 0; font-size: 13px; }
.item-row .q-type { width: auto; flex: none; font-weight: 600; }
.t-more summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.t-more[open] { display: flex; flex-direction: column; gap: 8px; }

.btn { height: 40px; padding: 0 16px; border: 1px solid var(--text); border-radius: 4px; background: #fff; color: var(--text); font-weight: 500; cursor: pointer; }
.btn.small { height: 32px; padding: 0 12px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn:disabled { background: #d9dee8; border-color: #d9dee8; color: #6b7590; cursor: not-allowed; }
.btn.primary:disabled { background: #9aa6c2; border-color: #9aa6c2; color: #fff; }
.icon { width: 36px; flex: none; border: 1px solid var(--border-strong); border-radius: 4px; background: #fff; cursor: pointer; color: var(--muted); }
.icon:hover { color: var(--err); border-color: var(--err); }
.add { height: 38px; border: 2px dashed #9fb0d4; border-radius: var(--radius); background: #f6f8fd; color: var(--accent); font-weight: 600; cursor: pointer; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; cursor: pointer; text-decoration: underline; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; align-self: flex-start; }
.seg button { border: 0; background: #fff; padding: 7px 14px; cursor: pointer; color: var(--text-2); font-size: 14px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

.code { margin: 0; background: var(--code-bg); color: var(--code-fg); border-radius: 4px; padding: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow: auto; }
.code.light { background: var(--soft); color: var(--text); border: 1px solid var(--border); }
.error { margin: 0; color: var(--err); background: var(--err-soft); border-radius: 4px; padding: 8px 12px; white-space: pre-wrap; }

/* ---------- exécution ---------- */
.dropzone { border: 2px dashed #9fb0d4; border-radius: var(--radius); background: #f6f8fd; padding: 14px; display: flex; align-items: center; gap: 10px; color: var(--text-2); cursor: pointer; }
.dropzone svg { color: var(--accent); flex: none; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 4px 4px 4px 10px; font-size: 14px; }
.file-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .icon { height: 28px; width: 28px; }
.example-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.example-row .field { flex: 1 1 260px; }
.example-row .btn { height: 38px; }
.expected { margin: 0; font-size: 14px; color: var(--text-2); background: #f6f8fd; border-left: 3px solid var(--accent); border-radius: 0 4px 4px 0; padding: 8px 12px; }
.expected b { color: var(--text); }
.mode-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.run-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.run-buttons .btn { flex: 1 1 160px; height: 42px; }

.progress { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.answers-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); }
.answers-head strong { font-size: 16px; color: var(--text); }
.note { background: #fff6e8; border: 1px solid #f0cf9a; border-radius: 4px; padding: 4px 8px; color: #6a3700; font-size: 13px; }
.results { display: flex; flex-direction: column; gap: 16px; }
.group { display: flex; flex-direction: column; gap: 12px; }
.group-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding-top: 4px; }
.group-title .tag { font-weight: 500; }
.file-group { background: var(--soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.file-group > summary { cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.file-group > summary .group-title { padding-top: 0; }
.file-group[open] > summary { margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.answer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }

.acard { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.acard.wide { grid-column: 1 / -1; }
.acard-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.acard-q { font-size: 14px; color: var(--text-2); }
.verdict { font-size: 12px; font-weight: 700; border-radius: 10px; padding: 3px 10px; white-space: nowrap; }
.verdict.auto { color: var(--ok); background: var(--ok-soft); }
.verdict.review { color: #7a3e00; background: var(--warn-soft); }
.verdict.yes { color: var(--ok); background: var(--ok-soft); }
.verdict.no { color: var(--text-2); background: #e6ebf5; }
.figures { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; }
.fig { display: flex; flex-direction: column; gap: 2px; }
.fig .k { font-size: 13px; color: var(--muted); }
.fig .v { font-size: 24px; font-weight: 700; line-height: 1.15; }
.fig .v.big { font-size: 26px; }
.fig .v.option { font-size: 17px; line-height: 1.3; }
.fig .v small { font-size: 14px; font-weight: 500; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr) 52px; gap: 12px; align-items: center; font-size: 14px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-row.top .lbl { font-weight: 700; color: var(--text); }
.track { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; display: flex; }
.fill { height: 100%; border-radius: 5px; background: var(--bar); }
.bar-row.top .fill { background: var(--accent); }
.pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.gauge { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; }
.gauge-track { position: relative; height: 14px; border-radius: 7px; background: var(--bg); overflow: hidden; }
.gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bool); border-radius: 7px; }
.gauge-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: #7a3e00; }
.gauge-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.dist { display: flex; height: 22px; border-radius: 4px; overflow: hidden; font-size: 11px; font-weight: 700; color: #fff; }
.dist span { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; }
.dist-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.dist-legend b { color: var(--text); }

.tag { font-size: 12px; border-radius: 4px; padding: 1px 7px; background: var(--accent-soft); color: var(--accent); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.none { background: #eef2f9; color: var(--muted); }
details.more > summary { cursor: pointer; font-size: 14px; color: var(--text-2); font-weight: 500; }
details.more[open] > summary { margin-bottom: 8px; }
.req-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.req-head code { background: var(--bg); border-radius: 4px; padding: 2px 8px; color: var(--text); }
table.fields { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
table.fields caption { text-align: left; font-weight: 600; padding: 4px 0; }
table.fields td { border-bottom: 1px solid var(--border); padding: 3px 6px; vertical-align: top; word-break: break-word; }
table.fields td:first-child { color: var(--muted); width: 40%; }
.file-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }

/* ---------- vignettes et visionneuse ---------- */
.file-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.thumb { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }
.thumb-open { display: block; padding: 0; border: 0; background: var(--soft); cursor: zoom-in; height: 150px; width: 100%; }
.thumb-open img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-open:hover, .thumb-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.thumb-open .ph { display: flex; height: 100%; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); padding: 8px; text-align: center; }
.thumb-info { padding: 6px 8px; display: flex; flex-direction: column; gap: 1px; }
.thumb-info .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-info .muted { font-size: 12px; }
.thumb .icon { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; background: rgba(255,255,255,0.92); }
.thumb .pages { position: absolute; top: 4px; left: 4px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(27,42,92,0.85); border-radius: 4px; padding: 1px 6px; }

.viewer { width: min(1100px, 94vw); max-height: 92vh; border: 0; border-radius: 8px; padding: 0; box-shadow: 0 10px 40px rgba(15,26,58,0.35); }
.viewer::backdrop { background: rgba(15,26,58,0.6); }
.viewer-head { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--border); }
.viewer-title { display: flex; flex-direction: column; min-width: 0; }
.viewer-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px; background: var(--bg); }
.viewer-pages figure { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.viewer-pages img { max-width: 100%; height: auto; box-shadow: 0 2px 8px rgba(27,42,92,0.18); background: #fff; }
.viewer-pages figcaption { font-size: 12px; color: var(--muted); }

/* ---------- jeton d'accès (zone discrète) ---------- */
.key-btn { position: relative; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--on-brand); opacity: 0.55; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.key-btn svg { width: 20px; height: 20px; }
.key-btn:hover, .key-btn:focus-visible, .key-btn.alert { opacity: 1; background: rgba(240, 245, 255, 0.12); }
.key-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #ff8a80; box-shadow: 0 0 0 2px var(--accent-2); }
.token-dialog { width: min(560px, 94vw); border: 0; border-radius: var(--radius); padding: 20px; box-shadow: 0 10px 40px rgba(0, 24, 73, 0.35); }
.token-dialog::backdrop { background: rgba(0, 24, 73, 0.5); }
.token-dialog h2 { margin: 0; }
.token-dialog .editor-foot { border-top: 0; padding-top: 0; }
.token-ok { color: var(--ok); font-weight: 600; }
.token-ko { color: var(--err); font-weight: 600; }

/* ---------- verrou : rien n'est utilisable sans jeton ---------- */
.volets.locked { filter: blur(3px) grayscale(0.4); opacity: 0.45; pointer-events: none; user-select: none; }
.locked-note { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- détail du paramétrage repliable ---------- */
.editor > .editor-summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; margin: -18px -20px; padding: 16px 20px; border-radius: var(--radius); }
.editor > .editor-summary::-webkit-details-marker { display: none; }
.editor > .editor-summary:hover { background: var(--soft); }
.editor > .editor-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.editor[open] > .editor-summary { margin-bottom: 0; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.summary-title { font-weight: 700; font-size: 17px; }
.chevron { width: 10px; height: 10px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); transition: transform 0.15s; flex: none; }
.editor[open] .chevron { transform: rotate(45deg); }
