/* ───────── Chat screen ───────── */
.view-chat { padding-bottom: calc(168px + var(--safe-b)); }
.chat-head { position: sticky; top: calc(var(--safe-t) + 54px); z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px calc(-1 * var(--gutter)) 14px; padding: 10px var(--gutter); background: rgba(9, 9, 18, 0.94); box-shadow: 0 1px 0 var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.chat-head::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 18px; pointer-events: none; background: linear-gradient(to bottom, rgba(9, 9, 18, 0.7), rgba(9, 9, 18, 0)); }
/* the global header above blends into the chat head */
body[data-view='chat'] .top { background: rgba(9, 9, 18, 0.94); }
.chat-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-ava { width: 42px; height: 42px; }
.chat-title { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -0.03em; }
.chat-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #6ee7b7; box-shadow: 0 0 10px #6ee7b7; animation: twinkle 2.4s ease-in-out infinite; }
.chat-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.pill-toggle { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--tx2); background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); transition: background 0.3s, color 0.3s, box-shadow 0.3s; }
.pt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tx3); transition: background 0.3s, box-shadow 0.3s; }
.pill-toggle[aria-pressed='true'] { color: #150e2e; background: var(--grad); box-shadow: 0 8px 22px -10px rgba(180, 140, 255, 0.9); }
.pill-toggle[aria-pressed='true'] .pt-dot { background: #150e2e; }
.round-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); transition: transform 0.25s var(--spring); }
.round-btn:active { transform: scale(0.9); }
.round-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--tx); stroke-width: 2; stroke-linecap: round; }

/* empty state */
.chat-empty { text-align: center; padding: 18px 6px 4px; }
.chat-empty[hidden] { display: none; }
.ce-orb { position: relative; width: 76px; height: 76px; margin: 6px auto 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.35), transparent 45%), var(--grad); box-shadow: 0 18px 50px -14px rgba(180, 140, 255, 0.95), inset 0 0 0 1px rgba(255, 255, 255, 0.25); animation: orbFloat 6s ease-in-out infinite; }
.ce-orb span { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 14px #fff; top: 50%; left: 50%; margin: -5px; animation: orbit 3.6s linear infinite; }
.ce-orb span + span { animation-delay: -1.8s; background: #ffe0c8; box-shadow: 0 0 14px #ffc28e; }
@keyframes orbit { from { transform: rotate(0deg) translateX(52px) scale(0.8); } 50% { transform: rotate(180deg) translateX(52px) scale(1.15); } to { transform: rotate(360deg) translateX(52px) scale(0.8); } }
@keyframes orbFloat { 50% { transform: translateY(-6px); } }
.chat-empty h3 { margin: 0 0 6px; font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.chat-empty p { margin: 0 auto 16px; max-width: 30ch; color: var(--tx2); font-size: 14.5px; line-height: 1.45; }
.ce-caps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 18px; text-align: left; }
.ce-caps > span { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 14px; font-size: 12.5px; font-weight: 600; color: var(--tx2); background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); }
.ce-caps .ic { width: 24px; height: 24px; flex: none; }
.ce-sugs { display: grid; gap: 8px; }
.sug { width: 100%; padding: 12px 14px; border-radius: 16px; text-align: left; font-size: 14px; font-weight: 500; color: var(--tx); background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)); box-shadow: inset 0 0 0 1px var(--line); transition: transform 0.25s var(--spring), background 0.2s; }
.sug::after { content: '↗'; float: right; color: var(--tx3); margin-left: 8px; }
.sug:active { transform: scale(0.98); background: var(--s2); }

