/*
 * AI文案智能体 - 前端样式
 * Design System: Ollama-inspired minimal
 *
 * 结构：
 *   1. 基础与通用组件（设备无关）
 *   2. 电脑版 .ai-app-pc
 *   3. 手机版 .ai-app-mobile
 *
 * Palette:
 *   ink:        #000   all headlines, primary CTA, active text
 *   charcoal:   #525   list text, disabled-state copy
 *   body:       #737   default body, secondary text
 *   mute:       #a3a   captions, lowest emphasis
 *   canvas:     #fff   page background
 *   surface:    #fafa  soft pill backgrounds
 *   hairline:   #e5e5  1px card borders, dividers
 *   dark:       #1717  inverted surface (featured card)
 */

/* ========== RESET & BASE ========== */

/* 本页全屏应用：抵消 Zibll 固定导航栏下方多余 padding（导航栏实际高度 52px） */
html, body.ai-copywriter-page {
    overflow: hidden;
}

body.ai-copywriter-page {
    padding-top: 52px !important;
}

/* Zibll 的 z_auto() 会给页面所有 <main> 注入 min-height（用于把页脚撑到屏幕底部），
   本应用的内容区正是 <main class="ai-content">，被注入后高度超出视口约 100px，
   消息区底部会被顶到屏幕外，最后一条消息看起来就"贴在屏幕底部"。必须压回 0。 */
.ai-app-pc .ai-content,
.ai-app-mobile .ai-content {
    min-height: 0 !important;
}

.ai-app-pc,
.ai-app-mobile {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #000;
    background: #fff;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

/* ========== PILL BUTTONS ========== */

.ai-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border-radius: 9999px;
    border: none;
    padding: 8px 20px;
    height: 36px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    text-decoration: none;
}

.ai-pill-primary {
    background: #000;
    color: #fff;
}

.ai-pill-primary:hover {
    background: #1a1a1a;
}

.ai-pill-primary:active {
    background: #090909;
}

.ai-pill-primary:disabled {
    background: #fafafa;
    color: #a3a3a3;
    cursor: not-allowed;
}

.ai-pill-primary.ai-pill-danger {
    background: #dc2626;
}

.ai-pill-lg {
    padding: 12px 28px;
    height: 44px;
    font-size: 15px;
    width: 100%;
}

.ai-pill-secondary {
    background: #fff;
    color: #000;
    border: 1px solid #d4d4d4;
}

.ai-pill-secondary:hover {
    background: #fafafa;
}

/* ========== CARD ========== */

.ai-card {
    position: relative;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: clamp(20px, 2.5vw, 32px);
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s;
    min-height: 280px;
}

.ai-card:hover {
    border-color: #d4d4d4;
}

.ai-card-featured {
    background: #171717;
    border-color: #171717;
    color: #fff;
}

.ai-card-featured:hover {
    border-color: #333;
}

.ai-card-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #a3a3a3;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.ai-card-featured .ai-card-badge {
    color: rgba(255,255,255,0.5);
}

.ai-card-title {
    font-family: "SF Pro Rounded", ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.33;
    color: #000;
    margin: 0 0 8px;
}

.ai-card-featured .ai-card-title {
    color: #fff;
}

.ai-card-structure {
    font-size: 13px;
    font-weight: 500;
    color: #525252;
    margin: 0 0 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    word-break: break-all;
}

.ai-card-featured .ai-card-structure {
    color: rgba(255,255,255,0.6);
}

.ai-card-case {
    font-size: 14px;
    line-height: 1.5;
    color: #737373;
    margin: 0 0 20px;
    flex: 1;
}

.ai-card-featured .ai-card-case {
    color: rgba(255,255,255,0.6);
}

.ai-card .ai-pill {
    align-self: flex-start;
}

.ai-card-featured .ai-pill {
    background: #fff;
    color: #000;
}

.ai-card-featured .ai-pill:hover {
    background: #e5e5e5;
}

/* ========== METHODS GRID ========== */

.ai-methods {
    margin-bottom: 40px;
}

.ai-empty {
    text-align: center;
    padding: 64px 0;
    color: #a3a3a3;
    font-size: 16px;
}

/* ========== OVERLAY & MODAL ========== */

.ai-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-overlay-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 0;
}

.ai-modal {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 480px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1;
    border: 1px solid #e5e5e5;
}

.ai-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
}

.ai-modal-head h2 {
    margin: 0;
    font-family: "SF Pro Rounded", ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #000;
}

.ai-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    border: none;
    background: transparent;
    color: #a3a3a3;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.ai-modal-close:hover {
    background: #fafafa;
    color: #000;
}

.ai-modal-body {
    padding: 24px;
}

