/* Odius — feuille de style */

:root {
  --bg: #faf5ec;
  --sb: #f3eadb;
  --surface: #fffdf9;
  --bubble: #f0e3cc;
  --text: #2a2219;
  --muted: #75654f;
  --faint: #a3927a;
  --line: #eadfcb;
  --accent: #a8661d;
  --accent-ink: #fffaf0;
  --soft: #ecd8b4;
  --soft-ink: #6e4614;
  --glow: rgba(214, 150, 60, .22);
  --logo-ink: var(--bg);
  --hover: rgba(120, 80, 20, .06);
  --active: rgba(120, 80, 20, .1);
  --shadow: 0 1px 2px rgba(90, 60, 20, .05), 0 8px 28px rgba(90, 60, 20, .08);
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, ui-serif, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --w: 740px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1915;
    --sb: #17140f;
    --surface: #27211b;
    --bubble: #352b20;
    --text: #f0e8dc;
    --muted: #b3a593;
    --faint: #847663;
    --line: #3a3128;
    --accent: #e0a458;
    --accent-ink: #2a1a06;
    --soft: #4a3920;
    --soft-ink: #f0c98a;
    --glow: rgba(224, 164, 88, .16);
    --hover: rgba(255, 225, 180, .06);
    --active: rgba(255, 225, 180, .1);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Structure ---------- */
.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---------- Barre latérale ---------- */
.sidebar {
  background: var(--sb);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 10px 10px;
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 14px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; }
.brand .logo { width: 24px; height: 24px; color: var(--accent); }
.brand span { font: 500 21px/1 var(--serif); }

.new-chat {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
}
.new-chat svg { width: 18px; height: 18px; color: var(--accent); }
.new-chat:hover { background: var(--hover); }

.history { flex: 1; overflow-y: auto; margin: 14px 0 8px; padding-right: 2px; }
.h-group { font-size: 12px; color: var(--faint); padding: 12px 10px 6px; font-weight: 500; }
.h-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; border-radius: 8px;
  font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.h-item:hover { background: var(--hover); }
.h-item.active { background: var(--active); }

.sb-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 4px; border-top: 1px solid var(--line);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--soft); color: var(--soft-ink);
  font-size: 13px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13.5px; font-weight: 600; }
.user-meta small { font-size: 12px; color: var(--muted); }

/* ---------- Zone principale ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 12px; flex: 0 0 auto;
}
.conv-title {
  flex: 1; min-width: 0; text-align: center;
  font-size: 14px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.only-mobile { display: none; }

.ghost-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--line); font-size: 13.5px;
}
.ghost-btn svg { width: 16px; height: 16px; }
.ghost-btn:hover { background: var(--hover); }

.model { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px 6px 10px; border-radius: 10px;
  font-size: 16px; font-weight: 600;
}
.model-btn svg { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.model-btn:hover { background: var(--hover); }
.model-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.model-menu {
  position: absolute; top: 44px; left: 0; z-index: 30;
  width: 290px; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
}
.model-menu li {
  display: grid; padding: 9px 36px 9px 12px; border-radius: 9px;
  cursor: pointer; position: relative;
}
.model-menu li:hover { background: var(--hover); }
.model-menu strong { font-size: 14px; font-weight: 600; }
.model-menu small { font-size: 12.5px; color: var(--muted); }
.model-menu li[aria-selected="true"]::after {
  content: ""; position: absolute; right: 14px; top: 50%;
  width: 10px; height: 5px; margin-top: -5px;
  border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

/* ---------- Logo (pastille, paupière, sourcil) ---------- */
.lg-bg { fill: currentColor; }
.lg-lid, .lg-brow { fill: none; stroke: var(--logo-ink); stroke-width: 2; stroke-linecap: round; }
.lg-brow { stroke-width: 1.8; transition: transform 1.1s ease; }
.lg-pupil {
  fill: var(--logo-ink);
  transform-box: fill-box; transform-origin: 50% 0;
  transition: transform 1.1s ease;
}
.msg.bot:not(.done) .lg-pupil { animation: blink 1.7s ease-in-out infinite; }
.dozing .lg-pupil { transform: scaleY(.18); }
.dozing .lg-brow { transform: translateY(.9px); }

