/* ============================================
   政务服务助手 - 专业演示�?CSS
   清新蓝绿 · 现代简�?· 政务风格
   ============================================ */

/* ========== 变量定义 ========== */
:root {
    --primary: #FF8A65;
    --primary-light: #FFAB91;
    --primary-dark: #F4511E;
    --secondary: #81C784;
    --secondary-light: #A5D6A7;
    --gradient-primary: linear-gradient(135deg, #FF8A65 0%, #FFAB91 100%);
    --gradient-secondary: linear-gradient(135deg, #81C784 0%, #A5D6A7 100%);
    --gradient-hero: linear-gradient(135deg, #FFF5F2 0%, #F8FDF7 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #90A4AE;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.12);
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-full: 9999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html {
    /* 完全禁止水平滚动和缩放 */
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    background: var(--bg-secondary); /* 和 body 一样的背景色，避免滚动时透出白色 */
    height: 100%;
    width: 100%;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    background: var(--bg-secondary);
    line-height: 1.6;
    height: 100%; /* 不要用 min-height:100vh，移动端有地址栏问题 */
    width: 100%;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto; /* 允许垂直滚动 */
    /* 禁止双击缩放 */
    touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-tertiary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== 登录页面 ========== */
.login-container {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient-hero);
    padding: 20px; z-index: 9999;
}
.login-container::before {
    content: ''; position: absolute; top: -50%; right: -30%; width: 80%; height: 150%;
    background: radial-gradient(circle, rgba(255, 138, 101, 0.08) 0%, transparent 60%); pointer-events: none;
}
.login-box {
    position: relative; width: 100%; max-width: 420px;
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px);
    border-radius: var(--radius-xl); padding: 48px 40px;
    box-shadow: var(--shadow-xl); border: 1px solid rgba(255, 255, 255, 0.8);
    animation: cardIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.login-header { text-align: center; margin-bottom: 40px; }
.login-logo {
    width: 72px; height: 72px; background: var(--gradient-primary); border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(255, 138, 101, 0.3);
}
.login-logo svg { width: 40px; height: 40px; fill: white; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.login-header p { font-size: 0.938rem; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-error {
    padding: 12px; background: rgba(239, 68, 68, 0.1); border-radius: var(--radius);
    color: var(--danger); font-size: 0.875rem; text-align: center;
}
.login-hint {
    text-align: center; margin-top: 16px; font-size: 0.813rem; color: var(--text-muted);
}

/* 登录表单通用样式 */
.login-box .form-group { position: relative; }
.login-box .form-group label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
.login-box .form-group input, .login-box .form-group select, .login-box .form-group textarea {
    width: 100%; padding: 14px 16px; background: var(--bg-secondary);
    border: 2px solid transparent; border-radius: var(--radius); font-size: 1rem;
    color: var(--text-primary); transition: var(--transition);
}
.login-box .form-group input:focus, .login-box .form-group select:focus, .login-box .form-group textarea:focus {
    background: white; border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.1);
}
.login-box .form-group input::placeholder, .login-box .form-group textarea::placeholder { color: var(--text-muted); }
.login-box .login-btn {
    width: 100%; padding: 16px; background: var(--gradient-primary); color: white;
    font-size: 1rem; font-weight: 600; border-radius: var(--radius); margin-top: 8px; transition: var(--transition);
}
.login-box .login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255, 138, 101, 0.4); }

/* ========== 主应用容�?========== */
.app-container { 
    display: none; 
    min-height: 100%; 
    height: 100%; 
    background: var(--bg-secondary); 
    position: relative; /* 确保子元素的固定定位正常 */
}

/* ========== 侧边栏 Logo ========== */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-logo h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* ========== 主内容区 ========== */
.main-content { 
    min-height: 100%; 
    height: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}
.page { 
    display: none; 
    min-height: 100%; 
    height: 100%;
    animation: fadeIn 0.3s ease; 
    max-width: 100vw;
    overflow-x: hidden;
}
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 弹窗 overlay 必须是最高 z-index */
.modal-overlay { 
    z-index: 10000 !important; 
}

/* ========== 智能助手页面 ========== */
.chat-page { 
    display: flex; 
    height: 100%; 
    max-height: 100%;
    overflow: hidden; /* 完全固定，不允许拉动 */
    position: relative;
}
.chat-sidebar { 
    width: 280px; 
    background: white; 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0; 
    max-height: 100%; /* 限制高度 */
    transition: width 0.3s ease;
}
.chat-sidebar.collapsed {
    width: 70px;
}
.sidebar-header { 
    padding: 16px 20px; 
    border-bottom: 1px solid var(--border); 
    display: flex;
    gap: 12px;
    align-items: center;
}
.chat-sidebar.collapsed .sidebar-header {
    padding: 16px 10px;
    flex-direction: column;
    align-items: center;
}
.chat-sidebar.collapsed .sidebar-logo {
    display: none;
}
.new-chat-btn {
    margin: 12px 20px;
    padding: 12px 16px; 
    background: var(--gradient-primary); 
    color: white;
    border-radius: var(--radius); 
    font-size: 0.875rem; 
    font-weight: 600;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    transition: var(--transition);
}
.chat-sidebar.collapsed .new-chat-btn {
    margin: 12px;
    padding: 12px;
}
.new-chat-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255, 138, 101, 0.3); }
.new-chat-btn svg { width: 18px; height: 18px; fill: currentColor; }
.chat-sidebar.collapsed .new-chat-btn span {
    display: none;
}
.sidebar-toggle-btn {
    padding: 8px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
    background: var(--bg-tertiary);
}
.sidebar-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--text-secondary);
}
.chat-sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}
.sidebar-search {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-sidebar.collapsed .sidebar-search {
    padding: 12px;
    justify-content: center;
}
.sidebar-search svg {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
    flex-shrink: 0;
}
.sidebar-search input {
    flex: 1;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition-fast);
}
.sidebar-search input:focus {
    background: white;
    box-shadow: 0 0 0 2px var(--primary);
}
.chat-sidebar.collapsed .sidebar-search input {
    display: none;
}
.role-btn { background: var(--bg-secondary); color: var(--text-primary); margin-top: 8px; border: 1px solid var(--border); }
.role-btn:hover { background: var(--bg-tertiary); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.chat-history { flex: 1; overflow-y: auto; padding: 12px; }
.chat-sidebar.collapsed .chat-history {
    padding: 12px 8px;
}
.history-item { 
    padding: 12px; border-radius: var(--radius); cursor: pointer; transition: var(--transition-fast); 
    margin-bottom: 4px; position: relative; display: flex; align-items: center;
}
.chat-sidebar.collapsed .history-item {
    padding: 12px 8px;
    justify-content: center;
}
.history-item:hover { background: var(--bg-secondary); }
.history-item.active { background: rgba(255, 138, 101, 0.08); }
.history-item-content { flex: 1; min-width: 0; }
.chat-sidebar.collapsed .history-item-content {
    display: none;
}
.history-item-title { font-size: 0.875rem; color: var(--text-primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-date { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.history-item-delete {
    width: 28px; height: 28px; border-radius: var(--radius-sm); background: transparent;
    display: flex; align-items: center; justify-content: center; opacity: 0; transition: var(--transition-fast);
    flex-shrink: 0; margin-left: 8px;
}
.chat-sidebar.collapsed .history-item-delete {
    display: none;
}
.history-item:hover .history-item-delete { opacity: 1; }
.history-item-delete:hover { background: rgba(239, 68, 68, 0.1); }
.history-item-delete:hover svg { fill: var(--danger); }
.history-item-delete svg { width: 16px; height: 16px; fill: var(--text-muted); transition: var(--transition-fast); }
.history-empty { text-align: center; padding: 24px 12px; color: var(--text-muted); font-size: 0.875rem; }
.chat-sidebar.collapsed .history-empty {
    display: none;
}
.history-role-tag { display: inline-block; margin-right: 4px; font-size: 0.875rem; }
.sidebar-footer { 
    padding: 0; 
    border-top: 1px solid var(--border); 
    flex-shrink: 0;
}
.chat-sidebar.collapsed .sidebar-footer {
    display: none;
}

/* 功能菜单折叠 */
.sidebar-nav-section {
    border-bottom: 1px solid var(--border);
}
.sidebar-nav-toggle {
    width: 100%;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}
.sidebar-nav-toggle:hover {
    background: var(--bg-secondary);
}
.sidebar-nav-toggle-label {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.sidebar-nav-arrow {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
    transition: transform 0.2s ease;
}
.sidebar-nav-toggle.open .sidebar-nav-arrow {
    transform: rotate(180deg);
}
.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 12px 12px;
}
.sidebar-nav-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.813rem;
    color: var(--text-secondary);
    background: transparent;
    text-align: left;
    transition: var(--transition-fast);
    cursor: pointer;
    border: none;
}
.sidebar-nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.sidebar-nav-item.active {
    background: rgba(255, 138, 101, 0.1);
    color: var(--primary);
    font-weight: 500;
}

/* 用户区折叠 */
.sidebar-user-section {
    /* no border-top needed */
}
.sidebar-user-toggle {
    width: 100%;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}
.sidebar-user-toggle:hover {
    background: var(--bg-secondary);
}
.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}
.sidebar-user-name {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-primary);
}
.sidebar-user-arrow {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
    transition: transform 0.2s ease;
}
.sidebar-user-toggle.open .sidebar-user-arrow {
    transform: rotate(180deg);
}
.sidebar-user-menu {
    padding: 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.813rem;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}
.sidebar-user-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.sidebar-user-item svg {
    fill: var(--text-secondary);
    flex-shrink: 0;
}
.sidebar-user-item:hover svg {
    fill: var(--primary);
}

/* 对话区域 */
.chat-area { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background: var(--bg-secondary); 
    max-height: 100%;
    overflow: hidden;
}
.sidebar-menu-btn { display: none; }
.chat-header { 
    background: white; 
    border-bottom: 1px solid var(--border); 
    flex-shrink: 0;
}
.chat-header-disclaimer {
    background: #FFFBEB;
    padding: 4px 16px;
    font-size: 0.7rem;
    color: #92400E;
    text-align: center;
    border-top: 1px solid rgba(245, 158, 11, 0.12);
}
.chat-header-row {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    gap: 4px;
}
.chat-header-row h2 { 
    font-size: 0.875rem; 
    font-weight: 600; 
    color: var(--text-primary); 
    margin: 0;
    white-space: nowrap;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius-full);
    font-size: 0.688rem;
    color: #10b981;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}
.role-badge.ai-collaborative {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
}
.role-badge.single-role {
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
}
.badge-dot { 
    width: 5px; height: 5px; 
    background: var(--success); 
    border-radius: 50%; 
    flex-shrink: 0;
}
.chat-header-spacer {
    flex: 1;
    min-width: 4px;
}
.role-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 5px 8px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: white;
    color: var(--text-secondary);
    font-size: 0.688rem;
    font-weight: 600;
    transition: var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}
