:root{--ink:#2c2925;--navy:#302d28;--paper:#f8f6f1;--white:#fffdfa;--line:#e7e1d7;--muted:#7b766f;--violet:#a74729;--soft:#f8e8dd;--green:#44745b;--amber:#a96400;--red:#ab3e3e;--shadow:0 18px 42px rgba(60,47,35,.08)}
*{box-sizing:border-box}
body{margin:0;background:var(--paper);color:var(--ink);font:14px/1.55 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
button,input,textarea{font:inherit}

/* ── Layout ── */
.app{height:100vh;min-height:100vh;display:grid;grid-template-columns:268px minmax(0,1fr) 340px;overflow:hidden}

/* ── Left sidebar ── */
.left{height:100vh;position:sticky;top:0;overflow:hidden;background:#f3f0e9;border-right:1px solid var(--line);padding:24px 14px;display:flex;flex-direction:column;min-width:0}
.brand{display:flex;gap:11px;align-items:center;padding:0 7px 24px}
.brand-mark{width:38px;height:38px;display:grid;place-items:center;overflow:hidden;border-radius:11px;background:#2d2a26;box-shadow:0 6px 13px #2e29251d}
.brand-mark img{display:block;width:100%;height:100%;object-fit:contain}
.logo-fallback{display:none;width:100%;height:100%;place-items:center;color:#fff;font:700 18px Georgia,serif}
.brand strong{display:block;font:700 19px Georgia,serif;letter-spacing:-.04em}
.brand small{display:block;margin-top:-2px;color:#978f84;font-size:9px;font-weight:800;letter-spacing:.16em;text-transform:uppercase}
.new-chat{width:100%;border:1px solid #2f2b27;border-radius:9px;background:#2f2b27;color:#fff;padding:10px 12px;font-weight:750;text-align:left;cursor:pointer}
.new-chat:hover{background:#504a44}
.new-chat span{margin-right:8px;font-size:16px}
.nav-label,.eyebrow{color:#968e83;font-size:10px;font-weight:800;letter-spacing:.16em;text-transform:uppercase}
.nav-label{padding:20px 10px 7px}
.chat-list{display:flex;flex-direction:column;align-content:start;gap:0;row-gap:0;flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.chat-item{margin:0;flex:0 0 auto;position:relative;width:100%;height:38px;min-height:38px;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:4px;border:0;border-radius:8px;background:transparent;color:#716b63;padding:0 4px 0 10px;text-align:left;cursor:pointer;white-space:nowrap;overflow:hidden}
.chat-item:hover,.chat-item.active{background:#eae4da;color:#2f2a25;font-weight:750}
.chat-item:focus-visible{outline:2px solid #c98d73;outline-offset:1px}
.chat-title{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-actions{display:flex;align-items:center;justify-content:flex-end;gap:1px;flex:0 0 auto}
.chat-rename,.chat-delete{width:25px;height:28px;display:grid;place-items:center;border:0;border-radius:6px;background:transparent;color:#9c9489;padding:0;cursor:pointer;opacity:0}
.chat-item:hover .chat-rename,.chat-item:hover .chat-delete,.chat-item:focus-within .chat-rename,.chat-item:focus-within .chat-delete{opacity:1}
.chat-rename:hover{background:#ded6ca;color:#5d554c}
.chat-delete:hover{background:#f2d9d2;color:var(--red)}
.side-note{margin-top:auto;border:1px solid #ddd4c6;border-radius:11px;background:#ece5da;color:#665e53;padding:13px;font-size:11px;line-height:1.55}
.side-note b{display:block;margin-bottom:3px;color:#423c35}
.site-footer{display:flex;align-items:center;gap:8px;margin:14px 7px 0;padding-top:12px;border-top:1px solid #ddd4c6;color:#837a70;font-size:10px;font-weight:700}
.site-footer img{width:22px;height:22px;border-radius:6px;object-fit:contain;background:#2d2a26}

/* ── Main chat column ── */
.chat{height:100vh;min-width:0;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.top{height:64px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 30px;background:#f8f6f1e8;backdrop-filter:blur(10px);position:sticky;top:0;z-index:3}
.crumb{color:#968f86;font-size:12px}
.crumb b{color:#4c463e}
.live{color:var(--green);font-size:12px}
.live i{display:inline-block;width:7px;height:7px;border-radius:50%;background:#6f997b;margin-right:6px}
.feed{--tail-space:0px;flex:1;min-height:0;overflow-y:auto;max-width:820px;width:100%;margin:0 auto;padding:44px 34px calc(196px + var(--tail-space))}

/* ── Welcome screen ── */
.welcome{margin:7vh 0 0}
.spark{display:grid;place-items:center;width:43px;height:43px;border:1px solid #e1d6c8;border-radius:50%;color:#a74729;background:#f8e8dd;font-size:19px}
.welcome h1{max-width:620px;margin:17px 0 10px;font:600 clamp(35px,5vw,56px)/1.05 Georgia,serif;letter-spacing:-.055em}
.welcome h1 em{color:#a74729;font-style:normal}
.welcome p{max-width:620px;color:#6c665e;font-size:15px;line-height:1.72}
.prompt-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:26px}
.prompt-chips button{border:1px solid #e2dbd1;border-radius:999px;background:#fffdfa;color:#665f57;padding:7px 11px;font-size:11px;cursor:pointer}
.prompt-chips button:hover{border-color:#c88c76;color:#a74729}

/* ── Messages ── */
.message{display:flex;gap:11px;margin:0 0 25px}
.message.user{justify-content:flex-end}
.avatar{width:30px;height:30px;flex:0 0 30px;display:grid;place-items:center;border-radius:50%;background:#f2e2d8;color:#a74729;font-size:10px;font-weight:800}
.user .avatar{order:2;background:#4b443d;color:#fff}
.bubble{max-width:82%;border:1px solid #e7e1d7;border-radius:14px;border-top-left-radius:4px;background:#fffdfa;padding:14px 15px;color:#504a43;font-size:14px;line-height:1.72;box-shadow:0 4px 14px #3c2f2306}
.user .bubble{border:0;border-top-right-radius:4px;background:#4a443d;color:#fff}
.message-title{margin-bottom:5px;color:#2d2925;font:600 16px Georgia,serif}
.citation{color:#a74729;font-weight:800}

/* ── Typing indicator ── */
.typing{display:inline-flex;align-items:center;gap:4px;padding:5px 0}
.typing i{display:block;width:6px;height:6px;border-radius:50%;background:#c5795e;animation:pulse 1.1s infinite}
.typing i:nth-child(2){animation-delay:.13s}
.typing i:nth-child(3){animation-delay:.26s}
@keyframes pulse{0%,70%,100%{opacity:.22}35%{opacity:1}}

/* ── Status row & chips ── */
.status-row{display:flex;align-items:center;gap:7px;margin:9px 0;color:#837c72;font-size:12px}
.status-chip{border-radius:999px;padding:3px 7px;font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
.supported{background:#e8f1e9;color:#35664c}
.mixed{background:#f9ebd8;color:#99601a}
.insufficient{background:#f8e8e5;color:#a43b3b}

/* ── Limitations block ── */
.limits{margin-top:13px;padding-top:11px;border-top:1px solid #ece6dd;color:#7a736a;font-size:12px}
.limits b{color:#514b43}
.limits ul{margin:4px 0 0;padding-left:17px}

/* ── Composer ── */
.composer-wrap{position:fixed;z-index:4;bottom:0;left:268px;right:340px;background:linear-gradient(transparent,#f8f6f1 28%);padding:34px 26px 20px}
.composer{max-width:820px;margin:auto;border:1px solid #dfd7cc;border-radius:15px;background:#fffdfa;padding:8px;display:flex;align-items:end;gap:8px;box-shadow:var(--shadow)}
.composer:focus-within{border-color:#c98d73;box-shadow:0 0 0 3px rgba(167,71,41,.08),var(--shadow)}
textarea{flex:1;min-width:0;min-height:48px;max-height:140px;resize:none;border:0;outline:0;padding:12px;color:#2d2925;font:14px/1.45 Inter,ui-sans-serif,system-ui}
.send{height:43px;min-width:88px;border:0;border-radius:10px;background:#a74729;color:#fff;font-weight:800;cursor:pointer}
.send:hover{background:#89391f}
.send:disabled{opacity:.5;cursor:not-allowed}
.composer-note{max-width:820px;margin:7px auto 0;color:#938b81;font-size:10px;text-align:center}

/* ── Sources panel ── */
.sources{border-left:1px solid var(--line);background:#f3f0e9;padding:22px 16px;overflow:auto;max-height:100vh;position:sticky;top:0}
.sources-head{display:flex;align-items:center;justify-content:space-between;margin:2px 4px 16px}
.sources-head h2{margin:0;font:600 18px Georgia,serif;letter-spacing:-.03em}
.source-count{border-radius:999px;background:#e9dfd2;color:#7a4d37;padding:3px 7px;font-size:10px;font-weight:800}
.source-empty{border:1px dashed #d9d0c4;border-radius:12px;padding:22px 15px;text-align:center;color:#7a736a;font-size:12px;line-height:1.6}
.source-card{display:block;border:1px solid #e2dbd1;border-radius:12px;background:#fffdfa;padding:13px;margin-bottom:9px;color:inherit;text-decoration:none}
.source-card:hover{border-color:#cf9c87;box-shadow:0 8px 20px #4531240b}
.source-tag{display:inline-block;border-radius:5px;background:#f8e8dd;color:#9d4529;padding:3px 5px;font-size:10px;font-weight:800}
.source-card h3{margin:7px 0 5px;font:600 15px/1.35 Georgia,serif;letter-spacing:-.014em}
.source-meta{color:#7c746a;font-size:11px;line-height:1.45}
.source-stats{display:flex;gap:6px;margin-top:9px;color:#7c746a;font-size:10px}
.source-stats span{border-radius:5px;background:#f3eee7;padding:3px 5px}
.source-link{display:block;margin-top:10px;color:#a74729;font-size:11px;font-weight:800}

/* ── Query focus & interpretation ── */
.query-focus{display:inline-flex;max-width:100%;margin:9px 0 1px;padding:4px 7px;border-radius:6px;background:#f4eee6;color:#786f64;font-size:10px;line-height:1.35}
.query-focus b{margin-right:4px;color:#4d453d}
.interpretation{color:#8a5b46;font-size:11px;font-weight:700}

/* ── Error & toast ── */
.error{max-width:820px;margin:0 auto 14px;border:1px solid #edcbc5;border-radius:12px;background:#fdf1ef;color:#a43b3b;padding:11px 13px;font-size:12px}
.toast{position:fixed;z-index:9;right:20px;bottom:20px;border-radius:9px;background:#39342f;color:#fff;padding:10px 13px;font-size:12px;box-shadow:var(--shadow);transform:translateY(90px);transition:.18s}
.toast.show{transform:translateY(0)}

/* ── Responsive: medium ── */
@media(max-width:1050px){
  .app{grid-template-columns:224px minmax(0,1fr)}
  .sources{display:none}
  .composer-wrap{left:224px;right:0}
}

/* ── Mobile bar elements (hidden on desktop) ── */
.mbar{display:none}
.scrim{display:none}

/* ── Responsive: mobile ── */
@media(max-width:900px){
  .app{display:block;height:auto;min-height:100dvh;overflow:visible}
  .mbar{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;align-items:center;gap:8px;position:sticky;top:0;z-index:50;height:56px;padding:0 10px;background:#f3f0e9f2;backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
  .mbtn{position:relative;width:40px;height:40px;flex:0 0 40px;display:grid;place-items:center;border:1px solid #e2dbd1;border-radius:10px;background:#fffdfa;color:#4c463e;font-size:17px;line-height:1;cursor:pointer;-webkit-tap-highlight-color:transparent}
  .mbtn:active{background:#eae4da}
  .mbtn em{position:absolute;top:-6px;right:-6px;min-width:18px;height:18px;display:grid;place-items:center;border-radius:999px;background:#a74729;color:#fff;font:800 10px/1 Inter,sans-serif;font-style:normal;padding:0 4px}
  .mbtn em[hidden]{display:none}
  .mbar-title{min-width:0;display:flex;flex-direction:column;justify-content:center}
  .mbar-title strong{font:700 15px Georgia,serif;letter-spacing:-.03em;color:#2d2925}
  .mbar-title span{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#8d857b;font-size:11px}
  .scrim{display:block;position:fixed;inset:0;z-index:55;background:rgba(38,32,26,.42);opacity:0;pointer-events:none;transition:opacity .22s}
  body.nav-open .scrim,body.src-open .scrim{opacity:1;pointer-events:auto}
  body.nav-open,body.src-open{overflow:hidden}
  .left{position:fixed;top:0;left:0;bottom:0;z-index:60;width:min(85vw,320px);height:100dvh;max-height:100dvh;display:flex;transform:translateX(-103%);transition:transform .25s ease;border-right:1px solid var(--line);box-shadow:0 0 44px rgba(48,40,32,.22);padding:18px 12px calc(18px + env(safe-area-inset-bottom));overflow-y:auto;-webkit-overflow-scrolling:touch}
  body.nav-open .left{transform:none}
  .sources{position:fixed;top:0;right:0;bottom:0;z-index:60;width:min(88vw,360px);height:100dvh;max-height:100dvh;display:block;transform:translateX(103%);transition:transform .25s ease;box-shadow:0 0 44px rgba(48,40,32,.22);padding:18px 14px calc(24px + env(safe-area-inset-bottom));overflow-y:auto;-webkit-overflow-scrolling:touch}
  body.src-open .sources{transform:none}
  .drawer-close{width:34px;height:34px;display:grid;place-items:center;border:1px solid #e2dbd1;border-radius:9px;background:#fffdfa;color:#6b645c;font-size:16px;cursor:pointer}
  .chat{height:auto;min-height:calc(100dvh - 56px);overflow:visible}
  .top{display:none}
  .chat-list{max-height:none;flex:0 1 auto}
  .chat-rename,.chat-delete{opacity:1;width:32px;height:32px}
  .chat-item{height:44px;min-height:44px}
  .feed{overflow:visible;max-width:none;padding:22px 16px calc(190px + var(--tail-space))}
  .welcome{margin:2vh 0 0}
  .welcome h1{font-size:clamp(28px,8.5vw,40px)}
  .welcome p{font-size:14.5px}
  .prompt-chips{gap:7px;margin-top:20px}
  .prompt-chips button{font-size:12px;padding:9px 12px;text-align:left}
  .message{gap:8px;margin-bottom:20px}
  .bubble{max-width:calc(100% - 40px);padding:13px}
  .bubble,.bubble div{overflow-wrap:anywhere;word-break:break-word}
  .query-focus{font-size:10.5px}
  .composer-wrap{left:0;right:0;padding:26px 12px calc(10px + env(safe-area-inset-bottom));background:linear-gradient(transparent,#f8f6f1 32%)}
  .composer{padding:7px;gap:7px}
  textarea{font-size:16px;min-height:46px;padding:11px}
  .send{min-width:72px;height:46px}
  .composer-note{font-size:10px}
  .error{margin-bottom:12px}
  .toast{right:11px;left:11px;bottom:calc(14px + env(safe-area-inset-bottom));text-align:center}
}

@media(max-width:900px) and (display-mode:browser){
  .left,.sources{will-change:transform}
}

@media(max-width:400px){
  .mbar-title strong{font-size:14px}
  .send{min-width:62px}
}