/* ---------- Fil de discussion ---------- */
.scroller { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: auto; }

.welcome {
  display: none; text-align: center; padding: 0 20px 30px;
  background: radial-gradient(closest-side, var(--glow), transparent) no-repeat 50% 0 / 280px 150px;
}
.main.is-empty .welcome { display: block; }
.welcome-logo { width: 54px; height: 54px; margin: 0 auto 20px; color: var(--accent); }
.welcome h1 { font: 400 42px/1.15 var(--serif); margin: 0 0 8px; }
.welcome p { margin: 0; color: var(--muted); font-size: 16px; }

.main.is-empty .scroller { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.main.is-empty .composer-wrap { margin-bottom: auto; padding-bottom: 9vh; }
.main.is-empty .thread { display: none; }

.thread { max-width: var(--w); margin: 0 auto; padding: 18px 20px 8px; }

.msg { margin: 20px 0; animation: rise .22s ease-out; }
.msg.user { display: flex; justify-content: flex-end; }
.bubble {
  background: var(--bubble);
  padding: 10px 16px; border-radius: 22px 22px 8px 22px;
  max-width: 82%; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 15.5px;
}

.msg.bot { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; }
.avatar { width: 26px; height: 26px; color: var(--accent); margin-top: 3px; }
.avatar svg { width: 100%; height: 100%; }

.think {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 13.5px;
  padding: 2px 0; margin: 3px 0 8px;
}
.think svg { width: 15px; height: 15px; transition: transform .15s; }
.think[aria-expanded="true"] svg { transform: rotate(90deg); }
.think:hover { color: var(--text); }
.think.loading { cursor: default; }
.think.loading svg { display: none; }
.think.loading .think-label {
  background: linear-gradient(90deg, var(--faint) 0%, var(--text) 45%, var(--faint) 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.3s linear infinite;
}
.think-text {
  border-left: 2px solid var(--line);
  padding: 2px 0 2px 12px; margin: -2px 0 12px;
  color: var(--muted); font-size: 14px; font-style: italic;
}

.content { font: 16px/1.65 var(--sans); overflow-wrap: anywhere; }
.content p { margin: 0 0 .75em; }
.content p:last-child { margin-bottom: 0; }
.content strong { font-weight: 600; }
.content code {
  font: .85em var(--mono); background: var(--hover);
  padding: .1em .35em; border-radius: 5px;
}
.content pre {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; margin: 0 0 .75em;
  overflow-x: auto;
}
.content pre code { background: none; padding: 0; font: 13.5px/1.55 var(--mono); }
.content .interrupted { color: var(--faint); font-style: italic; font-size: 14.5px; }

.caret {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--text); margin-left: 5px; vertical-align: .05em;
  animation: pulse 1s ease-in-out infinite;
}

.actions { display: flex; gap: 2px; margin: 8px 0 0 -6px; opacity: 0; transition: opacity .2s; }
.msg.bot.done .actions { opacity: 1; }
.act {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; color: var(--faint);
}
.act svg { width: 16px; height: 16px; }
.act:hover { background: var(--hover); color: var(--text); }
.act.on { color: var(--accent); }
.act[data-act="regen"] { display: none; }
.msg.bot.last .act[data-act="regen"] { display: grid; }

.sysnote {
  display: flex; align-items: center; gap: 14px;
  color: var(--faint); font-size: 13px; margin: 26px 0;
  animation: rise .22s ease-out;
}
.sysnote::before, .sysnote::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Zone de saisie ---------- */
.composer-wrap { flex: 0 0 auto; padding: 4px 16px calc(10px + env(safe-area-inset-bottom)); }
.composer {
  max-width: var(--w); margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--shadow);
  padding: 13px 12px 9px 18px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.composer textarea {
  display: block; width: 100%; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--text);
  font: 16px/1.5 var(--sans); max-height: 220px; padding: 0;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-row { display: flex; align-items: center; margin: 8px 0 0 -8px; }
.spacer { flex: 1; }
.send-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  transition: opacity .15s, transform .1s;
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:disabled { opacity: .3; cursor: default; }
.send-btn:not(:disabled):active { transform: scale(.94); }

.chips {
  max-width: var(--w); margin: 16px auto 0;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.main:not(.is-empty) .chips { display: none; }
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; color: var(--muted);
}
.chip:hover { background: var(--hover); color: var(--text); }

.disclaimer { text-align: center; font-size: 12px; color: var(--faint); margin: 9px 0 0; }
.disclaimer a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
.disclaimer a:hover { color: var(--muted); text-decoration-color: currentColor; }

/* ---------- Mentions légales ---------- */
.legal {
  width: min(600px, calc(100vw - 32px)); max-height: min(82vh, 760px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  overflow: hidden; flex-direction: column;
}
.legal[open] { display: flex; animation: rise .2s ease-out; }
.legal::backdrop { background: rgba(40, 25, 8, .35); }
.legal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px 24px; border-bottom: 1px solid var(--line);
}
.legal-head h2 { margin: 0; font: 500 22px/1.2 var(--serif); }
.legal-body { overflow-y: auto; padding: 6px 24px 22px; font-size: 14.5px; line-height: 1.6; }
.legal-body h3 { font-size: 13px; font-weight: 600; color: var(--accent); margin: 20px 0 6px; }
.legal-body p { margin: 0 0 8px; }
.legal-body a { color: var(--accent); }

/* ---------- Divers ---------- */
.toast {
  position: fixed; left: 50%; bottom: 150px; z-index: 50;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 10px; font-size: 14px;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.scrim { display: none; }
.noscript { text-align: center; padding: 40px; }

@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }
@keyframes blink { 0%, 72%, 100% { transform: none; } 82% { transform: scaleY(.08); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 284px; max-width: 86vw; z-index: 40;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .app.sb-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  .app.sb-open .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .ghost-btn span { display: none; }
  .ghost-btn { padding: 7px 9px; }
  .thread { padding: 10px 16px 6px; }
  .content { font-size: 15.5px; }
  .welcome h1 { font-size: 34px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .chip { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.legal-body:focus { outline: none; }

/* ---------- v3.5 : fausses publicités et Odius Plus ---------- */
.encart {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 14px;
  margin: 14px 0 0; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  font: 14px/1.45 var(--sans);
  animation: rise .22s ease-out;
}
.encart-tag { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); }
.encart-main { display: flex; flex-direction: column; min-width: 0; }
.encart-name { font-weight: 600; color: var(--text); }
.encart-text { color: var(--muted); }
.encart-cta {
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--soft); color: var(--soft-ink); font-size: 13px; font-weight: 600;
}
.encart-cta:hover { filter: brightness(.96); }
.encart-note { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); }
.plus-btn {
  margin-left: auto; flex: 0 0 auto; white-space: nowrap; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text); font-size: 12.5px; font-weight: 600;
}
.plus-btn:hover { background: var(--hover); }
@media (max-width: 520px) {
  .encart { grid-template-columns: 1fr; }
  .encart-cta { justify-self: start; }
}

/* ---------- v4.5 : page 404 ---------- */
.page404 { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.p404 { max-width: 520px; text-align: center; }
.p404-logo { display: block; color: var(--accent); text-decoration: none; }
.p404 h1 { font: 400 36px/1.15 var(--serif); margin: 0 0 14px; }
.p404-line { font-size: 17px; line-height: 1.55; color: var(--text); margin: 0 0 28px; }
.p404-btn {
  display: inline-block; padding: 10px 20px; border-radius: 999px;
  background: var(--soft); color: var(--soft-ink); text-decoration: none; font-weight: 500;
}
.p404-btn:hover { background: var(--accent); color: var(--accent-ink); }
.p404-code { margin: 28px 0 0; font-size: 13px; color: var(--faint); }
