/* AI chat entry styles: presentation only, no behaviour.
   Layout strategy: mobile first + progressive enhancement; the chat output area uses flexible sizing + sectioned scrolling,
   so it adapts to phones, tablets, desktops and every mainstream browser. */

:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --sidebar-bg: #eef0f3;
    --border: #e3e6ea;
    --text: #1f2329;
    --muted: #8a9099;
    --primary: #185fa5;
    --primary-soft: #e6f1fb;
    /* Assistant reply bubble: grey-white (the former cream #f1efe8 is deprecated), with a thin border to separate it from the page background */
    --ai-bubble: #f6f7f9;
    --danger: #a32d2d;
    --nav-bg: #000000;
    --nav-accent: #1db954;
    --nav-w: 100px;
    /* Content width basis shared by the welcome card / message output area / bottom input card:
       capped at 900px, and on narrow screens min() shrinks it to fill the available width, so all three share one centre line */
    --content-w: min(100%, 900px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

/* The three regions sit directly in body with no shared shell:
   body only provides the layout flow, carrying no border, radius or background shell */
body {
    margin: 0;
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

/* Overlay: shown only when the mobile drawer is open, toggled by the script through body.is-nav-open */
#overlay {
    display: none;
    position: fixed;
    inset: 0;
    left: var(--nav-w); /* The overlay avoids the standalone nav column so module items stay clickable while the drawer is open */
    background: rgba(31, 35, 41, .35);
    z-index: 10;
}
body.is-nav-open #overlay { display: block; }

/* Left nav: a drawer on mobile, always present on desktop */
#sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--nav-w);
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: 78%;
    max-width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    transform: translateX(calc(-100% - var(--nav-w)));
    transition: transform .22s ease;
}
body.is-nav-open #sidebar { transform: translateX(0); }

@media (min-width: 768px) {
    #sidebar {
        position: relative;
        left: auto;
        flex: 0 0 220px;
        width: 220px;
        max-width: none;
        transform: none;
        transition: none;
    }
}
@media (min-width: 1100px) {
    #sidebar { flex-basis: 260px; width: 260px; }
}

/* Sidebar header: kept on mobile only (it hosts the × button that closes the drawer) and fully hidden on desktop,
   so the New chat button moves to the very top of the sidebar */
#sidebarHead {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 12px 0;
}
@media (min-width: 768px) { #sidebarHead { display: none; } }
#closeSidebar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
#closeSidebar::before { content: "\00D7"; }

@media (min-width: 768px) { #closeSidebar { display: none; } }

#newChatWrap { padding: 12px 12px 8px; }
@media (min-width: 768px) { #newChatWrap { padding-top: 16px; } }
#newChat {
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--primary);
    border-radius: 8px;
    background: var(--panel);
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
}

/* Session list: keeps scrolling but hides the visible scrollbar (three engines covered).
   With the scrollbar removed the right padding is corrected so items do not hug the edge; scrolling by event, keyboard or touch is unaffected. */
#sessionList {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide the scrollbar: Firefox */
    scrollbar-width: none;
    /* Hide the scrollbar: IE / legacy Edge */
    -ms-overflow-style: none;
    /* Mobile inertia scrolling + prevent scroll chaining to the outer page (body already has overflow:hidden; this is a fallback) */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* With the scrollbar hidden the right side loses part of its gutter, so the padding is set to 10px and items no longer sit left against the edge */
    padding: 4px 10px 12px;
}
/* Hide the scrollbar: Chrome / Safari / new Edge */
#sessionList::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* Nav logo: box width adapts to narrow/wide screens, the image keeps a fixed 60×26 ratio without stretching */
#navLogo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* p187 定稿：10/12 -> 5/7，margin 4 -> 2 —— 只回收「外框留白」，
       给原版 11 项（每项 48px + 2px 间距）腾出空间；图标 28 / 文字 13 / 图标文字间距 8 一个像素不动。
       p188：上 5 -> 13，把「栏目栏那 8px 上内边距」搬进 logo 自己身上（总量不变：8+5 = 13）。 */
    padding: 13px 6px 7px 4px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    /* 🔴 p189 定稿：logo **不在滚动容器里**（见 index.html 的 #navScroll），
       所以「新增栏目 / 静默滚动 会不会推走或滚走 logo」这个问题从结构上就不存在了 ——
       它只是 #moduleNav 的固定首项，#navScroll 高度怎么变都与它无关。
       p188 曾用 position:sticky + z-index 钉住，属于「同一个元素既当固定头又当滚动流成员」的补丁式做法：
       sticky 依赖祖先 overflow 与浏览器实现（老 360/IE 内核尤其脆），改一层包裹就可能整条失效。
       这里已改结构，sticky 一并撤除，别再改回去。
       底色保留：万一将来给 logo 做半透明/圆角，也不至于透出下方内容。 */
    background: var(--nav-bg);
}
#navLogo img {
    display: block;
    width: 60px;
    height: 26px;
    max-width: 100%;
    object-fit: contain;
}

