/* EsoTech AI — ChatGPT-style chat (public homepage + signed-in chat). */
:root {
  --bg: #ffffff; --side: #f9f9f9; --ink: #0d0d0d; --ink-2: #3c3c3c; --muted: #6e6e6e; --faint: #8f8f8f;
  --line: #e5e5e5; --line-2: #ececec; --bubble: #f2f2f2; --hover: #ececec; --hover-2: #f4f4f4; --chip: #ffffff;
  --send: #111111; --send-ink: #ffffff; --voice: #0F766E; --accent: #0F766E; --accent-soft: #E6F4F2; --teal: #0F766E;
  --warn-bg: #fff8eb; --warn-ink: #92400e; --warn-line: #fde3b0; --ok-bg: #ecfdf5; --ok-ink: #065f46; --danger: #dc2626;
  --code: #f6f6f6; --overlay: rgba(0, 0, 0, .32);
  --shadow: 0 0 0 1px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --shadow-pop: 0 10px 40px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121; --side: #181818; --ink: #ececec; --ink-2: #d4d4d4; --muted: #a3a3a3; --faint: #8a8a8a;
    --line: #363636; --line-2: #2f2f2f; --bubble: #303030; --hover: #2c2c2c; --hover-2: #262626; --chip: #2a2a2a;
    --send: #ececec; --send-ink: #0d0d0d; --voice: #14B8A6; --accent: #2DD4BF; --accent-soft: #0f2e2b; --teal: #14B8A6;
    --warn-bg: #2d2412; --warn-ink: #fcd34d; --warn-line: #5c4a1c; --ok-bg: #11291f; --ok-ink: #6ee7b7;
    --code: #2a2a2a; --overlay: rgba(0, 0, 0, .55);
    --shadow: 0 0 0 1px rgba(255,255,255,.06), 0 4px 16px rgba(0,0,0,.4); --shadow-pop: 0 10px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body.chat-body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.cg { display: flex; height: 100vh; height: 100dvh; }

/* ---------- Sidebar ---------- */
.cg-side { width: 260px; flex: none; background: var(--side); display: flex; flex-direction: column; padding: 8px; transition: margin-left .2s ease; }
body.side-collapsed .cg-side { margin-left: -260px; }
.cg-side-top { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 4px 0 8px; }
.cg-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.cg-brand .et-logo { color: var(--ink); }
.cg-icon-btn { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.cg-icon-btn:hover { background: var(--hover); color: var(--ink); }
.cg-nav { display: flex; flex-direction: column; gap: 1px; margin: 4px 0 8px; }
.cg-nav a, .cg-nav button { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; width: 100%; font-size: 14px; color: var(--ink); }
.cg-nav a:hover, .cg-nav button:hover { background: var(--hover); }
.cg-search { display: none; margin: 0 2px 6px; }
.cg-search.open { display: block; }
.cg-search input { width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 7px 10px; font: inherit; outline: 0; }
.cg-history { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px 8px; }
.cg-group { font-size: 12px; font-weight: 500; color: var(--faint); padding: 14px 10px 4px; }
.cg-history a { display: block; padding: 7px 10px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.cg-history a:hover { background: var(--hover); }
.cg-history a.active { background: var(--hover); }
.cg-history .empty { color: var(--muted); font-size: 13px; padding: 6px 10px; }
.cg-guest-card { margin: auto 4px 6px; padding: 14px; border-radius: 14px; }
.cg-guest-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.cg-guest-card p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.cg-guest-card .cg-btn { width: 100%; justify-content: center; margin-top: 6px; }
.cg-account { border-top: 1px solid var(--line-2); padding-top: 6px; }
.cg-account-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.cg-account-btn:hover { background: var(--hover); }
.cg-initials { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 600; font-size: 12px; flex: none; }
.cg-account-meta { flex: 1; min-width: 0; line-height: 1.25; }
.cg-account-meta strong { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-account-meta small { color: var(--muted); font-size: 12px; }

/* ---------- Main ---------- */
.cg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.cg-top { height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; }
.cg-top-left { display: flex; align-items: center; gap: 2px; min-width: 0; }
.cg-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; padding: 6px 8px; border-radius: 10px; min-width: 0; }
.cg-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-top-actions { display: flex; align-items: center; gap: 6px; }
.cg-open-side { display: none; }
body.side-collapsed .cg-open-side { display: grid; }
.cg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; font-weight: 500; font-size: 14px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; white-space: nowrap; }
.cg-btn:hover { background: var(--hover-2); }
.cg-btn.dark { background: var(--send); color: var(--send-ink); border-color: var(--send); }
.cg-btn.dark:hover { opacity: .88; }

.cg-thread { flex: 1; overflow-y: auto; }
.cg-thread-inner { max-width: 768px; margin: 0 auto; padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 22px; }

.cg-msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.cg-bubble { max-width: min(80%, 560px); background: var(--bubble); padding: 9px 16px; border-radius: 18px; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.cg-msg.assistant { display: flex; flex-direction: column; }
.cg-avatar { display: none; }
.cg-body { min-width: 0; }
.cg-content { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.cg-msg.error .cg-content { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); padding: 10px 14px; border-radius: 12px; font-size: 14px; }
.cg-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 10px 0 4px; max-width: 560px; }
.cg-images a { position: relative; display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--hover-2); }
.cg-images img { display: block; width: 100%; height: auto; }
.cg-images .dl { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.cg-artifacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--chip); font-size: 13px; }
.cg-chip:hover { background: var(--hover-2); }
.cg-cites { margin-top: 8px; font-size: 12px; color: var(--muted); }
.cg-cites a { color: var(--accent); text-decoration: underline; }
.cg-cites em { color: var(--warn-ink); font-style: normal; }
.cg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; color: var(--muted); }
.cg-actions button { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.cg-actions button:hover { background: var(--hover); color: var(--ink); }
.cg-actions button.on { color: var(--voice); }
.cg-actions .model { font-size: 12px; color: var(--faint); margin-left: 6px; }
.cg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; max-width: min(80%, 560px); }
.cg-thumb img { display: block; max-width: 200px; max-height: 200px; border-radius: 14px; border: 1px solid var(--line); object-fit: cover; }
.cg-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--chip); font-size: 13px; max-width: 240px; }
.cg-file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* typing indicator */
.cg-typing { display: inline-flex; gap: 4px; padding: 8px 0 2px; }
.cg-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .35; animation: cg-blink 1.2s infinite ease-in-out; }
.cg-typing span:nth-child(2) { animation-delay: .15s; } .cg-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cg-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cg-step { font-size: 13px; color: var(--muted); }

