/* ==========================================================================
   拾光 AI 中枢 —— 页面样式
   PC 与移动端共用。断点 860px 以下切成移动端版式（左侧会话栏变抽屉）。
   ========================================================================== */

.aih {
    --aih-bg: #fbfbfc;
    --aih-panel: #ffffff;
    --aih-line: #ececf0;
    --aih-line-strong: #e0e0e6;
    --aih-ink: #1d1d20;
    --aih-ink-2: #55555f;
    --aih-ink-3: #8e8e99;
    --aih-brand: #6b5cff;
    --aih-brand-soft: #f0eeff;
    --aih-me: #f4f4f7;
    --aih-danger: #e5484d;
    --aih-radius: 14px;

    display: flex;
    height: 100%;
    min-height: 0;
    background: var(--aih-bg);
    color: var(--aih-ink);
    font-size: 14px;
    line-height: 1.62;
    position: relative;
    overflow: hidden;
}

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

/* 整页模式下让容器吃满可视高度。
   PC 端页头页脚是宿主的，先量出来写到 --aih-chrome 上（module.js 在挂载时算一次），
   量不到就退回 100dvh —— 宁可多留一点白，也不要输入框被裁到视口外面。 */
.aih {
    height: var(--aih-height, calc(100dvh - var(--aih-chrome, 0px)));
    max-height: 100%;
}

/* ============================ 骨架 ============================ */

.aih_sk {
    display: block;
    background: linear-gradient(90deg, #eeeef2 25%, #f6f6f9 37%, #eeeef2 63%);
    background-size: 400% 100%;
    animation: aih-shimmer 1.4s ease infinite;
    border-radius: 6px;
}
@keyframes aih-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
.aih_sk-logo { width: 26px; height: 26px; border-radius: 8px; }
.aih_sk-line { height: 10px; }
.aih_sk-dot { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
.aih_sk-btn { display: block; height: 38px; width: 100%; border-radius: 10px; }
.aih_sk-big { width: 200px; height: 24px; }
.aih_sk-input { height: 52px; border-radius: 12px; }

/* ============================ 左侧会话栏 ============================ */

.aih_side {
    width: 264px;
    flex: 0 0 264px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--aih-line);
    background: var(--aih-panel);
    min-height: 0;
}

.aih_side-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 10px;
}
.aih_brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    flex: 1;
}
.aih_brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(140deg, #7c6bff, #b39dff);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 15px;
    flex: 0 0 auto;
}
.aih_brand-text {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aih_side-gear {
    color: var(--aih-ink-3);
    text-decoration: none;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    flex: 0 0 auto;
}
.aih_side-gear:hover { background: var(--aih-me); color: var(--aih-ink); }

.aih_new {
    margin: 0 10px 8px;
    height: 38px;
    border: 1px solid var(--aih-line-strong);
    background: var(--aih-panel);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--aih-ink);
    cursor: pointer;
    transition: background .16s, border-color .16s;
}
.aih_new:hover { background: var(--aih-me); border-color: #d2d2da; }
.aih_new .remix-icon { font-size: 16px; }

.aih_side-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 8px 8px;
    overscroll-behavior: contain;
}
.aih_side-scroll::-webkit-scrollbar { width: 8px; }
.aih_side-scroll::-webkit-scrollbar-thumb {
    background: #dcdce2;
    border-radius: 4px;
    border: 2px solid var(--aih-panel);
}

.aih_side-label {
    font-size: 11px;
    color: var(--aih-ink-3);
    padding: 8px 8px 6px;
    letter-spacing: .02em;
}
.aih_side-empty {
    font-size: 12px;
    color: var(--aih-ink-3);
    padding: 10px 8px;
}

/* 骨架期的占位行：与 .aih_side-item 同高、同缩进，数据回来时不会跳一下 */
.aih_side-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 8px;
}
.aih_side-row .aih_sk-line { flex: 0 0 auto; }

.aih_side-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px;
    border-radius: 9px;
    cursor: pointer;
    color: var(--aih-ink-2);
    position: relative;
}
.aih_side-item:hover { background: var(--aih-me); }
.aih_side-item.is-active {
    background: var(--aih-brand-soft);
    color: var(--aih-brand);
    font-weight: 500;
}
.aih_side-item .remix-icon { font-size: 15px; flex: 0 0 auto; opacity: .8; }
.aih_side-item-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aih_side-del,
.aih_side-ren {
    border: 0;
    background: transparent;
    color: var(--aih-ink-3);
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: none;
    place-items: center;
    flex: 0 0 auto;
    font-size: 14px;
    padding: 0;
}
.aih_side-item:hover .aih_side-del,
.aih_side-item:hover .aih_side-ren { display: grid; }
/* 手机上没有 hover，两个按钮常显，否则根本改不了名 */
@media (hover: none) {
    .aih_side-del,
    .aih_side-ren { display: grid; }
}
.aih_side-del:hover { background: #ffe9e9; color: var(--aih-danger); }
.aih_side-ren:hover { background: var(--aih-line); color: var(--aih-ink); }

.aih_side-foot {
    border-top: 1px solid var(--aih-line);
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.aih_pick { display: flex; align-items: center; gap: 8px; }
.aih_pick-label { font-size: 12px; color: var(--aih-ink-3); flex: 0 0 auto; }
.aih_pick-sel {
    flex: 1;
    min-width: 0;
    height: 30px;
    border: 1px solid var(--aih-line-strong);
    border-radius: 8px;
    background: var(--aih-panel);
    font-size: 12px;
    color: var(--aih-ink);
    padding: 0 6px;
    outline: none;
}
.aih_pick-sel:focus { border-color: var(--aih-brand); }
.aih_usage {
    font-size: 11px;
    color: var(--aih-ink-3);
    display: flex;
    gap: 6px;
    align-items: center;
}
.aih_dot { opacity: .5; }

/* ============================ 主区 ============================ */

.aih_main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--aih-bg);
}

