:root {
  --bg: #F6F1E7; --surface: #FFFFFF; --soft: #F1EBDD; --ink: #16203A; --muted: #5A5F6E; --line: #E0D5BF;
  --navy: #16203A; --on-navy: #FFFFFF; --navy-muted: #D5D8E0; --accent: #B0601C; --accent-ink: #9A5212; --gold: #E9C9A3;
  --ok: #2E6B4E; --okbg: #DCEBE2; --warn: #8A5A00; --warnbg: #FBEFD3; --err: #9B2C2C; --errbg: #F6DEDA;
  --user: #E9DFCB; --radius: 16px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10172B; --surface: #1A2340; --soft: #222C4B; --ink: #F2EEE6; --muted: #A9AFBF; --line: #2E3A5C;
    --navy: #0B1122; --on-navy: #F2EEE6; --navy-muted: #B9BFCE; --accent: #E0924A; --accent-ink: #E0924A; --gold: #E9C9A3;
    --ok: #7CC5A0; --okbg: #1E3A2E; --warn: #F0C36A; --warnbg: #3A3020; --err: #F0A39B; --errbg: #3E2226; --user: #2B3558;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--accent-ink); }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 500; margin: 0; line-height: 1.2; }
.boot { min-height: 100vh; display: grid; place-items: center; font-family: Fraunces, Georgia, serif; font-size: 28px; color: var(--muted); }
.page { max-width: 640px; margin: 0 auto; padding: 16px 18px 110px; display: flex; flex-direction: column; gap: 16px; }
.page.chat { padding-bottom: 0; min-height: 100vh; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.brand { font-family: Fraunces, Georgia, serif; font-size: 22px; font-weight: 600; text-decoration: none; color: var(--ink); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.select { min-height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font-size: 14px; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.back { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; text-decoration: none; }

/* Type */
.hello { font-size: 30px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.hero { background: var(--navy); color: var(--on-navy); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.hero .label { color: var(--gold); }
.hero h2 { font-size: 22px; }
.hero p { margin: 0; color: var(--navy-muted); }
.banner { border-radius: 12px; padding: 12px 14px; font-size: 14px; background: var(--warnbg); color: var(--warn); }
.banner.err { background: var(--errbg); color: var(--err); }
.banner.ok { background: var(--okbg); color: var(--ok); }

/* Buttons */
.btn { min-height: 48px; border-radius: 12px; border: none; background: var(--navy); color: var(--on-navy); font-weight: 600; padding: 0 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; text-align: center; }
.btn.accent { background: var(--accent); color: #FFFFFF; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.hero .btn.ghost { color: var(--on-navy); border-color: rgba(255,255,255,.3); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }

/* Lists */
.route-item, .step-item { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-height: 44px; }
.dot { flex: none; width: 28px; height: 28px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; background: var(--soft); color: var(--muted); }
.dot.on { background: var(--accent); color: #FFFFFF; }
.dot.ok { background: var(--okbg); color: var(--ok); }
.grow { flex: 1 1 auto; min-width: 0; }
.tag { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tag.on { color: var(--accent-ink); }
.tag.ok { color: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; min-height: 72px; }
.tile strong { font-size: 15px; }
.tile span { font-size: 13px; color: var(--muted); }
.path { text-decoration: none; color: var(--ink); }
.progress { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.progress > i { display: block; height: 6px; background: var(--accent); }

/* Bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 10; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; min-width: 64px; min-height: 48px; justify-content: center; }
.nav a.on { color: var(--ink); font-weight: 600; }
.nav svg { width: 22px; height: 22px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.input, .textarea { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.textarea { min-height: 88px; resize: vertical; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 40px; min-width: 44px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; }
.chip.on { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }

/* Login */
.login { min-height: 100vh; background: var(--navy); color: var(--on-navy); }
.login .page { min-height: 100vh; padding-bottom: 32px; }
.login .input { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.25); color: var(--on-navy); font-size: 17px; }
.login .chip { background: transparent; color: var(--on-navy); border-color: rgba(255,255,255,.25); }
.login .chip.on { background: var(--on-navy); color: var(--navy); }
.login a { color: var(--gold); }
.logo { font-family: Fraunces, Georgia, serif; font-size: 52px; font-weight: 600; }

/* Chat */
.chat-head { position: sticky; top: env(safe-area-inset-top, 0px); background: var(--bg); padding: 8px 0 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.chat-head h1 { font-size: 24px; }
.msgs { display: flex; flex-direction: column; gap: 12px; padding: 12px 0; flex: 1 1 auto; }
.msg { max-width: 94%; border-radius: 16px; padding: 12px 14px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.note { align-self: center; background: var(--warnbg); color: var(--warn); font-size: 14px; text-align: center; }
.msg .who { font-size: 12px; font-weight: 600; letter-spacing: .6px; color: var(--accent-ink); margin-bottom: 4px; }
.msg-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md h3 { font-size: 18px; margin: 10px 0 6px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md li { margin-bottom: 4px; }
.md code { background: var(--soft); border-radius: 6px; padding: 1px 5px; font-size: 14px; }
.codeblock { position: relative; background: var(--soft); border-radius: 10px; margin: 6px 0 10px; }
.codeblock pre { margin: 0; padding: 12px 12px 44px; white-space: pre-wrap; font: 14px/1.5 ui-monospace, Menlo, Consolas, monospace; overflow-x: auto; }
.codeblock .btn { position: absolute; right: 8px; bottom: 8px; }
.sources { font-size: 13px; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.thinking { align-self: flex-start; color: var(--muted); font-size: 14px; padding: 6px 2px; }
.thinking::after { content: '…'; animation: blink 1.2s infinite steps(4); }
@keyframes blink { 0% { opacity: .2 } 50% { opacity: 1 } 100% { opacity: .2 } }
@media (prefers-reduced-motion: reduce) { .thinking::after { animation: none; } }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1 1 auto; min-height: 48px; max-height: 160px; border: 1px solid var(--line); border-radius: 22px; padding: 12px 16px; background: var(--surface); resize: none; }
.send { width: 48px; height: 48px; flex: none; border-radius: 24px; border: none; background: var(--accent); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.tools-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tools-row .btn { flex: none; }
.btn.armed { background: var(--okbg); color: var(--ok); border-color: var(--ok); }
.attach-pill { align-self: flex-start; font-size: 13px; background: var(--soft); border-radius: 14px; padding: 6px 10px; display: flex; gap: 8px; align-items: center; }
.attach-pill button { border: none; background: none; color: var(--accent-ink); font-weight: 600; cursor: pointer; min-height: 32px; }

/* Docs */
.doc-title { font-weight: 600; background: none; border: none; text-align: left; padding: 0; cursor: pointer; color: var(--ink); min-height: 32px; }
.doc-body { border-top: 1px solid var(--line); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; min-height: 32px; }

#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--navy); color: var(--on-navy); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Fòm Value Profile ---- */
.page.form { min-height: 100vh; padding: 0 18px calc(18px + env(safe-area-inset-bottom, 0px)); gap: 0; justify-content: flex-start; }
.form-head { position: sticky; top: env(safe-area-inset-top, 0px); background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 12px 0 10px; z-index: 5; }
.form-head .icon-btn { flex: none; font-size: 20px; line-height: 1; }
.qbody { flex: 1 1 auto; display: flex; flex-direction: column; gap: 14px; padding: 18px 0 24px; }
.qtitle { font-family: Fraunces, Georgia, serif; font-size: 25px; font-weight: 500; line-height: 1.25; margin: 0; }
.qhelp { margin: -6px 0 0; font-size: 14px; color: var(--muted); }
.input.big, .textarea.big { font-size: 17px; padding: 14px 16px; }
.textarea.big { min-height: 140px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; font-size: 16px; font-weight: 500; cursor: pointer; }
.opt .mark { flex: none; width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--line); }
.opt.on { border-color: var(--accent); background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.opt.on .mark { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 45%, transparent 46%); }
.linelist { display: flex; flex-direction: column; gap: 10px; }
.line { display: flex; align-items: center; gap: 8px; }
.line-n { flex: none; width: 24px; text-align: right; font-size: 14px; color: var(--muted); }
.line-x { flex: none; width: 40px; height: 40px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.form-foot { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); display: flex; gap: 10px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); }
.form-foot .btn.grow { flex: 1 1 auto; }
.rev { display: flex; align-items: flex-start; gap: 10px; width: 100%; background: none; border: none; border-top: 1px solid var(--line); padding: 12px 0; text-align: left; cursor: pointer; color: var(--ink); }
.card > .rev:first-of-type { border-top: none; }
.rev-q { display: block; font-size: 13px; color: var(--muted); }
.rev-a { display: block; font-size: 15px; margin-top: 2px; }
.rev-a.none { color: var(--muted); font-style: italic; }
.rev-edit { flex: none; font-size: 13px; font-weight: 600; color: var(--accent-ink); padding-top: 12px; }
.form-head .icon-btn { color: var(--muted); text-decoration: none; }
.form-head .icon-btn.close { font-size: 22px; }
.form-foot .btn.ghost { flex: 0 0 auto; padding: 0 20px; }

/* ---- Mak Olasan ---- */
.boot img { border-radius: 22px; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.mark-wrap { display: inline-flex; align-items: center; }
.mark-wrap img { display: block; height: 24px; width: auto; }
.mark-wrap img.mark-dark { display: none; }
@media (prefers-color-scheme: dark) { .mark-wrap img.mark-light { display: none; } .mark-wrap img.mark-dark { display: block; } }
.logo-img { width: 132px; height: auto; }
.login .logo { font-size: 40px; }

/* ---- Tablo modèl la voye, refèt pou telefòn ---- */
.tbl { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 10px; }
.tr { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.tr-h { font-weight: 600; margin-bottom: 4px; }
.tr-i { font-size: 14px; line-height: 1.45; margin-top: 3px; }
.tr-k { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---- Ti fenèt konfimasyon ---- */
.modal-back { position: fixed; inset: 0; background: rgba(10,14,28,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 100; padding: 16px; }
@media (min-width: 560px) { .modal-back { align-items: center; } }
.modal { background: var(--surface); border-radius: 18px; padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.3); margin-bottom: env(safe-area-inset-bottom, 0px); }
.modal h2 { font-size: 20px; }
.modal p { margin: 0; font-size: 15px; }
.modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal-btns .btn { flex: 1 1 0; }
.btn.danger { background: var(--err); color: #FFFFFF; }

/* ---- Fich, swivi, resous ---- */
.start-btn { align-self: flex-start; }
.choice { background: var(--soft); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.choice[open] { gap: 8px; }
.choice summary { font-size: 14px; }
.choice .textarea { min-height: 64px; margin: 6px 0; }
.sheet-entry .field label { font-size: 13px; }
.res-box { gap: 6px; padding: 12px; }
.res-item { display: flex; gap: 12px; align-items: flex-start; text-decoration: none; color: var(--ink); padding: 8px 0; border-top: 1px solid var(--line); }
.res-item:first-of-type, .res-box .small + .res-item { border-top: none; }
.res-item svg { flex: none; width: 22px; height: 22px; margin-top: 2px; color: var(--accent-ink); }
.res-item strong { display: block; font-size: 15px; }
.res-item .small { display: block; margin-top: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500 !important; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.chat-head.static { position: static; border-bottom: none; padding-bottom: 0; }
.choice textarea, .sheet-entry .input, .sheet-entry .textarea { box-sizing: border-box; width: 100%; }
.sheet-entry > summary { list-style: none; }
.sheet-entry > summary::-webkit-details-marker { display: none; }
.sheet-entry[open] > summary { margin-bottom: 4px; }
.sheet-entry .field + .field { margin-top: 8px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pair .select, .pair .input { width: 100%; box-sizing: border-box; }
.sheet-entry .line-x { flex: none; width: 40px; min-width: 40px; padding: 0; }
.sheet-entry[open] .tag.on { display: none; }

/* Chan kòd la ak bouton je a */
.pw-wrap { position: relative; width: 100%; }
.pw-wrap .input { padding-right: 56px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: inherit; opacity: .8; cursor: pointer; }
.pw-toggle:hover { opacity: 1; }
.pw-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; opacity: 1; }