/* markdown */
.cg-content > :first-child { margin-top: 0; } .cg-content > :last-child { margin-bottom: 0; }
.cg-content p { margin: 0 0 10px; }
.cg-content h1, .cg-content h2, .cg-content h3, .cg-content h4 { line-height: 1.35; margin: 18px 0 6px; font-weight: 600; }
.cg-content h1 { font-size: 19px; } .cg-content h2 { font-size: 17px; } .cg-content h3 { font-size: 15.5px; } .cg-content h4 { font-size: 15px; }
.cg-content ul, .cg-content ol { margin: 0 0 10px; padding-left: 22px; } .cg-content li { margin: 3px 0; }
.cg-content a { color: var(--accent); text-decoration: underline; }
.cg-content strong { font-weight: 600; }
.cg-content code { font-family: var(--mono); font-size: 13px; background: var(--code); padding: 2px 5px; border-radius: 6px; }
.cg-content pre { position: relative; background: var(--code); padding: 34px 14px 12px; border-radius: 12px; overflow-x: auto; white-space: pre-wrap; font-size: 14px; line-height: 1.55; border: 1px solid var(--line); }
.cg-content pre code { background: none; padding: 0; font-family: var(--font); font-size: 14px; }
.cg-copy { position: absolute; top: 6px; right: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); border-radius: 8px; padding: 2px 10px; font-size: 12px; font-weight: 500; cursor: pointer; }
.cg-copy:hover { background: var(--hover); }
.cg-content blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-2); }
.cg-content table { border-collapse: collapse; width: 100%; margin: 4px 0 12px; font-size: 14px; display: block; overflow-x: auto; }
.cg-content th, .cg-content td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.cg-content th { background: var(--side); font-weight: 600; }
.cg-content hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.cg-content img { max-width: 100%; max-height: 420px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0; display: block; }