/* Standalone feature nav column: parallel to the chat sidebar, not part of the chat module; icon + text in one row */
#moduleNav {
    flex: 0 0 var(--nav-w);
    width: var(--nav-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* p187 定稿：10px 0 -> 8px 0，只回收栏目栏自身的上下留白。
       p188：上内边距归 0（那 8px 已并入 #navLogo 的 padding-top）。
       p189：下内边距也下放到 #navScroll 的 padding-bottom —— 让「底边留白」跟着内容一起滚，
       滚动到底时最后一项不会被永久压住 8px。 */
    padding: 0;
    /* 🔴 p189：栏目栏本身**不再是滚动容器**（滚动交给 #navScroll）。
       这样 logo（固定首项）与滚动流彻底分离，新增多少栏目都动不了它。
       overflow:hidden 同时充当兜底裁剪：任何意外溢出的内容都不会把整列撑破。 */
    overflow: hidden;
    background: var(--nav-bg);
    border-right: 1px solid #000;
}

/* 功能入口滚动区（p189 新增 / p190 收窄为「只管功能项」）：栏目栏里唯一会滚的东西。
   高度 = 栏目栏高 − logo − 账号入口底栏 − 2 个 gap；放不下就自己滚，
   永远不挤压 logo、不挤压底栏、不挤压项间距。 */
#navScroll {
    flex: 1 1 auto;
    min-height: 0;              /* 🔴 没有它，flex 子项的自动最小高度 = 内容高 → 不滚、把整列撑破 */
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 8px;        /* 原 #moduleNav 的下内边距搬到这里 */
    overflow-y: auto;
    /* 滚动到顶/底时不把滚动链传给外层页面（外层 body 已 overflow:hidden，这是兜底） */
    overscroll-behavior: contain;
}
/* p187：滚动能力保留，但**永远不显示条**。
   起因：360 打开「显示收藏夹 + 状态栏」后视口只剩 634px，而原版 11 项要 636px →
   栏目栏自己溢出，画出那条长方形滚动条；滚动条还是占位式的，又吃掉 ~9px 宽度，
   「智能体 / 知识库」被切成「智…」（两个症状同一根因）。
   p189：三件套跟着滚动容器一起从 #moduleNav 移到 #navScroll。 */
#navScroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#navScroll::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}
.module-nav-item {
    /* 🔴 p187 红线：flex 必须是 0 0 auto —— 视口再矮也不许压缩每项高度。
       列容器是 overflow:auto 的 flex column，默认 flex-shrink:1 在极矮视口下会把
       各项往下压（间距肉眼可见变小，正是用户打回的写法）。写 0 之后：放不下就溢出→滚动（条已隐藏），
       间距永远等于原版 48px + 2px。 */
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    padding: 10px 8px 10px 4px;
    margin-bottom: 2px;
    border: none;
    border-radius: 8px;
    background: var(--nav-bg);
    color: #e8e8e8;
    font: inherit;
    font-size: 12px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}
/* Black background by default; hover gives a light green background + green text (transient feedback), a real click gives solid green + white text (persistent) */
.module-nav-item:hover {
    background: rgba(29, 185, 84, .16);
    color: var(--nav-accent);
}
.module-nav-item:active,
.module-nav-item.is-active,
.module-nav-item.is-active:hover {
    background: var(--nav-accent);
    color: #fff;
}
/* 账号入口：固定底栏（p190）
   🔴 它在 #navScroll **外面**，是 #moduleNav 的直接子项 —— 和 logo 对称，永不参与滚动。
   原因：新增栏目把列表撑长后，若它还在滚动流里就会被挤到列表末尾，用户要滚到底才点得到账号入口。
   高度预算不变（仍 630 ≤ 634）：10 个功能项留在 navScroll（480 + 20 + 18 + 8），
   用户项 48 + margin 2 + border 1 上移到 nav 这一层，加上 logo 49 与 2 个 gap 4，合计一样。
   ⚠️ 别把它挪回 #navScroll；也别给 #navScroll 或 #navLogo 加左右 padding 来「点缀」它，
      否则宽度一改，图标对齐就跟着歪。 */