.role-toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.role-toggle-btn.dispatcher-active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.role-btn-text {
    display: none;
}
.summary-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.625rem;
    color: var(--text-muted);
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.summary-toggle input {
    width: 12px;
    height: 12px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.icon-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-tertiary); }
.icon-btn svg { width: 16px; height: 16px; fill: var(--text-muted); }
.icon-btn:hover svg { fill: var(--text-secondary); }

/* ========== 桌面端 chat-header 还原单行 ========== */
@media (min-width: 1025px) {
    .chat-header {
        flex-direction: row;
        align-items: center;
    }
    .chat-header-row {
        padding: 12px 20px;
        gap: 8px;
    }
    .chat-header-row h2 {
        font-size: 1.125rem;
    }
    .role-badge {
        padding: 5px 12px;
        font-size: 0.75rem;
        gap: 5px;
    }
    .badge-dot {
        width: 7px;
        height: 7px;
    }
    .chat-header-spacer {
        flex: 1;
        min-width: 12px;
    }
    .role-toggle-btn {
        padding: 7px 14px;
        font-size: 0.813rem;
        gap: 5px;
    }
    .role-btn-text {
        display: inline;
    }
    .summary-toggle {
        font-size: 0.75rem;
        gap: 5px;
    }
    .summary-toggle input {
        width: 14px;
        height: 14px;
    }
    .icon-btn {
        width: 34px;
        height: 34px;
    }
    .icon-btn svg { width: 18px; height: 18px; }
}

