:root{--bg:#f7f7f5;--ink:#0b0b0b;--muted:#6b6b70;--line:rgba(0,0,0,.1);--glass:rgba(255,255,255,.72);--glass-edge:rgba(255,255,255,.85);--shadow:0 24px 80px rgba(0,0,0,.13);--chip:rgba(0,0,0,.06);
  --ubub:#0b0b0b;--utxt:#fff;--abub:rgba(255,255,255,.86);--input:rgba(255,255,255,.85);--overlay:linear-gradient(120deg,rgba(247,247,245,.95),rgba(247,247,245,.86));--danger:#a00;
  --gut:max(16px,env(safe-area-inset-left));font-family:Inter,system-ui,"Segoe UI",Roboto,Arial,sans-serif;color-scheme:light}
:root[data-theme=dark]{--bg:#0b0b0e;--ink:#f2f2f5;--muted:#9c9ca6;--line:rgba(255,255,255,.14);--glass:rgba(28,28,34,.72);--glass-edge:rgba(255,255,255,.12);--shadow:0 24px 80px rgba(0,0,0,.5);--chip:rgba(255,255,255,.09);
  --ubub:#f2f2f5;--utxt:#0b0b0e;--abub:rgba(36,36,44,.86);--input:rgba(30,30,36,.9);--overlay:linear-gradient(120deg,rgba(8,8,12,.95),rgba(8,8,12,.88));--danger:#ff8a80;color-scheme:dark}
*{box-sizing:border-box}[hidden],.hidden{display:none!important}
html,body{margin:0;height:100%;color:var(--ink);background:var(--bg);-webkit-text-size-adjust:100%}
body{overflow:hidden;background:var(--bg) url('../img/fundo.png') center/cover fixed no-repeat;overscroll-behavior:none}
.ambient{position:fixed;inset:0;background:var(--overlay);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:0}
button,input,textarea,select{font:inherit;color:inherit}
.glass{background:var(--glass);border:1px solid var(--glass-edge);box-shadow:var(--shadow);backdrop-filter:blur(26px);-webkit-backdrop-filter:blur(26px)}
.app{position:relative;z-index:1;display:flex;height:100dvh;height:100svh}
.app{height:100dvh}

/* ---------- barra lateral (PC) / gaveta (celular) ---------- */
.sidebar{width:260px;flex:none;height:100%;padding:22px 16px;background:rgba(5,5,5,.94);color:#fff;display:flex;flex-direction:column;z-index:30;box-shadow:12px 0 45px rgba(0,0,0,.15)}
.brand{display:flex;align-items:center;gap:11px;padding:6px 8px 20px}.brand img{width:42px;height:42px;border-radius:50%;background:#fff}
.brand strong{display:block;letter-spacing:1.5px;font-size:17px}.brand small{display:block;color:#aaa;font-size:9px;letter-spacing:2px}
.new-chat{border:0;background:#fff;color:#000;border-radius:16px;padding:12px;font-weight:700;cursor:pointer;margin-bottom:12px}
.nav{width:100%;border:0;background:transparent;color:#d8d8d8;text-align:left;border-radius:13px;padding:11px 13px;margin:2px 0;cursor:pointer}
.nav:hover,.nav.active{background:#1c1c1c;color:#fff}.nav .ic{display:inline-block;width:24px}
.history-title{font-size:11px;color:#777;margin:20px 10px 7px;letter-spacing:1px}
.search{border:1px solid #292929;background:#111;color:#fff;border-radius:12px;padding:9px 10px;outline:none;width:100%}
.chat-list{flex:1;overflow:auto;margin-top:8px}
.chat-item{display:flex;align-items:center;gap:6px;padding:9px 10px;border-radius:11px;color:#aaa;font-size:13px;cursor:pointer}
.chat-item:hover,.chat-item.on{background:#171717;color:#fff}.chat-item .t{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-item .x{border:0;background:transparent;color:#777;cursor:pointer;padding:2px 6px;border-radius:8px}.chat-item .x:hover{color:#f66}
.user-mini{display:flex;gap:9px;align-items:center;color:#aaa;font-size:11px;padding:12px 5px}.user-mini img{width:28px;height:28px;border-radius:50%;background:#fff}
.scrim{display:none}

/* ---------- área principal ---------- */
.main{flex:1;min-width:0;height:100%;padding:22px;display:flex;flex-direction:column}
.topbar{min-height:74px;border-radius:24px;padding:12px 18px;display:flex;align-items:center;justify-content:space-between;gap:10px}
.tb-left{display:flex;align-items:center;gap:12px;min-width:0}
.eyebrow{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:1.7px}
.topbar h1{font-size:22px;margin:2px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top-actions{display:flex;gap:8px;align-items:center}
.ghost,.round{border:1px solid var(--line);background:var(--chip);border-radius:13px;padding:9px 13px;cursor:pointer}
.ghost:hover,.round:hover{filter:brightness(.95)}
.page{display:none;flex:1;min-height:0}.active-page{display:flex;flex-direction:column}
.messages{flex:1;overflow:auto;padding:24px 8px 14px;-webkit-overflow-scrolling:touch}
.msg{display:flex;gap:11px;max-width:900px;margin:0 auto 16px;animation:rise .25s ease}
.avatar{width:32px;height:32px;border-radius:50%;background:#fff;object-fit:cover;flex:none;box-shadow:0 3px 12px rgba(0,0,0,.12)}
.bwrap{display:flex;flex-direction:column;gap:6px;min-width:0;max-width:calc(100% - 44px)}
.bubble{padding:12px 16px;border-radius:20px;line-height:1.55;white-space:pre-wrap;overflow-wrap:anywhere;min-width:0}
.msg.user{justify-content:flex-end}.msg.user .avatar{display:none}
.msg.user .bubble{background:var(--ubub);color:var(--utxt);border-bottom-right-radius:6px;max-width:85%}
.msg.assistant .bubble{background:var(--abub);border:1px solid var(--glass-edge);border-bottom-left-radius:6px}
.msg.assistant>.bubble{max-width:calc(100% - 44px)}
.bubble.err{border-color:#e3a5a5!important;color:var(--danger)}
.bubble pre{background:rgba(0,0,0,.08);padding:10px 12px;border-radius:12px;overflow:auto;margin:8px 0;white-space:pre}
.bubble code{font:12.5px/1.5 Consolas,"SF Mono",monospace;background:rgba(0,0,0,.08);padding:1px 5px;border-radius:6px}.bubble pre code{background:none;padding:0}
.bubble.live:not(:has(.dots))::after{content:"▍";opacity:.6;animation:bl 1s steps(2) infinite}
.srcs{margin-top:8px;display:flex;flex-wrap:wrap;gap:6px}.src{padding:4px 10px;border-radius:999px;background:var(--chip);color:var(--ink);text-decoration:none;font-size:12px}
.acts{display:flex;gap:6px;flex-wrap:wrap}.act{border:0;background:var(--chip);border-radius:999px;padding:5px 11px;font-size:12px;cursor:pointer;color:var(--muted)}.act:hover{color:var(--ink)}
.status-bar{display:flex;align-items:center;gap:10px;max-width:900px;margin:0 auto 6px;width:100%;padding:0 12px 8px 54px;color:var(--muted);font-size:12px}
.dots{display:inline-flex;gap:4px;vertical-align:middle}.dots i{width:6px;height:6px;border-radius:50%;background:var(--ink);opacity:.25;animation:dot 1.1s infinite}.dots i:nth-child(2){animation-delay:.18s}.dots i:nth-child(3){animation-delay:.36s}
.composer{display:flex;align-items:flex-end;gap:9px;padding:10px;border-radius:22px;max-width:900px;width:100%;margin:0 auto}
.composer textarea{flex:1;border:0;outline:0;resize:none;background:transparent;min-height:42px;max-height:130px;padding:10px;font-size:15px}
.round{width:42px;height:42px;padding:0;font-size:16px;flex:none}
.round.rec{background:#c62828;color:#fff;border-color:#c62828}
.send{border:0;background:var(--ubub);color:var(--utxt);border-radius:14px;padding:12px 18px;cursor:pointer;font-weight:700}.send.stop{background:#c62828;color:#fff}
.as-link{text-decoration:none;display:inline-block}
.hint{font-size:11px;color:var(--muted);text-align:center;padding:8px 12px;max-width:900px;margin:0 auto}
.attach{display:flex;align-items:center;gap:8px;margin:0 auto 8px;padding:8px 12px;border-radius:14px;background:var(--glass);border:1px solid var(--line);font-size:12px;max-width:900px;width:100%}
.attach img{width:36px;height:36px;object-fit:cover;border-radius:8px}.attach span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.page:not(#chatPage).active-page{overflow-y:auto;overflow-x:hidden}
.panel{margin:0 auto;width:min(900px,100%);padding:28px;border-radius:28px;flex:none}.panel h2{margin-top:0;font-size:28px}
.cmp{width:100%;border-collapse:collapse;margin:14px 0;font-size:14px}.cmp th,.cmp td{padding:9px 8px;border-bottom:1px solid var(--line);text-align:left}.cmp td:not(:first-child),.cmp th:not(:first-child){text-align:center;white-space:nowrap}
.row-actions,.actions-row{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px;align-items:center}
.muted{color:var(--muted);display:block;margin-top:12px;font-size:12px}
.setting-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.setting{display:flex;flex-direction:column;gap:6px}.setting-full{grid-column:1/-1}
.setting label{font-size:11px;color:var(--muted)}.setting small{color:var(--muted);font-size:11px;line-height:1.4}
.setting input,.setting select,.modal-card input,.modal-card select{border:1px solid var(--line);background:var(--input);border-radius:12px;padding:12px;outline:none;width:100%;font-size:16px}
.only-mobile-x-block{display:none}
.diag{margin-top:12px;padding:12px;border-radius:12px;background:var(--chip);font:12px/1.5 Consolas,monospace;white-space:pre-wrap}
.toast{position:fixed;right:24px;bottom:24px;z-index:60;background:#0b0b0b;color:#fff;padding:12px 16px;border-radius:14px;opacity:0;transform:translateY(8px);transition:.25s;pointer-events:none;max-width:min(380px,calc(100vw - 32px))}.toast.show{opacity:1;transform:none}
.modal{position:fixed;inset:0;z-index:50;display:grid;place-items:center;background:rgba(0,0,0,.35);backdrop-filter:blur(8px);padding:16px}
.modal-card{width:min(460px,100%);padding:26px;border-radius:26px;text-align:center;max-height:100%;overflow:auto}
.modal-card input,.modal-card select{display:block;margin:8px 0}.login-logo{width:68px;height:68px;border-radius:50%;background:#fff}
.small-link{font-size:12px;color:var(--muted)}.err-text{display:block;color:var(--danger);margin-top:8px}
.modal-actions{display:flex;justify-content:flex-end;margin-top:16px}
.tabbar{display:none}
@keyframes rise{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes dot{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}
@keyframes bl{50%{opacity:0}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

/* ---------- PC x celular: a interface muda conforme a plataforma ---------- */
html.desktop .only-mobile,html.desktop .only-mobile-x{display:none!important}
html.mobile .only-mobile-x-block{display:flex}
@media(max-width:820px){.setting-grid{grid-template-columns:1fr}}
html.mobile body{background-attachment:scroll}
html.mobile .sidebar{position:fixed;left:0;top:0;bottom:0;width:min(84vw,310px);transform:translateX(-102%);transition:transform .25s ease;padding-top:max(22px,env(safe-area-inset-top))}
html.mobile .sidebar.open{transform:none}
html.mobile .scrim.on{display:block;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:25}
html.mobile .main{padding:max(10px,env(safe-area-inset-top)) 10px calc(64px + max(0px,env(safe-area-inset-bottom)));}
html.mobile .topbar{min-height:58px;border-radius:20px;padding:8px 12px}
html.mobile .topbar h1{font-size:18px;margin:0}html.mobile .eyebrow{display:none}
html.mobile .messages{padding:14px 2px 10px}
html.mobile .msg{gap:8px;margin-bottom:12px}html.mobile .avatar{width:28px;height:28px}
html.mobile .bubble{font-size:15.5px;padding:11px 14px}
html.mobile .composer{padding:8px;border-radius:24px}
html.mobile .hint{display:none}
html.mobile .panel{padding:20px;border-radius:24px}html.mobile .panel h2{font-size:23px}
html.mobile .tabbar{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:20;background:var(--glass);backdrop-filter:blur(22px);-webkit-backdrop-filter:blur(22px);border-top:1px solid var(--line);padding:6px 6px max(6px,env(safe-area-inset-bottom))}
html.mobile .tabbar button{flex:1;border:0;background:transparent;display:flex;flex-direction:column;align-items:center;gap:2px;font-size:11px;color:var(--muted);padding:6px 0;border-radius:12px;cursor:pointer}
html.mobile .tabbar button span{font-size:19px}html.mobile .tabbar button.active{color:var(--ink);font-weight:700}
html.mobile .toast{left:16px;right:16px;bottom:calc(76px + env(safe-area-inset-bottom));max-width:none;text-align:center}
html.mobile .msg.hello .bubble{max-width:100%}