/* ========== FORM FIELDS ========== */

.ai-field {
    margin-bottom: 20px;
}

.ai-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #525252;
    margin-bottom: 8px;
}

.ai-select-wrap {
    position: relative;
}

.ai-select {
    appearance: none;
    width: 100%;
    padding: 10px 36px 10px 16px;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 15px;
    color: #000;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ai-select:hover {
    border-color: #d4d4d4;
}

.ai-select:focus {
    outline: none;
    border-color: #000;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.ai-select-wrap::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 6px;
    background: currentColor;
    pointer-events: none;
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    color: #a3a3a3;
}

.ai-segmented {
    display: inline-flex;
    background: #fafafa;
    border-radius: 9999px;
    padding: 3px;
    border: 1px solid #e5e5e5;
}

.ai-seg {
    position: relative;
    font-size: 14px;
    font-weight: 500;
    color: #737373;
    cursor: pointer;
    border-radius: 9999px;
    transition: color 0.15s, background 0.15s;
}

.ai-seg input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-seg span {
    display: block;
    padding: 6px 20px;
    min-width: 44px;
    text-align: center;
}

.ai-seg:has(input:checked) {
    background: #fff;
    color: #000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ai-seg:hover:not(:has(input:checked)) {
    color: #525252;
}

/* ========== TOGGLE SWITCH ========== */

.ai-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.ai-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-toggle-track {
    position: relative;
    width: 40px;
    height: 24px;
    border-radius: 9999px;
    background: #d4d4d4;
    transition: background 0.15s;
    flex-shrink: 0;
}

.ai-toggle input:checked + .ai-toggle-track {
    background: #000;
}

.ai-toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    background: #fff;
    transition: transform 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.ai-toggle input:checked + .ai-toggle-track .ai-toggle-knob {
    transform: translateX(16px);
}

.ai-toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: #525252;
}

/* ========== 团单选择器 & 团单勾选列表 ========== */

.ai-order-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 9999px;
}

.ai-order-picker-value {
    flex: 1;
    font-size: 15px;
    color: #000;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-order-picker-btn {
    flex-shrink: 0;
    padding: 7px 18px;
    border: none;
    border-radius: 9999px;
    background: #000;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.ai-order-picker-btn:hover {
    opacity: 0.85;
}