.module-nav-item--bottom {
    /* nav 是 flex column，navScroll 的 flex-grow:1 已吃掉全部剩余空间 → 这里 auto 实为 0；
       留着是为了「万一以后 navScroll 被去掉」它还能自己贴底，不依赖顺序。 */
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .14);
    border-radius: 0 0 8px 8px;
}
.module-nav-icon {
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}
.module-nav-icon svg {
    display: block;
    width: 28px;
    height: 28px;
}
/* The user icon alone is 25×25 while the other module icons stay 28×28 */
#navIconUser svg { width: 25px; height: 25px; }
/* Knowledge-base icon: its raw path nearly fills the 1024 viewBox (measured bounding box 83.3%×79.2%),
   so inside a 28px box it looks clearly bigger than its neighbours (search 75.2%, modeling 67.5%, music 66.1%).
   Rendered at 25px the actual glyph is about 20.8px, the same order as Search, while the 28px container keeps it centred and aligned. */
#navIconKnowledge svg { width: 25px; height: 25px; }
/* Override the fixed fill on the original SVG so icons recolour uniformly with the module state */
.module-nav-icon svg path { fill: currentColor; }
.module-nav-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (min-width: 768px) {
    :root { --nav-w: 100px; }
    .module-nav-item { gap: 8px; padding: 10px 10px 10px 4px; font-size: 13px; }
}
@media (max-width: 480px) {
    .module-nav-item { padding: 9px 6px 9px 4px; gap: 5px; }
}

/* ── 栏目栏尺寸口径（p187 间距冻结 / p188 logo 钉顶 / p189 结构分离 / p190 底栏对称）──
   用户要求（四次迭代后定稿）：
     · **始终保持原版样式** —— 图标 28、字号 13、图标与文字间距 8、每项上下 padding 10，
       以及各项之间的上下间距，一律写死；
     · **禁止**「上下间距跟随视口高度收缩」（上一版按 780/660/560 三档压缩，被明确否掉）；
     · 又不能让浏览器「显示收藏夹 / 显示状态栏」把栏目栏搞出内部滚动条；
     · p188：真放不下而静默滚动时，**顶部 logo 必须钉住不动**，不许随栏目一起上移；
     · p189（可扩展性）：**以后还会新增栏目** —— 加多少项都不许把 logo 顶走/滚走；
     · p190：**账号入口也一样**，不许被新增栏目挤到列表末尾、要滚到底才点得到 → 改固定底栏。

   落法：只有中间那段会滚。`#navLogo` 与 `#navItemUser` 都在 `#navScroll` **外面**，
   结构上就不在滚动流里，不靠 sticky。新增栏目只会让 `#navScroll` 变长 → 自己静默滚，
   上下两块位置恒定。

   原版预算（1366×768 + 收藏夹 + 状态栏 → 实测视口 634px，用户截图尺寸）：
     10 个功能项 × (icon 28 + padding 10+10) = 480   ← 留在 #navScroll
     + 10 × margin-bottom 2                  = 20
     + 9 个滚动区内 gap 2                     = 18
     + 滚动区下 padding 8                     = 8
     ────────── 滚动区内容小计 526 ──────────
     + logo（13 + 26 + 7 + 1 + 2）           = 49   ← 上 13 = 原 logo 上留白 5 + 栏目栏上内边距 8
     + 账号入口 48 + margin 2 + border-top 1  = 51   ← 已上移到 nav 这层（固定底栏）
     + nav 的 2 个 gap 2（logo↔滚动区、滚动区↔底栏）= 4
     ────────────────────────────────────
     合计 630 ≤ 634  ✅（与 p187/p189 一字不差，只是把用户项从滚动区挪到外框）
     固定部分 = logo 49 + 底栏 51 + 2 个 gap 4 = 104；滚动区拿剩下 530px，内容 526px 放得下。

   可回收的只有外框那 16px：logo 上下留白（10/12→5/7，margin 4→2）与栏目栏上下 padding（10→8）。
   再放不下（用户把窗口拖小、125% 缩放只剩 ~500px、或**以后新增栏目**）都走同一条路：
   `#navScroll` 溢出滚动但条已隐藏，logo、底栏与间距纹丝不动 —— 宁可让用户滚动，也不许压缩样式。
   ⚠️ 新增栏目时**不需要**动这里的任何尺寸，只要把 button 放进 `#navScroll` 即可；
      千万别为了「塞得下」去改 icon / padding / gap（那就是被打回的那版）。 */

