/* AubeMira-Core · interface moderne type Claude/ChatGPT */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --sidebar-w: 270px;
  --settings-w: 340px;
  --col: 760px; /* largeur colonne conversation */
  --radius: 14px;
  --radius-sm: 10px;
}

/* ===== Thème clair (défaut, type Claude cream) ===== */
body[data-theme="sepia"], body:not([data-theme]) {
  --bg: #faf9f5;
  --bg-2: #f0eee6;
  --bg-3: #e9e6dd;
  --ink: #1f1e1c;
  --ink-soft: #66635c;
  --ink-faint: #9a968c;
  --paper: #ffffff;
  --line: #e6e3da;
  --line-strong: #d2cec3;
  --accent: #c96442;
  --accent-soft: #f5e8e2;
  --user-bubble: #f0eee6;
  --ok: #2c8a3e;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
}
/* ===== Thème blanc (type ChatGPT clair) ===== */
body[data-theme="blanc"] {
  --bg: #ffffff;
  --bg-2: #f9f9f9;
  --bg-3: #ececec;
  --ink: #0d0d0d;
  --ink-soft: #5d5d5d;
  --ink-faint: #9b9b9b;
  --paper: #ffffff;
  --line: #ececec;
  --line-strong: #d9d9d9;
  --accent: #10a37f;
  --accent-soft: #e7f6f1;
  --user-bubble: #f4f4f4;
  --ok: #10a37f;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 6px 20px rgba(0,0,0,0.05);
}
/* ===== Thème sombre (type ChatGPT/Claude dark) ===== */
body[data-theme="sombre"] {
  --bg: #1a1a1a;
  --bg-2: #202020;
  --bg-3: #2a2a2a;
  --ink: #ececec;
  --ink-soft: #b4b4b4;
  --ink-faint: #7a7a7a;
  --paper: #232323;
  --line: #333333;
  --line-strong: #444444;
  --accent: #d97757;
  --accent-soft: #3a2c25;
  --user-bubble: #2f2f2f;
  --ok: #4caf50;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 6px 20px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  transition: transform 0.22s ease;
  z-index: 20;
}
.sidebar.hidden { transform: translateX(-100%); }

.sb-head { padding: 14px 14px 6px; }
.brand-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; padding: 4px; }
.cachet {
  width: 30px; height: 30px;
  background: var(--accent); color: #fff;
  font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.brand { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--ink-faint); }

.btn-new {
  width: 100%;
  padding: 11px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  color: var(--ink);
  text-align: left;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.12s;
}
.btn-new:hover { background: var(--bg-3); }

.modes { display: flex; padding: 12px 10px 6px; gap: 4px; }
.mode {
  flex: 1; padding: 7px 4px;
  color: var(--ink-soft);
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
  transition: all 0.12s;
}
.mode:hover { background: var(--bg-3); color: var(--ink); }
.mode.active { background: var(--accent-soft); color: var(--accent); }

.sb-section-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-faint);
  padding: 12px 16px 4px;
}
.sb-search { padding: 0 12px 6px; }
.sb-search input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  outline: none;
  font-size: 13px;
  color: var(--ink);
}
.sb-search input:focus { border-color: var(--accent); }

