/* JaphethShem Assist customer app. Mobile first. Light and dark themes follow the device. */
:root{
  --brand:#0b7a70;--brand-strong:#0a6d63;--brand-soft:#e3f4f1;--on-brand:#fff;
  --navy:#0f2742;--navy-2:#143a5e;
  --bg:#f4f6f9;--surface:#fff;--surface-2:#f0f3f7;--elev:#fff;
  --text:#152030;--muted:#556173;--border:#e1e6ee;--border-strong:#c9d1dc;
  --user-bubble:linear-gradient(135deg,#0f2742,#14506a);--on-user:#fff;
  --ok-bg:#e6f7ee;--ok:#14532d;--warn-bg:#fff4d6;--warn:#5c4300;--warn-line:#e3c35d;--err-bg:#fdecec;--err:#8f1d1d;--err-line:#f1b0b0;
  --info-bg:#e3f4f1;--info:#0a4f48;
  --focus:#2563eb;
  --radius:16px;--radius-sm:12px;
  --shadow:0 1px 2px rgba(16,30,54,.06),0 6px 20px rgba(16,30,54,.07);
  --shadow-lg:0 18px 50px rgba(16,30,54,.22);
  --tabbar-h:64px;--topbar-h:56px;
  --safe-t:env(safe-area-inset-top,0px);--safe-b:env(safe-area-inset-bottom,0px);--safe-l:env(safe-area-inset-left,0px);--safe-r:env(safe-area-inset-right,0px);
  --app-h:100dvh;
  color-scheme:light dark;
}
@media (prefers-color-scheme:dark){
  :root{
    --brand:#2fbfae;--brand-strong:#5eead4;--brand-soft:#123a3a;--on-brand:#062b27;
    --bg:#0b1622;--surface:#122233;--surface-2:#18293c;--elev:#1a2d42;
    --text:#e6edf5;--muted:#a3b3c6;--border:#22384f;--border-strong:#2f4a66;
    --user-bubble:linear-gradient(135deg,#1d6f8a,#0f8c7e);--on-user:#fff;
    --ok-bg:#0f3324;--ok:#9be6bd;--warn-bg:#3a2f0b;--warn:#ffe39a;--warn-line:#7a6320;--err-bg:#3b1414;--err:#ffb4b4;--err-line:#7a2a2a;
    --info-bg:#123a3a;--info:#a7f3e7;
    --focus:#7cb4ff;
    --shadow:0 1px 2px rgba(0,0,0,.3),0 8px 24px rgba(0,0,0,.25);
    --shadow-lg:0 18px 50px rgba(0,0,0,.5);
  }
}

*,*::before,*::after{box-sizing:border-box}
*{margin:0;padding:0}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-behavior:smooth}
body.app{font-family:"Segoe UI",system-ui,-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",Arial,sans-serif;font-size:16px;line-height:1.55;color:var(--text);background:var(--bg);min-height:100dvh;-webkit-tap-highlight-color:transparent;-webkit-font-smoothing:antialiased;overscroll-behavior-y:none}
a{color:var(--brand-strong)}
@media (prefers-color-scheme:light){a{color:var(--brand-strong)}}
img,svg{display:block;max-width:100%}
button,input,select,textarea{font:inherit;color:inherit}
h1,h2,h3{line-height:1.25;letter-spacing:-.01em}
.ico{width:22px;height:22px;flex-shrink:0}
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.skip{position:absolute;left:-999px;top:0;z-index:999;background:var(--navy);color:#fff;padding:.75rem 1rem;border-radius:0 0 10px 0}
.skip:focus{left:0}
:focus-visible{outline:3px solid var(--focus);outline-offset:2px;border-radius:8px}
main:focus{outline:none}
.muted{color:var(--muted)}
.small{font-size:.875rem}
.center{text-align:center}
code{background:var(--surface-2);padding:.05em .35em;border-radius:5px;font-size:.9em}

/* ---------- Shell ---------- */
.shell{min-height:100dvh}
.sidebar{display:none}
.main-col{min-width:0}
.topbar{position:sticky;top:0;z-index:40;padding-top:var(--safe-t);background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:saturate(1.6) blur(14px);-webkit-backdrop-filter:saturate(1.6) blur(14px);border-bottom:1px solid transparent}
.topbar-in{display:flex;align-items:center;gap:.5rem;height:var(--topbar-h);padding:0 max(12px,var(--safe-r)) 0 max(12px,var(--safe-l))}
.topbar-title{font-size:1.25rem;font-weight:750;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar-brand{display:none}
.topbar-actions{display:flex;align-items:center;gap:.4rem;margin-left:auto}
.spacer{flex:1}
.brand{display:flex;align-items:center;gap:.55rem;text-decoration:none;color:var(--text);font-weight:800;white-space:nowrap}
.brand-name b{color:var(--brand)}
.brand-mark{display:inline-grid;place-items:center;width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,#0f2742,#0b7a70);color:#fff;font-size:.82rem;font-weight:800;letter-spacing:.02em}
.brand-mark.lg{width:64px;height:64px;border-radius:18px;font-size:1.4rem;margin:0 auto 1rem;box-shadow:var(--shadow)}
.credit-pill{display:inline-flex;align-items:center;gap:.25em;min-height:36px;padding:0 .85rem;border-radius:999px;background:var(--brand-soft);color:var(--brand-strong);font-weight:700;font-size:.9rem;text-decoration:none;white-space:nowrap}
main{display:block;padding:8px max(16px,var(--safe-r)) calc(24px + var(--safe-b)) max(16px,var(--safe-l))}
.has-tabs main{padding-bottom:calc(var(--tabbar-h) + var(--safe-b) + 28px)}
.has-tabs:has(.fab) main{padding-bottom:calc(var(--tabbar-h) + var(--safe-b) + 100px)}
.page{max-width:880px;margin:0 auto;display:flex;flex-direction:column;gap:20px}

/* Bottom tab bar (mobile) */
.tabbar{position:fixed;left:0;right:0;bottom:0;z-index:50;display:grid;grid-template-columns:repeat(4,1fr);padding:6px max(6px,var(--safe-l)) calc(6px + var(--safe-b)) max(6px,var(--safe-r));background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:saturate(1.6) blur(16px);-webkit-backdrop-filter:saturate(1.6) blur(16px);border-top:1px solid var(--border)}
.tabbar a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:52px;border-radius:14px;text-decoration:none;color:var(--muted);font-size:.72rem;font-weight:650;letter-spacing:.01em}
.tabbar a[aria-current=page]{color:var(--brand-strong)}
.tabbar a[aria-current=page] .ico{background:var(--brand-soft);border-radius:999px;width:56px;height:30px;padding:4px 17px;box-sizing:border-box}
.tabbar .ico{width:24px;height:24px;transition:background .2s}

/* ---------- Buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;min-height:44px;padding:0 1.15rem;border-radius:999px;border:1.5px solid transparent;font-weight:700;font-size:.97rem;text-decoration:none;cursor:pointer;background:var(--surface-2);color:var(--text);transition:transform .12s,background .15s,box-shadow .15s;white-space:nowrap;user-select:none}
.btn:active{transform:scale(.97)}
.btn-primary{background:var(--brand);color:var(--on-brand);box-shadow:0 4px 14px color-mix(in srgb,var(--brand) 35%,transparent)}
.btn-primary:hover{background:var(--brand-strong)}
@media (prefers-color-scheme:dark){.btn-primary:hover{background:#4fd8c6}}
.btn-secondary{background:transparent;border-color:var(--border-strong);color:var(--text)}
.btn-ghost{background:transparent;color:var(--text)}
.btn-ghost:hover,.btn-secondary:hover{background:var(--surface-2)}
.btn-danger{background:transparent;color:var(--err);border-color:var(--err-line)}
.btn-danger:hover{background:var(--err-bg)}
.btn-sm{min-height:40px;padding:0 .9rem;font-size:.9rem}
.btn-lg{min-height:52px;font-size:1.02rem}
.btn-block{width:100%}
.btn.is-disabled,.btn:disabled{opacity:.55;cursor:default;transform:none;box-shadow:none}
.icon-btn{display:inline-grid;place-items:center;width:44px;height:44px;border-radius:999px;border:0;background:transparent;color:var(--text);cursor:pointer;text-decoration:none;flex-shrink:0}
.icon-btn:hover{background:var(--surface-2)}
.icon-btn:active{transform:scale(.94)}
.link{font-weight:700;text-decoration:none;color:var(--brand-strong);min-height:44px;display:inline-flex;align-items:center}
.fab{position:fixed;right:max(18px,var(--safe-r));bottom:calc(var(--tabbar-h) + var(--safe-b) + 18px);z-index:45;display:grid;place-items:center;width:58px;height:58px;border-radius:18px;background:var(--brand);color:var(--on-brand);box-shadow:var(--shadow-lg);text-decoration:none}
.fab .ico{width:28px;height:28px}

/* ---------- Cards, lists, banners ---------- */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow)}
.sec-head{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin:4px 2px 10px}
.sec-head h2{font-size:1.1rem}
.count{color:var(--muted);font-weight:600;font-size:.9rem;margin-left:.3rem}
.list{list-style:none;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.list>li{position:relative;border-top:1px solid var(--border)}
.list>li:first-child{border-top:0}
.row{display:flex;align-items:center;gap:14px;min-height:64px;padding:10px 14px;text-decoration:none;color:var(--text)}
a.row:hover{background:var(--surface-2)}
a.row:active{background:var(--surface-2)}
.row-main{display:flex;flex-direction:column;min-width:0;flex:1}
.row-title{font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row-sub{color:var(--muted);font-size:.85rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row-meta{color:var(--muted);font-size:.8rem;white-space:nowrap}
.row-icon{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;background:var(--brand-soft);color:var(--brand-strong)}
.chev{color:var(--muted)}
.chev .ico{width:18px;height:18px}
.asst .row{padding-right:64px}
.asst .row-action{position:absolute;right:8px;top:50%;transform:translateY(-50%)}
.asst .chev{display:none}
.avatar{display:inline-grid;place-items:center;width:40px;height:40px;border-radius:12px;background:var(--brand-soft);font-size:1.3rem;flex-shrink:0;line-height:1}
.avatar.lg{width:48px;height:48px;border-radius:14px;font-size:1.55rem}
.avatar.xl{width:72px;height:72px;border-radius:22px;font-size:2.2rem;margin:0 auto 12px}
.avatar.initials{background:linear-gradient(135deg,#0f2742,#0b7a70);color:#fff;font-weight:800;font-size:1.5rem}
.banner{display:block;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.6rem 1rem;border-radius:var(--radius-sm);padding:12px 14px;font-size:.92rem;border:1px solid}
.banner-demo,.banner-warn{background:var(--warn-bg);color:var(--warn);border-color:var(--warn-line)}
.banner-error{display:flex;background:var(--err-bg);color:var(--err);border-color:var(--err-line)}
.banner-info{background:var(--info-bg);color:var(--info);border-color:transparent}
.banner.compact{border-radius:10px;padding:8px 12px;font-size:.84rem;margin:0 0 8px}
.tag{display:inline-block;border-radius:999px;padding:.12rem .6rem;font-size:.75rem;font-weight:700;background:var(--surface-2);color:var(--muted)}
.tag-ok{background:var(--ok-bg);color:var(--ok)}
.empty{text-align:center;padding:32px 20px;display:flex;flex-direction:column;align-items:center;gap:8px}
.empty h3{font-size:1.15rem}
.empty .btn{margin-top:8px}
.toast{position:fixed;left:50%;bottom:calc(var(--tabbar-h) + var(--safe-b) + 20px);transform:translate(-50%,20px);opacity:0;pointer-events:none;z-index:200;background:var(--navy);color:#fff;padding:.7rem 1.1rem;border-radius:999px;font-weight:600;font-size:.92rem;box-shadow:var(--shadow-lg);transition:opacity .2s,transform .2s;max-width:90vw;text-align:center}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ---------- Home ---------- */
.hero-card{position:relative;overflow:hidden;border-radius:22px;padding:20px;color:#fff;background:radial-gradient(500px 220px at 100% 0%,rgba(94,234,212,.35),transparent 60%),linear-gradient(135deg,#0f2742 0%,#143a5e 55%,#0b7a70 100%);box-shadow:var(--shadow-lg)}
.hc-top{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem}
.hc-eyebrow{font-size:.78rem;text-transform:uppercase;letter-spacing:.08em;opacity:.85;font-weight:700}
.hero-card h2{font-size:1.45rem;margin-top:2px}
.hc-plan{background:rgba(255,255,255,.16);color:#fff;border-radius:999px;padding:.35rem .8rem;font-size:.82rem;font-weight:700;text-decoration:none;min-height:32px;display:inline-flex;align-items:center}
.hc-credits{display:flex;align-items:baseline;gap:.5rem;margin:18px 0 10px}
.hc-num{font-size:2.6rem;font-weight:800;line-height:1;letter-spacing:-.02em}
.hc-label{opacity:.9;font-weight:600}
.progress{height:8px;border-radius:999px;background:rgba(255,255,255,.2);overflow:hidden}
.progress span{display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,#5eead4,#a7f3d0)}
.hc-foot{margin-top:10px;font-size:.88rem;opacity:.92}
.hc-foot a{color:#a7f3e7;font-weight:700;margin-left:.3rem}

/* ---------- Auth ---------- */
.auth-page main{display:flex;align-items:center;justify-content:center;min-height:calc(100dvh - var(--topbar-h) - var(--safe-t))}
.auth-wrap{width:min(420px,100%);padding:8px 0 24px}
.auth-hero{text-align:center;margin-bottom:18px}
.auth-hero h1,.auth-wrap>h1{font-size:1.75rem;margin-bottom:.35rem}
.auth-wrap.center p{margin:.6rem 0}
.auth-form{display:flex;flex-direction:column;gap:2px;padding:20px}
.auth-form .btn{margin-top:8px}
.auth-alt{text-align:center;margin-top:16px}
.auth-alt{line-height:2.6}
.auth-alt a{font-weight:700;padding:.6rem .2rem}
.pw-wrap{position:relative}
.pw-wrap input{padding-right:72px}
.pw-toggle{position:absolute;right:4px;top:50%;transform:translateY(-50%);min-height:40px;min-width:60px;border:0;background:transparent;color:var(--brand-strong);font-weight:700;cursor:pointer;border-radius:10px}

/* ---------- Forms ---------- */
.field{display:block;margin-bottom:14px;border:0}
.field>label,.field>legend{display:block;font-weight:650;font-size:.92rem;margin-bottom:6px}
.opt{font-weight:400;color:var(--muted)}
.help{font-size:.84rem;color:var(--muted);margin:-2px 0 6px}
input:not([type=radio]):not([type=checkbox]),select,textarea{display:block;width:100%;min-height:48px;padding:12px 14px;border:1.5px solid var(--border-strong);border-radius:12px;background:var(--surface);color:var(--text);font-size:16px;line-height:1.4;transition:border-color .15s,box-shadow .15s;-webkit-appearance:none;appearance:none}
select{background-image:linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);background-position:calc(100% - 20px) 50%,calc(100% - 14px) 50%;background-size:6px 6px;background-repeat:no-repeat;padding-right:40px}
textarea{resize:vertical;min-height:96px}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 4px color-mix(in srgb,var(--brand) 22%,transparent)}
::placeholder{color:color-mix(in srgb,var(--muted) 80%,transparent)}
.form-status:empty{display:none}
.form-status{border-radius:12px;padding:12px 14px;margin:6px 0 10px;font-size:.92rem}
.form-status.ok{background:var(--ok-bg);color:var(--ok)}
.form-status.err{background:var(--err-bg);color:var(--err)}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{position:relative;cursor:pointer}
.chip input{position:absolute;opacity:0;inset:0;cursor:pointer}
.chip span{display:inline-flex;align-items:center;min-height:44px;padding:0 14px;border-radius:999px;border:1.5px solid var(--border-strong);background:var(--surface);font-size:.92rem;font-weight:600}
.chip input:checked+span{background:var(--brand-soft);border-color:var(--brand);color:var(--brand-strong)}
.chip input:focus-visible+span{outline:3px solid var(--focus);outline-offset:2px}
.name-row{display:grid;grid-template-columns:76px 1fr;gap:12px}
.name-row .field{margin-bottom:6px}
.emoji-input{text-align:center;font-size:1.6rem!important;padding:6px!important}
.counter{text-align:right;margin-top:6px}

/* ---------- Sheets (bottom sheet on mobile, dialog on desktop) ---------- */
.sheet-backdrop,.sheet-page{position:fixed;inset:0;z-index:100;background:rgba(6,14,24,.5);display:flex;align-items:flex-end;justify-content:center;animation:fade .2s ease}
.sheet-backdrop[hidden]{display:none}
.sheet-page-backdrop{position:absolute;inset:0}
.sheet{position:relative;width:100%;max-width:640px;max-height:calc(var(--app-h) - var(--safe-t) - 24px);display:flex;flex-direction:column;background:var(--surface);border-radius:24px 24px 0 0;box-shadow:var(--shadow-lg);animation:slideUp .28s cubic-bezier(.2,.8,.2,1);padding-bottom:var(--safe-b)}
.sheet-handle{width:40px;height:5px;border-radius:999px;background:var(--border-strong);margin:8px auto 2px}
.sheet-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:6px 12px 10px;border-bottom:1px solid var(--border)}
.sheet-head h1,.sheet-head h2{font-size:1.05rem;font-weight:750;flex:1;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sheet-backdrop .sheet-head h2{text-align:left;padding-left:8px}
.sheet-body{overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;padding:16px 18px 20px}
.editor-page main{padding:0}
.editor-form .btn-block{margin-top:8px}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:none}}
@keyframes fade{from{opacity:0}to{opacity:1}}

/* ---------- Chat ---------- */
.chat-page main{padding:0}
.chat-shell{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--app-h);display:flex;background:var(--bg)}
.conv-pane{position:fixed;top:0;bottom:0;left:0;z-index:70;width:min(86vw,330px);background:var(--surface);padding:calc(var(--safe-t) + 10px) 12px calc(var(--safe-b) + 12px) max(12px,var(--safe-l));display:flex;flex-direction:column;gap:10px;transform:translateX(-105%);transition:transform .25s cubic-bezier(.2,.8,.2,1);box-shadow:var(--shadow-lg)}
.conv-pane.open{transform:none}
.side-backdrop{position:fixed;inset:0;z-index:65;background:rgba(6,14,24,.45);animation:fade .2s}
.side-backdrop[hidden]{display:none}
.conv-head{display:flex;align-items:center;justify-content:space-between}
.conv-head h2{font-size:1.05rem;padding-left:4px}
.conv-list{list-style:none;overflow-y:auto;flex:1;margin:0 -4px;padding:0 4px}
.conv-list li{display:flex;align-items:center;border-radius:12px;margin-bottom:2px}
.conv-list li.active,.conv-list li:hover{background:var(--brand-soft)}
.conv-list li.none{padding:12px;color:var(--muted);font-size:.9rem}
.conv{flex:1;min-width:0;min-height:52px;text-align:left;background:none;border:0;padding:8px 10px;cursor:pointer;display:flex;flex-direction:column;justify-content:center;border-radius:12px}
.conv span:first-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;font-size:.94rem}
.conv .small{color:var(--muted);font-size:.78rem}
.conv-del{width:44px;height:44px;border:0;background:none;color:var(--muted);cursor:pointer;border-radius:999px;display:grid;place-items:center}
.conv-del .ico{width:18px;height:18px}
.chat-main{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0}
.chat-head{display:flex;align-items:center;gap:4px;padding:calc(var(--safe-t) + 6px) max(6px,var(--safe-r)) 6px max(4px,var(--safe-l));background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);border-bottom:1px solid var(--border)}
.chat-head .avatar{margin:0 4px}
.chat-title{display:flex;flex-direction:column;flex:1;min-width:0;line-height:1.25}
.chat-title strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-title span{font-size:.78rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-main>.banner{margin:8px 12px 0}
.messages{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;padding:16px max(12px,var(--safe-r)) 12px max(12px,var(--safe-l));display:flex;flex-direction:column;gap:14px;scroll-behavior:smooth}
.messages:focus-visible{outline-offset:-3px}
.empty-state{margin:auto;text-align:center;max-width:520px;padding:12px}
.empty-state h2{font-size:1.3rem;margin-bottom:4px}
.starters{display:flex;flex-direction:column;gap:8px;margin-top:16px}
.starter{min-height:48px;padding:10px 16px;border-radius:14px;border:1.5px solid var(--border);background:var(--surface);cursor:pointer;text-align:left;font-size:.93rem;font-weight:550;box-shadow:var(--shadow)}
.starter:hover{border-color:var(--brand)}
.msg{display:flex;gap:8px;width:100%;max-width:820px;margin:0 auto;align-items:flex-end;flex-wrap:wrap;animation:msgIn .22s ease}
@keyframes msgIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg .bubble{padding:10px 14px;border-radius:20px;max-width:min(85%,640px);overflow-wrap:anywhere;font-size:.98rem;line-height:1.5}
.from-user{justify-content:flex-end}
.from-user .bubble{background:var(--user-bubble);color:var(--on-user);border-bottom-right-radius:6px;white-space:pre-wrap}
.from-asst .bubble{background:var(--surface);border:1px solid var(--border);border-bottom-left-radius:6px;box-shadow:var(--shadow)}
.msg-avatar{width:30px;height:30px;border-radius:10px;background:var(--brand-soft);display:grid;place-items:center;font-size:1rem;flex-shrink:0}
.msg-foot{flex-basis:100%;display:flex;align-items:center;gap:6px;padding-left:38px;font-size:.76rem;color:var(--muted);min-height:20px}
.from-user .msg-foot{justify-content:flex-end;padding-left:0}
.msg.error .msg-foot{color:var(--err)}
.copy-msg{display:inline-flex;align-items:center;gap:4px;min-height:32px;padding:0 8px;border:0;border-radius:999px;background:transparent;color:var(--muted);cursor:pointer;font-size:.76rem;font-weight:600}
.copy-msg:hover{background:var(--surface-2)}
.copy-msg .ico{width:15px;height:15px}
.md p{margin:0 0 .6rem}.md p:last-child{margin-bottom:0}
.md ul,.md ol{margin:.25rem 0 .6rem 1.25rem}
.md li{margin:.15rem 0}
.md h1,.md h2,.md h3,.md h4{font-size:1.02rem;margin:.7rem 0 .3rem}
.md a{color:var(--brand-strong)}
.md pre{background:#0b1622;color:#e6edf5;padding:10px 12px;border-radius:10px;overflow-x:auto;margin:.4rem 0;font-size:.86rem}
.md pre code{background:none;padding:0;color:inherit}
.md table{border-collapse:collapse;margin:.4rem 0;font-size:.9rem;display:block;overflow-x:auto}
.md th,.md td{border:1px solid var(--border);padding:.35rem .6rem}
.md blockquote{border-left:3px solid var(--brand);padding-left:.8rem;color:var(--muted)}
.typing{display:inline-flex;gap:5px;padding:6px 2px}
.typing i{width:8px;height:8px;border-radius:50%;background:var(--muted);opacity:.35;animation:blink 1.2s infinite}
.typing i:nth-child(2){animation-delay:.2s}.typing i:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}
#credit-alert{padding:0 12px}
#credit-alert:empty{display:none}
#credit-alert .banner{max-width:820px;margin:0 auto 8px}
.composer-wrap{padding:8px max(10px,var(--safe-r)) calc(8px + var(--safe-b)) max(10px,var(--safe-l));background:linear-gradient(to top,var(--bg) 70%,transparent)}
.composer{display:flex;align-items:flex-end;gap:8px;max-width:820px;margin:0 auto;background:var(--surface);border:1.5px solid var(--border-strong);border-radius:26px;padding:5px 5px 5px 16px;box-shadow:var(--shadow);transition:border-color .15s,box-shadow .15s}
.composer:focus-within{border-color:var(--brand);box-shadow:0 0 0 4px color-mix(in srgb,var(--brand) 20%,transparent)}
.composer textarea{border:0!important;box-shadow:none!important;background:transparent;min-height:44px;max-height:160px;padding:11px 0;resize:none;border-radius:0}
.send-btn{display:grid;place-items:center;width:44px;height:44px;border-radius:999px;border:0;background:var(--brand);color:var(--on-brand);cursor:pointer;flex-shrink:0;transition:transform .12s,opacity .15s}
.send-btn:active{transform:scale(.92)}
.composer.busy .send-btn{opacity:.5;pointer-events:none}
.composer-note{text-align:center;font-size:.74rem;color:var(--muted);margin-top:6px}

/* ---------- Usage, plans, account ---------- */
.stat-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.stat{display:flex;flex-direction:column;gap:2px;padding:14px 16px}
.stat-label{font-size:.8rem;color:var(--muted);font-weight:600}
.stat-num{font-size:1.7rem;font-weight:800;letter-spacing:-.02em;line-height:1.15}
.stat-num.sm{font-size:1.15rem;padding-top:4px}
.stat-sub{font-size:.8rem;color:var(--muted)}
.explainer summary{cursor:pointer;font-weight:700;min-height:28px;display:flex;align-items:center}
.explainer p{margin-top:8px;font-size:.92rem}
.usage-row{display:flex;gap:12px;padding:12px 14px;align-items:flex-start}
.usage-row .row-sub{white-space:normal}
.usage-amt{display:flex;flex-direction:column;align-items:flex-end;text-align:right;white-space:nowrap;font-weight:700}
.neg{color:var(--err)}.pos{color:var(--ok)}
.lead-text{font-size:1.02rem}
.plan-grid{display:grid;grid-template-columns:1fr;gap:14px}
.plan{display:flex;flex-direction:column;gap:6px;padding:20px}
.plan-top{display:flex;align-items:center;justify-content:space-between}
.plan h3{font-size:1.3rem}
.plan .price{font-size:1.2rem;font-weight:800}
.plan.featured{border:2px solid var(--brand)}
.plan.current{box-shadow:0 0 0 4px var(--brand-soft),var(--shadow)}
.checks{list-style:none;margin:6px 0 12px;flex:1}
.checks li{padding-left:26px;position:relative;margin:6px 0}
.checks li::before{content:"";position:absolute;left:2px;top:.45em;width:12px;height:7px;border-left:2.5px solid var(--brand);border-bottom:2.5px solid var(--brand);transform:rotate(-45deg)}
.ph{background:var(--warn-bg);color:var(--warn);border:1px dashed var(--warn-line);border-radius:6px;padding:0 .35em;font-size:.86em;font-weight:700}
.profile{display:flex;align-items:center;gap:16px}
.profile .avatar.xl{margin:0}
.profile h2{font-size:1.2rem}
.install-card h2,.page>.card h2{font-size:1.05rem;margin-bottom:4px}
.install-card .btn{margin:12px 0 10px}
.ios-steps{margin-top:12px;background:var(--surface-2);border-radius:12px;padding:12px 14px}
.ios-steps ol{margin:6px 0 0 1.2rem}
.ios-steps li{margin:4px 0}
.ios-steps .ico{display:inline-block;vertical-align:-5px;width:20px;height:20px;color:var(--brand-strong)}

/* Install banner */
.install-banner{position:fixed;left:max(12px,var(--safe-l));right:max(12px,var(--safe-r));bottom:calc(var(--tabbar-h) + var(--safe-b) + 12px);z-index:60;display:flex;align-items:center;gap:10px;background:var(--elev);border:1px solid var(--border);border-radius:18px;padding:10px 6px 10px 12px;box-shadow:var(--shadow-lg);animation:slideUp .3s ease}
.install-banner[hidden]{display:none}
.install-banner img{border-radius:10px}
.ib-text{display:flex;flex-direction:column;flex:1;min-width:0;line-height:1.3}
.ib-text strong{font-size:.92rem}
.ib-text .small{color:var(--muted);font-size:.8rem}
.chat-page .install-banner,.editor-page .install-banner{display:none}

.hide-desktop{}
.hide-mobile{display:none!important}

/* ---------- Tablet and desktop ---------- */
@media (min-width:640px){
  .stat-grid{grid-template-columns:repeat(4,1fr)}
  .plan-grid{grid-template-columns:repeat(auto-fit,minmax(230px,1fr))}
  .starters{flex-direction:row;flex-wrap:wrap;justify-content:center}
  .starter{border-radius:999px}
  .hero-card{padding:26px 28px}
}
@media (min-width:900px){
  .hide-mobile{display:inline-flex!important}
  .hide-desktop{display:none!important}
  .shell{display:grid;grid-template-columns:256px 1fr}
  .sidebar{display:flex;flex-direction:column;gap:20px;position:sticky;top:0;height:100dvh;padding:20px 14px;background:var(--surface);border-right:1px solid var(--border)}
  .sidebar .brand{padding:0 8px}
  .side-nav{list-style:none;display:flex;flex-direction:column;gap:2px}
  .side-nav a{display:flex;align-items:center;gap:12px;min-height:46px;padding:0 12px;border-radius:12px;text-decoration:none;color:var(--muted);font-weight:650}
  .side-nav a:hover{background:var(--surface-2);color:var(--text)}
  .side-nav a[aria-current=page]{background:var(--brand-soft);color:var(--brand-strong)}
  .side-foot{margin-top:auto;display:flex;flex-direction:column;gap:6px}
  .side-credits{display:flex;flex-direction:column;padding:12px 14px;border-radius:14px;background:var(--surface-2);text-decoration:none;color:var(--text);margin-bottom:6px}
  .side-credits strong{font-size:1.4rem}
  .side-foot .btn{justify-content:flex-start;padding:0 12px;border-radius:12px}
  .tabbar,.fab{display:none}
  .has-tabs main{padding-bottom:40px}
  .has-tabs:has(.fab) main{padding-bottom:40px}
  .topbar{border-bottom-color:var(--border)}
  .topbar-in{height:68px;padding:0 32px}
  .topbar-title{font-size:1.5rem}
  .signed-in .topbar .credit-pill{display:none}
  .signed-out .shell{display:block}
  main{padding:28px 32px 40px}
  .asst-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));background:none;border:0;box-shadow:none;gap:12px;overflow:visible}
  .asst-list>li{border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);box-shadow:var(--shadow)}
  .asst-list>li:first-child{border-top:1px solid var(--border)}
  .asst-list .row{min-height:84px;border-radius:var(--radius)}
  .toast{bottom:28px}
  .install-banner{left:auto;right:24px;bottom:24px;max-width:420px}
  /* Chat: conversations column + chat */
  .chat-page .shell{display:block}
  .chat-page .sidebar{display:none}
  .chat-shell{position:fixed;inset:0;height:100dvh}
  .conv-pane{position:static;transform:none;box-shadow:none;width:300px;border-right:1px solid var(--border);padding:16px 12px}
  .side-backdrop{display:none!important}
  .chat-head{padding:10px 16px}
  .messages{padding:24px 24px 12px}
  /* Sheets become centred dialogs */
  .sheet-backdrop,.sheet-page{align-items:center;padding:24px}
  .sheet{border-radius:24px;max-height:calc(100dvh - 48px);animation:pop .22s ease}
  .sheet-handle{display:none}
  .sheet-head{padding:14px 16px}
  @keyframes pop{from{opacity:0;transform:scale(.97)}to{opacity:1;transform:none}}
}
@media (min-width:1200px){.asst-list{grid-template-columns:repeat(3,minmax(0,1fr))}.page{max-width:1040px}}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
  html,.messages{scroll-behavior:auto}
}
/* High contrast / forced colors */
@media (forced-colors:active){.btn,.chip span,.composer,.card,.list{border:1px solid CanvasText}}
