:root {
  --navy: #0f1b2d; --blue: #2563eb; --green: #16a34a; --red: #dc2626;
  --ink: #1e293b; --muted: #64748b; --faint: #94a3b8;
  --line: #eef1f5; --line2: #e3e8ef; --bg: #f1f5f9; --soft: #f8fafc;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, textarea { font: inherit; color: inherit; }

/* boutons */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 7px 14px; font-weight: 600; background: #fff; color: var(--ink); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.accent { background: #3ddc84; color: var(--navy); }
.btn.dark { background: var(--navy); color: #fff; padding: 9px 16px; }
.btn.ok { background: var(--green); color: #fff; }
.btn.cut { color: var(--red); border-color: #fecaca; font-size: 12px; padding: 4px 11px; }
.btn.ghost { background: transparent; color: #cbd5e1; border-color: rgba(255,255,255,.25); }
.audit .btn.ghost, dialog .btn.ghost { color: var(--muted); border-color: #cbd5e1; }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--navy); }
.auth-card { width: 100%; max-width: 360px; background: #fff; border-radius: 14px; padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.auth-card h1 { margin: 0; font-size: 18px; color: var(--navy); }
.auth-card .brand { color: var(--navy); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #475569; }
label small { font-weight: 400; color: var(--faint); }
label input { border: 1px solid #cbd5e1; border-radius: 9px; padding: 9px 12px; font-weight: 400; background: #fff; }
label input:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--blue); }
.form-error { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--red); }

/* en-tête */
#app { display: flex; flex-direction: column; height: 100%; max-width: 1400px; margin: 0 auto; padding: 14px; }
.top { display: flex; align-items: center; gap: 16px; padding: 12px 18px; background: var(--navy); color: #fff; border-radius: 12px 12px 0 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand small { opacity: .7; font-weight: 400; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.2); flex: none; }
.dot.live, .auth .dot { background: #3ddc84; box-shadow: 0 0 0 4px rgba(61,220,132,.2); }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab { background: transparent; border: none; color: #94a3b8; padding: 6px 12px; border-radius: 7px; font-weight: 600; }
.tab.active { background: rgba(255,255,255,.12); color: #fff; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.panel { flex: 1; min-height: 0; border: 1px solid var(--line2); border-top: none; border-radius: 0 0 12px 12px; background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px 1fr; }

/* liste */
.list { border-right: 1px solid var(--line); background: var(--soft); overflow-y: auto; }
.lh { padding: 11px 15px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.chk { flex-direction: row; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.item { padding: 11px 15px; border-top: 1px solid var(--line); cursor: pointer; }
.item:hover { background: #fff; }
.item.sel { background: #fff; box-shadow: inset 3px 0 0 var(--blue); }
.item.closed { opacity: .55; }
.item h4 { margin: 0; font-size: 13.5px; color: var(--navy); overflow-wrap: anywhere; }
.item .c { font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.p-diag { background: #eff6ff; color: #2563eb; }
.p-wait { background: #fff7ed; color: #c2410c; }
.p-go { background: #fef3c7; color: #92400e; }
.p-run { background: #f0fdf4; color: #15803d; }
.p-idle { background: #f1f5f9; color: #64748b; }
.os { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; letter-spacing: .3px; }
.os-windows { background: #e0f2fe; color: #0369a1; }
.os-linux { background: #fef9c3; color: #854d0e; }
.exp { font-size: 11px; color: var(--faint); }
.none { padding: 16px; color: var(--faint); font-size: 13px; }

/* chat */
.chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.empty { margin: auto; color: var(--faint); padding: 24px; text-align: center; }
.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chead { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chead h3 { margin: 0; font-size: 14px; color: var(--navy); }
.chead .meta { font-size: 12px; color: var(--faint); margin-left: auto; }
.note { padding: 8px 16px; background: #fff7ed; color: #9a3412; font-size: 12.5px; border-bottom: 1px solid #fed7aa; }
.feed { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #fcfdfe; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.ai { align-self: flex-start; background: #f1f5f9; color: var(--ink); border-bottom-left-radius: 4px; }
.sys { align-self: flex-start; max-width: 92%; font-size: 12px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.sys code { background: var(--navy); color: #e2e8f0; padding: 1px 6px; border-radius: 5px; }
.sys.bad { color: var(--red); }
.thinking { align-self: flex-start; color: var(--faint); font-size: 12.5px; font-style: italic; }

.plan { align-self: flex-start; max-width: 82%; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 12px 14px; }
.plan h4 { margin: 0 0 6px; font-size: 11.5px; color: #92400e; text-transform: uppercase; letter-spacing: .5px; }
.plan p { margin: 0 0 6px; font-size: 13px; }
.plan ul { margin: 0; padding-left: 18px; color: #334155; font-size: 13px; }
.plan ul li { margin: 2px 0; }
.plan .risks { margin-top: 8px; color: #b45309; }
.plan .btns { display: flex; gap: 8px; margin-top: 11px; }
.plan .done { margin-top: 10px; font-size: 12px; font-weight: 700; color: #15803d; }
.go { background: var(--green); color: #fff; border: none; border-radius: 7px; padding: 6px 18px; font-weight: 700; }
.no { background: #fff; color: #475569; border: 1px solid #cbd5e1; border-radius: 7px; padding: 6px 14px; }
.confirm { align-self: flex-start; max-width: 82%; background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.confirm h4 { margin: 0 0 6px; font-size: 11.5px; color: #991b1b; text-transform: uppercase; letter-spacing: .5px; }
.confirm code { display: block; margin: 6px 0 10px; background: var(--navy); color: #e2e8f0; padding: 6px 9px; border-radius: 6px; overflow-wrap: anywhere; white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; }
.confirm .danger { background: var(--red); color: #fff; border: none; border-radius: 7px; padding: 6px 14px; font-weight: 700; }

.input { border-top: 1px solid var(--line); padding: 11px 14px; display: flex; gap: 9px; align-items: flex-end; background: #fff; }
.input textarea { flex: 1; resize: none; max-height: 140px; border: 1px solid #cbd5e1; border-radius: 9px; padding: 9px 12px; }

/* journal */
.audit { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.audit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.audit-head h2 { margin: 0; font-size: 16px; color: var(--navy); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line2); }
td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.k { font-weight: 700; color: var(--navy); white-space: nowrap; }
td.d { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: #475569; overflow-wrap: anywhere; max-width: 520px; }
td.t { white-space: nowrap; color: var(--muted); }

/* dialogue */
dialog { border: none; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(15,27,45,.4); }
dialog::backdrop { background: rgba(15,27,45,.55); }
dialog form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 17px; color: var(--navy); }
.os-choice { border: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.os-choice legend { font-size: 12.5px; font-weight: 600; color: #475569; padding: 0; margin-bottom: 6px; }
.os-card { flex-direction: row; align-items: center; gap: 9px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.os-card:has(input:checked) { border-color: var(--blue); background: #eff6ff; }
.os-card span { display: flex; flex-direction: column; }
.os-card b { color: var(--navy); font-size: 14px; }
.os-card small { font-size: 11px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 10; }

@media (max-width: 760px) {
  #app { padding: 0; }
  .top { border-radius: 0; }
  .grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .list { max-height: 34vh; border-right: none; border-bottom: 1px solid var(--line); }
  .msg, .plan, .confirm { max-width: 94%; }
  .top-actions { margin-left: 0; }
}
