/* FasoGo / FasoChat — interface styles.
   Layout: sidebar (conversations, account) + main column (header, conversation, composer).
   Computers (≥ 900px): sidebar always visible. Phones: sidebar slides in from the left. */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --sidebar: #efede6;
  --hover: rgba(24, 32, 26, .06);
  --text: #18201a;
  --muted: #5f665e;
  --line: #e2e0d8;
  --accent: #0f7a3d;
  --accent-ink: #ffffff;
  --accent-soft: #e5f1e8;
  --bubble: #e9efe9;
  --red: #c8102e;
  --gold: #e0a400;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --sidebar-w: 280px;
  --col: 760px;
  /* Kept for the logo and older rules */
  --accent-2: var(--red);
  --star: var(--gold);
  --chip: var(--accent-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101310;
    --surface: #181c18;
    --sidebar: #0b0e0b;
    --hover: rgba(236, 239, 232, .07);
    --text: #ecefe8;
    --muted: #a1a89d;
    --line: #2a302a;
    --accent: #3fbf74;
    --accent-ink: #08130c;
    --accent-soft: #17281c;
    --bubble: #1f2a21;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Elements hidden by the script stay hidden, even when a rule gives them display: flex. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Shell ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.brand .brand-g { color: var(--accent); }
.brand .brand-o { margin: 3px 0 0 1px; }
.brand .brand-icon { margin-right: 8px; }

/* ---------- Buttons ---------- */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.text-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: none; }
.text-btn:hover { color: var(--text); text-decoration: underline; }
.btn-primary { width: 100%; border: 0; border-radius: 12px; padding: 13px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; cursor: pointer; }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--sidebar); border-right: 1px solid var(--line); }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; min-height: 44px; }
.sb-close { display: none; }
.sb-new { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.sb-new:hover { border-color: var(--accent); }
.sb-label { margin: 14px 8px 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.history-list { flex: 1; min-height: 60px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.history-item { position: relative; display: flex; align-items: center; border-radius: 10px; }
.history-item:hover { background: var(--hover); }
.history-item.active { background: var(--accent-soft); }
.history-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 9px 10px; border: 0; background: none; text-align: left; cursor: pointer; }
.history-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-when { font-size: 12px; color: var(--muted); }
.history-del { flex: none; width: 32px; height: 32px; margin-right: 4px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 18px; cursor: pointer; opacity: 0; }
.history-item:hover .history-del, .history-item.active .history-del, .history-del:focus-visible { opacity: 1; }
.history-del:hover { color: var(--red); background: var(--hover); }
.history-empty { margin: 6px 10px; font-size: 13px; color: var(--muted); }
.sb-meta { padding: 6px 8px 2px; }
.history-note { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.sb-account { margin-top: 6px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.sb-account:empty { display: none; }
.sb-account p { margin: 0; font-size: 13px; }
.account-head { display: flex; align-items: center; gap: 10px; }
.account-who { font-weight: 600; font-size: 14px !important; }
.account-note { color: var(--muted); }
.account-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.account-links a, .account-links button { font-size: 13px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; }
.account-links a:hover, .account-links button:hover { color: var(--text); text-decoration: underline; }
.account-links .danger:hover { color: var(--red); }
.sb-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 10px 8px 0; }
.scrim { display: none; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 14px; flex: none; }
.menu-btn, .top-brand { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lang-pill { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px 0 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.lang-pill:focus-within { border-color: var(--accent); }
.lang-pill select { appearance: none; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding-right: 2px; outline: none; max-width: 130px; }
.signin-pill { height: 38px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.signin-pill:hover { opacity: .9; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--gold); background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 16px; cursor: pointer; }
.avatar.small { width: 32px; height: 32px; font-size: 14px; flex: none; cursor: default; }

/* ---------- Scroll area, hero ---------- */
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px; }
.hero { max-width: var(--col); margin: 0 auto; padding: 9vh 0 40px; text-align: center; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.hero h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.1; letter-spacing: -0.03em; margin: 18px 0 10px; }
.hero .sub { margin: 0 auto 26px; max-width: 560px; color: var(--muted); font-size: clamp(15px, 2.4vw, 17px); }
.hero-slot { max-width: 680px; margin: 0 auto; }
.hero-slot .composer { box-shadow: var(--shadow); }
.chips { max-width: 680px; margin: 22px auto 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; text-align: left; }
.chip-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; font-size: 14px; line-height: 1.35; transition: border-color .15s, transform .15s; }
.chip-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
body.chatting .hero { display: none; }

/* ---------- Conversation ---------- */
.thread { max-width: var(--col); margin: 0 auto; padding: 18px 0 24px; display: flex; flex-direction: column; gap: 22px; }
.msg.user { align-self: flex-end; max-width: 85%; padding: 11px 16px; border-radius: 20px 20px 6px 20px; background: var(--bubble); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; }
.bot-mark { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); }
.bot-mark img { width: 20px; height: 20px; }
.bot-body { min-width: 0; }
.answer { font-size: 16px; overflow-wrap: anywhere; }
.answer > :first-child { margin-top: 3px; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 12px; }
.answer h4 { font-size: 16px; margin: 18px 0 6px; }
.answer ul, .answer ol { padding-left: 22px; margin: 0 0 12px; }
.answer li { margin: 4px 0; }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin-left: 2px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; text-decoration: none; vertical-align: 2px; }
.typing:empty::before, .typing::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 2px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.err { color: var(--red); }
.beta-note { margin: 12px 0 0; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--gold) 14%, transparent); font-size: 13px; color: var(--muted); }

