:root {
  color-scheme: light;
  --canvas: #f5f1e9;
  --paper: #fffdf8;
  --ink: #202b27;
  --muted: #69736e;
  --faint: #9a9f9a;
  --line: #dcd8ce;
  --sage: #536d61;
  --sage-soft: #e4ece7;
  --rose: #9a4e57;
  --rose-soft: #f3e4e3;
  --shadow: 0 24px 70px rgba(47, 54, 47, .10);
  --serif: Georgia, "Songti SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

.connecting-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
  color: var(--ink);
  background: radial-gradient(circle at 50% 38%, #fffdf8 0, var(--canvas) 62%);
}
.connecting-screen[hidden] { display: none; }
.connecting-screen h1 { margin: 0; font: 600 clamp(28px, 6vw, 46px)/1.2 var(--serif); }
.connecting-screen p { max-width: 420px; margin: 0; color: var(--muted); line-height: 1.7; }
.connecting-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--sage);
  font: 600 28px/1 var(--serif);
  box-shadow: var(--shadow);
}
.connecting-pulse { width: 64px; height: 3px; overflow: hidden; border-radius: 9px; background: var(--line); }
.connecting-pulse::after {
  content: "";
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
  animation: connect 1.1s ease-in-out infinite alternate;
}
@keyframes connect { to { transform: translateX(78px); } }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(184, 113, 116, .17), transparent 34rem),
    radial-gradient(circle at 100% 45%, rgba(96, 129, 109, .13), transparent 30rem),
    var(--canvas);
  font-family: var(--sans);
}

button, textarea, select { font: inherit; }
button, select { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
}

.topbar {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
  border-bottom: 1px solid rgba(181, 178, 168, .65);
}

