:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-sunk: #f1f5f9;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #ccfbf1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 12px 32px rgb(15 23 42 / 6%);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-alt);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.015em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
h2 { font-size: 1.15rem; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-sunk);
  padding: .1em .35em;
  border-radius: 5px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Barre supérieure --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.1rem;
  background: var(--ink);
  color: #e2e8f0;
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: inherit; font-weight: 650; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: #2dd4bf; font-size: 1.25rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.inline-form { margin: 0; }
.button-ghost {
  background: none; border: 1px solid #334155; color: #e2e8f0;
  padding: .35rem .7rem; border-radius: 999px; cursor: pointer; font: inherit;
  text-decoration: none; display: inline-block;
}
.button-ghost:hover { border-color: #64748b; background: #1e293b; text-decoration: none; }
.button-dark {
  background: var(--surface); border-color: var(--line); color: var(--ink);
}
.button-dark:hover { background: var(--surface-sunk); border-color: var(--ink-faint); }

.banner {
  display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: baseline;
  padding: .55rem 1rem; font-size: .88rem;
}
.banner-error { background: var(--danger-soft); color: #7f1d1d; border-bottom: 1px solid #fecaca; }
.banner a { font-weight: 650; }

/* --- Structure --- */
.shell {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  flex: 1;
}
.footer {
  padding: 1.5rem 1rem 2rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: .8rem;
}
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.fineprint { margin: 0; color: var(--ink-faint); font-size: .8rem; }

/* --- Accueil --- */
.hero { padding: 1.2rem 0 1.3rem; }
.eyebrow {
  margin: 0 0 .35rem; color: var(--accent);
  font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.lede { margin: 0; color: var(--ink-soft); max-width: 62ch; }

.ask-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1.4rem;
}
.agent-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .5rem; border: 0; padding: 0; margin: 0 0 .9rem;
}
.agent-card {
  position: relative; display: flex; flex-direction: column; gap: .15rem;
  padding: .6rem .65rem; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: var(--surface-alt);
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.agent-card:hover { border-color: #99f6e4; }
.agent-card input { position: absolute; opacity: 0; pointer-events: none; }
.agent-card:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.agent-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.agent-icon { font-size: 1.1rem; }
.agent-name { font-weight: 650; font-size: .88rem; }
.agent-tagline { color: var(--ink-soft); font-size: .75rem; line-height: 1.35; }

textarea {
  width: 100%; resize: vertical; min-height: 84px;
  padding: .8rem .85rem; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: inherit; background: var(--surface);
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.ask-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: .7rem;
}
.button-primary {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: .6rem 1.1rem; border-radius: 10px; font: inherit; font-weight: 650;
  cursor: pointer; white-space: nowrap;
}
.button-primary:hover { background: var(--accent-strong); }

.starters { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.chip {
  background: var(--surface-sunk); border: 1px solid var(--line); color: var(--ink-soft);
  padding: .3rem .6rem; border-radius: 999px; font: inherit; font-size: .8rem; cursor: pointer;
}
.chip:hover { background: var(--accent-soft); border-color: #99f6e4; color: var(--accent-strong); }

/* --- Panneaux --- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: 1rem;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.panel h2 { margin: 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { display: inline; }

.conversation-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.conversation-list li + li { border-top: 1px solid var(--line); }
.conversation-list a {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .55rem 0; color: var(--ink);
}
.conversation-list a:hover { color: var(--accent-strong); text-decoration: none; }

.tool-list { list-style: none; margin: .7rem 0 0; padding: 0; }
.tool-list li { padding: .45rem 0; border-top: 1px solid var(--line); display: grid; gap: .1rem; }
.tool-name { font-weight: 650; font-size: .9rem; }

/* --- Auth --- */
.auth-card {
  max-width: 420px; margin: 8vh auto 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem;
}
.stack { display: grid; gap: .5rem; margin: 1rem 0; }
.stack input {
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
.stack-card {
  display: grid; gap: .6rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.stack-card label { font-weight: 650; font-size: .88rem; }
.stack-card input {
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
.inline-form > * + * { margin-left: .5rem; }

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .5rem; margin: .3rem 0 .6rem;
}
.info-grid dt { color: var(--ink-soft); font-size: .72rem; }
.info-grid dd { margin: .1rem 0 0; font-weight: 650; font-size: .9rem; overflow-wrap: anywhere; }

/* --- Alertes --- */
.alert { border-radius: 10px; padding: .7rem .9rem; margin: 0 0 1rem; border: 1px solid; }
.alert p { margin: .35rem 0 0; }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.alert-ok { background: var(--accent-soft); border-color: #99f6e4; color: var(--accent-strong); }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }

.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .7rem; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-sunk); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge-ok { background: var(--accent-soft); color: var(--accent-strong); border-color: #99f6e4; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }

/* --- Conversation --- */
.conversation-head { margin-bottom: 1rem; }
.conversation-head h1 { margin-top: .35rem; }
.conversation-head p { margin: 0; }
.back { font-size: .85rem; }

.messages { display: grid; gap: .9rem; margin-bottom: 1.2rem; }
.bubble {
  border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem;
  background: var(--surface); box-shadow: var(--shadow);
}
.bubble-user { background: #eff6ff; border-color: #dbeafe; }
.bubble-label {
  margin: 0 0 .4rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  font-size: .78rem; font-weight: 700; color: var(--ink-soft);
}
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.highlights, .caveats { margin: .7rem 0 0; padding-left: 1.1rem; }
.highlights li, .caveats li { margin: .15rem 0; font-size: .9rem; }
.highlights { color: var(--accent-strong); }
.caveats { color: var(--warn); font-size: .85rem; }

.evidence { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.evidence > summary { font-size: .82rem; font-weight: 650; color: var(--ink-soft); }
.tool-block { margin-top: .8rem; }
.tool-block h4 { margin: 0 0 .35rem; font-size: .85rem; }
.metric-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .4rem; margin: 0;
}
.metric {
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .5rem;
}
.metric-warn { background: var(--warn-soft); border-color: #fde68a; }
.metric dt { color: var(--ink-soft); font-size: .72rem; }
.metric dd { margin: .1rem 0 0; font-weight: 650; font-size: .88rem; }
.confidence {
  display: inline-block; margin-left: .35rem; padding: 0 .3rem; border-radius: 4px;
  font-size: .65rem; font-weight: 600; vertical-align: middle;
  background: var(--surface-sunk); color: var(--ink-faint);
}
.confidence-high { color: var(--accent-strong); }
.confidence-low { color: var(--warn); }
.confidence-insufficient_data { color: var(--danger); }
.note { margin: .4rem 0 0; color: var(--ink-faint); font-size: .78rem; }

.ask-followup { position: sticky; bottom: .75rem; }

@media (max-width: 520px) {
  .shell { padding: 1rem .75rem 2rem; }
  .topbar { padding: .7rem .8rem; }
  .badge { font-size: .65rem; }
  .ask-actions { flex-direction: column-reverse; align-items: stretch; }
  .ask-actions .button-primary { width: 100%; }
  .ask-followup { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
