:root {
  --brown-900: #351919;
  --brown-800: #4b2020;
  --brown-700: #6a2b2b;
  --green-500: #87c774;
  --green-100: #e9f5e5;
  --gold-500: #c88732;
  --ink: #292323;
  --muted: #6a6060;
  --paper: #fffdfa;
  --sand: #f4efe8;
  --line: #d8cec4;
  --white: #fff;
  --shadow: 0 18px 50px rgba(53, 25, 25, .12);
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; padding-bottom: 190px; background: var(--paper); color: var(--ink); line-height: 1.6; }
button, textarea { font: inherit; }
a { color: var(--brown-700); }
a:hover { color: var(--brown-900); }

.skip-link { position: fixed; z-index: 100; top: .5rem; left: .5rem; padding: .75rem 1rem; background: var(--white); color: var(--brown-900); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.page-shell { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }

.site-header { background: var(--brown-700); border-bottom: 4px solid var(--green-500); }
.site-header__inner { width: min(1180px, calc(100% - 2rem)); min-height: 92px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.site-brand { color: var(--white); text-decoration: none; }
.site-brand__wordmark { display: inline-block; font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-weight: 700; letter-spacing: -.025em; }
.site-brand__wordmark span { color: var(--green-500); }
.site-header nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem 1.25rem; }
.site-header nav a { color: var(--white); font-weight: 700; text-decoration: none; }
.site-header nav a:hover, .site-header nav a:focus-visible { color: var(--green-500); }

.hero { color: var(--white); background: linear-gradient(125deg, rgba(53,25,25,.98), rgba(106,43,43,.93)); padding: clamp(1.5rem, 3vw, 2.5rem) 0; }
.hero .page-shell { max-width: 900px; margin-left: max(1rem, calc((100% - 1120px) / 2)); }
.eyebrow { margin: 0 0 .45rem; color: var(--gold-500); font-size: .82rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero .eyebrow { color: var(--green-500); }
h1, h2, h3 { line-height: 1.15; color: var(--brown-900); }
h1 { max-width: 850px; margin: 0; color: var(--white); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.25rem); font-weight: 500; letter-spacing: -.025em; }
.hero__intro { max-width: 760px; margin: .55rem 0 .8rem; font-size: 1rem; }
.notice { max-width: 780px; padding: .55rem .8rem; border-left: 3px solid var(--green-500); background: rgba(255,255,255,.08); font-size: .86rem; }
.notice strong { display: block; color: var(--green-500); }
.notice p { margin: .2rem 0 0; }

.conversation-workspace { width: min(1240px, calc(100% - 2rem)); display: grid; grid-template-columns: 270px minmax(0, 920px); align-items: start; gap: 1.25rem; }
.experience { width: 100%; min-height: 55vh; margin-block: 1.25rem 3rem; padding: clamp(1rem, 4vw, 2.5rem); border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: var(--shadow); }
.history-panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); margin-top: 1.25rem; padding: 1rem; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--sand); }
.history-panel__heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.history-panel h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 500; }
.history-close, .history-toggle { display: none; }
.history-new { width: 100%; margin-bottom: 1rem; text-align: left; }
.history-empty { color: var(--muted); font-size: .88rem; }
.history-list { display: grid; gap: .35rem; }
.history-item { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; border-radius: 8px; }
.history-item:hover, .history-item:focus-within { background: var(--white); }
.history-item--active { background: var(--green-100); }
.history-item__open { min-width: 0; padding: .65rem .35rem .65rem .65rem; border: 0; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.history-item__open span, .history-item__open small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item__open span { font-size: .88rem; font-weight: 700; }
.history-item__open small { color: var(--muted); font-size: .72rem; }
.history-item__actions { display: flex; padding-right: .25rem; opacity: 0; }
.history-item:hover .history-item__actions, .history-item:focus-within .history-item__actions { opacity: 1; }
.history-item__action { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; }
.history-item__action:hover { color: var(--brown-900); background: var(--green-100); }
.history-backdrop[hidden] { display: none; }
.access-gate { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgba(36,17,17,.92); backdrop-filter: blur(12px); }
body.access-locked { overflow: hidden; }
.access-gate[hidden] { display: none; }
.access-gate__panel { display: grid; gap: .7rem; width: min(430px, 100%); padding: clamp(1.4rem, 5vw, 2.3rem); border-radius: 16px; background: var(--paper); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.access-gate__panel h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; }
.access-gate__panel p { margin: 0 0 .5rem; }
.access-gate__panel label { font-weight: 800; }
.access-gate__panel input { width: 100%; min-height: 46px; padding: .7rem .8rem; border: 2px solid var(--line); border-radius: 8px; background: var(--white); }
.access-gate__panel input:focus { border-color: var(--brown-700); outline: 3px solid rgba(135,199,116,.5); }
.access-gate__error { padding: .65rem .75rem; border-left: 4px solid #a22; color: #741515; background: #fff0f0; }
.experience__heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.experience h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3rem); font-weight: 500; }
.suggestions { margin-bottom: 1.5rem; padding: 1.25rem; border-radius: 12px; background: var(--sand); }
.suggestions h3 { margin: 0 0 .85rem; font-size: 1rem; }
.suggestions__list { display: flex; flex-wrap: wrap; gap: .65rem; }
.suggestions button { padding: .7rem .9rem; border: 1px solid var(--brown-700); border-radius: 999px; color: var(--brown-700); background: var(--white); cursor: pointer; }
.suggestions button:hover { color: var(--white); background: var(--brown-700); }
.suggestions button:disabled { opacity: .55; cursor: not-allowed; }

