:root {
    --primary: #2F5496;
    --primary-light: #4472C4;
    --secondary: #333333;
    --accent: #00B050;
    --bg: #F5F5F5;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-light: #666666;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.logo-icon {
    font-size: 28px;
}

/* 品牌标识图标（图片版） */
img.logo-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
}

.logo-text {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
}

.btn-new-chat {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-new-chat:hover {
    background: var(--primary-light);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section h3 {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-left: 5px;
}

.nav-btn {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: var(--bg);
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
}

.model-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-light);
}

.model-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

/* 主聊天区域 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-header {
    padding: 15px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 18px;
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* 欢迎区图标（图片版） */
img.welcome-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}

.welcome-message h1 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--primary);
}

.welcome-message > p {
    color: var(--text-light);
    margin-bottom: 30px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    max-width: 700px;
    margin: 0 auto;
}

.feature-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    text-align: center;
}

.feature-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 10px;
}

.feature-card h4 {
    font-size: 14px;
    margin-bottom: 5px;
}

.feature-card p {
    font-size: 12px;
    color: var(--text-light);
}

/* 消息样式 */
.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

/* 消息头像（图片版） */
.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
}

.message.assistant .message-content {
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.message-content pre {
    background: #f4f4f4;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content code {
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

/* 对话中的可点击链接（含下载链接） */
.message-content .chat-link {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    cursor: pointer;
}

.message-content .chat-link:hover {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 3px;
}

/* 下载链接做成醒目的按钮式胶囊 */
.message-content a.chat-link-download {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 14px;
    background: #2563eb;
    color: #fff !important;
    text-decoration: none;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
    word-break: normal;
}

.message-content a.chat-link-download:hover {
    background: #1d4ed8;
}

/* 用户消息（蓝底）中的链接保持可读 */
.message.user .message-content .chat-link {
    color: #fff7cc;
}

/* ========== Markdown 标题 / 列表 / 段落（对话内操作流程说明） ========== */
.message-content .md-h {
    font-weight: 700;
    line-height: 1.5;
    margin: 10px 0 6px;
}
.message-content .md-h2 { font-size: 15px; border-left: 4px solid #2563eb; padding-left: 8px; }
.message-content .md-h3 { font-size: 14px; color: #1e40af; }
.message-content .md-h4 { font-size: 13.5px; color: #374151; }
.message-content .md-p { margin: 4px 0; line-height: 1.7; }
.message-content .md-blank { height: 6px; }
.message-content ul.md-ul,
.message-content ol.md-ol {
    margin: 4px 0 8px;
    padding-left: 22px;
    line-height: 1.75;
}
.message-content ul.md-ul li { list-style: disc; }
.message-content ol.md-ol li { list-style: decimal; }
.message-content .md-table {
    border-collapse: collapse;
    margin: 6px 0 10px;
    font-size: 12.5px;
    width: auto;
    max-width: 100%;
}
.message-content .md-table th,
.message-content .md-table td {
    border: 1px solid #d1d5db;
    padding: 4px 10px;
    text-align: left;
}
.message-content .md-table th { background: #f3f4f6; font-weight: 700; }
.message-content .md-table tr:nth-child(even) td { background: #fafafa; }

/* ========== 结构化操作流程步骤卡片 ========== */
.steps-wrap {
    margin: 10px 0 6px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fafbfc;
}
.steps-title {
    background: linear-gradient(90deg, #eff6ff, #f0f9ff);
    color: #1e40af;
    font-weight: 700;
    font-size: 13.5px;
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
}
.step-card {
    padding: 10px 12px 8px;
    border-bottom: 1px solid #eef0f3;
    position: relative;
}
.step-card:last-child { border-bottom: none; }
.step-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.step-no {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.step-title { font-weight: 700; font-size: 13.5px; color: #111827; }
.step-dur { margin-left: auto; font-size: 11.5px; color: #9ca3af; }
.step-rows { display: flex; flex-direction: column; gap: 4px; }
.step-row { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 1.65; }
.step-tag {
    flex: none;
    width: 56px;
    border-radius: 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 0;
    margin-top: 1px;
}
.tag-purpose { background: #dbeafe; color: #1d4ed8; }
.tag-method  { background: #dcfce7; color: #15803d; }
.tag-result  { background: #fef3c7; color: #b45309; }
.tag-notes   { background: #fee2e2; color: #b91c1c; }
.step-text { color: #374151; flex: 1; word-break: break-word; }
.step-notes { margin: 0; padding-left: 16px; }
.step-notes li { list-style: disc; margin: 1px 0; }

/* 结论与文件区块 */
.result-summary {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    border-radius: 4px;
    padding: 8px 10px;
    margin: 6px 0;
    font-size: 13px;
    line-height: 1.7;
}
.result-file {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
}
.result-file-name { font-size: 13px; font-weight: 600; color: #1f2937; margin-bottom: 8px; word-break: break-all; }
a.download-btn {
    display: inline-block;
    padding: 7px 18px;
    background: #2563eb;
    color: #fff !important;
    text-decoration: none;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}
a.download-btn:hover { background: #1d4ed8; }

.message-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

.action-btn:hover {
    background: var(--bg);
}

/* 输入区域 */
.chat-input-area {
    padding: 20px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    max-height: 120px;
}

#messageInput:focus {
    border-color: var(--primary);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
}

.send-btn:hover {
    background: var(--primary-light);
}

.input-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

/* 预览面板 */
.preview-panel {
    width: 300px;
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    display: none;
    flex-direction: column;
}

.preview-panel.active {
    display: flex;
}

.preview-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    font-size: 16px;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-item {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid transparent;
}

.file-item:hover {
    background: #e8e8e8;
}

.file-main {
    flex: 1;
    min-width: 0;
}

/* 已上传文件（当前对话的工作文件） */
.file-item--uploaded {
    border: 2px solid var(--primary);
    background: #f0f7ff;
}

.file-item--uploaded .file-ready-hint {
    color: var(--primary);
    font-weight: 500;
}

/* 选中态（与已上传态同级，后定义优先） */
.file-item.selected {
    background: #e8f0fe;
    border: 2px solid var(--primary-light);
    box-shadow: 0 0 0 1px rgba(68, 114, 196, 0.25);
}

.file-row-check {
    flex: none;
    width: 15px;
    height: 15px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* 文件管理工具栏 */
.file-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.toolbar-select-all {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.toolbar-select-all input.file-checkbox {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--primary);
}

.toolbar-select-all input:disabled + span {
    color: #aaa;
    cursor: not-allowed;
}

.selected-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
}

.file-del-btn {
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid #dc2626;
    background: #fff;
    color: #dc2626;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.file-del-btn:hover:not(:disabled) {
    background: #dc2626;
    color: #fff;
}

.file-del-btn:disabled {
    border-color: var(--border);
    background: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-all;
}

.file-meta {
    font-size: 11px;
    color: var(--text-light);
}

.file-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.file-btn {
    padding: 3px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

/* ========== 代码沙箱面板 ========== */
.sandbox-panel {
    margin: 0 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #1e1e2e;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 45vh;
}
.sandbox-panel.collapsed { display: none; }

.sandbox-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #2a2a3e;
    border-bottom: 1px solid #3a3a52;
}
.sandbox-title { color: #e5e7eb; font-size: 13.5px; font-weight: 700; }
.sandbox-header-btns { margin-left: auto; display: flex; gap: 6px; }

.sandbox-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
}
.badge-idle    { background: #374151; color: #9ca3af; }
.badge-running { background: #1e3a8a; color: #93c5fd; }
.badge-ok      { background: #14532d; color: #86efac; }
.badge-error   { background: #7f1d1d; color: #fca5a5; }
.badge-blocked { background: #7c2d12; color: #fdba74; }
.badge-timeout { background: #713f12; color: #fde047; }

.sandbox-btn {
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid #4b5563;
    background: #374151;
    color: #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
}
.sandbox-btn:hover { background: #4b5563; }
.sandbox-run { background: #166534; border-color: #22c55e; }
.sandbox-run:hover { background: #15803d; }

.sandbox-code {
    width: 100%;
    min-height: 110px;
    max-height: 200px;
    padding: 10px 12px;
    background: #181826;
    color: #d4d4d4;
    border: none;
    border-bottom: 1px solid #3a3a52;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

.sandbox-output {
    display: flex;
    gap: 1px;
    background: #3a3a52;
    min-height: 90px;
    max-height: 160px;
}
.sandbox-pane {
    flex: 1;
    background: #1e1e2e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sandbox-pane h5 {
    padding: 4px 12px;
    font-size: 11px;
    color: #9ca3af;
    background: #262637;
    flex: none;
}
.sandbox-pane pre {
    flex: 1;
    margin: 0;
    padding: 8px 12px;
    overflow: auto;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-break: break-all;
}
#sandboxStderr { color: #fca5a5; }

.sandbox-meta {
    padding: 5px 12px;
    font-size: 11px;
    color: #9ca3af;
    background: #262637;
    border-top: 1px solid #3a3a52;
}

/* ========== 多会话管理列表 ========== */
.session-list {
    flex: none;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.session-list:empty::after {
    content: '暂无保存的对话';
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    padding: 8px 0;
}

.session-empty {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    padding: 8px 0;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.session-item:hover {
    background: var(--bg);
}

.session-item.active {
    background: #e8f0fe;
    border-color: var(--primary-light);
}

.session-title {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item.active .session-title {
    color: var(--primary);
    font-weight: 600;
}

.session-del,
.session-rename {
    flex: none;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.session-item:hover .session-del,
.session-item:hover .session-rename {
    opacity: 1;
}

.session-del:hover {
    background: #fee2e2;
    color: #dc2626;
}

.session-rename:hover {
    background: #e8f0fe;
    color: var(--primary);
}

/* 内联命名编辑态 */
.session-item.editing {
    background: #fff;
    border-color: var(--primary-light);
    padding: 6px 8px;
}

.session-title-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 3px 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--primary);
    border-radius: 4px;
    outline: none;
    box-shadow: 0 0 0 1px rgba(47, 84, 150, 0.15);
}

.session-title-input:focus {
    border-color: var(--primary);
}

/* 触屏/窄屏无 hover，重命名与删除按钮常驻半显，保证移动端可触发 */
@media (hover: none), (max-width: 768px) {
    .session-del,
    .session-rename {
        opacity: 0.55;
    }
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 文件列表空状态 */
.file-empty {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    padding: 20px 0;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 响应式 */
@media (max-width: 1024px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .preview-panel {
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* ==================== 语音章节命名面板 ==================== */
.audio-panel {
    width: 380px;
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    display: none;
    flex-direction: column;
}

.audio-panel.active {
    display: flex;
}

.audio-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

.audio-add-btn {
    padding: 7px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

.audio-add-btn:hover { background: #1d4ed8; }

.audio-summary {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
}

.audio-dropzone {
    margin: 12px 15px;
    padding: 18px 12px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.audio-dropzone:hover,
.audio-dropzone.dragover {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.06);
}

.audio-drop-main {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
}

.audio-drop-sub {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.7;
    margin: 0;
}

.audio-task-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px 12px;
}

.audio-task {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    background: #fff;
}

.audio-task-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.audio-task-name {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
    line-height: 1.5;
}

.audio-task-meta {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 3px;
}

.audio-badge {
    flex-shrink: 0;
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.audio-badge.pending    { background: #f3f4f6; color: #6b7280; }
.audio-badge.uploading  { background: #dbeafe; color: #1d4ed8; }
.audio-badge.queued     { background: #f3f4f6; color: #6b7280; }
.audio-badge.processing { background: #fef3c7; color: #b45309; }
.audio-badge.success    { background: #d1fae5; color: #047857; }
.audio-badge.failed     { background: #fee2e2; color: #b91c1c; }

.audio-progress {
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    margin-top: 10px;
    overflow: hidden;
}

.audio-progress-bar {
    height: 100%;
    width: 0%;
    background: #2563eb;
    border-radius: 3px;
    transition: width 0.2s;
}

.audio-chapter {
    margin-top: 10px;
    padding: 8px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-all;
}

.audio-chapter .chapter-label {
    font-size: 11px;
    color: #047857;
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.audio-error {
    margin-top: 10px;
    padding: 8px 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 12px;
    color: #b91c1c;
    line-height: 1.6;
    word-break: break-all;
}

.audio-task-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.audio-btn {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: inline-block;
    transition: background .15s ease, opacity .15s ease, transform .1s ease;
}

.audio-btn:hover { background: #f9fafb; }
.audio-btn:active { transform: translateY(1px); }

.audio-btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    font-weight: 600;
}

.audio-btn.primary:hover { background: #1d4ed8; }
.audio-btn.primary:active { background: #1e40af; }

.audio-btn.danger { color: #b91c1c; }
.audio-btn.danger:hover { background: #fef2f2; }

.audio-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.audio-footer-hint {
    padding: 10px 15px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.6;
}

.audio-empty {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    padding: 24px 0;
}

@media (max-width: 1024px) {
    .audio-panel {
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    }
}
/* ==================== 语音章节命名独立页面 ==================== */
/* 独立页面：覆盖主页面的 body overflow:hidden，恢复滚动 */
.audio-page-body { overflow: auto !important; height: auto !important; }
.audio-page { max-width: 920px; margin: 0 auto; padding: 20px 24px 40px; min-height: 100vh; background: var(--bg-color); overflow-y: auto; }
html:has(.audio-page) body, body:has(.audio-page) { overflow: auto !important; height: auto !important; }
.audio-page-header{display:flex;align-items:center;gap:16px;margin-bottom:20px;flex-wrap:wrap}
.audio-back-btn{flex-shrink:0;padding:8px 16px;background:var(--card-bg);border:1px solid var(--border);border-radius:20px;text-decoration:none;color:var(--text-color);font-size:14px;font-weight:600;transition:all .2s;font-family:inherit;line-height:1.2;cursor:pointer}
.audio-back-btn:hover{background:#2563eb;color:#fff;border-color:#2563eb}
.audio-badge.cancelled{background:#f3f4f6;color:#6b7280}
/* 批量任务行内小操作按钮 */
.audio-row-btn{border:none;background:none;padding:2px 8px;font-size:12px;color:#2563eb;cursor:pointer;border-radius:10px}
.audio-row-btn:hover{background:#eff6ff}
.audio-row-btn.danger{color:#b91c1c}
.audio-row-btn.danger:hover{background:#fef2f2}
.audio-row-btn:disabled{opacity:.45;cursor:not-allowed}
.audio-progress-bar.indeterminate{width:40%;animation:audio-indet 1.1s ease-in-out infinite}
@keyframes audio-indet{0%{margin-left:-40%}100%{margin-left:100%}}
.audio-page-header h1{font-size:22px;margin:0;white-space:nowrap}
.audio-page-sub{font-size:12px;color:var(--text-light);white-space:nowrap}
.audio-page-toolbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap;padding:12px 16px;background:var(--card-bg);border:1px solid var(--border);border-radius:12px}
.audio-tool-btn{padding:7px 14px;font-size:13px;border-radius:16px;border:1px solid var(--border);background:#fff;cursor:pointer;color:inherit;transition:all .2s}
.audio-tool-btn:hover:not(:disabled){background:#f9fafb}
.audio-tool-btn.primary{background:#2563eb;border-color:#2563eb;color:#fff;font-weight:600}
.audio-tool-btn.primary:hover:not(:disabled){background:#1d4ed8}
.audio-tool-btn.danger{color:#b91c1c}
.audio-tool-btn.danger:hover:not(:disabled){background:#fef2f2}
.audio-tool-btn:disabled{opacity:.5;cursor:not-allowed}
.audio-toolbar-sep{width:1px;height:24px;background:var(--border);flex-shrink:0}
.audio-checkbox-wrap{flex-shrink:0;display:flex;align-items:center;cursor:pointer;margin-right:4px}
.audio-task-checkbox{width:16px;height:16px;cursor:pointer;accent-color:#2563eb}
.audio-task.selected{border-color:#2563eb;background:rgba(37,99,235,.03)}
.audio-task-info{flex:1;min-width:0}
.audio-toast{position:fixed;bottom:30px;left:50%;transform:translateX(-50%) translateY(60px);background:#1f2937;color:#fff;padding:10px 24px;border-radius:20px;font-size:14px;opacity:0;transition:all .3s;z-index:9999;pointer-events:none}
.audio-toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.audio-clip-select-wrap{margin-top:10px;display:flex;align-items:center;gap:8px}
.audio-clip-label{font-size:13px;color:var(--text-light);white-space:nowrap}
.audio-clip-select{padding:5px 12px;border:1px solid var(--border);border-radius:16px;font-size:13px;background:#fff;cursor:pointer;color:var(--text-color);outline:none}
.audio-clip-select:hover{border-color:#2563eb}
.audio-clip-select:focus{border-color:#2563eb;box-shadow:0 0 0 2px rgba(37,99,235,.15)}
.audio-page .audio-dropzone{margin:0 0 16px}
.audio-page .audio-task-list{padding:0}
@media(max-width:768px){.audio-page{padding:12px}.audio-page-toolbar{gap:6px}.audio-tool-btn{padding:5px 10px;font-size:12px}.audio-page-header h1{font-size:18px}}

/* ==================== 右侧音频文件管理框（语音章节命名/音频解析转换页共用） ==================== */
.audio-page-with-afm{min-height:100vh}
.audio-page-with-afm .audio-page-main{max-width:920px;margin:0 auto}
.afm-panel{display:none;width:300px;flex-shrink:0;background:var(--card-bg);border:1px solid var(--border);border-radius:12px;overflow:hidden;position:sticky;top:20px;max-height:calc(100vh - 40px);flex-direction:column}
@media(min-width:1300px){
    .audio-page-with-afm{display:flex;gap:20px;justify-content:center;align-items:flex-start;padding:20px 24px 40px}
    .audio-page-with-afm .audio-page-main{width:920px;flex-shrink:0}
    .audio-page-with-afm .audio-page-main .audio-page{max-width:none;padding:0;min-height:0}
    .afm-panel{display:flex}
}
@media(max-width:1299px){
    .afm-panel{display:flex;width:auto;position:static;max-height:none;margin:0 24px 40px}
}
.afm-header{display:flex;align-items:center;justify-content:space-between;padding:12px 15px;border-bottom:1px solid var(--border)}
.afm-header h3{font-size:15px;margin:0}
.afm-refresh-btn{border:1px solid var(--border);background:#fff;border-radius:6px;width:26px;height:26px;cursor:pointer;font-size:14px;line-height:1;color:var(--text-light);transition:all .2s}
.afm-refresh-btn:hover{border-color:#2563eb;color:#2563eb}
.afm-sortbar{display:flex;align-items:center;gap:6px;padding:8px 15px;border-bottom:1px solid var(--border);background:#fafafa}
.afm-sort-label{font-size:12px;color:var(--text-light)}
.afm-sort-select{flex:1;padding:3px 8px;font-size:12px;border:1px solid var(--border);border-radius:6px;background:#fff;cursor:pointer;color:var(--text-color);outline:none}
.afm-sort-dir{border:1px solid var(--border);background:#fff;border-radius:6px;width:26px;height:24px;cursor:pointer;font-size:13px;line-height:1;color:var(--text-light)}
.afm-sort-dir:hover{border-color:#2563eb;color:#2563eb}
.afm-toolbar{padding:8px 15px}
.afm-list-wrap{flex:1;overflow-y:auto;padding:12px 15px}
.afm-item{padding:9px 10px;cursor:default}
.afm-meta{display:flex;flex-wrap:wrap;gap:4px 10px;font-size:11px;color:var(--text-light);align-items:center}
.afm-tag{padding:0 6px;border-radius:8px;background:#eff6ff;color:#2563eb;font-size:10px;line-height:16px}
.afm-busy-tag{padding:0 6px;border-radius:8px;background:#fef2f2;color:#b91c1c;font-size:10px;line-height:16px;font-weight:600}
.afm-item-busy{background:#fafafa}
.afm-empty{padding:30px 10px;text-align:center;font-size:12px;color:var(--text-light)}