.aih_top {
    height: 52px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid var(--aih-line);
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(8px);
}
.aih_top-menu { display: none; }
.aih_top-title {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aih_top-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.aih_icon-btn {
    border: 0;
    background: transparent;
    color: var(--aih-ink-2);
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 17px;
    padding: 0;
}
.aih_icon-btn:hover { background: var(--aih-me); color: var(--aih-ink); }

.aih_persona-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--aih-ink-2);
    background: var(--aih-me);
    border-radius: 20px;
    padding: 4px 10px 4px 4px;
}
.aih_persona-pick {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.aih_persona-pick select {
    appearance: none;
    border: 1px solid var(--aih-line-strong);
    background: var(--aih-panel);
    border-radius: 20px;
    height: 30px;
    padding: 0 26px 0 10px;
    font-size: 12px;
    color: var(--aih-ink);
    cursor: pointer;
    outline: none;
    max-width: 140px;
}
.aih_persona-pick select:focus { border-color: var(--aih-brand); }
.aih_persona-pick .remix-icon {
    position: absolute;
    right: 6px;
    pointer-events: none;
    font-size: 15px;
    color: var(--aih-ink-3);
}
.aih_persona-ava {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}
.aih_persona-ava--txt {
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, #7c6bff, #b39dff);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

/* ============================ 正文 ============================ */

.aih_body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 0 8px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
.aih_body::-webkit-scrollbar { width: 10px; }
.aih_body::-webkit-scrollbar-thumb {
    background: #dcdce2;
    border-radius: 5px;
    border: 3px solid var(--aih-bg);
}

.aih_msgs {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.aih_msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.aih_msg--me { flex-direction: row-reverse; }

.aih_msg-ava {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 15px;
    margin-top: 2px;
}
.aih_msg-ava--ai {
    background: linear-gradient(140deg, #7c6bff, #b39dff);
    color: #fff;
}
.aih_msg-ava--me { background: var(--aih-me); color: var(--aih-ink-2); }

.aih_msg-col { min-width: 0; max-width: calc(100% - 40px); }
.aih_msg--me .aih_msg-col { display: flex; flex-direction: column; align-items: flex-end; }

.aih_msg-body {
    font-size: 14px;
    color: var(--aih-ink);
    word-break: break-word;
    overflow-wrap: anywhere;
}
.aih_msg--me .aih_msg-body {
    background: var(--aih-me);
    border-radius: 14px 14px 4px 14px;
    padding: 9px 14px;
    max-width: 100%;
}

/* markdown */
.aih_msg-body > *:first-child { margin-top: 0; }
.aih_msg-body > *:last-child { margin-bottom: 0; }
.aih_msg-body p { margin: 0 0 10px; }
.aih_msg-body h2,
.aih_msg-body h3,
.aih_msg-body h4,
.aih_msg-body h5,
.aih_msg-body h6 {
    margin: 18px 0 8px;
    font-weight: 600;
    line-height: 1.4;
}
.aih_msg-body h2 { font-size: 17px; }
.aih_msg-body h3 { font-size: 15.5px; }
.aih_msg-body h4,
.aih_msg-body h5,
.aih_msg-body h6 { font-size: 14px; }
.aih_msg-body ul,
.aih_msg-body ol { margin: 0 0 10px; padding-left: 22px; }
.aih_msg-body li { margin: 3px 0; }
.aih_msg-body blockquote {
    margin: 10px 0;
    padding: 2px 0 2px 12px;
    border-left: 3px solid var(--aih-line-strong);
    color: var(--aih-ink-2);
}
.aih_msg-body hr {
    border: 0;
    border-top: 1px solid var(--aih-line);
    margin: 16px 0;
}
.aih_msg-body a { color: var(--aih-brand); text-decoration: none; }
.aih_msg-body a:hover { text-decoration: underline; }
.aih_msg-body strong { font-weight: 600; }

.aih_inline {
    background: var(--aih-me);
    border-radius: 5px;
    padding: 1px 5px;
    font-size: 12.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #b5385c;
}
.aih_code {
    background: #1e1e24;
    color: #e6e6ec;
    border-radius: 10px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 12.5px;
    line-height: 1.6;
}
.aih_code code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre;
}

.aih_msg-tools {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity .16s;
}
.aih_msg:hover .aih_msg-tools { opacity: 1; }
.aih_msg-tool {
    border: 0;
    background: transparent;
    color: var(--aih-ink-3);
    font-size: 11.5px;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.aih_msg-tool:hover { background: var(--aih-me); color: var(--aih-ink-2); }
.aih_msg-tool .remix-icon { font-size: 13px; }

.aih_msg-err {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    color: var(--aih-danger);
    background: #fff4f4;
    border: 1px solid #ffdcdc;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
}
.aih_msg-err .remix-icon { margin-top: 2px; flex: 0 0 auto; }

.aih_caret {
    display: inline-block;
    width: 7px;
    height: 15px;
    background: var(--aih-brand);
    border-radius: 1px;
    margin-left: 2px;
    vertical-align: -2px;
    animation: aih-blink 1s steps(2) infinite;
}
@keyframes aih-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================ 空态 ============================ */

.aih_body--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px 40px;
}
.aih_hello {
    text-align: center;
    max-width: 560px;
    width: 100%;
}
.aih_hello-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    margin: 0 auto 18px;
    background: linear-gradient(140deg, #7c6bff, #b39dff);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 26px;
    box-shadow: 0 8px 22px -8px rgba(124, 107, 255, .55);
}
.aih_hello h2 {
    font-size: 21px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: -.01em;
}
.aih_hello-note {
    font-size: 13px;
    color: var(--aih-ink-3);
    margin: 0 0 20px;
}
.aih_hello-note--warn { color: #c2410c; }

.aih_hello-tips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 6px;
}
.aih_tip {
    border: 1px solid var(--aih-line-strong);
    background: var(--aih-panel);
    border-radius: 11px;
    padding: 11px 13px;
    font-size: 13px;
    color: var(--aih-ink-2);
    text-align: left;
    cursor: pointer;
    transition: border-color .16s, background .16s, transform .16s;
    line-height: 1.5;
}
.aih_tip:hover {
    border-color: #c8c2ff;
    background: #faf9ff;
    color: var(--aih-ink);
    transform: translateY(-1px);
}

/* ============================ 输入区 ============================ */

.aih_composer {
    flex: 0 0 auto;
    padding: 8px 20px 14px;
    background: var(--aih-bg);
}
.aih_composer-inner {
    max-width: 760px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--aih-panel);
    border: 1px solid var(--aih-line-strong);
    border-radius: var(--aih-radius);
    padding: 8px 8px 8px 14px;
    transition: border-color .16s, box-shadow .16s;
}
.aih_composer-inner:focus-within {
    border-color: #c8c2ff;
    box-shadow: 0 0 0 3px rgba(107, 92, 255, .1);
}
.aih_input {
    flex: 1;
    border: 0;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    color: var(--aih-ink);
    background: transparent;
    max-height: 200px;
    padding: 5px 0;
    min-height: 26px;
}
.aih_input::placeholder { color: var(--aih-ink-3); }
.aih_input:disabled { cursor: not-allowed; }

.aih_send {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: 0;
    background: var(--aih-brand);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 17px;
    transition: background .16s, opacity .16s;
    padding: 0;
}
.aih_send:hover { background: #5a4bea; }
.aih_send:disabled {
    background: var(--aih-line-strong);
    cursor: not-allowed;
}
.aih_send.is-busy { background: var(--aih-ink-2); }
.aih_send.is-busy:hover { background: var(--aih-ink); }

.aih_composer-tip {
    max-width: 760px;
    margin: 6px auto 0;
    font-size: 11.5px;
    color: var(--aih-ink-3);
    min-height: 16px;
    text-align: center;
    opacity: 0;
    transition: opacity .2s;
}
.aih_composer-tip.is-on { opacity: 1; }

/*
 * 剩余次数。只在站长设了「每人每天上限」时出现 ——
 * 不限量时后端给 left = -1，这里直接 hidden，不占位置。
 */
.aih_composer-quota {
    max-width: 760px;
    margin: 2px auto 0;
    font-size: 11.5px;
    color: var(--aih-ink-3);
    text-align: center;
}
.aih_composer-quota.is-out {
    color: #d9534f;
}
.aih_composer-quota[hidden] { display: none !important; }

/*
 * 每轮的账：模型 / 入出 token / 耗时。
 * 刻意做得比正文淡 —— 它是给人核对的，不该抢注意力。
 */
.aih_msg-stat {
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--aih-ink-3);
    font-variant-numeric: tabular-nums;
    letter-spacing: .1px;
}

/* ============================ 错误页 ============================ */

.aih--error {
    display: flex;
    align-items: center;
    justify-content: center;
}
.aih_errbox {
    text-align: center;
    max-width: 400px;
    padding: 24px;
}
.aih_errbox .remix-icon {
    font-size: 36px;
    color: var(--aih-ink-3);
    display: block;
    margin-bottom: 12px;
}
.aih_errbox h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.aih_errbox p { margin: 0 0 18px; font-size: 13px; color: var(--aih-ink-2); }
.aih_btn {
    border: 1px solid var(--aih-line-strong);
    background: var(--aih-panel);
    border-radius: 9px;
    height: 34px;
    padding: 0 16px;
    font-size: 13px;
    cursor: pointer;
    color: var(--aih-ink);
}
.aih_btn:hover { background: var(--aih-me); }
/* 表格里的按钮：撑不满一格，别把行高顶起来 */
.aih_btn--xs {
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 7px;
}
.aih_btn--xs[disabled] { opacity: .6; cursor: default; }
.aih_btn--ghost { background: transparent; }

/* ==========================================================================
   移动端：会话栏变抽屉
   ========================================================================== */

@media (max-width: 860px) {
    .aih_top-menu { display: grid; }

    .aih_side {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 30;
        width: 84%;
        max-width: 300px;
        transform: translateX(-102%);
        transition: transform .26s cubic-bezier(.32, .72, 0, 1);
        box-shadow: 0 0 0 1px rgba(0, 0, 0, .04);
    }
    .aih.is-side-open .aih_side { transform: translateX(0); }
    .aih.is-side-open::after {
        content: '';
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, .28);
        z-index: 25;
        animation: aih-fade .2s ease;
    }
    @keyframes aih-fade { from { opacity: 0; } to { opacity: 1; } }

    .aih_top { padding: 0 10px; gap: 6px; }
    .aih_msgs { padding: 0 14px; gap: 18px; }
    .aih_body { padding-top: 14px; }
    .aih_composer { padding: 6px 12px 10px; }
    .aih_hello-tips { grid-template-columns: 1fr; }
    .aih_hello h2 { font-size: 19px; }
    .aih_persona-pick select { max-width: 100px; }
    .aih_msg-col { max-width: calc(100% - 36px); }
    .aih_msg-tools { opacity: 1; }
}

@media (max-width: 420px) {
    .aih { font-size: 13.5px; }
    .aih_top-title { font-size: 13.5px; }
    .aih_hello-mark { width: 46px; height: 46px; font-size: 22px; border-radius: 14px; }
}

/* 深色模式跟随系统 —— 站点若自己上了 .dark 也认 */
@media (prefers-color-scheme: dark) {
    .aih:not(.aih--light) {
        --aih-bg: #16161a;
        --aih-panel: #1c1c21;
        --aih-line: #2a2a31;
        --aih-line-strong: #35353d;
        --aih-ink: #e9e9ee;
        --aih-ink-2: #a9a9b4;
        --aih-ink-3: #71717e;
        --aih-brand-soft: #262338;
        --aih-me: #26262c;
    }
    .aih:not(.aih--light) .aih_sk {
        background: linear-gradient(90deg, #26262c 25%, #2e2e36 37%, #26262c 63%);
        background-size: 400% 100%;
    }
    .aih:not(.aih--light) .aih_top { background: rgba(28, 28, 33, .85); }
    .aih:not(.aih--light) .aih_msg-err {
        background: #2a1a1c;
        border-color: #43252a;
    }
    .aih:not(.aih--light) .aih_tip:hover { background: #232030; }
    .aih:not(.aih--light) .aih_inline { color: #ff9ab5; }
    .aih:not(.aih--light) .aih_hello-note--warn { color: #fb923c; }
}

/* ==========================================================================
   AI 写作按钮（module.js 全站注入）
   这一段会出现在**全站每一页**（首页快速发布、发帖页、编辑页），
   所以类名一律 aih_gp / aih_gadget 前缀，绝不碰宿主的选择器。

   按钮本体借用站点的 .ls-action-btn（尺寸、hover、间距都由站点决定），
   这里只补一个「这是 AI」的颜色标识 —— 与站内那排灰色图标区分开。
   ========================================================================== */

.aih_gadget-btn {
    color: #6b5cff !important;
    position: relative;
}
.aih_gadget-btn:hover {
    color: #5646e6 !important;
    background: #f2eeff !important;
}
.aih_gadget-btn .remix-icon { font-size: 17px; }

/* 站点若没有 .ls-action-btn（某些主题），退回到自带样式，保证按钮还看得见 */
.aih_gadget-btn:not(.ls-action-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    color: #6b5cff;
}

/* ---------------- 面板 ---------------- */

.aih_gp-mask {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: rgba(20, 20, 26, .18);
    animation: aih-gp-fade .14s ease;
}
@keyframes aih-gp-fade { from { opacity: 0; } to { opacity: 1; } }

.aih_gp {
    position: fixed;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 48px -12px rgba(20, 20, 40, .28), 0 0 0 1px rgba(20, 20, 40, .06);
    padding: 14px;
    font-size: 13px;
    color: #1d1d20;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.6;
    box-sizing: border-box;
    animation: aih-gp-pop .16s cubic-bezier(.34, 1.3, .64, 1);
}
@keyframes aih-gp-pop {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: none; }
}
.aih_gp *, .aih_gp *::before, .aih_gp *::after { box-sizing: border-box; }

.aih_gp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.aih_gp-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}
.aih_gp-title .remix-icon {
    color: #6b5cff;
    font-size: 16px;
}
.aih_gp-x {
    border: 0;
    background: transparent;
    color: #8e8e99;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 15px;
    padding: 0;
}
.aih_gp-x:hover { background: #f4f4f7; color: #1d1d20; }

.aih_gp-hint {
    font-size: 12px;
    color: #6b6b75;
    background: #f7f7fa;
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 10px;
}
.aih_gp-hint b { color: #6b5cff; }

.aih_gp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}
.aih_gp-act {
    border: 1px solid #ececf0;
    background: #fff;
    border-radius: 9px;
    padding: 8px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-family: inherit;
    transition: border-color .14s, background .14s;
}
.aih_gp-act b {
    font-size: 12.5px;
    font-weight: 600;
    color: #1d1d20;
}
.aih_gp-act span {
    font-size: 10.5px;
    color: #8e8e99;
    transform: scale(.94);
}
.aih_gp-act:hover {
    border-color: #cec5ff;
    background: #faf8ff;
}
.aih_gp-act:disabled {
    opacity: .45;
    cursor: not-allowed;
}
.aih_gp-act:disabled:hover { border-color: #ececf0; background: #fff; }

.aih_gp-extra { margin-bottom: 10px; }
.aih_gp-input {
    width: 100%;
    height: 34px;
    border: 1px solid #ececf0;
    border-radius: 9px;
    padding: 0 10px;
    font-size: 12.5px;
    font-family: inherit;
    color: #1d1d20;
    outline: none;
    background: #fcfcfd;
}
.aih_gp-input:focus {
    border-color: #cec5ff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(107, 92, 255, .1);
}
.aih_gp-input::placeholder { color: #a8a8b2; }

.aih_gp-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: #6b6b75;
    padding: 14px 0;
    justify-content: center;
}
.aih_gp-spin {
    width: 14px;
    height: 14px;
    border: 2px solid #e6e2ff;
    border-top-color: #6b5cff;
    border-radius: 50%;
    animation: aih-gp-rot .7s linear infinite;
}
@keyframes aih-gp-rot { to { transform: rotate(360deg); } }

.aih_gp-result {
    max-height: 220px;
    overflow-y: auto;
    background: #fafafc;
    border: 1px solid #f0f0f4;
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.72;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 8px;
}
.aih_gp-result::-webkit-scrollbar { width: 6px; }
.aih_gp-result::-webkit-scrollbar-thumb {
    background: #dcdce2;
    border-radius: 3px;
}

.aih_gp-err {
    color: #e5484d;
    font-size: 12.5px;
    padding: 6px 0;
}

.aih_gp-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.aih_gp-btn {
    height: 30px;
    padding: 0 12px;
    border: 1px solid #ececf0;
    background: #fff;
    border-radius: 8px;
    font-size: 12.5px;
    color: #1d1d20;
    cursor: pointer;
    font-family: inherit;
    transition: background .14s, border-color .14s;
}
.aih_gp-btn:hover { background: #f6f6f9; border-color: #e0e0e6; }
.aih_gp-btn--main {
    background: #6b5cff;
    border-color: #6b5cff;
    color: #fff;
    font-weight: 500;
    flex: 1;
}
.aih_gp-btn--main:hover { background: #5a4bea; border-color: #5a4bea; }
.aih_gp-btn--ghost { color: #6b6b75; }

.aih_gp-foot {
    margin-top: 10px;
    font-size: 11px;
    color: #a8a8b2;
    text-align: center;
}

/* 「已切到 xxx」：用琥珀色，比正文轻、比灰字重，一眼能看到但不抢戏。
   虚线下划提示可以悬停看原因（为什么切了）。 */
.aih_gp-foot .aih_fb {
    color: #c98a16;
    border-bottom: 1px dashed currentColor;
    cursor: help;
}

@media (max-width: 520px) {
    .aih_gp {
        left: 12px !important;
        right: 12px;
        width: auto;
        max-width: none;
    }
    .aih_gp-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
 * 手机壳（mbshell.js）
 *
 * 与电脑壳同前缀不同命名空间：电脑壳是 .aih_*，手机壳是 .aihm*。
 * 两套 CSS 同在一个文件里，宿主只加载一份，省一次请求。
 * ========================================================================== */

/* ==========================================================================
   拾光 AI 中枢 —— 手机端
   类名一律 aihm 前缀，绝不碰宿主的样式。
   整页三段式：固定页头 / 可滚动消息区 / 底部输入条（吸底，避开安全区）。
   ========================================================================== */

.aihm {
    --aihm-bg: #f7f7fa;
    --aihm-card: #fff;
    --aihm-line: #ececf2;
    --aihm-text: #1b1c22;
    --aihm-sub: #8b8d99;
    --aihm-brand: #6b5cff;
    --aihm-brand-soft: #f0edff;
    --aihm-h: 100%;

    position: relative;
    display: flex;
    flex-direction: column;
    height: var(--aihm-h);
    min-height: 0;
    background: var(--aihm-bg);
    color: var(--aihm-text);
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
    .aihm {
        --aihm-bg: #131418;
        --aihm-card: #1c1d23;
        --aihm-line: #2a2c34;
        --aihm-text: #e8e9ee;
        --aihm-sub: #8b8d99;
        --aihm-brand-soft: #241f45;
    }
}

/* ---------------------------------------------------------------- 页头 */

.aihm-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 8px;
    background: var(--aihm-card);
    border-bottom: 1px solid var(--aihm-line);
    position: relative;
    z-index: 3;
}

.aihm-head-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--aihm-text);
    font-size: 19px;
    border-radius: 10px;
    cursor: pointer;
}
.aihm-head-btn:active { background: var(--aihm-brand-soft); }

.aihm-head-mid {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.25;
}
.aihm-head-title {
    font-size: 15px;
    font-weight: 600;
}
.aihm-head-sub {
    font-size: 11px;
    color: var(--aihm-sub);
}

/* ---------------------------------------------------------------- 消息区 */

.aihm-msgs {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px 18px;
    scroll-behavior: smooth;
}

.aihm-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    align-items: flex-start;
}

.aihm-msg.is-user {
    justify-content: flex-end;
}

.aihm-bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 16px;
    line-height: 1.6;
    word-break: break-word;
    white-space: normal;
}

.aihm-msg.is-user .aihm-bubble {
    background: var(--aihm-brand);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.aihm-msg.is-ai .aihm-bubble {
    background: var(--aihm-card);
    border: 1px solid var(--aihm-line);
    border-bottom-left-radius: 5px;
}

.aihm-avatar {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7b6cff, #a78bfa);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

/* 气泡里的富文本 */
.aihm-bubble p { margin: 0 0 8px; }
.aihm-bubble p:last-child { margin-bottom: 0; }
.aihm-bubble h3, .aihm-bubble h4 {
    margin: 10px 0 6px;
    font-size: 15px;
    font-weight: 600;
}
.aihm-bubble ul { margin: 6px 0; padding-left: 20px; }
.aihm-bubble li { margin: 3px 0; }
.aihm-bubble blockquote {
    margin: 8px 0;
    padding: 6px 10px;
    border-left: 3px solid var(--aihm-brand);
    background: var(--aihm-brand-soft);
    border-radius: 0 8px 8px 0;
    color: var(--aihm-sub);
}
.aihm-inline {
    background: rgba(107, 92, 255, .1);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: .92em;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.aihm-code {
    margin: 8px 0;
    padding: 10px 12px;
    background: #1e1f26;
    color: #e6e6ef;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.55;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* 打字光标 */
.aihm-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--aihm-brand);
    vertical-align: -2px;
    margin-left: 2px;
    animation: aihm-blink .9s steps(2) infinite;
}
@keyframes aihm-blink { 50% { opacity: 0; } }

.aihm-msg-err {
    margin-top: 8px;
    padding: 8px 10px;
    background: #fff2f2;
    border: 1px solid #ffd4d4;
    border-radius: 9px;
    color: #c0392b;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.aihm-msg-err button {
    flex: 0 0 auto;
    border: 0;
    background: #c0392b;
    color: #fff;
    border-radius: 7px;
    padding: 5px 11px;
    font-size: 12.5px;
}

/* ---------------------------------------------------------------- 空态 */

.aihm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 44px 20px 20px;
    text-align: center;
}
.aihm-empty-ico {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7b6cff, #a78bfa);
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.aihm-empty h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 20px;
    line-height: 1.5;
}
.aihm-sugs {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
    max-width: 340px;
}
.aihm-sug {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    background: var(--aihm-card);
    border: 1px solid var(--aihm-line);
    border-radius: 12px;
    color: var(--aihm-text);
    font-size: 14px;
    line-height: 1.4;
}
.aihm-sug:active { background: var(--aihm-brand-soft); }

/* ---------------------------------------------------------------- 输入条 */

.aihm-composer {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--aihm-card);
    border-top: 1px solid var(--aihm-line);
    /* 剩余次数要能当这一行的第一行，所以允许换行 */
    flex-wrap: wrap;
}

/*
 * 剩余次数。手机屏幕上一行值钱，所以只在不限量时才藏、有数字时才出现。
 * 用 order 把它顶到输入框上方，而不用绝对定位 —— 绝对定位会盖住输入框。
 */
.aihm-quota {
    order: -1;
    flex: 1 0 100%;
    text-align: center;
    font-size: 11.5px;
    color: var(--aihm-sub);
    line-height: 1.5;
    padding-bottom: 2px;
}
.aihm-quota.is-out { color: #c0392b; }
.aihm-quota[hidden] { display: none !important; }

/* 每轮的账。手机上比电脑更小一号，别抢走正文的行数。 */
.aihm-msg-stat {
    margin-top: 5px;
    font-size: 10.5px;
    line-height: 1.4;
    color: var(--aihm-sub);
    font-variant-numeric: tabular-nums;
}

.aihm-input {
    flex: 1 1 auto;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid var(--aihm-line);
    border-radius: 20px;
    background: var(--aihm-bg);
    color: var(--aihm-text);
    font-size: 15px;
    line-height: 1.45;
    resize: none;
    outline: none;
    font-family: inherit;
}
.aihm-input:focus {
    border-color: var(--aihm-brand);
    background: var(--aihm-card);
}

.aihm-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--aihm-brand);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity .15s, transform .15s;
}
.aihm-send:disabled { opacity: .35; }
.aihm-send:active:not(:disabled) { transform: scale(.94); }
.aihm-stop {
    background: #e05b5b;
    font-size: 13px;
}

/* ---------------------------------------------------------------- 登录拦截 */

/*
 * hidden 属性必须能压住 display:flex —— 否则「已经登录」也会一直显示登录引导。
 * 这是 HTML 层面的通用坑：display 是作者样式，优先级高于 UA 的 [hidden]{display:none}。
 */
.aihm [hidden],
.aihm-gate[hidden],
.aihm-send[hidden] {
    display: none !important;
}

.aihm-gate {
    position: absolute;
    inset: 52px 0 0 0;
    background: var(--aihm-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
}
.aihm-gate-box { text-align: center; padding: 0 28px; }
.aihm-gate-ico { font-size: 40px; margin-bottom: 12px; }
.aihm-gate-box h3 { font-size: 17px; margin: 0 0 8px; }
.aihm-gate-box p { color: var(--aihm-sub); font-size: 14px; margin: 0 0 20px; }

.aihm-btn {
    display: inline-block;
    padding: 11px 26px;
    border: 0;
    border-radius: 22px;
    background: var(--aihm-brand);
    color: #fff;
    font-size: 15px;
    font-weight: 500;
}

/* ---------------------------------------------------------------- 抽屉 */

.aihm-drawer {
    position: absolute;
    inset: 0;
    z-index: 9;
    pointer-events: none;
    visibility: hidden;
}
.aihm.is-drawer .aihm-drawer {
    pointer-events: auto;
    visibility: visible;
}

.aihm-drawer-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .38);
    opacity: 0;
    transition: opacity .22s;
}
.aihm.is-drawer .aihm-drawer-mask { opacity: 1; }

.aihm-drawer-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 78%;
    max-width: 300px;
    background: var(--aihm-card);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.22, .8, .3, 1);
    box-shadow: 2px 0 16px rgba(0, 0, 0, .1);
}
.aihm.is-drawer .aihm-drawer-panel { transform: translateX(0); }