.ai-order-list {
    max-height: 380px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.ai-order-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.ai-order-item:last-child {
    margin-bottom: 0;
}

/* 隐藏原生 checkbox（Zibll 主题对 input[type=checkbox] 有全局样式，会多出一个选择框） */
.ai-order-item input[type="checkbox"] {
    display: none !important;
}

.ai-order-item-check {
    width: 20px;
    height: 20px;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.ai-order-item input:checked + .ai-order-item-check {
    background: #000;
    border-color: #000;
}

.ai-order-item input:checked + .ai-order-item-check::after {
    content: "";
    width: 10px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
    margin-top: -2px;
}

.ai-order-item-title {
    flex: 1;
    font-size: 15px;
    color: #000;
}

.ai-order-item:has(input:checked) {
    border-color: #000;
    background: #fafafa;
}

/* ========== 文案长度胶囊 Tab ========== */

.ai-tabs-length {
    display: flex;
    width: 100%;
}

.ai-tabs-length .ai-len-tab {
    width: auto;
    flex: 1;
    padding: 8px 0;
}

.ai-tabs-length .ai-len-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    background: #000;
    border-radius: 9999px;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== COST CARD ========== */

.ai-cost-card {
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.ai-cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.ai-cost-row-sub {
    border-top: 1px solid #e5e5e5;
    padding-top: 10px;
    margin-top: 8px;
}

.ai-cost-meta {
    font-size: 14px;
    color: #737373;
}

.ai-cost-num {
    font-size: 20px;
    font-weight: 600;
    color: #000;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ai-cost-bal {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ========== MODAL ACTIONS ========== */

.ai-modal-actions {
    margin-bottom: 20px;
}

/* ========== 信息栏（头像 + HI + 积分，设备无关） ========== */

.ai-sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.ai-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-avatar-fallback {
    font-size: 20px;
    font-weight: 600;
    color: #525252;
}

.ai-sidebar-info {
    flex: 1;
    min-width: 0;
}

.ai-sidebar-name {
    font-size: 17px;
    font-weight: 600;
    color: #000;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 积分胶囊 + 签到按钮 */
.ai-sidebar-points-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.ai-points-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 12px;
    border-radius: 9999px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    font-size: 12px;
    color: #737373;
}

.ai-points-pill b {
    font-weight: 600;
    color: #000;
}

.ai-checkin-wrap {
    display: inline-flex;
}

.ai-checkin-btn {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 9999px;
    background: #000;
    color: #fff !important;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    text-decoration: none !important;
    cursor: pointer;
    transition: opacity 0.15s;
}

.ai-checkin-btn:hover {
    opacity: 0.85;
}

/* ========== TABS（胶囊 + 滑动指示器，设备无关） ========== */

.ai-tabs-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin: 0 0 20px;
    box-sizing: border-box;
}

.ai-tabs {
    position: relative;
    display: flex;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 9999px;
    padding: 3px;
}

.ai-tabs-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 84px;
    height: calc(100% - 6px);
    background: #000;
    border-radius: 9999px;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

.ai-tabs-thumb.is-right {
    transform: translateX(84px);
}

.ai-tab,
.ai-len-tab {
    position: relative;
    z-index: 1;
    width: 84px;
    padding: 8px 0;
    border: none;
    background: transparent;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #737373;
    cursor: pointer;
    transition: color 0.22s;
}

.ai-tab-active,
.ai-len-tab-active {
    color: #fff;
}

.ai-tabs-actions {
    display: none;
    gap: 8px;
}

.ai-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    border: 1px solid #e5e5e5;
    background: #fff;
    color: #525252;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ai-icon-btn:hover {
    background: #fafafa;
    color: #000;
}

/* ========== 历史信息栏（内容部分，设备无关） ========== */

.ai-sidebar-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ai-sidebar-history-title {
    font-size: 14px;
    font-weight: 600;
    color: #000;
}

.ai-chat-new-btn {
    padding: 6px 14px;
    border-radius: 9999px;
    border: 1px solid #000;
    background: #000;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-chat-new-btn:hover {
    background: #1a1a1a;
}

.ai-chat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-list-empty {
    text-align: center;
    color: #a3a3a3;
    font-size: 13px;
    padding: 20px 0;
}

.ai-chat-list-item {
    position: relative;
    padding: 10px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ai-chat-list-item:hover {
    background: #fafafa;
}

.ai-chat-list-item-active {
    border-color: #000;
    background: #fafafa;
}

.ai-chat-list-title {
    font-size: 13px;
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-list-preview {
    font-size: 12px;
    color: #a3a3a3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-list-del {
    position: absolute;
    top: 8px;
    right: 10px;
    display: none;
    padding: 2px 8px;
    border: none;
    border-radius: 9999px;
    background: #f5f5f5;
    color: #737373;
    font-size: 11px;
    cursor: pointer;
}

.ai-chat-list-item:hover .ai-chat-list-del {
    display: block;
}

.ai-chat-list-del:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* ========== 对话模式（气泡 / 打字机，设备无关） ========== */

.ai-chat-login-tip {
    text-align: center;
    padding: 60px 0;
    color: #737373;
    font-size: 15px;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: #a3a3a3;
}

.ai-chat-empty-avatar {
    width: 64px;
    height: 64px;
    border-radius: 9999px;
    overflow: hidden;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.ai-chat-empty-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-chat-empty-greeting {
    font-size: 20px;
    font-weight: 600;
    color: #000;
    margin-bottom: 6px;
}

.ai-chat-empty-sub {
    font-size: 14px;
    color: #737373;
}

.ai-chat-msg {
    display: flex;
    flex-wrap: wrap;
}

/* AI 回复下方的积分消耗提示 */
.ai-chat-cost {
    flex-basis: 100%;
    margin-top: 6px;
    font-size: 12px;
    color: #a3a3a3;
}

.ai-chat-msg-user {
    justify-content: flex-end;
}

.ai-chat-msg-assistant {
    justify-content: flex-start;
}

.ai-chat-bubble {
    max-width: 72%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-msg-user .ai-chat-bubble {
    background: #000;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-chat-msg-assistant .ai-chat-bubble {
    background: #fafafa;
    color: #000;
    border: 1px solid #e5e5e5;
    border-bottom-left-radius: 4px;
}

.ai-chat-typing-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    margin-left: 2px;
    background: #000;
    vertical-align: text-bottom;
    animation: ai-chat-blink 1s step-start infinite;
}

@keyframes ai-chat-blink {
    50% { opacity: 0; }
}

.ai-chat-thinking-line {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 12px;
    color: #a3a3a3;
}

.ai-chat-thinking-line i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #a3a3a3;
    animation: ai-thinking-bounce 1.2s infinite ease-in-out;
}

.ai-chat-thinking-line i:nth-child(1) { animation-delay: 0s; }
.ai-chat-thinking-line i:nth-child(2) { animation-delay: 0.15s; }
.ai-chat-thinking-line i:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-thinking-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-3px); opacity: 1; }
}

.ai-order-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
}