.convs { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.convs li {
  padding: 9px 12px; margin-bottom: 1px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  display: flex; justify-content: space-between; align-items: center;
  gap: 6px;
  transition: background 0.1s;
}
.convs li:hover { background: var(--bg-3); color: var(--ink); }
.convs li.active { background: var(--bg-3); color: var(--ink); }
.convs li .meta { font-size: 10px; color: var(--ink-faint); flex-shrink: 0; }
.convs li .ttl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stats-block { padding: 8px 16px; font-size: 11px; color: var(--ink-faint); }
.stats-block .stat { display: flex; justify-content: space-between; padding: 1px 0; }
.stats-block .stat .v { color: var(--ink-soft); font-weight: 600; }

.sb-foot { padding: 8px 10px; border-top: 1px solid var(--line); }
.btn-foot {
  width: 100%; padding: 9px 12px;
  color: var(--ink-soft);
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  text-align: left;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 2px;
}
.btn-foot:hover { background: var(--bg-3); color: var(--ink); }

.status { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-faint); padding: 6px 12px 2px; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: #aaa; }
.status.ok .dot { background: var(--ok); }
.status.err .dot { background: var(--accent); }

/* ===================== MAIN ===================== */
.main {
  position: fixed; top: 0; bottom: 0; right: 0;
  left: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--bg);
  transition: left 0.22s ease, right 0.22s ease;
}
.main.full-left { left: 0; }
.main.with-settings { right: var(--settings-w); }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
}
.btn-icon {
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--ink-soft);
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
}
.btn-icon:hover { background: var(--bg-3); color: var(--ink); }

.conv-title {
  flex: 1;
  background: none; outline: none; border: none;
  font-size: 15px; font-weight: 500;
  color: var(--ink); padding: 4px 0;
}
.topbar-right { display: flex; gap: 4px; align-items: center; }
.badge {
  font-size: 11px; font-weight: 500;
  color: var(--ink-soft);
  background: var(--bg-3);
  padding: 4px 10px; border-radius: 20px;
}
.ephemeral-btn.active { background: var(--accent); color: #fff; }
.system-on { background: var(--accent-soft) !important; color: var(--accent) !important; }

/* ===================== MESSAGES ===================== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 8px;
  display: flex; flex-direction: column;
  align-items: center;
}
/* chaque message dans une colonne centrée */
.msg {
  width: 100%;
  max-width: var(--col);
  display: flex; gap: 14px;
  padding: 14px 0;
  animation: msg-in 0.25s ease;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  margin-top: 2px;
}
.msg.bot .msg-avatar { background: var(--accent); color: #fff; }
.msg.user .msg-avatar { background: var(--bg-3); color: var(--ink-soft); }

.msg-main { flex: 1; min-width: 0; }
.msg-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 2px; min-height: 20px;
}
.msg-role { font-size: 13px; font-weight: 600; color: var(--ink); }
.msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions .btn-icon { padding: 4px 7px; font-size: 12px; }

.msg-body {
  font-size: 15px; line-height: 1.65;
  color: var(--ink);
  word-break: break-word;
}
.msg.user .msg-body {
  background: var(--user-bubble);
  padding: 10px 14px;
  border-radius: var(--radius);
  display: inline-block;
}
.msg-body p { margin: 0 0 10px; white-space: pre-wrap; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h1, .msg-body h2, .msg-body h3 { font-weight: 600; margin: 16px 0 8px; line-height: 1.3; }
.msg-body h1 { font-size: 20px; }
.msg-body h2 { font-size: 17px; }
.msg-body h3 { font-size: 15px; }
.msg-body ul, .msg-body ol { margin: 8px 0; padding-left: 24px; }
.msg-body li { margin: 3px 0; }
.msg-body strong { font-weight: 600; }
.msg-body em { font-style: italic; }
.msg-body code.inline {
  background: var(--bg-3);
  padding: 2px 6px; border-radius: 5px;
  font-family: var(--mono); font-size: 0.88em;
}

.codeblock {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 10px 0;
  overflow: hidden;
}
.codeblock-head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-3);
  padding: 6px 12px;
  font-size: 11px; color: var(--ink-soft);
  font-family: var(--mono);
}
.codeblock pre {
  margin: 0; padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
}
.copy-cb { font-size: 11px; }

.attached-file {
  display: inline-flex; gap: 6px; align-items: center;
  background: var(--bg-3);
  padding: 4px 10px; border-radius: 16px;
  font-size: 12px; color: var(--ink-soft);
  margin: 0 6px 6px 0;
}
.attached-file .x { color: var(--accent); cursor: pointer; }