.sources { margin-top: 14px; }
.sources h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
.card { flex: 0 0 min(250px, 78%); scroll-snap-align: start; display: block; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card .n { font-size: 12px; color: var(--accent); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .t { font-size: 14px; font-weight: 600; margin: 3px 0 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; }

.answer-foot { display: flex; align-items: center; gap: 2px; margin-top: 10px; flex-wrap: wrap; }
.answer-foot .feedback { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.act { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 10px; border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.act:hover { background: var(--hover); color: var(--text); }
.act.on { color: var(--accent); }
.actions { display: flex; gap: 2px; }
.followups { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.followups > span { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.followups .chip { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; text-align: left; cursor: pointer; }
.followups .chip::before { content: "↳"; color: var(--accent); font-weight: 700; }
.followups .chip:hover { border-color: var(--accent); }

/* ---------- Composer ---------- */
.dock { flex: none; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 22%); }
.dock .composer { max-width: var(--col); margin: 0 auto; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 18px; border-radius: 24px; border: 1px solid var(--line); background: var(--surface); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.composer textarea { flex: 1; min-height: 28px; max-height: 180px; padding: 9px 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; line-height: 1.45; resize: none; outline: none; }
.composer button { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.composer button:disabled { opacity: .45; cursor: default; }
.foot { max-width: var(--col); margin: 8px auto 0; text-align: center; font-size: 12px; color: var(--muted); }
body:not(.chatting) .dock { background: none; }

/* ---------- Dialogs (centred on computers, bottom sheets on phones) ---------- */
.sheet { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 26px 24px 22px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.sheet::backdrop { background: rgba(10, 14, 10, .5); backdrop-filter: blur(2px); }
.sheet-close { position: absolute; top: 10px; right: 10px; }
.sheet-mark { display: flex; justify-content: center; }
.sheet-mark svg { width: 46px; height: 46px; }
.sheet h2 { text-align: center; font-size: 22px; letter-spacing: -0.02em; margin: 12px 0 6px; }
.sheet-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.sheet-sub:empty { display: none; }
.signin-choose { display: flex; flex-direction: column; gap: 10px; }
.signin-choose:empty { display: none; }
.provider-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
.provider-btn:hover { border-color: var(--accent); background: var(--hover); }
.sheet form { display: flex; flex-direction: column; gap: 10px; }
.sheet label { font-size: 14px; color: var(--muted); }
.phone-row { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); overflow: hidden; }
.phone-row:focus-within { border-color: var(--accent); }
.phone-row span { padding: 0 12px; color: var(--muted); border-right: 1px solid var(--line); white-space: nowrap; }
.phone-row input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 18px; letter-spacing: .04em; padding: 12px; outline: none; }
.code-input { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; font-size: 26px; letter-spacing: .45em; text-align: center; padding: 10px; outline: none; }
.code-input:focus { border-color: var(--accent); }
.signin-sent { margin: 0; text-align: center; font-size: 14px; }
.signin-error { margin: 10px 0 0; text-align: center; font-size: 14px; color: var(--red); }
.signin-error:empty { margin: 0; }
.sheet-consent { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.sheet .text-btn { align-self: center; }

.contact-card h2 { text-align: left; font-size: 20px; margin: 0 0 6px; }
.contact-card p { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.contact-links { display: flex; flex-direction: column; gap: 8px; }
.contact-links a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.contact-links a:hover { border-color: var(--accent); }
.contact-links svg { color: var(--accent); flex: none; }

.toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); pointer-events: none; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 899px) {
  .menu-btn, .top-brand { display: inline-flex; }
  .top { padding: 0 8px; }
  .top-brand { margin-left: 2px; font-size: 20px; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(320px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.25); padding-top: calc(14px + env(safe-area-inset-top)); }
  body.sb-open .sidebar { transform: none; }
  .sb-close { display: inline-flex; }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgba(10, 14, 10, .45); }
  body.sb-open .scrim { display: block; }
  .history-del { opacity: 1; }
  .hero { padding-top: 5vh; }
  .chips { grid-template-columns: 1fr 1fr; }
  .chip-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; font-size: 13.5px; }
  /* Language: a round globe button; the invisible select on top opens the phone's own picker. */
  .lang-pill { width: 40px; height: 40px; padding: 0; justify-content: center; color: var(--text); }
  .lang-pill select { position: absolute; inset: 0; width: 100%; max-width: none; opacity: 0; }
  .top-right { gap: 6px; }
  .signin-pill { padding: 0 14px; }
  .msg.bot { grid-template-columns: minmax(0, 1fr); }
  .bot-mark { display: none; }
  .sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
@media (max-width: 370px) {
  .signin-pill { padding: 0 11px; font-size: 13px; }
  .top-brand { font-size: 18px; }
}

/* ---------- Privacy page ---------- */
body.legal { height: auto; }
.proto-banner { background: var(--red); color: #fff; font-size: 13px; text-align: center; padding: 6px 16px; }
.legal-page { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.legal-page h1 { font-size: clamp(26px, 5vw, 34px); margin: 18px 0 6px; }
.legal-page h2 { font-size: 19px; margin: 30px 0 8px; }
.legal-page .sub { color: var(--muted); }
.legal-page ul { padding-left: 20px; }
.legal-page li { margin: 6px 0; }