.ai-order-option {
    padding: 8px 16px;
    border-radius: 9999px;
    border: 1px solid #d4d4d4;
    background: #fff;
    color: #000;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-order-option:hover {
    background: #fafafa;
}

.ai-order-option-skip {
    color: #737373;
}

.ai-chat-input-bar {
    border-top: 1px solid #e5e5e5;
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-chat-text {
    flex: 1;
    resize: none;
    border: 1px solid #e5e5e5;
    border-radius: 18px;
    padding: 10px 16px;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #000;
    max-height: 120px;
    outline: none;
}

.ai-chat-text:focus {
    border-color: #000;
}

.ai-chat-send-btn {
    padding: 10px 22px;
    border-radius: 9999px;
    border: none;
    background: #000;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-chat-send-btn:hover {
    background: #1a1a1a;
}

/* ========== 电脑版 ========== */

.ai-app-pc {
    width: 100%;
    height: calc(100vh - 52px);
    min-height: 560px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

.ai-app-pc .ai-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
    border-right: 1px solid #e5e5e5;
    padding: 24px 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.ai-app-pc .ai-tabs-actions {
    display: none;
}

.ai-app-pc .ai-sidebar-history {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e5e5e5;
    padding-top: 16px;
}

.ai-app-pc .ai-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-app-pc .ai-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ai-app-pc .ai-panel-chat {
    overflow: hidden;
}

.ai-app-pc .ai-panel-template {
    overflow-y: auto;
    padding: 24px 32px 40px;
}

.ai-app-pc .ai-methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.ai-app-pc.ai-app-chat-mode .ai-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.ai-app-pc.ai-app-chat-mode .ai-chat-input-bar {
    flex-shrink: 0;
}

/* ========== 手机版 ========== */

/* 手机端整体固定全屏：隐藏 Zibll 导航栏 */
.ai-app-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    width: 100%;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
}

/* 顶部区：返回按钮 + 信息栏 + Tab，悬浮固定在视口顶部 */
.ai-app-mobile .ai-mobile-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    box-sizing: border-box;
}

.ai-mobile-top-bar {
    display: flex;
    align-items: center;
    height: 36px;
    margin-bottom: 8px;
}

.ai-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 9999px;
    border: 1px solid #e5e5e5;
    background: #fff;
    color: #000;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.ai-mobile-back svg {
    flex-shrink: 0;
}

.ai-mobile-back:active {
    background: #fafafa;
}

.ai-app-mobile .ai-sidebar-profile {
    margin-bottom: 12px;
}

.ai-app-mobile .ai-tabs-row {
    justify-content: space-between;
    margin-bottom: 0;
}

.ai-app-mobile .ai-tabs-actions {
    display: flex;
}

.ai-app-mobile .ai-action-new {
    display: none;
}

.ai-app-mobile.ai-app-chat-mode .ai-action-new {
    display: flex;
}

/* 内容区：绝对定位填满顶部区下方，默认可滚动（模版模式） */
.ai-app-mobile .ai-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-sizing: border-box;
}

.ai-app-mobile .ai-panel {
    display: flex;
    flex-direction: column;
}

.ai-app-mobile .ai-panel-template {
    display: block;
    padding: 16px;
}

.ai-app-mobile .ai-methods-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.ai-app-mobile .ai-card {
    padding: 20px;
    min-height: auto;
}

/* 对话模式：内容区铺满顶部栏下方，输入框固定贴底，消息区独立滚动 */
.ai-app-mobile.ai-app-chat-mode .ai-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.ai-app-mobile.ai-app-chat-mode .ai-panel-chat {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.ai-app-mobile.ai-app-chat-mode .ai-chat-messages {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 16px;
}

/* 内容末尾留白块：高度由 JS 同步为输入框实际高度，保证最后一条消息不被固定输入框遮挡 */
.ai-chat-spacer {
    display: none;
}

.ai-app-mobile.ai-app-chat-mode .ai-chat-spacer {
    display: block;
    flex: 0 0 auto;
    height: 88px;
}

.ai-app-mobile.ai-app-chat-mode .ai-chat-input-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: #fff;
    box-shadow: 0 -1px 0 #e5e5e5;
}

/* 手机端：历史信息栏变抽屉（点击历史图标弹出） */
.ai-app-mobile .ai-sidebar-history {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: #fff;
    border-left: 1px solid #e5e5e5;
    padding: 16px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 99991;
}

.ai-app-mobile .ai-sidebar-history.open {
    transform: translateX(0);
}

.ai-app-mobile .ai-chat-sidebar-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99990;
    display: none;
}

.ai-app-mobile .ai-chat-sidebar-mask.open {
    display: block;
}