.aihm-drawer-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 10px;
    font-size: 15px;
    font-weight: 600;
}
.aihm-drawer-head button {
    border: 0;
    background: transparent;
    font-size: 22px;
    color: var(--aihm-sub);
    line-height: 1;
    padding: 0 4px;
}

.aihm-new {
    flex: 0 0 auto;
    margin: 4px 12px 10px;
    padding: 11px;
    border: 1px dashed var(--aihm-brand);
    border-radius: 11px;
    background: var(--aihm-brand-soft);
    color: var(--aihm-brand);
    font-size: 14px;
    font-weight: 500;
}

.aihm-sess {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 10px;
    -webkit-overflow-scrolling: touch;
}
.aihm-sess-empty {
    padding: 26px 0;
    text-align: center;
    color: var(--aihm-sub);
    font-size: 13px;
}
.aihm-sess-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 11px 12px;
    margin-bottom: 4px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--aihm-text);
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.aihm-sess-item.is-on {
    background: var(--aihm-brand-soft);
    color: var(--aihm-brand);
    font-weight: 500;
}

.aihm-drawer-foot {
    flex: 0 0 auto;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--aihm-line);
    font-size: 13px;
    color: var(--aihm-sub);
}
.aihm-me { font-weight: 500; color: var(--aihm-text); }