.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--rose);
  border-radius: 50%;
  color: var(--rose);
  font: 600 19px/1 var(--serif);
}
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font: 600 18px/1 var(--serif); letter-spacing: .045em; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: .1em; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.language-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.language-picker select,
.quiet-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, .68);
  color: var(--ink);
  padding: 8px 12px;
}
.quiet-button:hover { border-color: #bab4a8; background: var(--paper); }

.conversation-panel {
  width: min(780px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(42px, 8vh, 88px) 0 36px;
}

.welcome, .login-card { animation: arrive .48s ease-out; }
.login-card { max-width: 640px; }
.eyebrow { margin: 0 0 17px; color: var(--rose); font-size: 10px; font-weight: 700; letter-spacing: .17em; }
h1 { margin: 0; font: 500 clamp(40px, 7vw, 68px)/1.08 var(--serif); letter-spacing: -.04em; }
h1 em { color: var(--rose); font-weight: inherit; }
.welcome-copy { max-width: 610px; margin: 24px 0 28px; color: var(--muted); font-size: 16px; line-height: 1.8; }
.suggestions { display: flex; flex-wrap: wrap; gap: 9px; }
.suggestion {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 253, 248, .68);
  color: #4c5a54;
  font-size: 13px;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.suggestion:hover { transform: translateY(-1px); border-color: #aeb9b2; background: var(--paper); }

.login-form { display: grid; gap: 14px; margin-top: 28px; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,253,248,.78); box-shadow: var(--shadow); }
.login-form > label:first-child { color: var(--muted); font-size: 12px; font-weight: 700; }
.login-form input[type="text"], .login-form input[type="email"], .account-email input[type="email"] { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; background: var(--paper); color: var(--ink); font-size: 16px; outline: none; }
.login-form input[type="text"] { text-transform: uppercase; }
.login-form input:focus, .account-email input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(83,109,97,.11); }
.form-help, .form-status { margin: -4px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.form-heading { margin: 0; color: var(--ink); font-weight: 650; line-height: 1.6; }
.account-email { display: grid; gap: 8px; margin: 18px 0; padding: 16px; border-radius: 16px; background: var(--sage-soft); }
.account-email p { margin: 0; font-size: 14px; line-height: 1.6; }
.account-email form { display: grid; gap: 10px; }
.consent-row { display: flex; align-items: flex-start; gap: 10px; color: #56625c; font-size: 12px; line-height: 1.65; }
.consent-row input { margin-top: 3px; accent-color: var(--sage); }
.privacy-details { color: var(--muted); font-size: 12px; line-height: 1.65; }
.privacy-details summary { cursor: pointer; font-weight: 650; }
.primary-button { justify-self: start; border: 0; border-radius: 999px; padding: 11px 18px; background: var(--rose); color: white; font-weight: 700; }
.primary-button:disabled { opacity: .5; cursor: wait; }

.conversation { display: flex; flex-direction: column; gap: 18px; }
.message { animation: arrive .3s ease-out; }
.user-message {
  align-self: flex-end;
  max-width: min(82%, 620px);
  padding: 13px 17px;
  border-radius: 18px 18px 5px 18px;
  background: var(--sage);
  color: white;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.assistant-message {
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(192, 187, 176, .72);
  border-radius: 22px;
  background: rgba(255, 253, 248, .84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.answer-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.assistant-name { color: var(--rose); font: 600 13px/1 var(--serif); letter-spacing: .08em; }
.status-pill { padding: 6px 10px; border-radius: 999px; background: var(--sage-soft); color: #405a4d; font-size: 11px; }
.answer { margin-top: 21px; white-space: pre-wrap; font: 400 17px/1.95 var(--serif); }
.answer strong { color: #7c6433; font-weight: 650; }
.follow-up,
.professional-note { margin: 20px 0 0; padding: 14px 16px; border-radius: 13px; line-height: 1.7; }
.follow-up { background: var(--sage-soft); color: #3d564a; font-weight: 600; }
.professional-note { border-left: 3px solid var(--rose); border-radius: 3px 13px 13px 3px; background: var(--rose-soft); }
.sources { margin-top: 28px; padding-top: 21px; border-top: 1px solid var(--line); }
.sources summary { color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.source { margin-top: 12px; padding: 13px 15px; border-radius: 12px; background: rgba(242, 239, 232, .8); }
.source-id { color: var(--rose); font-size: 11px; font-weight: 700; }
.source p { margin: 6px 0 0; color: #58615d; font-size: 12px; line-height: 1.65; }
.source a { display: inline-block; margin-top: 7px; color: var(--rose); font-size: 12px; }
.disclaimer { margin: 23px 0 0; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.65; }
.feedback-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.feedback-actions span { color: var(--muted); font-size: 11px; }
.feedback-button { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: transparent; color: var(--muted); font-size: 12px; }
.feedback-button.selected { border-color: var(--sage); background: var(--sage-soft); color: var(--sage); }

.status { width: fit-content; margin: 20px auto 0; color: var(--muted); font-size: 13px; }
.status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: var(--sage); animation: pulse 1.1s infinite; }
.status.error { width: auto; padding: 12px 15px; border-radius: 12px; background: var(--rose-soft); color: #7e3740; }
.status.error::before { display: none; }

.composer-wrap {
  position: sticky;
  bottom: 0;
  z-index: 3;
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  padding: 13px 0 18px;
  background: linear-gradient(to bottom, transparent, var(--canvas) 18%, var(--canvas));
}
.composer {
  padding: 14px 15px 11px 18px;
  border: 1px solid rgba(180, 176, 166, .85);
  border-radius: 22px;
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 12px 40px rgba(45, 51, 46, .12);
}
.composer:focus-within { border-color: #9caea4; box-shadow: 0 12px 44px rgba(45, 51, 46, .15); }
textarea { display: block; width: 100%; min-height: 32px; max-height: 170px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.65; }
textarea::placeholder { color: var(--faint); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; }
.counter { color: var(--faint); font-size: 11px; }
.send-button { display: flex; align-items: center; gap: 10px; border: 0; border-radius: 999px; padding: 8px 9px 8px 14px; background: var(--rose); color: white; font-weight: 700; }
.send-button:hover { background: #853f48; }
.send-button:disabled { cursor: wait; opacity: .5; }
.send-arrow { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.16); }
.privacy-note { margin: 8px 12px 0; color: #7e8581; text-align: center; font-size: 10px; line-height: 1.5; }
.delete-account { display: block; margin: 5px auto 0; border: 0; background: transparent; color: #8b6568; font-size: 10px; text-decoration: underline; }

.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; }

@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { opacity: .3; transform: scale(.78); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

@media (max-width: 620px) {
  .topbar { width: min(100% - 28px, 980px); padding: 15px 0; }
  .brand-copy small, .language-picker > span { display: none; }
  .conversation-panel { width: min(100% - 28px, 780px); padding-top: 38px; }
  h1 { font-size: clamp(38px, 12vw, 52px); }
  .welcome-copy { font-size: 15px; }
  .suggestions { display: grid; }
  .suggestion { text-align: left; }
  .user-message { max-width: 91%; }
  .assistant-message { border-radius: 18px; }
  .composer-wrap { width: calc(100% - 20px); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* Rèsa conversation — warm paper, champagne accents and quiet teal replies. */
:root {
  --canvas: #ebe5d8;
  --paper: #fffdfa;
  --ink: #252522;
  --muted: #7e7a71;
  --faint: #a5a094;
  --line: #eee5d4;
  --sage: #577f79;
  --sage-soft: #eef3f1;
  --rose: #987b37;
  --rose-soft: #f6efdf;
  --shadow: 0 18px 60px rgba(112, 93, 51, .05);
}
[hidden] { display: none !important; }
html { background: var(--canvas); }
body { background: radial-gradient(ellipse at 15% 5%, #f3e8d0, transparent 55%), var(--canvas); }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--sage); outline-offset: 4px; }
.app-shell {
  display: flex; flex-direction: column;
  width: min(940px, calc(100% - 64px)); min-height: calc(100dvh - 32px);
  margin: 32px auto 0; padding: 0 44px;
  border: 1px solid #ddcfb3; border-bottom: 0; border-radius: 56px 56px 0 0;
  background: radial-gradient(ellipse at 48% 16%, rgba(241, 222, 183, .28), transparent 36%), #fbfaf7;
  box-shadow: 0 20px 90px #786d5310;
}
.topbar { width: 100%; padding: 36px 8px 22px; border: 0; }
.brand-copy strong { color: #8b7951; font: 600 29px/1 var(--serif); letter-spacing: .23em; }
.connection-status { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 30px; padding: 11px 16px; color: #615e56; background: #ffffff80; font-size: 12px; letter-spacing: .06em; }
.connection-status i { width: 8px; height: 8px; background: #c3a866; border-radius: 50%; }
.hero { padding: 8px 0 30px; }
.hero h1 { font: 400 clamp(30px, 4.1vw, 45px)/1.32 var(--sans); letter-spacing: -.035em; }
.hero h1 em { color: #dcb574; font-style: italic; }
.conversation-panel { flex: 1; width: 100%; margin: 0; padding: 28px 30px 34px; border: 1px solid var(--line); border-bottom: 0; border-radius: 42px 42px 0 0; background: linear-gradient(125deg, #faf5e9a0, #ffffffa8 44%); box-shadow: var(--shadow); }
.login-card { margin: 6px auto 20px; }
.login-card h1 { font-size: 38px; line-height: 1.25; }
.login-card .welcome-copy { font-size: 15px; }
.login-form { box-shadow: none; }
.day-divider { align-self: center; width: fit-content; margin: 3px auto 16px; padding: 8px 15px; border: 1px solid var(--line); border-radius: 24px; color: var(--muted); background: #ffffffa0; font-size: 12px; }
.welcome-message { position: relative; margin: 26px 12px 24px 64px; padding: 22px; border: 1px solid #eddfc2; border-radius: 28px 28px 28px 8px; background: linear-gradient(130deg, #f5e8cd99, #fffdfa80 85%); }
.welcome-message h2 { margin: 0; color: var(--rose); font-size: 18px; font-weight: 600; line-height: 1.6; }
.welcome-message .welcome-copy { margin: 7px 0 0; color: #625f57; font-size: 16px; line-height: 1.8; }
.welcome-avatar, .assistant-name { position: absolute; left: -62px; bottom: 0; display: grid; place-items: center; width: 45px; height: 45px; border: 1px solid #eadfc7; border-radius: 18px; background: #f1ecdf; color: #987a34; font: 400 24px/1 var(--serif); }
.welcome > .suggestions { margin: 0 12px 24px 64px; }
.suggestion { border-color: var(--line); background: #fffdfa88; color: #656158; padding: 10px 14px; font-size: 13px; }
.suggestion:hover { border-color: #cdb985; background: #faf3e5; }
.conversation { gap: 18px; }
.message { overflow-wrap: anywhere; }
.user-message { margin-right: 0; max-width: 82%; padding: 15px 20px; border: 1px solid #d4dfdc; border-radius: 26px 26px 8px 26px; background: #edf2f0; color: var(--sage); font-size: 16px; line-height: 1.75; }
.assistant-message { position: relative; margin: 0 12px 0 64px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 28px 28px 28px 8px; background: #ffffffa8; box-shadow: none; backdrop-filter: none; }
.assistant-message:first-of-type { background: linear-gradient(130deg, #f6e9ccaa, #ffffffa0 80%); }
.answer-header { display: block; }
.status-pill { display: inline-block; margin-bottom: 10px; }
.answer { margin: 0; color: #55534e; font: 400 16px/1.8 var(--sans); }
.follow-up, .professional-note { margin-top: 15px; font-size: 14px; }
.sources { margin-top: 16px; padding-top: 12px; }
.disclaimer { margin-top: 14px; padding-top: 12px; }
.feedback-actions { flex-wrap: wrap; margin-top: 12px; }
.feedback-button { background: #fffdfa66; }
.composer-wrap { position: sticky; bottom: 79px; width: 100%; margin: 0; padding: 0 18px 12px; border-inline: 1px solid var(--line); background: linear-gradient(180deg, #fbfaf7f2, #fbfaf7); }
.quick-prompts { display: flex; gap: 9px; padding: 14px 0 13px; border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.quick-prompts .suggestion { flex: 0 0 auto; }
.composer { display: flex; align-items: flex-end; gap: 12px; padding: 13px 14px 13px 19px; border-color: #e6dcc8; border-radius: 25px; box-shadow: 0 6px 24px #9a874b09; background: #fffefa; }
.composer:focus-within { border-color: #c4b079; box-shadow: 0 0 0 3px #c4b07912; }
textarea { min-height: 36px; padding-top: 4px; }
.composer-bottom { margin: 0; gap: 8px; }
.counter { white-space: nowrap; font-size: 9px; }
.send-button { padding: 0; width: 38px; height: 38px; justify-content: center; flex: 0 0 auto; background: #ad914a; }
.send-button > span:first-child { display: none; }
.send-button:hover { background: #947937; }
.send-arrow { background: none; font-size: 23px; font-weight: 400; transform: rotate(35deg); }
.privacy-note { font-size: 10px; color: #979185; }
.bottom-nav { position: sticky; bottom: 0; z-index: 4; display: flex; width: 100%; min-height: 80px; padding: 13px 12px max(13px, env(safe-area-inset-bottom)); border: 1px solid #e5ddcc; border-bottom: 0; border-radius: 30px 30px 0 0; background: #f3f2edee; box-shadow: 0 -8px 36px #82734b0a; backdrop-filter: blur(20px); }
.bottom-nav button { flex: 1; display: grid; justify-items: center; align-content: center; gap: 8px; border: 0; background: none; color: #767369; font-size: 13px; }
.bottom-nav i { display: block; width: 6px; height: 6px; border-radius: 50%; background: #d1ccbe; }
.bottom-nav [aria-current] { color: #a88a40; }
.bottom-nav [aria-current] i { background: #a88a40; }
.settings-dialog { width: min(460px, calc(100% - 32px)); padding: 26px; border: 1px solid var(--line); border-radius: 26px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: #3b352c40; backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-header h2 { margin: 0; font: 400 26px var(--serif); }
.settings-dialog p { color: var(--muted); line-height: 1.8; font-size: 14px; }
.settings-dialog .language-picker { margin: 22px 0; }
.settings-dialog .delete-account { margin: 28px 0 0; color: #987b64; font-size: 12px; }
.settings-dialog .suggestions { display: grid; }
.suggestion-dialog form { display: grid; gap: 12px; margin-top: 18px; }
.suggestion-dialog label { font-size: 13px; color: var(--ink); }
.suggestion-dialog textarea { width: 100%; min-height: 130px; resize: vertical; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fffefa; color: var(--ink); font: inherit; line-height: 1.6; }
.suggestion-dialog textarea:focus { outline: 2px solid var(--sage); outline-offset: 2px; }
.suggestion-dialog .suggestion-error { margin: 0; color: #9d3e45; }
.suggestion-dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.feedback-toast { position: fixed; left: 50%; bottom: max(100px, calc(env(safe-area-inset-bottom) + 94px)); z-index: 10; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; background: #405a4d; color: white; box-shadow: var(--shadow); text-align: center; font-size: 13px; }
.feedback-toast[hidden] { display: none; }
@media (min-width: 1000px) { .hero h1 { font-size: 43px; } .desktop-break { display: none; } }
@media (max-width: 620px) {
  html, body { background: #fbfaf7; }
  .app-shell { width: 100%; min-height: 100dvh; margin: 0; padding: 0 18px; border: 0; border-radius: 0; }
  .topbar { width: 100%; padding: 25px 5px 23px; gap: 10px; }
  .brand-copy strong { font-size: 22px; }
  .connection-status { font-size: 10px; padding: 9px 12px; gap: 7px; }
  .connection-status i { width: 6px; height: 6px; }
  .hero { padding: 0 2px 24px; }
  .hero h1 { font-size: clamp(25px, 6.6vw, 38px); line-height: 1.4; }
  .desktop-break { display: none; }
  .conversation-panel { width: 100%; padding: 22px 14px 25px; border-radius: 30px 30px 0 0; }
  .day-divider { font-size: 11px; padding: 7px 13px; margin-bottom: 10px; }
  .conversation { gap: 15px; }
  .assistant-message, .welcome-message { margin-left: 42px; margin-right: 0; padding: 16px; border-radius: 23px 23px 23px 7px; }
  .assistant-name, .welcome-avatar { left: -43px; width: 33px; height: 36px; border-radius: 13px; font-size: 21px; }
  .answer, .user-message, .welcome-message .welcome-copy { font-size: 14px; line-height: 1.8; }
  .welcome-message h2 { font-size: 16px; }
  .welcome > .suggestions { margin-left: 42px; margin-right: 0; }
  .user-message { max-width: 86%; padding: 12px 16px; }
  .composer-wrap { width: 100%; bottom: calc(70px + env(safe-area-inset-bottom)); padding: 0 12px 10px; }
  .quick-prompts { gap: 7px; padding-block: 12px; }
  .quick-prompts .suggestion { padding: 8px 12px; font-size: 12px; }
  .composer { padding: 10px 10px 10px 14px; gap: 6px; border-radius: 22px; }
  .counter { display: none; }
  textarea { font-size: 16px; }
  .bottom-nav { min-height: calc(70px + env(safe-area-inset-bottom)); padding-block: 11px max(11px, env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; }
  .bottom-nav button { font-size: 12px; }
  .login-card h1 { font-size: 32px; }
  .login-form { padding: 16px; }
}

.memory-card { border-top: 1px solid #d9d4ca; padding: 16px 0; }
.memory-card h3 { margin: 0 0 6px; font-size: 1rem; }
.memory-card textarea { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #d9d4ca; border-radius: 10px; font: inherit; resize: vertical; }
.memory-help { font-size: .8rem; line-height: 1.6; opacity: .8; }
.memory-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.memory-evidence { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; }
#memory-dialog { width: min(620px, calc(100vw - 32px)); max-height: 85vh; overflow-y: auto; }