.cursor {
  display: inline-block; width: 8px; height: 16px;
  background: var(--accent); vertical-align: text-bottom;
  border-radius: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* fact banner */
.fact-banner {
  width: 100%; max-width: var(--col);
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  margin: 6px 0;
  animation: msg-in 0.25s ease;
}
.fact-banner.dismissed { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.fact-icon { font-size: 17px; }
.fact-text { flex: 1; color: var(--ink); }
.fact-text strong { color: var(--accent); text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; }
.fact-text em { font-style: normal; font-weight: 600; }
.fact-actions { display: flex; gap: 6px; }
.fact-actions .btn { padding: 6px 14px; font-size: 12px; }

/* msg edit form */
.msg-edit-form { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.msg-edit-form textarea {
  min-height: 80px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font); font-size: 14px;
  background: var(--paper); color: var(--ink);
  resize: vertical; outline: none;
}
.edit-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ===================== CODE / VISION PANELS ===================== */
.code-panel { flex: 1; display: flex; flex-direction: column; background: var(--paper); border-top: 1px solid var(--line); }
.code-head { display: flex; gap: 8px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.code-filename { flex: 1; background: none; border: 1px solid transparent; font-family: var(--mono); font-size: 13px; color: var(--ink); padding: 5px 8px; border-radius: 6px; }
.code-filename:focus { background: var(--paper); border-color: var(--line); outline: none; }
.code-actions { display: flex; gap: 4px; }
.code-editor { flex: 1; width: 100%; border: none; outline: none; resize: none; background: var(--paper); color: var(--ink); font-family: var(--mono); font-size: 13px; line-height: 1.6; padding: 16px 20px; tab-size: 4; }

.vision-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.vision-card { max-width: 520px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px; box-shadow: var(--shadow); }
.vision-card h2 { margin: 0 0 10px; font-size: 22px; font-weight: 600; }
.vision-card p { color: var(--ink-soft); margin: 0 0 10px; }
.vision-soon { font-style: italic; color: var(--ink-faint); }
.vision-card button { margin-top: 12px; padding: 10px 20px; background: var(--accent); color: #fff; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; }
#vision-preview { margin-top: 14px; font-size: 13px; color: var(--ink-soft); }
#vision-preview img { max-width: 100%; border-radius: var(--radius-sm); margin-top: 8px; }

.hidden { display: none !important; }

/* empty state (type ChatGPT/Claude) */
.empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  margin-top: 18vh;
  animation: msg-in 0.4s ease;
}
.empty-logo {
  width: 52px; height: 52px;
  background: var(--accent); color: #fff;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 600;
  margin-bottom: 20px;
}
.empty-state h1 { font-size: 28px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.4px; }
.empty-state p { font-size: 16px; color: var(--ink-soft); margin: 0; }

/* ===================== COMPOSER ===================== */
.composer {
  padding: 8px 20px 18px;
  display: flex; flex-direction: column; align-items: center;
}
.composer .attached { width: 100%; max-width: var(--col); display: flex; flex-wrap: wrap; padding-bottom: 6px; }
.composer textarea {
  width: 100%; max-width: var(--col);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 14px 16px;
  outline: none; resize: none;
  font-size: 15px; line-height: 1.5;
  min-height: 54px; max-height: 220px;
  box-shadow: var(--shadow);
  transition: border-color 0.12s;
}
.composer textarea:focus { border-color: var(--accent); }
.composer-bar {
  width: 100%; max-width: var(--col);
  display: flex; gap: 6px; align-items: center;
  margin-top: 8px;
}
.hint { flex: 1; font-size: 11px; color: var(--ink-faint); }

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  transition: opacity 0.12s, background 0.12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { background: var(--bg-3); color: var(--ink-soft); }
.btn-ghost:not(:disabled):hover { color: var(--ink); }
.btn-danger { background: none; color: var(--accent); border: 1px solid var(--accent); padding: 9px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.btn-danger:hover { background: var(--accent); color: #fff; }
#btn-mic.recording { background: var(--accent); color: #fff; animation: blink 1.2s infinite; }

/* ===================== SETTINGS ===================== */
.settings {
  position: fixed; top: 0; bottom: 0; right: 0;
  width: var(--settings-w);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  z-index: 15;
}
.set-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.set-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.set-section { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.set-section h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); margin: 0 0 14px; }
.set-section label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.set-section label span { float: right; color: var(--accent); font-weight: 600; }
.set-section input[type="range"] { width: 100%; margin-top: 6px; accent-color: var(--accent); }
.set-section label.check { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 14px; }
.set-section label.check input { accent-color: var(--accent); }
#model-info { font-size: 12px; color: var(--ink-soft); margin: 0; }
#model-info dt { color: var(--ink-faint); margin-top: 7px; }
#model-info dd { margin: 0; font-weight: 500; }
.set-foot { padding: 16px 20px; font-size: 11px; color: var(--ink-faint); }

.theme-picker { display: flex; gap: 8px; }
.theme-opt { flex: 1; cursor: pointer; }
.theme-opt input { display: none; }
.theme-card {
  display: block; padding: 16px 6px; text-align: center;
  font-size: 11px; font-weight: 500;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color 0.12s, transform 0.1s;
}
.theme-card.sepia { background: #faf9f5; color: #1f1e1c; }
.theme-card.blanc { background: #ffffff; color: #0d0d0d; border-color: #d9d9d9; }
.theme-card.sombre { background: #1a1a1a; color: #ececec; border-color: #444; }
.theme-opt input:checked + .theme-card { border-color: var(--accent); transform: scale(1.03); }

.kbds { border-collapse: collapse; width: 100%; font-size: 12px; color: var(--ink-soft); }
.kbds td { padding: 4px 0; }
.kbds td:last-child { text-align: right; }
kbd { display: inline-block; padding: 2px 7px; margin: 0 2px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 5px; font-family: var(--mono); font-size: 10px; }

/* ===================== MODAL ===================== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(3px); }
.modal-card { background: var(--paper); border-radius: var(--radius); width: 600px; max-width: 92vw; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-help { margin: 16px 22px 8px; font-size: 13px; color: var(--ink-soft); }
#system-textarea { margin: 8px 22px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; font-family: var(--font); font-size: 14px; background: var(--bg); color: var(--ink); resize: vertical; outline: none; }
#system-textarea:focus { border-color: var(--accent); }
.modal-presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 22px 14px; }
.modal-presets button { font-size: 12px; padding: 6px 12px; background: var(--bg-3); border-radius: 16px; color: var(--ink-soft); }
.modal-presets button:hover { color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--line); }

/* memory */
.memory-card { width: 720px; max-width: 92vw; }
.memory-add { display: grid; grid-template-columns: 120px 160px 1fr auto; gap: 6px; padding: 12px 22px 6px; }
.memory-add select, .memory-add input { padding: 8px 11px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; font-size: 13px; outline: none; }
.memory-add select:focus, .memory-add input:focus { border-color: var(--accent); }
.memory-list { margin: 8px 22px 12px; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.memory-row { display: grid; grid-template-columns: 110px 1fr 60px; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.memory-row:last-child { border-bottom: none; }
.memory-row .mem-type { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.memory-row .mem-content { font-size: 13px; color: var(--ink); }
.memory-row .mem-content .k { color: var(--ink-soft); }
.memory-row .mem-content .v { color: var(--ink); font-weight: 600; }
.memory-row .mem-actions { display: flex; gap: 4px; justify-content: flex-end; }
.memory-empty { padding: 30px 20px; text-align: center; font-size: 13px; color: var(--ink-faint); }
.memory-actions { display: flex; gap: 8px; align-items: center; padding: 16px 22px; border-top: 1px solid var(--line); }
.memory-count { flex: 1; font-size: 12px; color: var(--ink-faint); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) { .sidebar { width: 240px; } .main { left: 240px; } }
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); }
  .main { left: 0; }
  .settings { width: 100%; }
  .main.with-settings { right: 0; }
  .messages { padding: 20px 14px 8px; }
}
