/* ============================================================
   XINGHUOS 星火跨境 AI 工作台
   布局参考豆包 Web 版：全宽 · 固定左侧栏 · 居中对话列 · 底部输入舱
   视觉沿用插件 DESIGN.md：莫兰迪橙 + 淡蓝、毛玻璃、圆润年轻
   ============================================================ */
:root {
    --orange: #E8A87C;
    --orange-deep: #D4845A;
    --orange-soft: #F5D5BC;
    --blue: #A8C8D8;
    --blue-soft: #D4E6EF;
    --ink: #2F2A26;
    --ink-2: #5C554E;
    --ink-3: #8E867D;
    --line: rgba(212, 132, 90, 0.16);
    --line-2: rgba(0, 0, 0, 0.07);
    --bg: #FBF7F2;
    --panel: #FFFFFF;
    --panel-soft: #FDFAF6;
    --glass: rgba(255, 255, 255, 0.72);
    --gradient: linear-gradient(135deg, #F5D5BC 0%, #D4E6EF 100%);
    --gradient-btn: linear-gradient(135deg, #E8A87C 0%, #D4845A 100%);
    --shadow-sm: 0 2px 10px rgba(212, 132, 90, 0.08);
    --shadow: 0 8px 30px rgba(212, 132, 90, 0.14);
    --shadow-lg: 0 18px 56px rgba(212, 132, 90, 0.2);
    --r-lg: 18px;
    --r-md: 12px;
    --r-sm: 8px;
    --sidebar-w: 268px;
    --col-w: 860px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* 防止组件类的 display 声明覆盖 hidden 属性 */
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(212, 132, 90, 0.28); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212, 132, 90, 0.45); }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; height: 100vh; width: 100vw; }

/* ================= 左侧边栏 ================= */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    height: 100%;
    background: var(--panel);
    border-right: 1px solid var(--line-2);
    display: flex;
    flex-direction: column;
    padding: 14px 12px 10px;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 60;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; flex: 1; }