/* 消息区域 */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; min-height: 0; }
.welcome-message { text-align: center; padding: 60px 20px; animation: slideUp 0.5s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.welcome-icon {
    width: 80px; height: 80px; background: var(--gradient-primary); border-radius: var(--radius-xl);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 24px;
    box-shadow: 0 12px 32px rgba(255, 138, 101, 0.3);
}
.welcome-icon svg { width: 44px; height: 44px; fill: white; }
.welcome-message h3 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.welcome-message p { font-size: 1rem; color: var(--text-secondary); max-width: 400px; margin: 0 auto 32px; }
.quick-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 600px; margin: 0 auto; }
.quick-prompt {
    padding: 12px 20px; background: white; border: 1px solid var(--border);
    border-radius: var(--radius-full); font-size: 0.875rem; color: var(--text-secondary); transition: var(--transition);
}
.quick-prompt:hover { background: white; border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }

/* 消息气泡 */
.message { display: flex; gap: 10px; margin: 16px 0; animation: messageIn 0.3s ease; }
@keyframes messageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.user { flex-direction: row-reverse; }
.message-avatar { width: 36px; height: 36px; background: var(--gradient-primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.message.user .message-avatar { background: var(--bg-tertiary); }
.message-avatar svg { width: 20px; height: 20px; fill: white; }
.message.user .message-avatar svg { fill: var(--text-secondary); }
.message-content { max-width: 70%; }
.message-bubble {
    padding: 12px 16px; background: white; border-radius: var(--radius-lg);
    border-top-left-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
    font-size: 0.85rem; line-height: 1.6; color: var(--text-primary);
}
.message.user .message-bubble { background: var(--gradient-primary); color: white; border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-sm); }
.message-bubble p { margin-bottom: 12px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { margin: 12px 0; padding-left: 20px; }
.message-bubble li { margin-bottom: 6px; }
.message-bubble strong { font-weight: 600; }
.message-bubble code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 0.875em; }
.message.user .message-bubble code { background: rgba(255,255,255,0.2); }
.message-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; padding: 0 4px; }
.message.user .message-time { text-align: right; }

/* 加载动画 */
.typing-indicator { display: flex; gap: 4px; padding: 16px 20px; }
.typing-indicator span { width: 8px; height: 8px; background: var(--text-muted); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; }
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

/* 输入区域 */
.chat-input-area { 
    padding: 16px 24px; 
    background: white; 
    border-top: 1px solid var(--border); 
    flex-shrink: 0; /* 完全固定，不压缩 */
}
.chat-input-container { display: flex; gap: 16px; align-items: flex-end; background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 12px; border: 2px solid transparent; transition: var(--transition); }
.chat-input-container:focus-within { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.1); }
.chat-input { flex: 1; padding: 12px 16px; background: transparent; border: none; font-size: 1rem; color: var(--text-primary); resize: none; min-height: 56px; max-height: 140px; line-height: 1.5; }
.chat-input::placeholder { color: var(--text-muted); }
.send-btn { width: 56px; height: 56px; background: var(--gradient-primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: var(--transition); flex-shrink: 0; }
.send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(255, 138, 101, 0.3); }
.send-btn:active { transform: scale(0.95); }
.send-btn svg { width: 24px; height: 24px; fill: white; }
.send-btn:disabled { background: var(--bg-tertiary); cursor: not-allowed; transform: none; box-shadow: none; }
.send-btn:disabled svg { fill: var(--text-muted); }
.role-modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; }
.multi-role-group { display: grid; gap: 16px; }
.role-response-card { background: white; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.role-response-card.user { border-left: 4px solid #64748b; }
.role-response-card.mediator { border-left: 4px solid #0ea5e9; }
.role-response-card.women_federation { border-left: 4px solid #f472b6; }
.role-response-card.community { border-left: 4px solid #22c55e; }
.role-response-card.police { border-left: 4px solid #6366f1; }
.role-response-card.lawyer { border-left: 4px solid #f59e0b; }
.role-response-card.psychology { border-color: rgba(168, 85, 247, 0.35); background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%); border-left: 4px solid #a855f7; }
.role-response-card.summary-card { border-color: rgba(16, 185, 129, 0.35); background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 100%); border-left: 4px solid #10b981; }

/* 潜在风险预警卡片样式 */
.risk-warning-card {
    background: linear-gradient(180deg, #fef2f2 0%, #ffffff 100%);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-left: 4px solid #ef4444;
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin: 16px 0;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.risk-warning-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

.risk-warning-icon {
    font-size: 1.2rem;
    margin-right: 6px;
}

.risk-warning-title {
    font-weight: 700;
    color: #dc2626;
}

.risk-warning-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.risk-warning-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.risk-warning-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.risk-warning-close:hover {
    color: var(--text-primary);
}

.risk-warning-body {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 0.85rem;
}

.risk-warning-body br {
    display: block;
    margin-bottom: 6px;
    content: "";
}

.role-response-header { display: flex; justify-content: flex-start; align-items: center; margin-bottom: 10px; gap: 8px; }
.role-response-name { font-weight: 700; color: var(--text-primary); }
.role-response-time { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.role-response-body { font-size: 0.85rem; color: var(--text-primary); line-height: 1.7; }
.role-response-icon { font-size: 1.2rem; margin-right: 6px; }
.typing-dots { display: flex; gap: 4px; padding: 8px 0; }
.typing-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); animation: typingBounce 1.4s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* 新的加载动画样式 */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 0;
}
.loading-dots {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}
.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: loadingBounce 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loadingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}
.loading-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s ease;
}
.typing-hint { margin-top: 8px; font-size: 0.875rem; color: var(--text-muted); }
.typing-role-flow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.typing-role-flow span { padding: 4px 8px; border-radius: var(--radius-full); background: rgba(8,145,178,0.08); color: var(--primary); font-size: 0.75rem; }

/* 扩展问题区域 */
.suggested-questions { padding: 0 24px 16px; background: var(--bg-secondary); animation: slideUp 0.3s ease; margin-bottom: 24px; }
.suggested-label { font-size: 0.813rem; color: var(--text-muted); margin-bottom: 12px; font-weight: 500; }
.suggested-list { display: flex; flex-wrap: wrap; gap: 10px; }
.suggested-item {
    padding: 10px 16px; background: white; border: 1px solid var(--border);
    border-radius: var(--radius-full); font-size: 0.875rem; color: var(--text-secondary);
    cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 8px;
}
.suggested-item::before { content: '?'; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; background: rgba(255, 138, 101, 0.1); border-radius: 50%; font-size: 0.75rem; color: var(--primary); font-weight: 600; }
.suggested-item:hover { background: var(--gradient-primary); color: white; border-color: transparent; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 138, 101, 0.2); }
.suggested-item:hover::before { background: rgba(255,255,255,0.2); color: white; }

/* ========== 案例库页�?========== */
.cases-page { padding: 32px; max-width: 1200px; margin: 0 auto; }
.page-hero { text-align: center; margin-bottom: 48px; animation: slideUp 0.6s ease; }
.page-hero h1 { font-size: 2.25rem; font-weight: 800; color: var(--text-primary); margin-bottom: 16px; }
.page-hero p { font-size: 1.125rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto; }
.filter-bar { display: flex; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; animation: slideUp 0.6s ease 0.1s both; }
.search-box { flex: 1; min-width: 280px; position: relative; }
.search-box input { width: 100%; padding: 14px 20px 14px 48px; background: white; border: 2px solid var(--border); border-radius: var(--radius); font-size: 0.938rem; transition: var(--transition); }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.1); }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: var(--text-muted); }
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-tab { padding: 12px 20px; background: white; border: 2px solid var(--border); border-radius: var(--radius); font-size: 0.875rem; color: var(--text-secondary); font-weight: 500; transition: var(--transition); }
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { background: var(--gradient-primary); border-color: transparent; color: white; }
.cases-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 24px; }
.case-card { background: white; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: var(--transition); cursor: pointer; animation: slideUp 0.5s ease both; }
.case-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); }
.case-card:nth-child(1) { animation-delay: 0.1s; }
.case-card:nth-child(2) { animation-delay: 0.15s; }
.case-card:nth-child(3) { animation-delay: 0.2s; }
.case-card:nth-child(4) { animation-delay: 0.25s; }
.case-card:nth-child(5) { animation-delay: 0.3s; }
.case-card:nth-child(6) { animation-delay: 0.35s; }
.case-card-image { height: 160px; background: var(--gradient-hero); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.case-card-image::before { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230891b2' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
.case-icon { width: 64px; height: 64px; background: white; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); position: relative; z-index: 1; }
.case-icon svg { width: 32px; height: 32px; fill: var(--primary); }
.case-category { position: absolute; top: 16px; left: 16px; padding: 6px 12px; background: rgba(255,255,255,0.95); backdrop-filter: blur(8px); border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; color: var(--primary); }
.case-card-body { padding: 24px; }
.case-card-title { font-size: 1.125rem; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; line-height: 1.4; }
.case-card-desc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.case-card-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 16px; border-top: 1px solid var(--border); }
.case-tag { padding: 4px 10px; background: var(--bg-secondary); border-radius: var(--radius-full); font-size: 0.75rem; color: var(--text-muted); }
.case-status { display: flex; align-items: center; gap: 6px; font-size: 0.813rem; color: var(--success); font-weight: 500; }
.case-status-dot { width: 6px; height: 6px; background: var(--success); border-radius: 50%; }