/* messages */
.chat-list { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 8px; animation: msgIn 0.45s var(--ease) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { max-width: 84%; padding: 10px 14px; border-radius: 20px 20px 6px 20px; color: #170f30; font-weight: 500; background: linear-gradient(120deg, #a9b8ff, #c9b0ff 45%, #ffb6d3); box-shadow: 0 10px 28px -16px rgba(180, 140, 255, 0.9); word-wrap: break-word; overflow-wrap: anywhere; }
.me-text { font-size: 15px; line-height: 1.45; }
.msg-img-sm { display: block; max-width: 220px; max-height: 220px; border-radius: 14px; margin: 2px 0 6px; }
.msg-file { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0 0 6px; border-radius: 12px; background: rgba(20, 12, 46, 0.12); font-size: 13px; font-weight: 600; }
.msg-file .ic { width: 22px; height: 22px; flex: none; }
.msg-file small { margin-left: auto; opacity: 0.7; font-weight: 500; }
.msg.ai { align-items: flex-start; }
.msg-ava { flex: none; width: 28px; height: 28px; margin-top: 2px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.4), transparent 45%), var(--grad); box-shadow: 0 6px 16px -6px rgba(180, 140, 255, 0.9); }
.msg-col { min-width: 0; max-width: calc(100% - 36px); }
.msg.ai .bubble { padding: 11px 14px; border-radius: 6px 20px 20px 20px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035)); box-shadow: inset 0 0 0 1px var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); overflow-wrap: anywhere; }
.msg.hint .bubble { width: 100%; padding: 11px 14px; border-radius: 16px; font-size: 13.5px; color: var(--tx2); background: rgba(180, 140, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(190, 170, 255, 0.28); }
.msg.hint .bubble p { margin: 0; }
.msg-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 2px 0; }
.msg-foot:empty { display: none; }
.msg-act { height: 28px; padding: 0 10px; border-radius: 9px; font-size: 12px; font-weight: 700; color: var(--tx2); background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); }
.msg-act.strong { color: #150e2e; background: var(--grad); box-shadow: none; }
.srcs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; font-size: 11.5px; color: var(--tx3); }
.src { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 8px; border-radius: 8px; color: var(--tx2); text-decoration: none; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); }
.err { margin: 0; color: #ffb3c1; }
.typing { display: inline-flex; gap: 4px; vertical-align: middle; margin-right: 8px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #c9b5ff; animation: dot 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.typing-label { font-size: 13.5px; color: var(--tx2); }
.caret { display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--grad); animation: blink 0.9s steps(1) infinite; }

/* markdown inside answers */
.md { font-size: 15px; line-height: 1.55; color: var(--tx); }
.md p { margin: 0 0 0.6em; }
.md > :last-child { margin-bottom: 0; }
.md h3, .md h4 { margin: 0.8em 0 0.4em; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.md h3:first-child, .md h4:first-child { margin-top: 0; }
.md ul, .md ol { margin: 0 0 0.6em; padding-left: 1.25em; }
.md li { margin: 0.2em 0; }
.md li::marker { color: #b9a6ff; }
.md b { font-weight: 700; color: #fff; }
.md a { color: #c9b5ff; text-decoration: underline; text-decoration-color: rgba(201, 181, 255, 0.4); text-underline-offset: 2px; }
.md code { padding: 1px 5px; border-radius: 6px; font: 13px/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: rgba(201, 181, 255, 0.12); color: #e3d8ff; }
.md pre { position: relative; margin: 0.4em 0 0.7em; padding: 12px; border-radius: 12px; overflow-x: auto; background: rgba(0, 0, 0, 0.35); box-shadow: inset 0 0 0 1px var(--line); }
.md pre code { padding: 0; background: none; white-space: pre; font-size: 12.5px; }
.copy-code { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px; font-size: 13px; color: var(--tx2); background: var(--s2); }
.md blockquote { margin: 0.4em 0 0.7em; padding: 6px 12px; border-left: 3px solid #b48cff; border-radius: 0 10px 10px 0; color: var(--tx2); background: rgba(180, 140, 255, 0.07); }
.md hr { border: 0; height: 1px; margin: 0.8em 0; background: var(--line2); }
.tbl { margin: 0.4em 0 0.7em; overflow-x: auto; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); }
.tbl table { border-collapse: collapse; min-width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { font-weight: 700; background: var(--s1); }
.tbl tr:last-child td { border-bottom: 0; }

/* images drawn in the chat */
.msg.is-art .bubble { padding: 6px; }
.art { display: block; width: 100%; border-radius: 15px; overflow: hidden; }
.art img { display: block; width: 100%; height: auto; animation: reveal 1.1s var(--ease); }
.art-cap { padding: 8px 6px 2px; font-size: 12.5px; color: var(--tx3); }
.art-wait { display: grid; justify-items: center; gap: 8px; padding: 34px 16px; border-radius: 15px; text-align: center; background: linear-gradient(110deg, rgba(255, 255, 255, 0.03) 30%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.03) 70%) 0 0 / 220% 100%; animation: shimmer 1.6s linear infinite; }
.art-wait > span:nth-child(2) { font-weight: 700; }
.art-wait small { max-width: 34ch; color: var(--tx3); font-size: 12px; line-height: 1.4; }
.aw-orb { width: 44px; height: 44px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 30px rgba(180, 140, 255, 0.8); animation: orbFloat 2s ease-in-out infinite; }

/* composer */
.chat-bar { position: fixed; z-index: 35; left: 0; right: 0; bottom: calc(78px + var(--safe-b)); max-width: 560px; margin: 0 auto; padding: 0 var(--gutter); transition: transform 0.4s var(--ease), opacity 0.3s, bottom 0.25s var(--ease); }
.chat-bar.is-hidden { transform: translateY(40px); opacity: 0; pointer-events: none; }
.cb-row { display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 24px; background: rgba(20, 20, 38, 0.86); box-shadow: inset 0 0 0 1px var(--line2), 0 20px 50px -24px rgba(0, 0, 0, 0.9); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4); }
#chatInput { flex: 1; min-width: 0; height: 22px; max-height: 140px; margin: 9px 4px; resize: none; border: 0; outline: 0; background: transparent; color: var(--tx); font: 500 16px/22px var(--body); }
#chatInput::placeholder { color: var(--tx3); }
.cb-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--tx2); transition: transform 0.25s var(--spring), background 0.2s, color 0.2s; }
.cb-btn:active { transform: scale(0.88); background: var(--s2); }
.cb-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cb-mic.pulse { color: #fff; background: rgba(180, 140, 255, 0.25); animation: micPulse 1.2s ease-in-out infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 8px rgba(180, 140, 255, 0.18); } }
.cb-send { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--grad); box-shadow: 0 8px 22px -8px rgba(180, 140, 255, 1); transition: transform 0.25s var(--spring); animation: popIn 0.3s var(--spring); }
.cb-send:active { transform: scale(0.9); }
.cb-send svg { width: 20px; height: 20px; fill: none; stroke: #150e2e; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cb-file { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 8px 10px; border-radius: 16px; background: rgba(20, 20, 38, 0.9); box-shadow: inset 0 0 0 1px var(--line2); backdrop-filter: blur(16px); animation: msgIn 0.3s var(--ease); }
.cb-file[hidden] { display: none; }
.cb-file-ic { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; overflow: hidden; background: var(--s2); }
.cb-file-ic img { width: 100%; height: 100%; object-fit: cover; }
.cb-file-ic .ic { width: 26px; height: 26px; }
.cb-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.cb-file-meta { flex: none; font-size: 12px; color: var(--tx3); }
.cb-file-x { flex: none; width: 28px; height: 28px; border-radius: 50%; font-size: 12px; background: var(--s2); }
.cb-rec { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 10px 14px; border-radius: 16px; font-weight: 700; font-variant-numeric: tabular-nums; background: rgba(40, 14, 34, 0.9); box-shadow: inset 0 0 0 1px rgba(255, 120, 160, 0.35); backdrop-filter: blur(16px); }
.cb-rec[hidden] { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff5a7a; box-shadow: 0 0 12px #ff5a7a; animation: twinkle 1s ease-in-out infinite; }
.rec-wave { display: flex; align-items: center; gap: 3px; height: 18px; }
.rec-wave i { width: 3px; height: 100%; border-radius: 2px; background: linear-gradient(#ffb3c8, #b48cff); animation: wave 0.9s ease-in-out infinite; }
.rec-wave i:nth-child(2) { animation-delay: 0.1s; }
.rec-wave i:nth-child(3) { animation-delay: 0.2s; }
.rec-wave i:nth-child(4) { animation-delay: 0.3s; }
.rec-wave i:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.cb-rec-cancel { margin-left: auto; height: 28px; padding: 0 10px; border-radius: 9px; font-size: 12px; color: var(--tx2); background: var(--s2); }
.chat-bar.is-rec .cb-mic { color: #fff; background: #ff5a7a; box-shadow: 0 0 0 6px rgba(255, 90, 122, 0.2); }
/* keyboard open in the chat: the tab bar steps aside, the composer drops to the bottom */
body.kb-open[data-view='chat'] .tabbar { transform: translate(-50%, 120%); opacity: 0; pointer-events: none; }
body.kb-open[data-view='chat'] .chat-bar { bottom: calc(8px + var(--safe-b)); }
.tabbar { transition: transform 0.35s var(--ease), opacity 0.3s; }

/* ───────── Tools screen ───────── */
.feature-card { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; border-radius: 24px; text-align: left; overflow: hidden; background: linear-gradient(135deg, rgba(142, 162, 255, 0.2), rgba(180, 140, 255, 0.16) 45%, rgba(255, 141, 187, 0.14)); box-shadow: inset 0 0 0 1px rgba(200, 185, 255, 0.35), 0 20px 50px -26px rgba(180, 140, 255, 0.9); transition: transform 0.3s var(--spring); }
.feature-card:active { transform: scale(0.98); }
.fc-glow { position: absolute; width: 180px; height: 180px; right: -60px; top: -80px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 141, 187, 0.45), transparent 65%); filter: blur(10px); }
.fc-ic { width: 56px; height: 56px; flex: none; }
.fc-body { position: relative; display: grid; gap: 3px; flex: 1; min-width: 0; }
.fc-title { font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.fc-sub { font-size: 13px; color: var(--tx2); line-height: 1.35; }
.fc-go { position: relative; display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--grad); }
.fc-go svg { width: 18px; height: 18px; fill: none; stroke: #150e2e; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tool-grid-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tool-sm { min-height: 132px; padding: 12px; gap: 6px; }
.tool-sm .tool-ic { width: 40px; height: 40px; margin: -2px 0 4px -2px; }
.tool-sm .tool-name { font-size: 13.5px; line-height: 1.2; }
.tool-sm .tool-sub { font-size: 11.5px; }
.tool-sm .tool-cost { top: 12px; right: 10px; }
@media (max-width: 360px) { .tool-grid-3 { grid-template-columns: 1fr 1fr; } }

/* inline brand icons inside buttons and pills (instead of system emoji) */
.ib { display: inline-grid; place-items: center; width: 22px; height: 22px; vertical-align: -5px; }
.ib .ic { width: 22px; height: 22px; }
.result-actions .btn-secondary .ic { width: 26px; height: 26px; }
.meta-pill { display: inline-flex; align-items: center; gap: 6px; }
.meta-pill .ic { width: 18px; height: 18px; }
.chip .ic { width: 20px; height: 20px; margin-left: -4px; }

/* long status texts (and other languages) wrap instead of running under the buttons */
.chat-id { flex: 1; }
.chat-id > div { min-width: 0; flex: 1; }
.chat-status { align-items: flex-start; white-space: normal; line-height: 1.25; }
.chat-status i { margin-top: 3px; }
.chat-status span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.msg-act[data-tts].is-busy { opacity: 0.55; }
.msg-act[data-tts].is-on { color: var(--tx); box-shadow: inset 0 0 0 1px rgba(190, 170, 255, 0.6); }
.msg-act .ib { width: 16px; height: 16px; vertical-align: -3px; }
