@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Source+Sans+3:wght@400;500;600&display=swap');

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
:root {
  --accent: #9BBFA8; /* Nourrisson — pousse pâle, couleur par défaut avant connexion */
  --accent-rgb: 155, 191, 168;
}
body.stage-enfant { --accent: #7CC98A; --accent-rgb: 124, 201, 138; }       /* vert franc, feuille jeune */
body.stage-adolescent { --accent: #4FB89E; --accent-rgb: 79, 184, 158; }   /* émeraude, plus affirmé */
body.stage-adulte { --accent: #D9A85C; --accent-rgb: 217, 168, 92; }       /* or mature, sagesse */
body { transition: background-color .6s ease; }
body {
  background: #101A15;
  color: #EDE7D9;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  min-height: 100vh;
}
::selection { background: #4C6B57; color: #F4F0E4; }

.eyebrow { font-size: 13px; color: #7E9A87; margin: 0 0 4px 0; }

/* --- Login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: #182420;
  border: 1px solid #263029;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.login-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  margin: 0 0 20px 0;
  color: #F4F0E4;
}
.login-card input {
  width: 100%;
  background: #101A15;
  border: 1px solid #33423A;
  border-radius: 10px;
  padding: 12px 14px;
  color: #EDE7D9;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 12px;
}
.login-card button {
  width: 100%;
  background: var(--accent);
  color: #101A15;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.login-error { color: #D98383; font-size: 13px; margin-top: 12px; }
.forgot-link {
  background: none; border: none; color: #7E9A87; font-size: 13px;
  cursor: pointer; text-decoration: underline; margin-top: 14px; font-family: inherit; padding: 0;
}

/* --- App shell --- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.header { display: flex; justify-content: space-between; align-items: flex-end; }
.title { font-family: 'Fraunces', Georgia, serif; font-size: 30px; font-weight: 500; margin: 0; color: #F4F0E4; }
.stage-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #C9D8CE;
  border: 1px solid #33423A; padding: 6px 12px; border-radius: 999px; background: #182420;
}
.stage-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }

.growth-row {
  display: flex; gap: 18px; align-items: center;
  background: #182420; border: 1px solid #263029; border-radius: 16px; padding: 16px 18px;
}
.growth-text { flex: 1; min-width: 0; }
.growth-line { margin: 0 0 10px 0; font-size: 14.5px; color: #DCE4DA; }
.progress-track { height: 6px; background: #263029; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; width: 0%; }
.progress-label { margin: 8px 0 0 0; font-size: 12.5px; color: #7E9A87; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid #263029; }
.tab-btn {
  background: none; border: none; color: #7E9A87; font-size: 14.5px; font-family: inherit;
  padding: 10px 4px; margin-right: 20px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab-btn.active { color: #F4F0E4; border-bottom: 2px solid var(--accent); }

.panel { background: #182420; border: 1px solid #263029; border-radius: 16px; min-height: 380px; display: flex; flex-direction: column; }

.chat-scroll { flex: 1; padding: 18px; display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; }
.empty-state { margin: auto; text-align: center; max-width: 360px; padding: 24px; }
.empty-title { font-family: 'Fraunces', Georgia, serif; font-size: 19px; margin: 0 0 8px 0; color: #F4F0E4; }
.empty-body { font-size: 14px; color: #8FA396; line-height: 1.5; margin: 0; }

.bubble-row { display: flex; }
.bubble-row.user { justify-content: flex-end; }
.bubble-row.bot { justify-content: flex-start; }
.bubble {
  padding: 10px 14px; max-width: 80%; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap;
}
.bubble.user { background: #3F5647; color: #F4F0E4; border-radius: 14px 14px 2px 14px; }
.bubble.bot { background: #22302A; color: #DCE4DA; border-radius: 14px 14px 14px 2px; }
.used-memories { margin-top: 8px; font-size: 11.5px; color: #7E9A87; border-top: 1px solid #33423A; padding-top: 6px; }

.composer { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid #263029; }
.composer input {
  flex: 1; background: #101A15; border: 1px solid #33423A; border-radius: 10px;
  padding: 10px 12px; color: #EDE7D9; font-size: 14.5px; font-family: inherit;
}
.composer button {
  background: var(--accent); color: #101A15; border: none; border-radius: 10px;
  padding: 0 18px; font-size: 14.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}

.feed-form { padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 13px; color: #8FA396; margin-top: 8px; }
.feed-form input, .feed-form textarea {
  background: #101A15; border: 1px solid #33423A; border-radius: 10px;
  padding: 10px 12px; color: #EDE7D9; font-size: 14.5px; font-family: inherit; resize: vertical;
}
.feed-form button {
  margin-top: 6px; align-self: flex-start; background: var(--accent); color: #101A15; border: none;
  border-radius: 10px; padding: 10px 18px; font-size: 14.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.hint { font-size: 12.5px; color: #7E9A87; margin-top: 4px; line-height: 1.5; }

.mem-list { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; }
.mem-card { background: #101A15; border: 1px solid #263029; border-radius: 12px; padding: 14px; }
.mem-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mem-label { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.mem-delete { background: none; border: none; color: #7E9A87; font-size: 12px; cursor: pointer; text-decoration: underline; font-family: inherit; }
.mem-text { font-size: 14px; color: #DCE4DA; line-height: 1.5; margin: 0 0 6px 0; white-space: pre-wrap; }
.mem-date { font-size: 11px; color: #5E7267; }

.footer { font-size: 12px; color: #5E7267; text-align: center; line-height: 1.5; padding: 0 20px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #101A15; padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
}

@media (max-width: 420px) {
  .app { padding: 16px 12px 24px; }
  .title { font-size: 26px; }
}

/* --- Import de documents --- */
.import-divider {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 4px 0;
  color: #5E7267; font-size: 12px;
}
.import-divider::before, .import-divider::after {
  content: ""; flex: 1; height: 1px; background: #263029;
}
.file-input {
  background: #101A15; border: 1px dashed #33423A; border-radius: 10px;
  padding: 14px 12px; color: #DCE4DA; font-size: 13.5px; font-family: inherit;
}
.url-import-row { display: flex; gap: 8px; }
.url-import-row input {
  flex: 1; background: #101A15; border: 1px solid #33423A; border-radius: 10px;
  padding: 10px 12px; color: #EDE7D9; font-size: 14px; font-family: inherit;
}
.url-import-row button {
  background: var(--accent); color: #101A15; border: none; border-radius: 10px;
  padding: 0 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}

.import-modal {
  position: fixed; inset: 0; background: rgba(8, 12, 10, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.import-modal-card {
  background: #182420; border: 1px solid #263029; border-radius: 16px;
  padding: 22px; width: 100%; max-width: 520px; max-height: 85vh;
  display: flex; flex-direction: column; gap: 10px;
}
.import-modal-title { font-family: 'Fraunces', Georgia, serif; font-size: 21px; margin: 0; color: #F4F0E4; }
.import-proposals { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.import-item {
  background: #101A15; border: 1px solid #263029; border-radius: 10px; padding: 10px 12px;
  display: flex; gap: 10px; align-items: flex-start;
}
.import-item input[type="checkbox"] { margin-top: 4px; accent-color: var(--accent); }
.import-item-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.import-item-label {
  background: transparent; border: none; color: var(--accent); font-size: 12px; font-weight: 600;
  font-family: inherit; padding: 0; width: 100%;
}
.import-item-text {
  background: transparent; border: none; color: #DCE4DA; font-size: 13.5px; line-height: 1.5;
  font-family: inherit; resize: vertical; width: 100%; padding: 0;
}
.import-item-count { font-size: 11px; color: #5E7267; }
.import-item-count.too-long { color: #D9A85C; font-weight: 600; }
.import-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.import-cancel-btn {
  background: none; border: 1px solid #33423A; color: #DCE4DA; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-size: 14px; font-family: inherit;
}
.import-confirm-btn {
  background: var(--accent); color: #101A15; border: none; border-radius: 10px;
  padding: 10px 18px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
}

/* --- Réglages IA --- */
.settings-form { padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.settings-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding-bottom: 16px; border-bottom: 1px solid #263029; margin-bottom: 6px;
}
.settings-title { font-size: 15px; color: #F4F0E4; margin: 0 0 6px 0; font-weight: 600; }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0; background: #33423A;
  border-radius: 999px; transition: background .2s ease;
}
.switch-slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #EDE7D9; border-radius: 50%; transition: transform .2s ease;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

.settings-form select {
  background: #101A15; border: 1px solid #33423A; border-radius: 10px;
  padding: 10px 12px; color: #EDE7D9; font-size: 14px; font-family: inherit;
}
.settings-form input[type="password"] {
  background: #101A15; border: 1px solid #33423A; border-radius: 10px;
  padding: 10px 12px; color: #EDE7D9; font-size: 14px; font-family: inherit;
}
.settings-actions { display: flex; gap: 10px; margin-top: 8px; }
#ai-save-btn {
  background: var(--accent); color: #101A15; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.ai-clear-btn {
  background: none; border: 1px solid #33423A; color: #D98383; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; cursor: pointer; font-family: inherit;
}

.source-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; display: inline-block; }
.source-tag.ia { color: var(--accent); }
.source-tag.recherche { color: #5E7267; }