/* ---------------------------------------------------------------- 载入 / 错误 */

.aihm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    gap: 14px;
    color: #8b8d99;
    font-size: 14px;
}
.aihm-spin {
    width: 26px;
    height: 26px;
    border: 2.5px solid #e6e2ff;
    border-top-color: #6b5cff;
    border-radius: 50%;
    animation: aihm-rot .8s linear infinite;
}
@keyframes aihm-rot { to { transform: rotate(360deg); } }

.aihm-err {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 70vh;
    padding: 0 30px;
    text-align: center;
}
.aihm-err-ico {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff2f2;
    color: #c0392b;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.aihm-err h3 { font-size: 16px; margin: 0 0 8px; }
.aihm-err p { color: #8b8d99; font-size: 13.5px; margin: 0 0 20px; }

/* ---------------------------------------------------- 手机壳在真实页面里的定位 */

/*
 * 手机壳挂在站点内容区里，视口高度得自己撑：宿主给了 fixed 页头和底部导航，
 * 用 100dvh 减去它们不现实（站点头部高度会变），改成用 JS 写死 --aihm-h。
 * 这里只兜底：没有 JS 值时按视口八成算，至少不会塌成一条线。
 */
body.aih-mb-on .aihm {
    --aihm-h: var(--aih-mb-h, calc(100dvh - 120px));
}

/* 手机壳自己滚，外层别跟着滚 —— 否则底部输入条会被浏览器地址栏遮住 */
body.aih-mb-on {
    overflow: hidden;
}

body.aih-mb-on .ls-page-body,
html.aih-mb-html body {
    padding-bottom: 0 !important;
}

/* 小屏上电脑壳的骨架（如果先画出来了）不该占位 */
body.aih-mb-on .aih {
    display: none !important;
}

/* 会话项里的删除按钮：平时淡，按下去才明显 */
.aihm-sess-del {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--aihm-sub);
    border-radius: 8px;
    cursor: pointer;
    opacity: .55;
}

.aihm-sess-del:active {
    opacity: 1;
    background: rgba(255, 92, 92, .12);
    color: #e5484d;

}

/* 重命名按钮和删除长得一样，只是按下去不变红 —— 它不是破坏性操作 */
.aihm-sess-del[data-ren-session]:active {
    background: rgba(0, 0, 0, .06);
    color: var(--aihm-text);
}

/* 手机壳自己的错误页（后端挂了 / 取数失败） */
.aihm-err {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
    color: #1b1c22;
}

.aihm-err h3 {
    margin: 0;
    font-size: 17px;
}

.aihm-err p {
    margin: 0;
    color: #8b8d99;
    font-size: 14px;
    line-height: 1.6;
}

.aihm-empty-tip {
    margin: 6px 0 0;
    color: #8b8d99;
    font-size: 14px;
}

/* -------------------------------------------------------------------------
 * 手机壳铺满视口
 *
 * 不能靠 flex / 100% 撑：手机壳挂在 body 下，body 里还有站点自己的 fixed 页头、
 * 底部 tab、广告浮钮、迷你音乐条，那些东西一起参与布局会把高度算歪（实测只剩 269px）。
 * 也不适合直接写 top/bottom:0 全屏 —— 那样会盖住站点的底部 tab，用户回不去别的页。
 *
 * 所以取中间态：固定定位，从视口顶到底部 tab 之上；高度由 JS 每 180ms 校正一次。
 * 断点与模块里的视口判定保持一致（这里只管样式，判定在 JS）。
 * ---------------------------------------------------------------------- */

body.aih-mb-on .aihm {
    position: fixed;
    top: var(--aihm-top, 0px);
    left: 0;
    right: 0;
    bottom: var(--aihm-bottom, 0px);
    z-index: 30;
    height: auto;
    min-height: 0;
    /* 让底部输入条避开刘海屏与浏览器工具栏 */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* 站点自己的悬浮件压到手机壳下面：广告浮钮、迷你音乐条、回到顶部之类 */
body.aih-mb-on .ads-fab,
body.aih-mb-on .ls-mini-music,
body.aih-mb-on [class*="back-top"],
body.aih-mb-on [class*="go-top"] {
    z-index: 20;
}

/* 输入条永远在最上层，别被任何悬浮件挡操作 */
body.aih-mb-on .aihm-composer {
    position: relative;
    z-index: 32;
}

/* 手机壳里不再需要站点给 body 留的顶部空隙 */
body.aih-mb-on {
    padding-top: 0 !important;
}

/* ============================ 诊断抽屉（管理员） ============================ */

.aih_side-diag {
    display: flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: var(--aih-ink-3);
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}
.aih_side-diag:hover { background: var(--aih-me); color: var(--aih-ink); }
.aih_side-diag[hidden] { display: none !important; }

.aih_diag[hidden] { display: none !important; }
.aih_diag {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.aih_diag-mask {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 24, .34);
}
.aih_diag-box {
    position: relative;
    width: min(920px, 100%);
    max-height: min(78vh, 720px);
    background: var(--aih-panel);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.aih_diag-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 12px 18px;
    border-bottom: 1px solid var(--aih-line);
}
.aih_diag-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.aih_diag-act { display: flex; align-items: center; gap: 6px; }
.aih_diag-body {
    overflow: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}
.aih_diag-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--aih-ink-3);
    font-size: 13px;
    line-height: 1.7;
}
.aih_diag-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.aih_diag-tbl th {
    position: sticky;
    top: 0;
    background: var(--aih-panel);
    text-align: left;
    font-weight: 500;
    color: var(--aih-ink-3);
    font-size: 11.5px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--aih-line);
    white-space: nowrap;
}
.aih_diag-tbl td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--aih-line);
    vertical-align: top;
    color: var(--aih-ink-2);
}
.aih_diag-tbl tbody tr:hover { background: #fafafd; }
.aih_diag-tbl .num { text-align: right; white-space: nowrap; }
.aih_diag-tbl .mono {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--aih-ink-3);
}
.aih_diag-tbl .q {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.aih_diag-tbl .res { white-space: nowrap; }
.aih_diag-ok { color: #2f9e44; }
.aih_diag-bad { color: var(--aih-danger); }
.aih_diag-wait { color: var(--aih-ink-3); }
.aih_diag-tbl .act { text-align: right; white-space: nowrap; }
/* 模型那张表的「结果」列要能放下一句中文，别被 nowrap 挤成一条 */
.aih_diag-tbl--model .res { white-space: normal; max-width: 240px; }
.aih_diag-hint {
    padding: 10px 12px 2px;
    font-size: 12px;
    color: var(--aih-ink-3);
}
.aih_diag-tbl tr.is-errrow td {
    padding-top: 0;
    background: #fdf4f4;
}
.aih_diag-tbl tr.is-errrow code {
    display: block;
    font-size: 11.5px;
    line-height: 1.6;
    color: #a33;
    white-space: pre-wrap;
    word-break: break-all;
    user-select: text;
}

@media (max-width: 720px) {
    .aih_diag { padding: 0; align-items: flex-end; }
    .aih_diag-box {
        width: 100%;
        max-height: 86vh;
        border-radius: 16px 16px 0 0;
    }
    .aih_diag-tbl .q { max-width: 130px; }
}

/* ================================================================
   手机壳：页签 + 写作面板
   ================================================================ */

.aihm-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    background: var(--aihm-bg, #fff);
}

.aihm-tab {
    flex: 0 0 auto;
    padding: 8px 16px 10px;
    border: 0;
    background: none;
    font-size: 14px;
    color: #8a8a95;
    cursor: pointer;
    position: relative;
}

.aihm-tab.is-on {
    color: #3d3d46;
    font-weight: 600;
}

/* 选中态那条短横线：只贴着字的宽度，不要拉满，拉满像导航栏 */
.aihm-tab.is-on::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 20px;
    height: 3px;
    margin-left: -10px;
    border-radius: 3px 3px 0 0;
    background: #6d5bd0;
}

.aihm-write {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
}

.aihm-w-src {
    position: relative;
    background: #f6f6f8;
    border-radius: 12px;
    padding: 10px 12px 26px;
}

.aihm-w-text {
    width: 100%;
    min-height: 120px;
    max-height: 42vh;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.7;
    color: #2f2f36;
    font-family: inherit;
}

.aihm-w-count {
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 11px;
    color: #a0a0ac;
}

.aihm-w-count.is-over { color: #d9534f; }

.aihm-w-extra {
    width: 100%;
    margin-top: 10px;
    padding: 11px 12px;
    border: 1px solid #e6e6ec;
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.aihm-w-extra:focus { border-color: #b9aef0; }

.aihm-w-acts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.aihm-w-act {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 12px;
    border: 1px solid #ececf1;
    border-radius: 12px;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.aihm-w-act b {
    font-size: 14px;
    font-weight: 600;
    color: #3d3d46;
}

.aihm-w-act span {
    font-size: 11.5px;
    color: #9a9aa6;
    line-height: 1.45;
}

.aihm-w-act:disabled { opacity: .45; cursor: not-allowed; }

.aihm-w-act:not(:disabled):active {
    background: #f4f2ff;
    border-color: #cfc6f5;
}

.aihm-w-tip {
    grid-column: 1 / -1;
    padding: 14px;
    text-align: center;
    font-size: 13px;
    color: #9a9aa6;
}

.aihm-w-out { margin-top: 14px; }

.aihm-w-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 0;
    font-size: 13px;
    color: #8a8a95;
}

.aihm-w-result {
    padding: 13px 14px;
    border-radius: 12px;
    background: #f7f6ff;
    border: 1px solid #e7e3fb;
    font-size: 15px;
    line-height: 1.75;
    color: #2f2f36;
    white-space: pre-wrap;
    word-break: break-word;
    /* 复制失败时用户要能手选，所以别禁选 */
    user-select: text;
}

.aihm-w-bar {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.aihm-w-btn {
    flex: 1 1 auto;
    padding: 10px 12px;
    border: 1px solid #e6e6ec;
    border-radius: 10px;
    background: #fff;
    font-size: 13.5px;
    color: #4a4a54;
    cursor: pointer;
    font-family: inherit;
}

.aihm-w-btn--main {
    flex: 1.4 1 auto;
    background: #6d5bd0;
    border-color: #6d5bd0;
    color: #fff;
    font-weight: 600;
}

.aihm-w-btn--ghost { flex: 0 0 auto; color: #8a8a95; }

.aihm-w-foot {
    margin-top: 8px;
    font-size: 11px;
    color: #a8a8b2;
    text-align: center;
}

/* 极轻的浮动提示：不挡内容、不打断操作 */
.aihm-toast {
    position: fixed;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    max-width: 78vw;
    padding: 9px 15px;
    border-radius: 20px;
    background: rgba(38, 38, 44, .9);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    z-index: 100200;
    animation: aihm-toast-in .18s ease-out;
}

@keyframes aihm-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* `hidden` 属性会被上面的 display 规则盖掉（CSS 优先级高于属性），
   写作面板和消息区都靠它切换，所以显式压一条。别删。 */
.aihm-write[hidden],
.aihm-msgs[hidden],
.aihm-composer[hidden] {
    display: none !important;
}

/* 诊断面板的「对话 / 写作」切换 */
.aih_diag-tabs {
    display: flex;
    gap: 6px;
    padding: 0 18px 12px;
    border-bottom: 1px solid #eeeef3;
}

.aih_diag-tab {
    padding: 6px 14px;
    border: 1px solid #e6e6ec;
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    color: #6b6b76;
    cursor: pointer;
}

.aih_diag-tab.is-on {
    background: #f1eefd;
    border-color: #cfc6f5;
    color: #5b48c8;
    font-weight: 600;
}