#sidebarFoot {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}
#sidebarMeta { font-size: 11px; color: var(--muted); }

/* Session items are generated by the script and styled through class names */
.session-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.session-item:hover { background: #3a8cdd; }
.session-item.is-active { background: #3a8cdd; color: #ffffff; }

/* Right main area: vertical flex; the output area takes the remaining height and scrolls on its own */
#main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

#chatHeader {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}
#menuBtn {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
}
#menuBtn::before { content: "\2261"; }
@media (min-width: 768px) { #menuBtn { display: none; } }

#chatTitle {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#pipeline {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}
@media (max-width: 480px) { #pipeline { display: none; } }
/* No skeleton title bar on desktop; the hamburger entry is kept on mobile */
@media (min-width: 768px) { #chatHeader { display: none; } }

/* The hidden attribute must override display:flex on #welcome and the block display of #messages;
   author styles win over the UA default [hidden]{display:none}, hence the explicit !important.
   Hiding the welcome area after sending and showing it again on New chat both depend on this rule. */
[hidden] { display: none !important; }

/* Startup overlay: before the script takes over, every home module whose visibility is decided dynamically stays hidden,
   preventing the home chat content / bottom input from flashing on refresh (especially a #Creation deep link or returning home after sign-in).
   body.is-booting is removed once the script has initialized; from then on JS controls each module precisely. */
body.is-booting #welcome,
body.is-booting #messages,
body.is-booting #composer,
body.is-booting #sessionList,
body.is-booting #newChatWrap,
body.is-booting #sidebarFoot {
    display: none !important;
}

/* Welcome area: shown while the session has no user message, replacing the skeleton system prompt.
   2026-11-23: removed the old white card frame (border/background/shadow/padding);
   the greeting and example questions now sit centred on the same vertical centre line and adapt responsively. */
#welcome {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    padding: 24px 32px;
}
/* Only a centring layout container now, with no frame-module appearance;
   the id is kept so the DOM contract is not broken (the script toggles only #welcome). */
#welcomeCard {
    width: 100%;
    max-width: min(100%, 760px);
    /* margin:auto centres horizontally and vertically inside a flex container, and the content still scrolls when it overflows */
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
}
#welcomeHead {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
#welcomeAvatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90d9, #7b5fd0);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
#welcomeTitle {
    margin: 0;
    font-size: clamp(16px, 2vw, 20px);
    font-weight: 600;
    line-height: 1.5;
}
#welcomeDesc {
    margin: 10px auto 26px;
    max-width: 640px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}
/* Example questions: rounded pills kept, the grid wraps by available width and is centred as a whole */
#suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 10px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}
.suggestion-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.suggestion-item:hover { border-color: var(--primary); background: var(--primary-soft); }
@media (max-width: 600px) {
    #welcome { padding: 16px; }
    #welcomeCard { max-width: 100%; }
    #welcomeDesc { margin-bottom: 20px; }
    #suggestions { max-width: 100%; }
}

/* Chat output area: adaptive height + independent scrolling + mobile inertia scrolling */
/* Message content container: width follows the workspace and shares the same vertical centre line as the welcome card and bottom input */
#messagesInner {
    max-width: var(--content-w);
    margin: 0 auto;
}
#messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Horizontal padding must match #composer (24px) exactly: below 900px the two modules align edge to edge
       (the old 16px inset the content area 8px less per side than the input card, which is the left shift users reported with screenshots) */
    padding: 16px 24px;
    /* Reserve the scrollbar gutter symmetrically so the centre line does not move when the scrollbar appears/disappears,
       otherwise the classic Windows scrollbar (~15px) pushes the centred message area about 8px to the left */
    scrollbar-gutter: stable both-edges;
}
/* Slim scrollbar styling: width narrowed to 8px (gutter stays symmetric, alignment unaffected) */
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-thumb { background: rgba(31, 35, 41, .18); border-radius: 8px; }
#messages::-webkit-scrollbar-thumb:hover { background: rgba(31, 35, 41, .3); }
#messages::-webkit-scrollbar-track { background: transparent; }
@media (max-width: 480px) { #messages { padding: 12px; } }

#err {
    flex: 0 0 auto;
    min-height: 16px;
    padding: 0 16px 6px;
    color: var(--danger);
    font-size: 12px;
}

