:root {
  --bg: #f6f6f4; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e2e2dc;
  --accent: #2f5bd3; --accent-text: #ffffff; --danger: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616; --panel: #1f1f1f; --text: #ececea; --muted: #9a9a94; --line: #2e2e2c;
    --accent: #7b9bff; --accent-text: #0d0d0d; --danger: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input { font: inherit; }

/* Connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.login label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.login input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.login button { width: 100%; margin-top: 16px; padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
.login button:disabled { opacity: .6; cursor: default; }
.error { color: var(--danger); font-size: 14px; min-height: 1.5em; margin-top: 10px; }

/* Application */
.app { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); height: 100%; }
.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.top .brand { font-weight: 600; }
.top .usage { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; color: var(--text); cursor: pointer; }
#desk { display: flex; min-height: 0; min-width: 0; }

/* Fenêtres et séparateurs */
.split { display: flex; min-width: 0; min-height: 0; }
.split-row { flex-direction: row; }
.split-col { flex-direction: column; }
#desk > * { flex: 1 1 0; }
.separator { flex: 0 0 6px; background: var(--line); position: relative; touch-action: none; }
.split-row > .separator { cursor: col-resize; }
.split-col > .separator { cursor: row-resize; }
.separator:hover, .separator.dragging { background: var(--accent); }
.win { position: relative; display: flex; flex-direction: column; min-width: 120px; min-height: 90px; background: var(--bg); }
.win-body { flex: 1; overflow: auto; padding: 20px 16px; }
.win-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; border-top: 1px solid var(--line); background: var(--panel); }
.win-spaces, .win-actions { display: flex; gap: 2px; }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--bg); }
.placing { position: absolute; inset: 0; z-index: 5; cursor: copy; }
.placing-half { position: absolute; background: var(--muted); opacity: .25; pointer-events: none; }
.placing-half[data-side="left"]   { left: 0; top: 0; bottom: 0; width: 50%; }
.placing-half[data-side="right"]  { right: 0; top: 0; bottom: 0; width: 50%; }
.placing-half[data-side="top"]    { left: 0; right: 0; top: 0; height: 50%; }
.placing-half[data-side="bottom"] { left: 0; right: 0; bottom: 0; height: 50%; }
.placeholder { max-width: 640px; color: var(--muted); }
.placeholder h2 { color: var(--text); margin-top: 0; }
@media (max-width: 600px) { .win { min-width: 80px; } }

/* Fenêtre de dialogue (mot de passe) */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 24px; width: min(380px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin: 0 0 16px; font-size: 18px; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
dialog input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dialog-actions button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; }
.dialog-actions .primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* Connexions IA */
dialog.wide { width: min(560px, calc(100vw - 32px)); }
.muted { color: var(--muted); }
.ai-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.ai-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.ai-state { margin-left: auto; font-size: 13px; color: var(--muted); }
.ai-state[data-on="1"] { color: var(--accent); }
.ai-actions { display: flex; gap: 8px; margin-top: 10px; }
.ai-actions button { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; }
.ai-actions .primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.ai-actions button[hidden] { display: none; }
#ai-claude-flow p { margin: 10px 0 6px; }
#ai-claude-flow a { color: var(--accent); }
.ai-msg { font-size: 14px; margin-top: 8px; min-height: 1.2em; overflow-wrap: anywhere; }