.conversation { display: grid; gap: 1rem; }
.message { max-width: 88%; padding: 1rem 1.1rem; border-radius: 14px; }
.message--visitor { justify-self: end; color: var(--white); background: var(--brown-700); border-bottom-right-radius: 3px; }
.message--guilhem { justify-self: start; border: 1px solid var(--line); border-left: 5px solid var(--green-500); background: var(--paper); border-bottom-left-radius: 3px; }
.message__heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.message__speaker { margin: 0 0 .35rem; font-size: .82rem; font-weight: 800; letter-spacing: .035em; }
.message__text { margin: 0; white-space: pre-wrap; }
.confidence { flex: 0 0 auto; margin: 0; padding: .25rem .5rem; border-radius: 5px; color: var(--brown-900); background: var(--green-100); font-size: .78rem; }
.confidence__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.historical-note { margin-top: 1rem; padding: .85rem 1rem; border-left: 3px solid var(--gold-500); background: #fbf1e3; }
.historical-note h3 { margin: 0 0 .25rem; font-size: 1rem; }
.historical-note p { margin: 0; }
.fiction-notice { display: grid; gap: .15rem; margin-top: 1rem; padding: .8rem 1rem; border: 1px solid #d89a43; border-left: 5px solid #c56f16; border-radius: 7px; color: #562f09; background: #fff2d9; }
.fiction-notice strong { font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; }
.fiction-notice span { font-size: .92rem; }
.sources { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.sources summary, .method summary { color: var(--brown-700); font-weight: 800; cursor: pointer; }
.sources ul { margin: .75rem 0 0; padding-left: 1.2rem; }
.sources li + li { margin-top: .65rem; }
.source__warning { display: block; color: #7a4911; font-size: .86rem; font-weight: 700; }
.source__badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.source__badge { display: inline-block; padding: .18rem .45rem; border-radius: 999px; color: #3f3732; background: var(--sand); font-size: .72rem; font-weight: 800; }
.source__badge--fiction_litteraire { color: #562f09; background: #ffe1ab; }
.source__badge--fait_documente, .source__badge--temoignage { color: #23431d; background: var(--green-100); }
.source__reason { margin: .4rem 0; color: var(--muted); font-size: .84rem; }
.source__passages { margin-top: .4rem; font-size: .86rem; }
.source__passages summary { color: var(--brown-700); font-weight: 700; }
.source__context { margin: .55rem 0 .2rem; color: var(--muted); font-size: .78rem; font-weight: 700; }
.source__passages blockquote { margin: 0; padding: .65rem .8rem; border-left: 3px solid var(--line); background: var(--sand); }
.response-guidance { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.response-guidance__title { flex-basis: 100%; margin: 0; color: var(--muted); font-size: .82rem; font-weight: 800; }
.response-guidance__button { padding: .48rem .7rem; border: 1px solid var(--brown-700); border-radius: 999px; color: var(--brown-700); background: var(--white); font-size: .82rem; font-weight: 700; cursor: pointer; }
.response-guidance__button:hover, .response-guidance__button:focus-visible { color: var(--white); background: var(--brown-700); }
.response-guidance--clarification { padding: .85rem; border: 1px solid #d89a43; border-radius: 8px; background: #fff8ea; }
.status { min-height: 1.6rem; margin: 1rem 0 .25rem; color: var(--muted); font-weight: 700; }
.status--error { padding: .7rem .85rem; border-left: 4px solid #a22; color: #741515; background: #fff0f0; }

.composer { position: fixed; z-index: 50; left: max(calc((100% - 1240px) / 2 + 291px), 307px); bottom: 0; width: min(840px, calc(100% - 330px)); padding: .7rem .9rem max(.7rem, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; background: rgba(255,253,250,.97); box-shadow: 0 -10px 35px rgba(53,25,25,.13); backdrop-filter: blur(12px); }
.composer label { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .78rem; font-weight: 800; }
.composer textarea { display: block; width: 100%; min-height: 56px; max-height: 140px; resize: vertical; padding: .7rem .85rem; border: 2px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--white); }
.composer textarea:focus { border-color: var(--brown-700); outline: 3px solid rgba(135,199,116,.5); }
.composer__footer { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .75rem; margin-top: .4rem; }
.composer__footer p { margin: 0; color: var(--muted); font-size: .86rem; }
#character-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.button { min-height: 44px; padding: .65rem 1rem; border: 2px solid var(--brown-700); border-radius: 6px; font-weight: 800; cursor: pointer; }
.button--primary { color: var(--white); background: var(--brown-700); }
.button--secondary { color: var(--brown-700); background: var(--white); }
.button:hover:not(:disabled) { color: var(--brown-900); border-color: var(--green-500); background: var(--green-500); }
.button:disabled { opacity: .5; cursor: not-allowed; }

.method { max-width: 920px; margin-top: 1rem; }
.method details { padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--sand); }
.method summary { font-size: .88rem; }
.method__content { max-width: 760px; padding-top: .5rem; }
.project-signature { padding: 2.25rem 0; background: var(--green-100); }
.project-signature__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.project-signature p { margin: 0; }
.project-signature strong, .project-signature span { display: block; }
.project-signature strong { color: var(--brown-700); }

.site-footer { padding: 2rem 0; color: var(--white); background: var(--brown-900); }
.site-footer__inner { display: grid; grid-template-columns: 200px 1fr auto; align-items: center; gap: 2rem; }
.site-footer p { margin: 0; font-size: .9rem; }
.site-footer a { color: var(--green-500); }

button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 3px; }

/* Interface conversationnelle plein écran */
body { height: 100vh; padding: 0; overflow: hidden; }
.conversation-workspace { width: 100%; height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 0; }
.history-panel { position: static; width: auto; max-height: none; height: 100vh; margin: 0; padding: 1rem .75rem; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: var(--sand); }
.app-brand { display: block; margin: .15rem .5rem 1.4rem; color: var(--brown-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; font-weight: 700; text-decoration: none; }
.app-brand span { color: var(--brown-700); }
.history-panel__heading { padding-inline: .5rem; }
.history-panel__heading h2 { font-family: inherit; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.history-new { border-radius: 9px; }
.experience { --conversation-gutter: max(1.5rem, calc((100% - 800px) / 2)); position: relative; height: 100vh; min-height: 0; margin: 0; padding: 0 var(--conversation-gutter) 215px; overflow-y: auto; border: 0; border-radius: 0; box-shadow: none; }
.experience__heading { position: sticky; z-index: 40; top: 0; min-height: 64px; margin: 0 calc(-1 * var(--conversation-gutter)); padding: .75rem var(--conversation-gutter); align-items: center; border-bottom: 1px solid var(--line); background: rgba(255,253,250,.94); backdrop-filter: blur(12px); }
.experience__heading h1 { margin: 0; color: var(--brown-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 500; }
.experience__heading #restart-button { display: none; }
.history-toggle { display: none; }
.method { width: 100%; max-width: none; margin: .5rem auto 0; color: var(--muted); text-align: center; }
.method details, .method { padding: 0; border: 0; background: transparent; }
.method summary { color: var(--muted); font-size: .72rem; font-weight: 500; }
.method__content { position: absolute; right: .9rem; bottom: calc(100% - .25rem); left: .9rem; max-width: none; margin: auto; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); box-shadow: var(--shadow); font-size: .8rem; text-align: left; }
.method__content p { margin: .35rem 0; }
.suggestions, .conversation, .status { width: 100%; max-width: 760px; margin-inline: auto; }
.suggestions { margin-top: clamp(4rem, 16vh, 10rem); padding: 0; background: transparent; text-align: center; }
.suggestions__eyebrow { margin: 0 0 .45rem; color: var(--brown-700); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.suggestions h3 { margin-bottom: 1.4rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.6rem, 3vw, 2.25rem); font-weight: 500; }
.suggestions__list { justify-content: center; }
.suggestions button { max-width: 230px; padding: .8rem 1rem; border-color: var(--line); border-radius: 12px; color: var(--ink); text-align: left; }
.conversation { padding-bottom: 1rem; }
.composer { left: calc(280px + (100% - 280px) / 2); right: auto; bottom: 18px; width: min(760px, calc(100% - 330px)); padding: .75rem .85rem .55rem; border: 1px solid var(--line); border-radius: 16px; transform: translateX(-50%); }
.composer label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.composer textarea { min-height: 58px; padding: .9rem 4.8rem .8rem 1rem; border: 0; resize: none; }
.composer textarea:focus { border-color: transparent; outline: 0; }
.composer__footer { min-height: 36px; margin-top: .15rem; }
.composer__footer p { font-size: .75rem; }
.composer__footer .button { min-height: 38px; padding: .45rem .85rem; border-radius: 9px; }

@media (max-width: 760px) {
  .site-header__inner { flex-direction: column; align-items: flex-start; padding: .8rem 0 1rem; }
  .site-header nav { justify-content: flex-start; gap: .45rem 1rem; }
  body { padding-bottom: 176px; }
  .hero { padding-block: 1.5rem; }
  .experience { width: 100%; margin-top: 0; border-inline: 0; border-radius: 0; box-shadow: none; }
  .conversation-workspace { width: 100%; display: block; }
  .history-toggle { position: sticky; z-index: 45; top: .5rem; display: block; margin: .6rem 1rem; background: rgba(255,255,255,.94); }
  .history-panel { position: fixed; z-index: 80; inset: 0 auto 0 0; width: min(330px, 88vw); max-height: none; margin: 0; padding: 1rem; border: 0; border-radius: 0 14px 14px 0; background: var(--sand); box-shadow: 18px 0 50px rgba(53,25,25,.25); transform: translateX(-105%); transition: transform .2s ease; }
  .history-open .history-panel { transform: translateX(0); }
  .history-close { display: block; width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; font-size: 1.7rem; cursor: pointer; }
  .history-backdrop { position: fixed; z-index: 70; inset: 0; background: rgba(36,17,17,.5); }
  .experience__heading { align-items: start; }
  .message { max-width: 96%; }
  .message__heading { display: block; }
  .confidence { display: inline-block; margin-bottom: .55rem; }
  .composer__footer { grid-template-columns: 1fr auto; }
  .composer__footer p { grid-column: 1 / -1; }
  .composer__footer .button { min-width: 110px; }
  .composer { left: 0; width: 100%; padding-inline: .75rem; border-inline: 0; border-radius: 14px 14px 0 0; }
  .composer__footer p { display: none; }
  .response-guidance__button { width: 100%; text-align: left; }
  .project-signature__grid, .site-footer__inner { grid-template-columns: 1fr; }
  body { height: 100dvh; padding: 0; }
  .conversation-workspace { height: 100dvh; display: block; }
  .experience { height: 100dvh; padding: 0 1rem 176px; }
  .experience__heading { margin-inline: -1rem; padding: .65rem 1rem; }
  .experience__heading h1 { flex: 1; font-size: 1.1rem; text-align: center; }
  .history-toggle { position: static; display: grid; place-items: center; width: 42px; min-height: 42px; margin: 0; padding: 0; border: 0; border-radius: 7px; color: var(--brown-900); background: transparent; font-size: 1.25rem; }
  .history-panel { position: fixed; height: 100dvh; }
  .method { margin-top: .6rem; }
  .suggestions { margin-top: 2rem; }
  .composer { left: 50%; width: 100%; transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