/* Bottom input card: light grey background + rounded white card + feature chips + dark send button */
#composer {
    flex: 0 0 auto;
    padding: 12px 24px calc(18px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
}
#composerCard {
    max-width: var(--content-w);
    margin: 0 auto;
    padding: 14px 16px 12px;
    border: 1px solid #cfd8e3;
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 4px 18px rgba(31, 35, 41, .08);
}
#input {
    display: block;
    width: 100%;
    /* Grows with the content (JS autosizeInput), capped at 120px; past the cap the overflow scrolls inside the box for reading/editing */
    min-height: 44px;
    max-height: 120px;
    padding: 4px 2px 10px;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 15px; /* Below 16px a viewport handler is required, see below */
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
}
/* Hard requirement: no scrollbar of any kind (round or rectangular) may appear.
   Only the scrollbar widget is hidden and scrolling still works: the wheel scrolls inside the box to read/edit. */
#input { scrollbar-width: none; -ms-overflow-style: none; }
#input::-webkit-scrollbar { width: 0; height: 0; display: none; }
#composerBar {
    display: flex;
    align-items: center;
    gap: 10px;
}
#composerChips {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.composer-chip {
    /* flex + vertical centring: icon and text are forced onto one horizontal axis,
       no longer relying on the inline baseline (so a font metric change cannot misalign them) */
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
}
.composer-chip::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--primary);
    vertical-align: middle;
}
/* The two chips that carry icons use their own SVG instead of the default dot */
#chipThink::before,
#chipSearch::before { display: none; }

/* Icon container: size in em so it follows the font size, scaled one step up (1.7em); the SVGs have a lot of internal whitespace,
   so the perceived size matches the button text; the radius is in em as well and matches the pill button shape.
   Vertical alignment is handled by .composer-chip flex align-items:center instead of vertical-align hacks. */
.chip-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7em;
    height: 1.7em;
    margin-right: 6px;
    border-radius: .5em;
    flex: 0 0 auto;
}
.chip-icon {
    display: block;
    width: 100%;
    height: 100%;
}
/* Line height fixed at 1: under flex centring the text box height is deterministic and stays exactly on the icon axis */
.chip-label { line-height: 1; }
/* CSS overrides the fill presentation attribute of the SVG so the selected icon follows the primary colour */
.chip-icon path { fill: currentColor; }
.chip-icon-search path { fill: currentColor; }
.composer-chip.is-selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

/* The dynamic glow/spin of the two icons was removed as requested;
   the icon stays still while streaming and only the send button shows a spinning SVG. */

/* The send-button spin still uses chip-spin */
@keyframes chip-spin { to { transform: rotate(360deg); } }
#send {
    flex: 0 0 auto;
    min-width: 64px;
    padding: 8px 14px;
    border: none;
    border-radius: 16px;
    background: #1f2329;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}
/* The triangle icon is written as a CSS escape (\27A4 = ➤): a raw multi-byte character would decode into the mojibake seen online when the
   static asset is served with a single-byte charset header; the escape is pure ASCII and unaffected. */
#send::before { content: "\27A4"; margin-right: 6px; }
/* Streaming: hide the original triangle and text, show the spinning SVG instead (magnetic icon, blue) */
#send .send-spinner { display: none; }
#send.is-busy::before,
#send.is-busy #sendLabel { display: none; }
#send.is-busy .send-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    animation: chip-spin 1s linear infinite;
    transform-origin: center;
}
#send:disabled { opacity: .5; cursor: not-allowed; }
#send.is-busy { opacity: 1; }

@media (max-width: 600px) {
    /* Aligned with the ≤600px padding (12px) of #messages: both modules share the same edges on narrow screens */
    #messages { padding: 12px; }
    #composer { padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
    #composerCard { padding: 12px 12px 10px; border-radius: 14px; }
    #input { font-size: 16px; } /* No zoom on focus in iOS Safari */
    #composerBar { gap: 6px; }
    #composerChips { gap: 6px; }
    .composer-chip { padding: 4px 8px; font-size: 10px; }
    #send { min-width: 56px; padding: 7px 10px; }
}

/* Message rows are generated by the script and styled through class names */
.msg {
    display: flex;
    margin-bottom: 14px;
}
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }
.msg.system { justify-content: center; }

.msg .bubble {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}
.msg.user .bubble { background: var(--primary-soft); }
.msg.assistant .bubble {
    background: #fff;
    border: 1px solid var(--border);
}
.msg.system .bubble {
    max-width: 92%;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
}
@media (max-width: 480px) {
    .msg .bubble { max-width: 88%; font-size: 13px; padding: 9px 12px; }
}