/* ---------- Composer ---------- */
.cg-composer-wrap { flex: none; padding: 0 16px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.cg-composer { max-width: 768px; margin: 0 auto; position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 28px; padding: 8px; box-shadow: var(--shadow); }
.cg-composer.dragging { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cg-composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font: inherit; font-size: 15px; line-height: 1.5; max-height: 200px; min-height: 24px; padding: 6px 10px 4px; }
.cg-composer textarea::placeholder { color: var(--faint); }
.cg-composer-bar { display: flex; align-items: center; gap: 4px; }
.cg-composer-bar .spacer { flex: 1; }
.cg-round { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.cg-round:hover { background: var(--hover); }
.cg-round:disabled { opacity: .35; cursor: default; }
.cg-model-btn { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 6px 10px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.cg-model-btn:hover { background: var(--hover); color: var(--ink); }
.cg-send { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--send); color: var(--send-ink); transition: opacity .15s; }
.cg-send.voice { background: var(--voice); color: #fff; }
.cg-send:disabled { opacity: .3; cursor: default; }
.cg-pending-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 6px 8px; }
.cg-pending-files[hidden] { display: none; }
.cg-pf { position: relative; display: flex; align-items: center; gap: 8px; max-width: 230px; padding: 6px 28px 6px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--side); font-size: 12px; }
.cg-pf img { width: 38px; height: 38px; object-fit: cover; border-radius: 8px; }
.cg-pf .ico { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); font-size: 16px; }
.cg-pf .meta { min-width: 0; line-height: 1.25; } .cg-pf .meta b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .cg-pf .meta small { color: var(--muted); }
.cg-pf button { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--hover); cursor: pointer; font-size: 11px; line-height: 1; }
/* dictation (recording a voice note into the box) */
.cg-rec { display: none; align-items: center; gap: 10px; padding: 6px 10px; font-size: 14px; color: var(--ink-2); }
.cg-composer.recording textarea { display: none; }
.cg-composer.recording .cg-rec { display: flex; }
.cg-rec .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: cg-pulse 1s infinite; }
.cg-rec .wave { flex: 1; height: 22px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.cg-rec .wave i { width: 3px; border-radius: 2px; background: var(--muted); height: 4px; transition: height .08s; }
@keyframes cg-pulse { 50% { opacity: .3; } }
.cg-note { text-align: center; color: var(--faint); font-size: 12px; margin: 8px 0 0; }
.cg-note a { text-decoration: underline; }
.cg-suggestions { max-width: 768px; margin: 14px auto 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cg-suggestions button { border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.cg-suggestions button:hover { background: var(--hover-2); color: var(--ink); }

/* Empty state: greeting + composer centred, like a new ChatGPT chat. */
.cg-hero { display: none; text-align: center; padding: 0 20px 22px; }
.cg-hero h1 { font-size: 26px; font-weight: 500; letter-spacing: -.01em; margin: 0 0 6px; }
.cg-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.cg-center { display: contents; }
.cg-main.is-empty .cg-thread { display: none; }
.cg-main.is-empty .cg-center { display: flex; flex: 1; flex-direction: column; justify-content: center; padding-bottom: 8vh; }
.cg-main.is-empty .cg-hero { display: block; }
.cg-main:not(.is-empty) .cg-suggestions { display: none; }

.cg-banner { max-width: 768px; margin: 0 auto 10px; padding: 9px 14px; border-radius: 12px; font-size: 13px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.cg-flash { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); z-index: 30; max-width: min(560px, 92vw); padding: 9px 16px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow-pop); background: var(--bg); color: var(--ok-ink); animation: cg-fade 6s forwards; }
.cg-flash.bad { color: var(--warn-ink); }
@keyframes cg-fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* ---------- Popovers (menus) ---------- */
.cg-pop { position: fixed; z-index: 60; min-width: 230px; max-width: calc(100vw - 24px); background: var(--bg); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 6px; display: none; font-size: 14px; }
.cg-pop.open { display: block; animation: cg-in .12s ease-out; }
.cg-pop a, .cg-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; font-size: 14px; color: var(--ink); }
.cg-pop a:hover, .cg-pop button:hover { background: var(--hover-2); }
.cg-pop .sep { height: 1px; background: var(--line-2); margin: 6px 4px; }
.cg-pop .head { padding: 8px 10px 6px; color: var(--muted); font-size: 13px; }
.cg-pop .head strong { display: block; color: var(--ink); font-weight: 500; }
.cg-pop .right { margin-left: auto; color: var(--faint); font-size: 12px; }
@keyframes cg-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Modals (ChatGPT-style dialog) ---------- */
.cg-modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; background: var(--overlay); padding: 16px; }
.cg-modal.open { display: flex; }
.cg-dialog { width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--bg); border-radius: 24px; box-shadow: var(--shadow-pop); animation: cg-in .15s ease-out; overflow: hidden; }
.cg-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 8px 24px; }
.cg-dialog-head h2 { margin: 0; font-size: 20px; font-weight: 500; }
.cg-close { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.cg-close:hover { background: var(--hover-2); }
.cg-dialog-body { padding: 8px 24px 20px; overflow-y: auto; font-size: 14px; color: var(--ink-2); }
.cg-dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line-2); }
.cg-dialog-foot .muted { color: var(--muted); font-size: 13px; }
.cg-options { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cg-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-top: 1px solid var(--line-2); background: var(--bg); cursor: pointer; text-align: left; }
.cg-option:first-child { border-top: 0; }
.cg-option:hover { background: var(--hover-2); }
.cg-option[disabled] { cursor: default; opacity: .55; }
.cg-radio { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; display: grid; place-items: center; }
.cg-option.selected .cg-radio { border-color: var(--ink); }
.cg-option.selected .cg-radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.cg-option .txt { flex: 1; min-width: 0; }
.cg-option .txt strong { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; color: var(--ink); }
.cg-option .txt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.cg-badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--ink-2); }
.cg-badge.warn { background: #fff1e6; color: #c2410c; } .cg-badge.ok { background: var(--ok-bg); color: var(--ok-ink); } .cg-badge.blue { background: var(--accent-soft); color: var(--teal); }

/* ---------- Voice mode (full-screen): the logo is the visualizer ---------- */
.cg-voice { position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--bg); padding: 20px; }
.cg-voice.open { display: flex; }
.cg-voice-brand { position: absolute; top: 16px; left: 18px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--ink); }
.cg-orb { position: relative; width: 250px; height: 250px; border: 0; background: transparent; padding: 0; cursor: pointer; display: grid; place-items: center; color: var(--ink); border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.cg-orb .et-logo { position: relative; z-index: 1; width: 190px; height: 190px; transition: transform .2s ease; }
.cg-orb .et-rays path { transition: transform .07s linear, opacity .07s linear; }
.cg-orb-glow { position: absolute; inset: 24px; border-radius: 50%; background: radial-gradient(circle, rgba(15,118,110,.45) 0%, rgba(15,118,110,.12) 45%, transparent 70%); opacity: .15; transition: transform .1s linear, opacity .1s linear; }
.cg-voice[data-state="listening"] .cg-orb::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; border: 2px solid var(--teal); opacity: .5; animation: cg-ring 1.6s ease-out infinite; }
.cg-voice[data-state="thinking"] .cg-orb .et-logo { animation: et-breathe 1.4s ease-in-out infinite; }
.cg-voice[data-state="speaking"] .cg-orb-glow { background: radial-gradient(circle, rgba(17,17,17,.28) 0%, rgba(15,118,110,.16) 45%, transparent 70%); }
.cg-voice.muted .cg-orb { opacity: .45; }
.cg-voice[data-state="speaking"] .voice-logo .et-rays path { animation: cg-ray-talk 1.1s ease-in-out infinite; animation-delay: calc(var(--i) * -0.09s); }
.cg-voice[data-state="speaking"] .voice-logo .et-e { animation: et-breathe 1.1s ease-in-out infinite; transform-origin: 500px 500px; }
@keyframes cg-ray-talk { 0%, 100% { transform: scale(1); opacity: .65; } 50% { transform: scale(1.28); opacity: 1; } }
.cg-voice[data-state="listening"] .voice-logo .et-rays path { opacity: .65; }
@keyframes cg-ring { from { transform: scale(.92); opacity: .55; } to { transform: scale(1.18); opacity: 0; } }
.cg-voice-status { font-size: 15px; font-weight: 500; color: var(--ink-2); min-height: 22px; text-align: center; padding: 0 20px; }
.cg-voice-meter { width: 160px; height: 4px; border-radius: 4px; background: var(--hover); overflow: hidden; }
.cg-voice-meter i { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 4px; transition: width .08s linear; }
.cg-voice-text { max-width: 560px; text-align: center; font-size: 14px; color: var(--muted); padding: 0 24px; max-height: 18vh; overflow-y: auto; }
.cg-voice-controls { display: flex; gap: 16px; margin-top: 6px; }
.cg-voice-controls button { width: 58px; height: 58px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--hover); color: var(--ink); }
.cg-voice-controls button.send { background: var(--teal); color: #fff; }
.cg-voice-controls button.end { background: var(--danger); color: #fff; }
.cg-voice.muted [data-voice-mic] { background: var(--ink); color: var(--bg); }
.cg-voice.live [data-voice-send] { display: none; } /* live voice answers on its own when you pause */

/* ---------- Live activity: what the AI is doing ---------- */
.cg-activity { margin: 2px 0 10px; font-size: 13.5px; color: var(--muted); }
.cg-activity-head { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 0; color: var(--muted); font: inherit; cursor: default; text-align: left; }
.cg-activity.done .cg-activity-head { cursor: pointer; border-radius: 8px; padding: 4px 8px 4px 4px; }
.cg-activity.done .cg-activity-head:hover { background: var(--hover-2); color: var(--ink); }
.cg-activity-head .et-logo { color: var(--ink); }
.cg-activity-head .ok { color: var(--teal); }
.cg-activity-head .chev { transition: transform .15s; }
.cg-activity.open .cg-activity-head .chev { transform: rotate(90deg); }
.cg-activity-status { font-weight: 500; color: var(--ink-2); }
.cg-activity-time { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.shimmer { background: linear-gradient(90deg, var(--ink-2) 0%, var(--ink-2) 40%, var(--teal) 50%, var(--ink-2) 60%, var(--ink-2) 100%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: cg-shimmer 2.2s linear infinite; }
.cg-activity-status.swap { animation: cg-shimmer 2.2s linear infinite, cg-swap .35s ease-out; }
@keyframes cg-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes cg-swap { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.cg-activity-steps { list-style: none; margin: 4px 0 0; padding: 0 0 0 9px; border-left: 2px solid var(--line-2); display: flex; flex-direction: column; gap: 6px; }
.cg-activity-steps:empty { display: none; }
.cg-activity.done .cg-activity-steps { display: none; margin-left: 4px; }
.cg-activity.done.open .cg-activity-steps { display: flex; }
.cg-activity-steps li { display: flex; gap: 9px; align-items: flex-start; padding-left: 6px; line-height: 1.45; }
.cg-activity-steps li.enter { animation: cg-step-in .35s ease-out; }
@keyframes cg-step-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.cg-activity-steps .lbl { color: var(--ink-2); }
.cg-activity-steps .det { color: var(--faint); font-size: 12.5px; margin-top: 1px; white-space: pre-line; }
.cg-activity-steps li.i-think .lbl { font-weight: 500; }
.cg-activity-steps li.s-running .lbl { color: var(--ink); }
.cg-activity-steps li.s-error .lbl { color: var(--warn-ink); }
.cg-activity-steps .ico { width: 15px; height: 15px; flex: none; margin-top: 2px; background: currentColor; color: var(--faint); -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat;
  --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3C/svg%3E"); }
.cg-activity-steps li.s-running .ico { color: var(--teal); animation: cg-pulse 1s infinite; }
.cg-activity-steps li.s-done .ico { color: var(--teal); }
.cg-activity-steps li.s-error .ico { color: var(--danger); }
.i-search .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") !important; }
.i-globe .ico, .i-link .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18'/%3E%3C/svg%3E") !important; }
.i-audit .ico, .i-calc .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M4 20V10M10 20V4M16 20v-7M22 20H2'/%3E%3C/svg%3E") !important; }
.i-doc .ico, .i-pdf .ico, .i-file .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6M8 13h8M8 17h6'/%3E%3C/svg%3E") !important; }
.i-fees .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M3 7h18v4a2 2 0 0 0 0 4v4H3v-4a2 2 0 0 0 0-4z'/%3E%3Cpath d='M13 7v12' stroke-dasharray='2 2'/%3E%3C/svg%3E") !important; }
.i-bed .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M3 18V6M3 13h18v5M21 13a3 3 0 0 0-3-3H10v3'/%3E%3Ccircle cx='6.5' cy='10' r='1.5'/%3E%3C/svg%3E") !important; }
.i-map .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2'%3E%3Cpath d='M12 21s-7-6-7-11a7 7 0 0 1 14 0c0 5-7 11-7 11z'/%3E%3Ccircle cx='12' cy='10' r='2.5'/%3E%3C/svg%3E") !important; }
.i-image .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='3'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E") !important; }
.i-book .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3C/svg%3E") !important; }
.i-user .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E") !important; }
.i-send .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M22 2 11 13M22 2l-7 20-4-9-9-4z'/%3E%3C/svg%3E") !important; }
.i-clock .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") !important; }
.i-write .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") !important; }
.i-audio .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M4 10v4M8 6v12M12 9v6M16 5v14M20 10v4'/%3E%3C/svg%3E") !important; }
.i-think .ico { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l1.8 5.6L19.5 9l-5.7 1.6L12 16l-1.8-5.4L4.5 9l5.7-1.4z'/%3E%3Cpath d='M19 14l.9 2.6 2.6.9-2.6.9L19 21l-.9-2.6-2.6-.9 2.6-.9z'/%3E%3C/svg%3E") !important; }
.cg-thought { margin: 8px 0 0 11px; padding: 8px 12px; border-radius: 12px; background: var(--hover-2); color: var(--muted); font-size: 13px; animation: cg-step-in .3s ease-out; }
.cg-thought[hidden] { display: none; }
.cg-thought .tt { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.cg-thought .tt .et-logo { color: var(--ink); }
.cg-thought p { margin: 4px 0 0; max-height: 6.2em; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
.cg-live-text:empty { display: none; }
.cg-caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--teal); animation: cg-pulse .9s infinite; }

/* ---------- Link previews ---------- */
.cg-links { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-top: 6px; width: 100%; }
.cg-link-slot { width: min(100%, 420px); height: 74px; border-radius: 14px; background: linear-gradient(90deg, var(--hover-2), var(--hover), var(--hover-2)); background-size: 200% 100%; animation: cg-shimmer 1.4s linear infinite; }
.cg-link-card { display: flex; width: min(100%, 420px); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--chip); color: var(--ink); text-align: left; }
.cg-link-card:hover { background: var(--hover-2); }
.cg-link-card .thumb { position: relative; flex: none; width: 120px; background: var(--hover); }
.cg-link-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cg-link-card .thumb .play { position: absolute; inset: 0; margin: auto; width: 42px; height: 42px; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; display: grid; place-items: center; }
.cg-link-card .meta { min-width: 0; padding: 9px 12px; display: flex; flex-direction: column; gap: 2px; }
.cg-link-card .meta b { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cg-link-card .desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cg-link-card small { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-embed { width: min(100%, 520px); aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.cg-embed iframe { width: 100%; height: 100%; border: 0; display: block; }
.cg-composer-links { position: relative; display: flex; padding: 2px 6px 8px; }
.cg-composer-links[hidden] { display: none; }
.cg-network-notice { margin: 0 8px 8px; padding: 9px 12px; border: 1px solid #f2c36d; border-radius: 10px; background: #fff7df; color: #7a4a00; font-size: 13px; font-weight: 600; }
.cg-network-notice[hidden] { display: none; }
.is-offline .cg-composer { opacity: .7; }
.cg-cancel-task { margin-top: 8px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.cg-cancel-task:hover { color: var(--danger); border-color: var(--danger); }
.cg-link-card.mini { width: 100%; max-width: 520px; } .cg-link-card.mini .thumb { width: 84px; }
.cg-link-x { position: absolute; top: 6px; right: 12px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--bg); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--ink); }

/* ---------- Audio & video players, PDF / Word cards ---------- */
.cg-media { display: contents; }
.cg-audio { display: flex; align-items: center; gap: 10px; width: min(100%, 360px); padding: 10px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--chip); }
.cg-audio audio { display: none; }
.cg-audio-btn { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: var(--teal); color: #fff; display: grid; place-items: center; cursor: pointer; }
.cg-audio-btn:disabled { background: var(--faint); cursor: default; }
.cg-audio-mid { flex: 1; min-width: 0; }
.cg-audio-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.cg-audio-bar { height: 6px; border-radius: 6px; background: var(--hover); cursor: pointer; overflow: hidden; }
.cg-audio-bar i { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 6px; }
.cg-audio-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.cg-audio-time { flex: 1; font-variant-numeric: tabular-nums; }
.cg-audio-speed { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 0 7px; font-size: 11px; cursor: pointer; color: var(--ink-2); }
.cg-audio-dl { color: var(--muted); display: grid; place-items: center; }
.cg-audio.unsupported .cg-audio-name { color: var(--warn-ink); white-space: normal; }
.cg-video { width: min(100%, 480px); border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.cg-video video { display: block; width: 100%; max-height: 420px; background: #000; }
.cg-video-cap { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--chip); font-size: 12px; color: var(--muted); }
.cg-video-cap span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-video.unsupported { background: var(--chip); padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; font-size: 13px; }
.cg-doc { display: flex; align-items: center; gap: 10px; width: min(100%, 380px); padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--chip); text-align: left; }
.cg-doc-badge { width: 40px; height: 46px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; background: #dc2626; }
.cg-doc.word .cg-doc-badge { background: #185abd; font-size: 18px; }
.cg-doc-meta { flex: 1; min-width: 0; line-height: 1.3; }
.cg-doc-meta b { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-doc-meta small { color: var(--muted); font-size: 11.5px; }
.cg-doc-acts { display: flex; gap: 4px; }
.cg-doc-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--ink); }
.cg-doc-btn:hover { background: var(--hover-2); }
.cg-chip[data-preview] { cursor: zoom-in; }

/* ---------- Viewer (PDF, Word) ---------- */
.cg-viewer { position: fixed; inset: 0; z-index: 95; display: none; flex-direction: column; background: #2b2b2b; }
.cg-viewer.open { display: flex; animation: cg-in .15s ease-out; }
body.viewer-open { overflow: hidden; }
.cg-viewer-top { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.cg-viewer-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-viewer-pages { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cg-viewer-tools { display: flex; align-items: center; gap: 2px; }
.cg-viewer-tools [hidden] { display: none !important; }
.cg-viewer-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.cg-viewer-body .et-center-loader { color: #d4d4d4; min-height: 60vh; }
.cg-viewer-body .et-center-loader .et-logo { color: #fff; }
.cg-pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 8px 40px; }
.cg-pdf-page { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.4); max-width: 100%; }
.cg-pdf-page canvas { display: block; max-width: 100%; height: auto !important; }
.cg-docx { padding: 12px 0 40px; }
.cg-docx .docx-wrapper { background: transparent !important; padding: 10px !important; }
.cg-docx .docx-wrapper > section.docx { box-shadow: 0 2px 12px rgba(0,0,0,.4); margin-bottom: 14px !important; max-width: 100%; }

/* ---------- Brand & profile bits ---------- */
.cg-hero-logo { display: flex; justify-content: center; margin-bottom: 12px; color: var(--ink); }
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; background: var(--teal); color: #fff; font-weight: 600; overflow: hidden; }
.cg-pop .head-user { display: flex; align-items: center; gap: 10px; }
.cg-pop .head-user span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cg-composer.transcribing::after { content: ""; position: absolute; left: 24px; right: 24px; bottom: 6px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--teal), transparent); background-size: 200% 100%; animation: cg-shimmer 1.1s linear infinite; }
.cg-overlay { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  body.chat-body { font-size: 14px; }
  .cg-side { position: fixed; inset: 0 auto 0 0; z-index: 70; width: 280px; transform: translateX(-100%); transition: transform .2s ease, box-shadow .2s ease; box-shadow: none; margin-left: 0 !important; }
  body.side-open .cg-side { transform: none; box-shadow: var(--shadow-pop); }
  body.side-open .cg-overlay { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 65; }
  .cg-open-side { display: grid !important; }
  .cg-collapse { display: none; }
  .cg-top { padding: 0 6px; height: 48px; }
  .cg-top .cg-btn { padding: 6px 12px; font-size: 13px; }
  .cg-thread-inner { padding: 10px 14px 24px; gap: 18px; }
  .cg-bubble { max-width: 88%; }
  .cg-composer-wrap { padding: 0 8px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .cg-composer textarea { font-size: 16px; } /* avoids iOS zoom on focus */
  .cg-hero h1 { font-size: 22px; }
  .cg-suggestions button { font-size: 12.5px; }
  .cg-modal { align-items: flex-end; padding: 0; }
  .cg-dialog { max-width: none; border-radius: 22px 22px 0 0; max-height: 88dvh; }
  .cg-images { grid-template-columns: 1fr; }
  .cg-orb { width: 210px; height: 210px; } .cg-orb .et-logo { width: 160px; height: 160px; }
  .cg-viewer-tools .cg-btn { padding: 6px 10px; }
  .cg-link-card .thumb { width: 92px; }
  .cg-voice-brand { top: 12px; left: 12px; }
}

/* Public website links under the composer (guests, empty chat only; always in the HTML for search engines). */
.cg-site-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin: 10px auto 0; font-size: 12px; }
.cg-site-links a { color: var(--muted); }
.cg-site-links a:hover { color: var(--ink); text-decoration: underline; }
.cg-main:not(.is-empty) .cg-site-links { display: none; }