/* ========== 服务黄页页面 ========== */
.yellow-page { padding: 32px; max-width: 1200px; margin: 0 auto; }
.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.contact-card { background: white; border-radius: var(--radius-lg); padding: 24px; display: flex; gap: 16px; box-shadow: var(--shadow-sm); transition: var(--transition); cursor: pointer; animation: slideUp 0.5s ease both; }
.contact-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.contact-icon { width: 56px; height: 56px; background: var(--gradient-primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.contact-icon svg { width: 28px; height: 28px; fill: white; }
.contact-icon.green { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); }
.contact-icon.orange { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
.contact-icon.purple { background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%); }
.contact-icon.red { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); }
.contact-info { flex: 1; }
.contact-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.contact-department { font-size: 0.813rem; color: var(--text-muted); margin-bottom: 12px; }
.contact-phone { font-size: 1.125rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.contact-phone svg { width: 20px; height: 20px; fill: currentColor; }
.call-btn { padding: 8px 16px; background: var(--bg-secondary); border-radius: var(--radius); font-size: 0.813rem; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; transition: var(--transition-fast); margin-top: 12px; }
.contact-card:hover .call-btn { background: var(--primary); color: white; }
.call-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* ========== 文书生成页面 ========== */
.document-page { padding: 32px; max-width: 1400px; margin: 0 auto; }
.document-container { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 32px; 
    animation: slideUp 0.5s ease; 
    width: 100%;
}
.document-form { 
    background: white; 
    border-radius: var(--radius-lg); 
    padding: 32px; 
    box-shadow: var(--shadow); 
    overflow: visible; /* 防止内部独立滚动，统一靠主页面 */
}
.form-section { margin-bottom: 32px; }
.form-section:last-child { margin-bottom: 0; }
.form-section h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }
.ai-generate-btn {
    padding: 8px 14px; background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: white; border-radius: var(--radius); font-size: 0.813rem; font-weight: 500;
    display: flex; align-items: center; gap: 6px; transition: var(--transition); cursor: pointer;
}
.ai-generate-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.ai-generate-btn svg { width: 16px; height: 16px; fill: currentColor; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.btn {
    padding: 14px 24px; border-radius: var(--radius); font-size: 0.938rem; font-weight: 600;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition); cursor: pointer;
}
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn-primary { background: var(--gradient-primary); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255, 138, 101, 0.3); }
.btn-secondary { background: white; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* 文书预览 */
.document-preview { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.preview-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.preview-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.preview-hint { font-size: 0.813rem; color: var(--text-muted); }
.preview-content { flex: 1; padding: 32px; overflow-y: auto; background: #fafafa; min-height: 500px; }
.preview-placeholder { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.preview-placeholder svg { width: 80px; height: 80px; fill: var(--border); margin-bottom: 16px; }
.preview-placeholder p { font-size: 0.938rem; }

/* 文书内容样式 */
.doc-content { background: white; padding: 48px; border-radius: var(--radius); box-shadow: var(--shadow-sm); font-size: 0.938rem; line-height: 2; }
.doc-title { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 32px; padding-bottom: 16px; border-bottom: 2px solid var(--border); }
.doc-section { margin-bottom: 24px; }
.doc-section-title { font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.doc-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.doc-table td { padding: 12px; border: 1px solid var(--border); }
.doc-table td:first-child { font-weight: 500; width: 120px; background: var(--bg-secondary); }
.doc-signature { display: flex; justify-content: space-between; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.signature-item { text-align: center; }
.signature-item p { margin-bottom: 8px; }
.signature-line { display: inline-block; width: 150px; border-bottom: 1px solid var(--text-muted); }

/* ========== 法条库页�?========== */
.law-page { padding: 32px; max-width: 1400px; margin: 0 auto; }
.law-container { display: grid; grid-template-columns: 240px 1fr; gap: 32px; animation: slideUp 0.5s ease; }
.law-sidebar { background: white; border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); height: fit-content; position: sticky; top: 96px; }
.law-sidebar h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.law-categories { display: flex; flex-direction: column; gap: 8px; }
.law-cat-btn { padding: 12px 16px; background: var(--bg-secondary); border-radius: var(--radius); font-size: 0.875rem; color: var(--text-secondary); text-align: left; transition: var(--transition-fast); }
.law-cat-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.law-cat-btn.active { background: rgba(255, 138, 101, 0.1); color: var(--primary); font-weight: 500; }
.law-content { display: flex; flex-direction: column; gap: 24px; }
.law-search { position: relative; display: flex; align-items: center; gap: 8px; }
.law-search input { flex: 1; padding: 14px 20px 14px 48px; background: white; border: 2px solid var(--border); border-radius: var(--radius); font-size: 0.938rem; transition: var(--transition); }
.law-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.1); }
.law-search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: var(--text-muted); pointer-events: none; }
.law-list { display: flex; flex-direction: column; gap: 16px; }
.law-item { background: white; border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); transition: var(--transition); cursor: pointer; }
.law-item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.law-item-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.law-item-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.law-item-code { padding: 4px 10px; background: rgba(255, 138, 101, 0.1); border-radius: var(--radius-full); font-size: 0.75rem; color: var(--primary); font-weight: 500; }
.law-item-content { font-size: 0.938rem; color: var(--text-secondary); line-height: 1.8; }

/* ========== 用户管理页面 ========== */
.users-page { padding: 32px; max-width: 1200px; margin: 0 auto; animation: slideUp 0.5s ease; }
.users-container { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.users-toolbar { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.users-table-wrapper { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { padding: 16px 20px; text-align: left; border-bottom: 1px solid var(--border); }
.users-table th { background: var(--bg-secondary); font-weight: 600; color: var(--text-primary); font-size: 0.875rem; }
.users-table td { color: var(--text-secondary); font-size: 0.875rem; }
.users-table tr:hover td { background: var(--bg-secondary); }
.users-table .role-badge { padding: 4px 10px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 500; }
.users-table .role-badge.admin { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.users-table .role-badge.user { background: rgba(255, 138, 101, 0.1); color: var(--primary); }
.users-table .actions { display: flex; gap: 8px; }
.users-table .action-btn { padding: 6px 12px; border-radius: var(--radius); font-size: 0.75rem; cursor: pointer; border: none; transition: var(--transition-fast); }
.users-table .action-btn.reset { background: rgba(255, 138, 101, 0.1); color: var(--primary); }
.users-table .action-btn.reset:hover { background: rgba(255, 138, 101, 0.2); }
.users-table .action-btn.delete { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.users-table .action-btn.delete:hover { background: rgba(239, 68, 68, 0.2); }
.table-loading { text-align: center; color: var(--text-muted); padding: 40px !important; }
.reset-pwd-info { margin-bottom: 16px; color: var(--text-secondary); }
.law-item-actions { display: flex; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.law-action-btn { padding: 8px 14px; background: var(--bg-secondary); border-radius: var(--radius); font-size: 0.813rem; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; transition: var(--transition-fast); }
.law-action-btn:hover { background: var(--primary); color: white; }
.law-action-btn svg { width: 14px; height: 14px; fill: currentColor; }

.law-search-btn { padding: 10px 20px; background: var(--primary); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.law-search-btn:hover { background: var(--primary-dark); }
.law-force-online { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 12px; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--border); transition: var(--transition); }
.law-force-online:hover { border-color: var(--primary); color: var(--primary); }
.law-force-online input { display: none; }
.law-force-online input:checked + span { color: var(--primary); font-weight: 500; }
.law-force-online:has(input:checked) { background: rgba(8,145,178,0.1); border-color: var(--primary); }
.law-search-info { padding: 8px 0; font-size: 13px; color: var(--text-secondary); }
.law-item-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.law-item-meta span { padding: 2px 8px; background: var(--bg-secondary); border-radius: var(--radius-full); }
.law-pagination { display: flex; gap: 8px; justify-content: center; padding: 16px 0; }
.law-pagination button { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: white; cursor: pointer; font-size: 13px; }
.law-pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.law-pagination button:hover:not(.active) { background: var(--bg-secondary); }
.law-detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 1000; }
.law-detail-overlay.show { display: flex; }
.law-detail-modal { width: 100%; max-width: 900px; max-height: 85vh; background: white; border-radius: var(--radius-xl); overflow: hidden; display: flex; flex-direction: column; animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1); }
.law-detail-header { padding: 20px 24px; background: var(--gradient-hero); display: flex; justify-content: space-between; align-items: center; }
.law-detail-header h2 { font-size: 1.1rem; color: white; margin: 0; flex: 1; }
.law-detail-close { background: none; border: none; color: white; font-size: 24px; cursor: pointer; padding: 0 4px; }
.law-detail-meta { padding: 12px 24px; display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.law-detail-meta span { padding: 2px 8px; background: var(--bg-secondary); border-radius: var(--radius-full); }
.law-detail-body { flex: 1; overflow-y: auto; padding: 24px; }
.law-detail-html { line-height: 1.8; font-size: 14px; }
.law-detail-html p { margin: 8px 0; text-indent: 2em; }
.law-detail-html h1,.law-detail-html h2,.law-detail-html h3 { text-indent: 0; margin: 16px 0 8px; }
.law-detail-loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.law-detail-actions { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }
.law-detail-actions .law-action-btn { padding: 8px 20px; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 弹窗 ========== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 10002; animation: fadeIn 0.2s ease; }
.modal-overlay.active { display: flex; }
#modalOverlay { display: none !important; }
#modalOverlay.active { display: flex !important; }
.modal { width: 100%; max-width: 600px; max-height: 80vh; background: white; border-radius: var(--radius-xl); overflow: hidden; animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { padding: 24px; background: var(--gradient-hero); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.modal-meta { display: flex; gap: 16px; font-size: 0.875rem; color: var(--text-secondary); }
.modal-close { width: 36px; height: 36px; background: white; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: var(--transition-fast); }
.modal-close:hover { background: var(--bg-secondary); }
.modal-close svg { width: 20px; height: 20px; fill: var(--text-secondary); }
.modal-body { padding: 24px; overflow-y: auto; max-height: 50vh; }
.modal-section { margin-bottom: 24px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.modal-section-title svg { width: 18px; height: 18px; fill: var(--primary); }
.modal-section p { font-size: 0.938rem; color: var(--text-secondary); line-height: 1.7; }
.modal-footer { padding: 20px 24px; background: var(--bg-secondary); border-top: 1px solid var(--border); display: flex; gap: 12px; }
.modal-btn { flex: 1; padding: 14px 20px; border-radius: var(--radius); font-size: 0.938rem; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition); }
.modal-btn svg { width: 18px; height: 18px; fill: currentColor; }
.modal-btn-primary { background: var(--gradient-primary); color: white; }
.modal-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255, 138, 101, 0.3); }
.modal-btn-secondary { background: white; color: var(--text-secondary); border: 1px solid var(--border); }
.modal-btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ========== Toast ========== */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px); padding: 14px 24px; background: var(--text-primary); color: white; border-radius: var(--radius); font-size: 0.875rem; box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transition: var(--transition); z-index: 2000; }
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ========== 空状�?========== */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-state svg { width: 80px; height: 80px; fill: var(--border); margin-bottom: 24px; }
.empty-state h3 { font-size: 1.25rem; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 0.938rem; color: var(--text-muted); }

/* ========== 响应�?========== */
@media (max-width: 1200px) {
    .document-container { grid-template-columns: 1fr; }
    .law-container { grid-template-columns: 1fr; }
    .law-sidebar { position: static; }
    .law-categories { flex-direction: row; flex-wrap: wrap; }
    /* 平板尺寸表单两列变一列 */
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .header-nav { display: none; }
    .nav-btn { min-width: 70px; }
    
    .page-hero h1 { font-size: 1.75rem; }
    .cases-grid { grid-template-columns: 1fr; }
    
    /* 移动端输入框优化，至少44px高度，容易点击 */
    .form-group input, .form-group select, .form-group textarea {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 16px; /* 防止 iOS 自动缩放 */
    }
    
    /* 移动端聊天输入框已优化过 */
}

/* ========== 角色选择弹窗 ========== */
.role-modal, .model-modal {
    max-width: 800px;
    width: 90%;
}

/* 调度官模式开关栏 */
.dispatcher-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    margin: 0 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    transition: var(--transition);
}
.dispatcher-toggle-bar.active {
    border-color: #6366f1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.03));
}

.dispatcher-toggle-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.dispatcher-toggle-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.dispatcher-toggle-info div strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.dispatcher-toggle-info div p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

/* 开关组件 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 26px;
    transition: all 0.3s ease;
    cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider {
    background: #6366f1;
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* 角色项禁用态 */
.role-item.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(30%);
    pointer-events: none;
}
.role-item.disabled:hover {
    background: var(--bg-secondary);
    border-color: transparent;
    transform: none;
    box-shadow: none;
}
.role-item.disabled.selected {
    box-shadow: none;
}

.modal-header {
    text-align: center;
    padding: 28px 28px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.375rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.role-list {
    padding: 20px;
    max-height: 480px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.role-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.role-item:hover {
    background: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.role-item.selected {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.12), var(--shadow);
}

.role-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: linear-gradient(135deg, rgba(255, 138, 101, 0.08), rgba(255, 138, 101, 0.02));
    border: 1px solid rgba(255, 138, 101, 0.15);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}

.role-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.role-info h4 {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.role-info p {
    font-size: 0.813rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.role-modal-actions {
    padding: 20px 28px 28px;
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
    .role-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========== 模型选择弹窗 ========== */
.model-list {
    padding: 16px;
}

.model-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius);
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.model-item:last-child {
    margin-bottom: 0;
}

.model-item:hover {
    background: white;
    border-color: var(--info);
}

.model-item.active {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 138, 101, 0.1);
}

.model-badge {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.model-badge.pro {
    background: rgba(255, 138, 101, 0.1);
    color: var(--primary);
}

.model-badge.fast {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.model-badge.deep {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.model-badge.comprehensive {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.model-badge.dispatcher {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

/* 调度官卡片样式 */
.dispatcher-card {
    border-left: 3px solid #6366f1;
}

.dispatcher-card .role-response-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
}

.dispatcher-done {
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.dispatcher-ask-body {
    padding: 4px 0;
}

.dispatcher-reply-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 10px;
}

.dispatcher-questions {
    margin-top: 8px;
}

.dispatcher-question {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.6;
    border-left: 2px solid rgba(99, 102, 241, 0.3);
}

.dispatcher-ask-hint {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.model-info h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.model-info p {
    font-size: 0.813rem;
    color: var(--text-muted);
}

@media (max-width: 1200px) {
    .document-container { grid-template-columns: 1fr; }
    .law-container { grid-template-columns: 1fr; }
    .law-sidebar { position: static; }
    .law-categories { flex-direction: row; flex-wrap: wrap; }
    .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    /* 移动端：不设固定高度，由 JS 动态计算 */
    html, body {
        overflow: hidden;
    }
    .app-container {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .main-content {
        flex: 1;
        padding-top: 0 !important;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .page {
        display: none !important;
    }
    .page.active {
        display: flex !important;
        flex: 1;
        overflow: hidden;
        flex-direction: column;
    }
    .chat-page {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .chat-area {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .chat-header {
        flex-shrink: 0;
    }
    .suggested-questions {
        flex-shrink: 0;
    }
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }
    .chat-input-area {
        flex-shrink: 0;
    }
    .cases-page, .yellow-page, .document-page, .law-page, .users-page, .welcome-page { 
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 24px 16px;
    }
    
    .header-nav { display: none; }
    .nav-btn { min-width: 70px; }
    .page-hero h1 { font-size: 1.75rem; }
    .cases-grid { grid-template-columns: 1fr; }
    .form-group input, .form-group select, .form-group textarea {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 16px;
    }
}
@media (max-width: 768px) {
    /* 最基本的重置 */
    html, body {
        height: 100%;
        overflow-x: hidden;
        position: relative;
    }
    
    
    /* 移动端直接隐藏页脚！不需要显示 */
    .site-footer {
        display: none !important;
    }
    
    /* 聊天页面布局 - 最最简单的！保持原样！ */
    .chat-page {
        display: flex;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
        position: relative;
    }
    
    .chat-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        background: var(--bg-secondary);
        max-height: 100%;
        overflow: hidden;
    }
    
    .chat-header {
        background: white;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    
    .chat-header-row {
        padding: 8px 10px;
        gap: 6px;
    }
    
    .role-badge {
        padding: 3px 8px;
        font-size: 0.625rem;
    }
    
    .badge-dot {
        width: 5px;
        height: 5px;
    }
    
    .role-toggle-btn {
        padding: 5px 8px;
        font-size: 0.688rem;
        gap: 3px;
    }
    
    .role-toggle-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .role-btn-text {
        display: none;
    }
    
    .role-summary {
        display: none;
    }
    
    .summary-toggle {
        font-size: 0.625rem;
        gap: 3px;
    }
    
    .summary-toggle input {
        width: 12px;
        height: 12px;
    }
    
    .icon-btn {
        width: 30px;
        height: 30px;
    }
    
    .icon-btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* 消息区域 - 可以滚动 */
    .chat-messages { 
        flex: 1; 
        padding: 16px; 
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 16px !important;
    }
    
    .message-content { max-width: 85%; }
    .welcome-icon { width: 64px; height: 64px; }
    .welcome-icon svg { width: 32px; height: 32px; }
    .welcome-message h3 { font-size: 1.25rem; }
    .quick-prompts { flex-direction: column; }
    .quick-prompt { width: 100%; text-align: center; }
    
    /* 输入框区域 - 回到原来的布局 */
    .chat-input-area { 
        padding: 12px 16px; 
        position: relative;
        z-index: 1;
        flex-shrink: 0;
    }
    
    /* 聚焦时稍微加一点padding，让输入法出来时不遮挡 */
    .chat-messages.focus-mode { 
        padding-bottom: 100px !important;
    }
    
    .chat-input-container { 
        display: flex;
        gap: 8px;
        align-items: flex-end; 
        padding: 10px;
        border-radius: var(--radius-lg);
    }
    
    .chat-input {
        flex: 1;
        min-height: 44px;
        max-height: 120px;
        padding: 12px 16px;
        border: 2px solid var(--border);
        border-radius: 22px;
        font-size: 16px !important;
        resize: none;
        line-height: 1.4;
        -webkit-appearance: none;
    }
    
    .chat-input:focus {
        border-color: var(--primary);
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--gradient-primary);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .send-btn svg { width: 20px; height: 20px; fill: white; }
    
    /* 移动端侧边栏 */
    .chat-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85% !important;
        max-width: 300px;
        height: 100%;
        z-index: 10001;
        transition: left 0.3s ease;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        background: white;
        border-right: 1px solid var(--border);
    }
    
    .chat-sidebar.collapsed {
        width: 85% !important;
    }
    
    /* 移动端重置所有 collapsed 状态的隐藏样式 */
    .chat-sidebar.collapsed .sidebar-header {
        padding: 20px !important;
        flex-direction: row !important;
    }
    .chat-sidebar.collapsed .new-chat-btn {
        padding: 12px 16px !important;
    }
    .chat-sidebar.collapsed .new-chat-btn span {
        display: inline !important;
    }
    .chat-sidebar.collapsed .sidebar-search {
        padding: 12px 20px !important;
        justify-content: flex-start !important;
    }
    .chat-sidebar.collapsed .sidebar-search input {
        display: block !important;
    }
    .chat-sidebar.collapsed .chat-history {
        padding: 12px !important;
    }
    .chat-sidebar.collapsed .history-item {
        padding: 12px !important;
        justify-content: flex-start !important;
    }
    .chat-sidebar.collapsed .history-item-content {
        display: block !important;
    }
    .chat-sidebar.collapsed .sidebar-footer {
        display: block !important;
    }
    
    .chat-sidebar.open {
        left: 0;
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 10000;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    #sidebarOverlay { display: none !important; }
    #sidebarOverlay.show { display: block !important; }
    
    .sidebar-toggle-btn {
        display: none !important;
    }
    
    .sidebar-menu-btn {
        display: flex !important;
        width: 30px;
        height: 30px;
        background: var(--bg-secondary);
        border-radius: var(--radius-sm);
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .sidebar-menu-btn svg { width: 18px; height: 18px; fill: var(--text-secondary); }
    
    /* 输入时隐藏页脚 */
    .site-footer.hidden { display: none !important; }
    .chat-messages.focus-mode { padding-bottom: 80px; }
    
    /* 其他移动端优化 */
    .form-row { grid-template-columns: 1fr; }
    .document-form { padding: 20px; }
    .doc-content { padding: 24px; }
    .doc-title { font-size: 1.25rem; }
    .doc-signature { flex-direction: column; gap: 24px; }
    .modal { max-height: 90vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: 100%; }
    .modal-overlay { align-items: flex-end; padding: 0; }
    .users-page { padding: 16px; }
    .users-table { font-size: 0.813rem; }
    .users-table th, .users-table td { padding: 12px 8px; }
    .users-table .actions { flex-direction: column; gap: 4px; }
    .users-table .action-btn { padding: 6px 8px; font-size: 0.688rem; width: 100%; }
    .welcome-container { padding: 24px 16px; }
    .suggested-questions { padding: 0 16px; }
    .suggested-question { padding: 10px 14px; font-size: 0.813rem; }
    .cases-grid { gap: 12px; }
    .case-card { padding: 16px; }
    .case-card-title { font-size: 0.938rem; }
    .document-container { gap: 16px; }
    .template-card { padding: 10px 12px; }
    .category-toggle { padding: 12px 14px; font-size: 0.875rem; }
    .template-group.expanded { max-height: 50vh; overflow-y: auto; }
    .contacts-grid { grid-template-columns: 1fr; gap: 12px; }
    .contact-card { padding: 14px; }
    .form-actions { flex-direction: column; gap: 10px; }
    .form-actions .btn { width: 100%; padding: 14px; font-size: 1rem; }

    .role-modal { 
        width: 100% !important;
        max-height: 85vh;
        display: flex;
        flex-direction: column;
    }
    .role-list {
        flex: 1;
        max-height: calc(85vh - 140px);
        overflow-y: auto;
        padding: 12px;
        gap: 10px;
    }
    .role-item { 
        padding: 14px 12px; 
        gap: 12px;
    }
    .role-icon { 
        width: 48px; 
        height: 48px; 
        font-size: 1.375rem;
    }
    .role-info h4 { 
        font-size: 1rem; 
    }
    .role-info p { 
        font-size: 0.813rem; 
    }
    .role-modal-actions {
        padding: 12px 16px 16px;
        flex-shrink: 0;
        background: white;
    }
    .role-modal-actions .btn {
        flex: 1;
        padding: 12px;
        font-size: 0.875rem;
    }
}

/* ========== 协议模板样式 ========== */
.template-category { margin-bottom: 12px; border: 1px solid var(--border-light); border-radius: 12px; background: white; overflow: hidden; }
.category-toggle {
    width: 100%; padding: 14px 16px; border: none; background: var(--bg-soft); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; font-size: 0.938rem; font-weight: 600;
    color: var(--text-primary); transition: all 0.2s;
}
.category-toggle:hover { background: var(--bg-primary-soft); }
.category-arrow { font-size: 1rem; transition: transform 0.2s; }
.template-group { 
    display: flex; flex-direction: column; gap: 8px; padding: 12px; max-height: 0; overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.template-group.expanded { max-height: 600px; }
.template-card {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border-light);
    border-radius: 10px; cursor: pointer; background: white; transition: all 0.2s;
}
.template-card:hover { border-color: var(--primary-light); background: var(--bg-soft); }
.template-card.active { border-color: var(--primary); background: var(--bg-primary-soft); box-shadow: 0 4px 12px rgba(255, 138, 101, 0.15); }
.template-icon { font-size: 1.5rem; }
.template-info { flex: 1; }
.template-name { font-weight: 600; color: var(--text-primary); margin-bottom: 2px; font-size: 0.938rem; }
.template-desc { font-size: 0.813rem; color: var(--text-secondary); }
.template-check {
    width: 24px; height: 24px; border: 2px solid var(--border-light); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 0.875rem; color: white; font-weight: bold;
}
.template-check.checked { background: var(--primary); border-color: var(--primary); }

#variablesSection { margin-top: 20px; }
#variablesSection .form-group { margin-bottom: 18px; }
#variablesSection .form-group label {
    font-size: 0.938rem; display: block; margin-bottom: 8px; color: var(--text-primary); font-weight: 500;
}
#variablesSection .form-group input {
    width: 100%; padding: 14px 16px; border: 1px solid var(--border-light); border-radius: 10px;
    font-size: 1rem; transition: border-color 0.2s;
}
#variablesSection .form-group input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px rgba(255, 138, 101, 0.1); }
#variablesSection .form-actions { margin-top: 24px; }

.doc-content h2.doc-title { font-size: 1.25rem; text-align: center; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }
.doc-section { margin-bottom: 12px; line-height: 1.8; }
.doc-footer { margin-top: 20px; padding-top: 10px; border-top: 1px solid var(--border-light); text-align: right; color: var(--text-secondary); font-size: 0.813rem; }

/* 协议预览弹窗 */
.document-preview-modal { max-width: 950px; max-height: 90vh; }
.preview-wrapper { max-height: 60vh; overflow-y: auto; padding: 0; background: #f9f9f9; border: 1px solid var(--border); border-radius: 8px; }
.save-options { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-footer { display: flex; gap: 12px; align-items: center; }
.modal-footer .btn { display: flex; align-items: center; gap: 6px; }
.modal-footer .btn svg { width: 16px; height: 16px; fill: currentColor; }

/* ========== 页脚 ========== */
.site-footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 24px 20px;
    text-align: center;
    flex-shrink: 0;
}
.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}
.footer-content p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.footer-content p:first-child {
    margin-bottom: 8px;
    color: var(--text-secondary);
}
.footer-disclaimer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.footer-disclaimer span:first-child {
    font-size: 1.125rem;
}

/* ========== 角色卡片折叠功能 ========== */
.role-response-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.role-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-collapse-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.role-collapse-btn:hover {
    background: var(--primary);
}

.role-collapse-btn:hover svg {
    fill: white;
}

.role-collapse-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
    transition: fill 0.2s ease, transform 0.2s ease;
}

.role-response-card.collapsed .role-collapse-btn svg {
    transform: rotate(180deg);
}

.role-response-card.collapsed .role-response-body {
    display: none;
}

/* 确保历史消息里的卡片头部也有正确的布局 */
.role-response-card .role-response-header {
    flex-wrap: nowrap;
}

/* 兼容旧的历史消息（没有 role-header-right 的情况） */
.role-response-header:not(:has(.role-header-right)) .role-response-time {
    margin-left: auto;
}

/* 修复 role-response-icon 的定位 */
.role-response-icon {
    display: inline-block;
    margin-right: 8px;
}