.brand-mark { display: block; width: 32px; height: 32px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-en { font-size: 9.5px; font-weight: 600; letter-spacing: 2.8px; color: var(--ink-3); text-transform: uppercase; }
.brand-cn { font-size: 14.5px; font-weight: 700; color: var(--ink); letter-spacing: 0.5px; white-space: nowrap; }
.brand:hover .brand-cn { color: var(--orange-deep); }
.icon-btn {
    width: 32px; height: 32px; border: none; background: transparent;
    color: var(--ink-3); border-radius: var(--r-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.icon-btn:hover { background: var(--orange-soft); color: var(--orange-deep); }

.new-chat-btn {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    width: 100%; padding: 11px 0; margin-bottom: 12px;
    border: none; border-radius: var(--r-md);
    background: var(--gradient-btn); color: #fff;
    font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: 0 6px 18px rgba(212, 132, 90, 0.3);
    transition: all 0.2s;
}
.new-chat-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.new-chat-btn:active { transform: translateY(0); }

.sidebar-search {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 11px; margin-bottom: 10px;
    background: var(--panel-soft);
    border: 1px solid var(--line-2);
    border-radius: var(--r-md);
    color: var(--ink-3);
}
.sidebar-search input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 13px; color: var(--ink);
}
.sidebar-search input::placeholder { color: var(--ink-3); }

.history-list { flex: 1; overflow-y: auto; padding: 2px 2px 8px; }
.history-group-label {
    font-size: 11px; color: var(--ink-3); font-weight: 600;
    padding: 10px 8px 5px; letter-spacing: 0.5px;
}
.history-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px; margin-bottom: 2px;
    border-radius: var(--r-sm); cursor: pointer;
    color: var(--ink-2); font-size: 13px;
    transition: background 0.18s;
    position: relative;
}
.history-item:hover { background: var(--panel-soft); }
.history-item.active {
    background: linear-gradient(135deg, rgba(232, 168, 124, 0.16), rgba(168, 200, 216, 0.18));
    color: var(--orange-deep); font-weight: 600;
}
.history-item .h-title {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item .h-mode { font-size: 12px; flex-shrink: 0; opacity: 0.75; }
.history-item .h-actions { display: none; gap: 2px; flex-shrink: 0; }
.history-item:hover .h-actions { display: flex; }
.h-act {
    width: 22px; height: 22px; border: none; background: transparent;
    border-radius: 5px; color: var(--ink-3); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.h-act:hover { background: var(--orange-soft); color: var(--orange-deep); }
.history-empty { text-align: center; color: var(--ink-3); font-size: 12px; padding: 26px 10px; }

.sidebar-foot {
    display: flex; align-items: center; gap: 8px;
    margin-top: auto;
    padding-top: 10px; border-top: 1px solid var(--line-2);
}
.points-badge {
    flex: 1; display: flex; align-items: center; gap: 5px;
    padding: 8px 12px; border-radius: 999px;
    background: var(--gradient); cursor: pointer;
    font-size: 12px; transition: all 0.2s;
}
.points-badge:hover { box-shadow: var(--shadow-sm); }
.points-icon { color: var(--orange-deep); }
.points-value { font-weight: 700; color: var(--orange-deep); }
.points-unit { color: var(--ink-2); }

.sidebar-mask {
    display: none; position: fixed; inset: 0;
    background: rgba(47, 42, 38, 0.4); z-index: 55;
}

/* ================= 主区域 ================= */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; position: relative; }

/* 顶栏 */
.topbar {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line-2);
    background: var(--glass);
    backdrop-filter: saturate(3) blur(18px);
    -webkit-backdrop-filter: saturate(3) blur(18px);
    z-index: 20;
}
.topbar-menu { display: none; }
.topbar-spacer { flex: 1; }

/* 模式分段（对话/作图） */
.mode-seg {
    display: flex; padding: 3px; gap: 2px;
    background: rgba(0, 0, 0, 0.05); border-radius: 999px;
}
.mode-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 16px; border: none; border-radius: 999px;
    background: transparent; color: var(--ink-3);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.mode-btn.active {
    background: #fff; color: var(--orange-deep);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

/* 智能体胶囊 */
.agent-seg { display: flex; gap: 4px; }
.agent-btn {
    padding: 6px 13px; border: 1px solid var(--line);
    border-radius: 999px; background: var(--panel);
    color: var(--ink-2); font-size: 12px; cursor: pointer;
    transition: all 0.22s; white-space: nowrap;
}
.agent-btn:hover { border-color: var(--orange); color: var(--orange-deep); }
.agent-btn.active {
    background: linear-gradient(135deg, #E8A87C, #D4796A);
    border-color: transparent; color: #fff; font-weight: 600;
    box-shadow: 0 3px 10px rgba(232, 168, 124, 0.35);
}

/* 开关 */
.switch-wrap { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.switch-label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0; border-radius: 999px;
    background: rgba(0, 0, 0, 0.14); transition: 0.25s;
}
.slider::before {
    content: ''; position: absolute; width: 16px; height: 16px;
    left: 2px; top: 2px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); transition: 0.25s;
}
.switch input:checked + .slider { background: var(--orange); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* 模型下拉 */
.model-select-wrap { position: relative; }
.model-select {
    appearance: none; -webkit-appearance: none;
    padding: 7px 30px 7px 12px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E867D' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
    font-size: 12px; color: var(--ink-2); cursor: pointer; outline: none;
    max-width: 210px; transition: border-color 0.2s;
}
.model-select:hover { border-color: var(--orange); }

/* ================= 消息区 ================= */
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-column { max-width: var(--col-w); margin: 0 auto; padding: 26px 24px 20px; min-height: 100%; display: flex; flex-direction: column; }

/* 欢迎空态（豆包式建议卡片） */
.welcome { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px 0 30px; }
.welcome-hello {
    font-size: 30px; font-weight: 700; margin-bottom: 6px;
    background: linear-gradient(120deg, var(--orange-deep), var(--blue));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.welcome-sub { color: var(--ink-3); font-size: 14px; margin-bottom: 26px; }
.suggest-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.suggest-card {
    text-align: left; padding: 16px;
    border: 1px solid var(--line-2); border-radius: var(--r-lg);
    background: var(--panel); cursor: pointer;
    transition: all 0.22s;
}
.suggest-card:hover {
    border-color: var(--orange);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.suggest-card .sc-icon { margin-bottom: 10px; color: var(--orange-deep); display: flex; }
.suggest-card .sc-title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.suggest-card .sc-desc { font-size: 12px; color: var(--ink-3); line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 消息 */
.msg { display: flex; gap: 12px; margin-bottom: 26px; animation: msgIn 0.3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
    width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
}
.msg.assistant .msg-avatar { background: var(--gradient); }
.msg.user .msg-avatar { background: var(--blue); }
.msg-main { min-width: 0; max-width: calc(100% - 52px); display: flex; flex-direction: column; }
.msg.user .msg-main { align-items: flex-end; }
.msg-bubble {
    padding: 12px 16px; border-radius: var(--r-lg);
    font-size: 14px; word-break: break-word; overflow-wrap: anywhere;
}
.msg.assistant .msg-bubble {
    background: var(--panel);
    border: 1px solid var(--line-2);
    border-top-left-radius: 5px;
    box-shadow: var(--shadow-sm);
}
.msg.user .msg-bubble {
    background: var(--gradient-btn); color: #fff;
    border-top-right-radius: 5px;
    box-shadow: 0 4px 14px rgba(212, 132, 90, 0.25);
}
.msg.user .msg-bubble a { color: #fff; text-decoration: underline; }
.msg-meta {
    display: flex; align-items: center; gap: 8px;
    margin-top: 6px; font-size: 11px; color: var(--ink-3);
}
.msg-acts { display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s; }
.msg:hover .msg-acts { opacity: 1; }
.msg-act {
    width: 26px; height: 26px; border: none; background: transparent;
    border-radius: 6px; color: var(--ink-3); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.msg-act:hover { background: var(--orange-soft); color: var(--orange-deep); }

/* Markdown 排版 */
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 8px; line-height: 1.35; font-weight: 700; }
.md h1 { font-size: 19px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15.5px; } .md h4 { font-size: 14px; }
.md ul, .md ol { padding-left: 22px; margin: 6px 0; }
.md li { margin: 3px 0; }
.md strong { font-weight: 700; }
.md a { color: var(--orange-deep); text-decoration: none; border-bottom: 1px solid rgba(212, 132, 90, 0.4); }
.md blockquote {
    border-left: 3px solid var(--orange);
    background: rgba(232, 168, 124, 0.1);
    padding: 8px 12px; margin: 8px 0; border-radius: 0 var(--r-sm) var(--r-sm) 0;
    color: var(--ink-2);
}
.md code {
    background: rgba(212, 132, 90, 0.12);
    padding: 2px 6px; border-radius: 5px;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12.5px; color: var(--orange-deep);
}
.md pre {
    position: relative;
    background: #2F2A26; color: #F3ECE4;
    padding: 14px 14px 12px; border-radius: var(--r-md);
    overflow-x: auto; margin: 10px 0;
}
.md pre code { background: none; color: inherit; padding: 0; font-size: 12.5px; line-height: 1.6; }
.md .code-copy {
    position: absolute; top: 7px; right: 7px;
    border: none; border-radius: 6px; padding: 3px 9px;
    background: rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.85);
    font-size: 11px; cursor: pointer;
}
.md .code-copy:hover { background: rgba(255, 255, 255, 0.26); }
.md table { border-collapse: collapse; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.md th { background: rgba(232, 168, 124, 0.14); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--line-2); margin: 14px 0; }
.md img { max-width: 100%; border-radius: var(--r-sm); }

/* 打字指示器 */
.typing { display: flex; gap: 5px; padding: 5px 2px; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--orange);
    animation: typing 1.4s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* 图片消息 */
.img-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 4px; }
.img-grid.single { grid-template-columns: 1fr; max-width: 360px; }
.img-cell {
    position: group; border-radius: var(--r-md); overflow: hidden;
    border: 1px solid var(--line-2); background: var(--panel-soft);
}
.img-cell img { width: 100%; display: block; cursor: zoom-in; }
.img-cell .img-ops {
    display: flex; gap: 6px; padding: 7px 9px;
}
.img-op-btn {
    flex: 1; padding: 5px 0; border: 1px solid var(--line);
    border-radius: 7px; background: var(--panel);
    font-size: 12px; color: var(--ink-2); cursor: pointer;
    text-decoration: none; text-align: center;
    transition: all 0.18s;
}
.img-op-btn:hover { border-color: var(--orange); color: var(--orange-deep); background: var(--panel-soft); }
.img-loading {
    grid-column: 1 / -1; padding: 34px; text-align: center;
    color: var(--ink-3); font-size: 13px;
    border: 1px dashed var(--line); border-radius: var(--r-md);
}
.img-loading .spin {
    width: 26px; height: 26px; margin: 0 auto 10px;
    border: 3px solid var(--orange-soft); border-top-color: var(--orange-deep);
    border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 底部输入舱 ================= */
.composer-zone {
    flex-shrink: 0;
    padding: 8px 24px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 78%, rgba(251, 247, 242, 0));
}
.composer-column { max-width: var(--col-w); margin: 0 auto; }

/* 作图参数 */
.image-controls {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 0 4px 8px;
}
.ratio-row, .count-seg { display: flex; gap: 5px; flex-wrap: wrap; }
.ic-label { font-size: 12px; color: var(--ink-3); margin-right: 2px; }
.ratio-btn, .count-btn {
    padding: 4px 11px; border: 1px solid var(--line-2);
    border-radius: 999px; background: var(--panel);
    font-size: 12px; color: var(--ink-2); cursor: pointer;
    transition: all 0.18s;
}
.ratio-btn:hover, .count-btn:hover { border-color: var(--orange); }
.ratio-btn.active, .count-btn.active {
    background: var(--gradient-btn); border-color: transparent;
    color: #fff; font-weight: 600;
}
.ic-points {
    margin-left: auto; font-size: 12px; color: var(--orange-deep);
    background: var(--gradient); padding: 3px 10px; border-radius: 999px; font-weight: 600;
}

/* ================= 积分中心弹窗 ================= */
.modal.points-modal { max-width: 420px; text-align: left; padding: 20px 22px; }
.pm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pm-title { font-size: 16px; font-weight: 700; }
.pm-close { flex: none; padding: 6px 14px; }
.pm-balance {
    display: flex; align-items: baseline; gap: 6px; justify-content: center;
    padding: 14px 0 10px; border-radius: var(--r-md);
    background: var(--gradient);
}
.pm-num { font-size: 30px; font-weight: 800; color: var(--orange-deep); }
.pm-unit { font-size: 12px; color: var(--ink-2); }
.pm-recharge { display: flex; justify-content: center; margin-top: 10px; text-decoration: none; }
.pm-list-title { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin: 16px 0 6px; }
.pm-list { max-height: 260px; overflow-y: auto; }
.pm-loading { text-align: center; color: var(--ink-3); font-size: 12px; padding: 22px 0; }
.pm-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.pm-row:last-child { border-bottom: none; }
.pm-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pm-desc { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-time { font-size: 11px; color: var(--ink-3); }
.pm-val { font-size: 13.5px; font-weight: 700; flex-shrink: 0; }
.pm-val.plus { color: #4B9168; }
.pm-val.minus { color: #C0392B; }

/* 附件预览 */
.attach-preview { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 4px 8px; }
.attach-chip {
    position: relative; width: 62px; height: 62px;
    border-radius: var(--r-sm); overflow: hidden;
    border: 1px solid var(--line-2);
}
.attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.attach-chip .chip-x {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border: none; border-radius: 50%;
    background: rgba(47, 42, 38, 0.65); color: #fff;
    font-size: 11px; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}

.composer-box {
    display: flex; align-items: flex-end; gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 9px 10px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-box:focus-within {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(232, 168, 124, 0.14), var(--shadow-sm);
}
.composer-tool {
    width: 36px; height: 36px; flex-shrink: 0;
    border: none; border-radius: 10px;
    background: transparent; color: var(--ink-3);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.composer-tool:hover { background: var(--orange-soft); color: var(--orange-deep); }
.composer-input {
    flex: 1; border: none; outline: none; resize: none;
    background: transparent; font-size: 14.5px; line-height: 1.55;
    color: var(--ink); max-height: 160px; min-height: 24px;
    padding: 6px 2px;
}
.composer-input::placeholder { color: var(--ink-3); }
.send-btn {
    width: 38px; height: 38px; flex-shrink: 0;
    border: none; border-radius: 11px;
    background: var(--gradient-btn); color: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 13px rgba(212, 132, 90, 0.35);
    transition: all 0.2s;
}
.send-btn:hover { transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.send-btn.stop {
    background: var(--panel);
    border: 1.5px solid var(--orange-deep);
    box-shadow: none;
}
.send-btn.stop .stop-square { width: 11px; height: 11px; border-radius: 2.5px; background: var(--orange-deep); }
.disclaimer { text-align: center; font-size: 11px; color: var(--ink-3); padding-top: 8px; }

/* ================= 指令库抽屉 ================= */
.drawer-mask {
    position: fixed; inset: 0; background: rgba(47, 42, 38, 0.38);
    z-index: 80;
}
.cmd-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 420px; max-width: 92vw;
    background: var(--panel); z-index: 85;
    display: flex; flex-direction: column;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: drawerIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 18px 10px; font-size: 16px; font-weight: 700;
}
.drawer-search {
    display: flex; align-items: center; gap: 8px;
    margin: 0 18px 12px; padding: 9px 12px;
    background: var(--panel-soft); border: 1px solid var(--line-2);
    border-radius: var(--r-md); color: var(--ink-3);
}
.drawer-search input { flex: 1; border: none; outline: none; background: transparent; font-size: 13px; }
.drawer-tabs {
    display: flex; gap: 6px; padding: 0 18px 12px;
    overflow-x: auto; flex-shrink: 0;
}
.drawer-tab {
    padding: 5px 13px; border: 1px solid var(--line-2);
    border-radius: 999px; background: var(--panel);
    font-size: 12px; color: var(--ink-2); cursor: pointer;
    white-space: nowrap; transition: all 0.18s;
}
.drawer-tab.active { background: var(--gradient-btn); border-color: transparent; color: #fff; font-weight: 600; }
.drawer-list { flex: 1; overflow-y: auto; padding: 0 18px; }
.cmd-item {
    padding: 13px 14px; margin-bottom: 8px;
    border: 1px solid var(--line-2); border-radius: var(--r-md);
    cursor: pointer; transition: all 0.18s;
    background: var(--panel);
}
.cmd-item:hover { border-color: var(--orange); box-shadow: var(--shadow-sm); }
.cmd-item .ci-title { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.cmd-item .ci-title svg { color: var(--orange-deep); flex-shrink: 0; }
.cmd-item .ci-body { font-size: 12px; color: var(--ink-3); line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cmd-item .ci-del { float: right; border: none; background: none; color: var(--ink-3); cursor: pointer; font-size: 13px; }
.cmd-item .ci-del:hover { color: #d9534f; }
.drawer-foot { padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); }
.ghost-btn {
    width: 100%; padding: 10px; border: 1px dashed var(--orange);
    border-radius: var(--r-md); background: transparent;
    color: var(--orange-deep); font-size: 13px; cursor: pointer;
    transition: all 0.18s;
}
.ghost-btn:hover { background: rgba(232, 168, 124, 0.1); }

/* ================= 令牌条 / Toast / Modal ================= */
.token-bar {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 8px; align-items: center;
    padding: 9px 14px; background: #FFF7E6;
    border: 1px solid #F0D8A0; border-radius: var(--r-md);
    font-size: 12px; color: #7A5C00; z-index: 200;
    box-shadow: var(--shadow);
}
.token-bar input {
    width: 280px; max-width: 52vw;
    border: 1px solid #E3D9BC; border-radius: 7px;
    padding: 5px 9px; font: 12px/1.4 inherit; outline: none;
}
.mini-btn {
    padding: 5px 14px; border: none; border-radius: 7px;
    background: #A0755A; color: #fff; cursor: pointer; font-size: 12px;
}
.mini-btn:hover { background: #8A5A3B; }

.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    padding: 10px 20px; background: rgba(47, 42, 38, 0.92); color: #fff;
    border-radius: 999px; font-size: 13px; z-index: 300;
    box-shadow: var(--shadow);
    animation: toastIn 0.25s ease; max-width: 84vw;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.modal-root {
    position: fixed; inset: 0; z-index: 250;
    background: rgba(47, 42, 38, 0.42);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
    background: #fff; border-radius: var(--r-lg);
    width: 100%; max-width: 380px; padding: 26px 24px;
    box-shadow: var(--shadow-lg); text-align: center;
    animation: msgIn 0.22s ease;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; padding-top: 2px; }
.modal-text { font-size: 13px; color: var(--ink-2); line-height: 1.7; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
    flex: 1; padding: 10px 0; border: none; border-radius: var(--r-md);
    font-size: 13.5px; cursor: pointer; transition: all 0.18s;
}
.modal-btn.primary { background: var(--gradient-btn); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(212,132,90,0.28); }
.modal-btn.primary:hover { transform: translateY(-1px); }
.modal-btn.secondary { background: #F3EFEA; color: var(--ink-2); }
.modal-btn.secondary:hover { background: #EAE3DB; }
.modal-btn.danger { background: #E0645A; color: #fff; }

/* 图片预览 lightbox */
.lightbox {
    position: fixed; inset: 0; z-index: 280;
    background: rgba(20, 17, 14, 0.88);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out; padding: 40px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); }

/* ================= 模块导航 ================= */
.module-nav { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }
.module-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 12px;
    border: none; border-radius: var(--r-md);
    background: transparent; color: var(--ink-2);
    font-size: 13.5px; font-weight: 500; cursor: pointer;
    text-align: left; transition: all 0.2s;
}
.module-btn:hover { background: var(--panel-soft); color: var(--orange-deep); }
.module-btn.active {
    background: linear-gradient(135deg, rgba(232, 168, 124, 0.18), rgba(168, 200, 216, 0.2));
    color: var(--orange-deep); font-weight: 700;
}
.module-btn svg { flex-shrink: 0; }

/* ================= 视图切换 ================= */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.view[hidden] { display: none !important; }
.module-scroll { flex: 1; overflow-y: auto; }
.view-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 16px; font-weight: 700; color: var(--ink);
}
.view-title small { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.view-title-icon { display: inline-flex; align-items: center; color: var(--orange-deep); }
.pill-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 15px; border: 1px solid var(--line);
    border-radius: 999px; background: var(--panel);
    color: var(--ink-2); font-size: 12.5px; cursor: pointer;
    transition: all 0.2s; white-space: nowrap;
}
.pill-btn:hover { border-color: var(--orange); color: var(--orange-deep); }
.pill-btn.primary { background: var(--gradient-btn); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(212,132,90,0.28); }
.pill-btn.primary:hover { color: #fff; transform: translateY(-1px); }

/* ================= 产品生成器 ================= */
.pg-wrap { max-width: 1080px; margin: 0 auto; padding: 24px; }
.pg-card {
    background: var(--panel); border: 1px solid var(--line-2);
    border-radius: var(--r-lg); padding: 22px; margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.pg-card-title {
    display: flex; align-items: center; gap: 9px;
    font-size: 15px; font-weight: 700; margin-bottom: 16px;
}
.pg-step-num {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--gradient-btn); color: #fff;
    font-size: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.pg-step-num.done { background: linear-gradient(135deg, #7BC49A, #57A87C); }
.pg-step-num.pending { background: rgba(0,0,0,0.12); color: var(--ink-3); }

/* 智能体卡片 */
.agent-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.agent-card {
    text-align: left; padding: 16px; cursor: pointer;
    border: 1.5px solid var(--line-2); border-radius: var(--r-md);
    background: var(--panel-soft); transition: all 0.2s;
}
.agent-card:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.agent-card.selected { border-color: var(--orange-deep); background: rgba(232,168,124,0.08); box-shadow: 0 0 0 3px rgba(232,168,124,0.15); }
.agent-card .ac-icon { margin-bottom: 10px; color: var(--orange-deep); display: flex; }
.agent-card .ac-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.agent-card .ac-desc { font-size: 12px; color: var(--ink-3); line-height: 1.55; min-height: 36px; }
.agent-card .ac-meta { display: flex; gap: 8px; margin-top: 10px; font-size: 11px; }
.agent-card .ac-tag { padding: 2px 8px; border-radius: 999px; background: var(--gradient); color: var(--orange-deep); font-weight: 600; }

/* 上传区 */
.upload-zone {
    border: 2px dashed var(--line); border-radius: var(--r-md);
    padding: 30px 18px; text-align: center; cursor: pointer;
    color: var(--ink-3); transition: all 0.2s; background: var(--panel-soft);
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--orange); background: rgba(232,168,124,0.07); color: var(--orange-deep); }
.upload-zone .uz-icon { margin-bottom: 10px; display: flex; justify-content: center; }
.src-thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.src-thumb { position: relative; width: 92px; height: 92px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line-2); }
.src-thumb img { width: 100%; height: 100%; object-fit: cover; }
.src-thumb .st-x {
    position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
    border: none; border-radius: 50%; background: rgba(47,42,38,0.65); color: #fff;
    cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
}

/* 表单行 */
.pg-form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.pg-field { flex: 1; min-width: 200px; }
.pg-field label { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 5px; font-weight: 600; }
.pg-field input, .pg-field textarea, .pg-field select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--line-2);
    border-radius: var(--r-sm); font: 13px/1.5 inherit; color: var(--ink);
    outline: none; background: var(--panel); transition: border-color 0.2s;
}
.pg-field input:focus, .pg-field textarea:focus { border-color: var(--orange); }
.pg-field textarea { resize: vertical; min-height: 70px; }

/* 阶段结果 */
.stage-result { margin-top: 14px; }
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kv-item { background: var(--panel-soft); border-radius: var(--r-sm); padding: 10px 12px; }
.kv-item .k { font-size: 11px; color: var(--ink-3); font-weight: 600; margin-bottom: 3px; }
.kv-item .v { font-size: 13px; color: var(--ink); }
.field-block { margin-bottom: 14px; }
.field-block .fb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field-block .fb-label { font-size: 12px; font-weight: 700; color: var(--orange-deep); }
.field-block .fb-ops { display: flex; gap: 5px; }
.fb-btn {
    padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 999px;
    background: var(--panel); font-size: 11px; color: var(--ink-2);
    cursor: pointer; transition: all 0.18s;
}
.fb-btn:hover { border-color: var(--orange); color: var(--orange-deep); }
.field-block textarea, .field-input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line-2);
    border-radius: var(--r-sm); font: 13px/1.6 inherit; outline: none;
    background: var(--panel-soft); resize: vertical; min-height: 60px;
}
.field-block textarea:focus { border-color: var(--orange); background: var(--panel); }
.feature-list { display: flex; flex-direction: column; gap: 8px; }
.feature-item { display: flex; gap: 8px; align-items: flex-start; }
.feature-item .fi-index {
    width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
    background: var(--gradient); color: var(--orange-deep);
    font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
    margin-top: 8px;
}
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table th, .spec-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.spec-table th { background: rgba(232,168,124,0.12); width: 38%; }

/* 进度条 */
.stage-progress { display: flex; align-items: center; gap: 0; margin: 18px 0 6px; }
.sp-node { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; }
.sp-dot {
    width: 30px; height: 30px; border-radius: 50%;
    background: rgba(0,0,0,0.08); color: var(--ink-3);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; transition: all 0.3s;
}
.sp-node.active .sp-dot { background: var(--gradient-btn); color: #fff; box-shadow: 0 0 0 5px rgba(232,168,124,0.18); }
.sp-node.done .sp-dot { background: linear-gradient(135deg, #7BC49A, #57A87C); color: #fff; }
.sp-label { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.sp-node.active .sp-label, .sp-node.done .sp-label { color: var(--ink); font-weight: 600; }
.sp-line { flex: 1; height: 2px; background: rgba(0,0,0,0.08); margin: 0 8px; margin-bottom: 22px; border-radius: 1px; }
.sp-line.done { background: #7BC49A; }
.spin-sm {
    width: 15px; height: 15px; border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* 记录抽屉/列表 */
.records-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.record-card {
    background: var(--panel); border: 1px solid var(--line-2);
    border-radius: var(--r-md); overflow: hidden; cursor: pointer;
    transition: all 0.2s;
}
.record-card:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: var(--shadow); }
.record-card .rc-thumb {
    width: 100%; height: 140px; object-fit: cover;
    background: var(--panel-soft); display: flex; align-items: center; justify-content: center;
    color: var(--ink-3); font-size: 34px;
}
.rc-pts { display: inline-flex; align-items: center; gap: 3px; }
.rc-pts svg { color: var(--orange-deep); }
.rc-check { position: absolute; top: 8px; right: 8px; z-index: 3; }
.rc-check input { width: 16px; height: 16px; cursor: pointer; }
.records-batch {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 12px; margin-bottom: 12px;
    background: var(--panel-soft); border: 1px solid var(--line-2); border-radius: var(--r-md);
    font-size: 12.5px; color: var(--ink-2);
}
.records-batch .rb-info b { color: var(--orange-deep); }
.records-batch .rb-del { color: #C0392B; }
.records-batch .rb-del:hover { border-color: #C0392B; background: rgba(192,57,43,0.06); }
/* 列表视图：单列紧凑行 */
.records-grid.list-view { grid-template-columns: 1fr; }
.records-grid.list-view .record-card {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
}
.records-grid.list-view .rc-thumb { width: 56px; height: 56px; border-radius: var(--r-sm); flex-shrink: 0; }
.records-grid.list-view .rc-body { flex: 1; padding: 0; }
.records-grid.list-view .rc-check { position: static; }
.records-grid.list-view .rc-cat, .records-grid.list-view .rc-time { font-size: 11px; color: var(--ink-3); }
.record-card .rc-body { padding: 12px 14px; }
.record-card .rc-title {
    font-size: 13.5px; font-weight: 600; margin-bottom: 5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.record-card .rc-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }
.status-chip { padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; }
.status-chip.saved { background: rgba(123,196,154,0.18); color: #4B9168; }
.status-chip.draft, .status-chip.init, .status-chip.vision_done, .status-chip.content_done, .status-chip.images_done { background: rgba(232,168,124,0.18); color: var(--orange-deep); }

/* ================= 媒体库 ================= */
.media-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.media-toolbar input, .media-toolbar select {
    padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
    font: 13px inherit; outline: none; background: var(--panel); color: var(--ink);
}
.media-toolbar input { flex: 1; min-width: 180px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.media-card {
    background: var(--panel); border: 1px solid var(--line-2);
    border-radius: var(--r-md); overflow: hidden; transition: all 0.2s;
}
.media-card:hover { border-color: var(--orange); box-shadow: var(--shadow-sm); }
.media-card .mc-img {
    width: 100%; height: 150px; object-fit: cover; cursor: zoom-in;
    background: var(--panel-soft); display: block;
}
.media-card .mc-body { padding: 10px 12px; }
.media-card .mc-name {
    font-size: 12.5px; font-weight: 600; margin-bottom: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-card .mc-tags { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mc-source { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.mc-source.generated { background: rgba(168,200,216,0.3); color: #5B8499; }
.mc-source.upload { background: rgba(232,168,124,0.22); color: var(--orange-deep); }
.mc-source.detail { background: rgba(123,196,154,0.2); color: #4B9168; }
.mc-ops { display: flex; gap: 2px; }
.mc-op {
    width: 24px; height: 24px; border: none; background: transparent;
    border-radius: 6px; color: var(--ink-3); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.mc-op:hover { background: var(--orange-soft); color: var(--orange-deep); }
.media-empty {
    grid-column: 1 / -1; text-align: center; padding: 70px 20px;
    color: var(--ink-3); border: 1.5px dashed var(--line); border-radius: var(--r-lg);
}
.media-empty .me-icon { margin-bottom: 12px; color: var(--ink-3); display: flex; justify-content: center; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 22px; font-size: 13px; color: var(--ink-3); }
.pager button {
    padding: 6px 16px; border: 1px solid var(--line-2); border-radius: 999px;
    background: var(--panel); cursor: pointer; color: var(--ink-2); font-size: 12.5px;
}
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--orange); color: var(--orange-deep); }

/* 响应式 */
@media (max-width: 900px) {
    .agent-cards { grid-template-columns: 1fr; }
    .kv-grid { grid-template-columns: 1fr; }
    .view-title small { display: none; }
    .topbar { flex-wrap: wrap; row-gap: 6px; }   /* 顶栏放不下时换行，不隐藏任何功能入口 */
    .media-grid { grid-template-columns: repeat(3, 1fr); }
    .records-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* 平板/中屏 */
@media (max-width: 1024px) {
    .suggest-grid { grid-template-columns: repeat(2, 1fr); }
    .pg-wrap { max-width: 100%; padding: 20px 18px; }
    .media-toolbar input { min-width: 140px; }
    .agent-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

/* 大屏：利用横向空间 */
@media (min-width: 1440px) {
    .suggest-grid { grid-template-columns: repeat(4, 1fr); }
    .pg-wrap { max-width: 1180px; }
    .kv-grid { grid-template-columns: repeat(3, 1fr); }
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .chat-column { max-width: 900px; }
}

/* 手机 */
@media (max-width: 760px) {
    .pg-wrap { padding: 14px; }
    .pg-card { padding: 16px; }
    .stage-progress { overflow-x: auto; padding-bottom: 4px; }
    .media-grid { grid-template-columns: repeat(2, 1fr); }
    .records-grid { grid-template-columns: 1fr 1fr; }
    .mode-seg { font-size: 12px; }
    .model-select { max-width: 118px; font-size: 12px; }
    .media-toolbar input { min-width: 0; width: 100%; }
    .media-toolbar select { flex: 1; min-width: 0; }
    .pager { flex-wrap: wrap; gap: 8px; }
    .modal { max-width: 100%; }
    .lightbox { padding: 16px; }
    .token-bar { flex-wrap: wrap; }
    .token-bar input { width: 150px; flex: 1; }
    .h-mode { display: none; }             /* 手机上会话列表更紧凑 */
    .pg-form-row { flex-direction: column; }
    .pg-field { min-width: 0; }
}

@media (max-width: 760px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        width: min(300px, 84vw);
    }
    .app.sidebar-open .sidebar { transform: translateX(0); }
    .app.sidebar-open .sidebar-mask { display: block; }
    .topbar-menu { display: flex; }
    .sidebar-collapse { display: none; }
    .topbar { padding: 10px 14px; gap: 8px; }
    .chat-column { padding: 18px 14px 14px; }
    .composer-zone { padding: 6px 14px calc(8px + env(safe-area-inset-bottom)); }
    .suggest-grid { grid-template-columns: 1fr; }
    .welcome-hello { font-size: 24px; }
    .switch-wrap .switch-label span { display: none; }
    .cmd-drawer { width: 100%; max-width: 100%; border-radius: 0; }
}

/* 极窄手机：顶栏再收敛 */
@media (max-width: 480px) {
    .model-select-wrap { flex: 1; min-width: 0; }
    .model-select { max-width: 100%; width: 100%; }
    .mode-seg .mode-btn { padding: 6px 10px; }
    .brand-cn { font-size: 13.5px; }
    .brand-en { letter-spacing: 2px; }
}
