* { box-sizing:border-box; margin:0; padding:0; font-family:"Segoe UI",Arial,sans-serif; -webkit-tap-highlight-color:transparent; }
html,body { height:100%; }
body { background:#e8f4fb; display:flex; flex-direction:column; overflow:hidden; }
#topbar { background:#7ec3ea; color:#08344d; padding:12px 14px 10px; position:relative; padding-top:calc(10px + env(safe-area-inset-top)); }
#topbar h1 { font-size:19px; font-weight:700; display:inline-block; }
#menuBtn { position:absolute; left:10px; top:calc(8px + env(safe-area-inset-top)); background:none; border:none; font-size:24px; color:#08344d; padding:4px 8px; }
#menu { position:absolute; left:8px; top:calc(44px + env(safe-area-inset-top)); background:#fff; border-radius:12px; box-shadow:0 4px 14px rgba(0,0,0,.18); padding:6px; z-index:30; min-width:150px; }
#menu button { display:block; width:100%; text-align:right; background:none; border:none; padding:10px 12px; font-size:15px; color:#08344d; border-radius:8px; }
#menu button:active { background:#e8f4fb; }
#ver { font-size:11px; color:#8aa; padding:6px 12px 4px; }
.hidden { display:none !important; }
#chips { display:flex; gap:6px; margin-top:8px; flex-wrap:wrap; }
.chip { background:#ffffffcc; border-radius:20px; padding:3px 10px; font-size:12px; color:#0b527a; display:flex; align-items:center; gap:5px; }
.dot { width:8px; height:8px; border-radius:50%; background:#9fb3bf; }
.dot.ok { background:#2ea44f; } .dot.off { background:#c0392b; }
#chat { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:10px; }
.msg-user { align-self:flex-start; background:#a5dcf5; border-radius:16px 16px 16px 4px; padding:9px 13px; max-width:82%; font-size:15px; color:#08344d; box-shadow:0 1px 2px rgba(0,0,0,.08); white-space:pre-wrap; }
.msg-ai { align-self:stretch; background:#fff; border-radius:16px; padding:10px 13px; font-size:15px; color:#222; box-shadow:0 1px 3px rgba(0,0,0,.10); border-top:3px solid #f4a83b; }
.msg-ai .tag { font-size:12px; color:#b06d0e; font-weight:700; margin-bottom:5px; }
.msg-ai p { line-height:1.5; white-space:pre-wrap; }
.msg-ai.err { border-top-color:#c0392b; color:#7a2015; font-size:14px; }
.srcbtn { align-self:flex-start; background:#fff8ec; border:1px solid #f0d9ae; border-radius:12px; padding:8px 12px; font-size:13px; color:#7a5a1e; cursor:pointer; }
.srcbtn b { color:#b06d0e; }
.instinct-btn { align-self:flex-start; background:#7ec3ea; border:none; border-radius:22px; padding:10px 18px; font-size:14.5px; font-weight:700; color:#08344d; box-shadow:0 1px 3px rgba(0,0,0,.12); display:flex; align-items:center; gap:8px; cursor:pointer; text-decoration:none; }
.instinct-btn .wa { width:20px; height:20px; border-radius:50%; background:#25D366; color:#fff; display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; }
.thinking { align-self:stretch; background:#fff; border-radius:16px; padding:10px 13px; box-shadow:0 1px 3px rgba(0,0,0,.10); font-size:13.5px; color:#5b87a0; }
.thinking .dots { font-size:18px; letter-spacing:2px; }
.eng-line { display:flex; gap:8px; margin-top:6px; flex-wrap:wrap; }
.eng-st { font-size:12px; background:#eef7fc; border-radius:10px; padding:2px 8px; color:#0b527a; }
#quota { text-align:center; font-size:11.5px; color:#5b87a0; padding:2px 8px; }
#inputbar { background:#fff; padding:10px; padding-bottom:calc(10px + env(safe-area-inset-bottom)); display:flex; gap:8px; border-top:1px solid #cfe7f3; }
#q { flex:1; background:#eef7fc; border:none; outline:none; border-radius:22px; padding:11px 14px; font-size:15px; color:#08344d; }
#send { width:46px; height:46px; border:none; border-radius:50%; background:#f4a83b; font-size:20px; color:#fff; cursor:pointer; }
#send:disabled { background:#c9d8e2; }
#compare, #history { position:fixed; inset:0; background:#e8f4fb; z-index:50; display:flex; flex-direction:column; }
.overlaybar { background:#7ec3ea; color:#08344d; padding:12px 14px; padding-top:calc(10px + env(safe-area-inset-top)); display:flex; align-items:center; gap:12px; }
.overlaybar h2 { font-size:17px; }
.backBtn { background:none; border:none; font-size:22px; color:#08344d; padding:2px 8px; }
.overlayBody { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:10px; }

.cmp-q { align-self:flex-start; background:#a5dcf5; border-radius:14px; padding:8px 12px; font-size:13.5px; color:#08344d; max-width:92%; white-space:pre-wrap; }
.cmp-ans { background:#fff; border-radius:14px; padding:10px 12px; box-shadow:0 1px 3px rgba(0,0,0,.10); font-size:14px; color:#222; line-height:1.5; white-space:pre-wrap; }
.cmp-ans .who { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:700; margin-bottom:4px; }
.badge { border-radius:10px; padding:1px 8px; color:#fff; font-size:11px; }
.b-gemini { background:#4285f4; } .b-groq { background:#e8590c; } .b-openrouter { background:#5f3dc4; } .b-cloudflare { background:#c2410c; }
.cmp-ans .time { font-weight:400; color:#8aa; margin-inline-start:auto; font-size:11px; }
.cmp-note { background:#fff8ec; border:1.5px solid #f4a83b; border-radius:14px; padding:10px 12px; font-size:13px; color:#7a5a1e; }
.cmp-ans.failed { opacity:.75; font-size:13px; color:#7a2015; }

#mic { width:46px; height:46px; border:none; border-radius:50%; background:#7ec3ea; font-size:19px; cursor:pointer; flex:none; }
#mic.listening { background:#e05252; animation:pulse 1.1s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(224,82,82,.45);} 70%{box-shadow:0 0 0 12px rgba(224,82,82,0);} 100%{box-shadow:0 0 0 0 rgba(224,82,82,0);} }
.hist-item { background:#fff; border-radius:14px; padding:11px 13px; box-shadow:0 1px 3px rgba(0,0,0,.10); display:flex; align-items:center; gap:10px; }
.hist-item .t { flex:1; text-align:right; }
.hist-item .title { font-size:14.5px; color:#08344d; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:240px; display:block; }
.hist-item .when { font-size:11.5px; color:#8aa; }
.hist-item .del { background:none; border:none; font-size:17px; color:#c0392b; padding:6px; }
.hist-empty { text-align:center; color:#5b87a0; font-size:14px; margin-top:30px; }

#imgBtn { width:46px; height:46px; border:none; border-radius:50%; background:#7ec3ea; font-size:19px; cursor:pointer; flex:none; }
#imgBtn:disabled { background:#c9d8e2; }
.msg-note { align-self:center; background:#fff8ec; border:1.5px solid #f4a83b; border-radius:14px; padding:8px 12px; font-size:13px; color:#7a5a1e; max-width:90%; }
.msg-image { align-self:flex-start; background:#fff; border-radius:14px; padding:8px; box-shadow:0 1px 3px rgba(0,0,0,.10); max-width:92%; display:flex; flex-direction:column; gap:6px; }
.msg-image img { width:100%; border-radius:10px; display:block; }
.msg-image a { font-size:13px; color:#1b6c9a; text-align:center; }
