/* ==========================================================================
   AI写作系统 - 新拟态风格 (Neumorphism)
   支持日间/夜间模式自适应
   ========================================================================== */

:root {
    /* 浅色模式（默认） */
    --bg-color: #e6e9ef;
    --bg-color-2: #eef1f6;
    --text-color: #2d3748;
    --text-color-2: #4a5568;
    --text-color-3: #718096;
    --border-color: rgba(0, 0, 0, 0.05);
    --shadow-light: rgba(255, 255, 255, 0.85);
    --shadow-dark: rgba(163, 177, 198, 0.55);
    --accent: #5e72e4;
    --accent-2: #7c3aed;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --user-bubble: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --ai-bubble: #e6e9ef;
    --code-bg: #2d3748;
    --code-text: #e2e8f0;
    --scroll-thumb: rgba(0, 0, 0, 0.15);
    --scroll-thumb-hover: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    --bg-color: #2a2d3a;
    --bg-color-2: #232531;
    --text-color: #e2e8f0;
    --text-color-2: #cbd5e0;
    --text-color-3: #a0aec0;
    --border-color: rgba(255, 255, 255, 0.05);
    --shadow-light: rgba(60, 64, 80, 0.5);
    --shadow-dark: rgba(15, 16, 23, 0.7);
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --ai-bubble: #34384a;
    --code-bg: #1a1d2b;
    --scroll-thumb: rgba(255, 255, 255, 0.15);
    --scroll-thumb-hover: rgba(255, 255, 255, 0.3);
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
                 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 4px;
    transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* ---------- 新拟态核心组件 ---------- */

/* 凸起 - 凸出效果 */
.neu {
    background: var(--bg-color);
    border-radius: 16px;
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
    transition: all 0.3s ease;
}

/* 凹陷 - 按下/输入框效果 */
.neu-inset {
    background: var(--bg-color);
    border-radius: 16px;
    box-shadow:
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light);
    transition: all 0.3s ease;
}

/* 圆角尺寸变体 */
.neu-sm { border-radius: 10px; box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light); }
.neu-inset-sm { border-radius: 10px; box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); }
.neu-lg { border-radius: 24px; box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light); }
.neu-pill { border-radius: 999px; }

/* 按下/悬停效果 */
.neu-pressable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}
.neu-pressable:hover {
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
    transform: translateY(-1px);
}
.neu-pressable:active, .neu-pressable.active {
    box-shadow:
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light);
    transform: translateY(0);
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-color);
    color: var(--text-color);
    border: none;
    border-radius: 12px;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover {
    color: var(--accent);
    box-shadow:
        4px 4px 8px var(--shadow-dark),
        -4px -4px 8px var(--shadow-light);
    transform: translateY(-1px);
}
.btn:active {
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    transform: translateY(0);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
}
.btn-primary:hover { color: #fff; opacity: 0.92; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: var(--danger); }
.btn-success { color: var(--success); }
.btn-success:hover { color: var(--success); }
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
}
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-circle { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color-2);
    font-size: 13px;
    font-weight: 500;
}
.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-color);
    color: var(--text-color);
    border: none;
    border-radius: 12px;
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
}
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    box-shadow:
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light),
        0 0 0 2px var(--accent);
}
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-color-3);
}
textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* 开关 toggle */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-color);
    border-radius: 999px;
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    transition: 0.3s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    top: 3px;
    background: var(--bg-color);
    border-radius: 50%;
    box-shadow:
        2px 2px 4px var(--shadow-dark),
        -2px -2px 4px var(--shadow-light);
    transition: 0.3s;
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(24px);
    background: var(--primary-gradient);
}
.toggle input:checked + .toggle-slider {
    background: var(--bg-color);
}

/* ---------- 布局 ---------- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    height: 100%;
    background: var(--bg-color);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

.main-content {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    overflow: hidden;
}

/* ---------- 头部 ---------- */
.app-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    min-height: 64px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-title-logo {
    width: 36px; height: 36px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    box-shadow:
        4px 4px 8px var(--shadow-dark),
        -4px -4px 8px var(--shadow-light);
    -webkit-text-fill-color: #fff;
}

.app-subtitle {
    font-size: 12px;
    color: var(--text-color-3);
    margin-top: 2px;
}

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

/* ---------- 历史对话列表 ---------- */
.history-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 4px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-color-2);
    margin-bottom: 6px;
    font-size: 13px;
    transition: all 0.2s;
    position: relative;
}
.history-item:hover {
    background: var(--bg-color);
    color: var(--text-color);
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.history-item.active {
    background: var(--bg-color);
    color: var(--accent);
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    font-weight: 500;
}
.history-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-item-actions {
    display: none;
    gap: 4px;
}
.history-item:hover .history-item-actions { display: flex; }
.history-item-actions .icon-btn {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--bg-color);
    box-shadow:
        2px 2px 4px var(--shadow-dark),
        -2px -2px 4px var(--shadow-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color-3);
    font-size: 11px;
}
.history-item-actions .icon-btn:hover { color: var(--danger); }
.history-item-actions .icon-btn:active {
    box-shadow:
        inset 1px 1px 2px var(--shadow-dark),
        inset -1px -1px 2px var(--shadow-light);
}

.section-label {
    font-size: 11px;
    color: var(--text-color-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info-card {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.user-name { font-size: 14px; font-weight: 500; }
.user-plan { font-size: 11px; color: var(--text-color-3); }

/* ---------- 对话区域 ---------- */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    scroll-behavior: smooth;
}
.chat-inner {
    max-width: 900px;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
    max-width: 85%;
}
.message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}
.message.assistant {
    margin-right: auto;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.message-avatar {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.message.user .message-avatar { background: var(--user-bubble); }
.message.assistant .message-avatar { background: var(--bg-color); color: var(--accent); }
.message-body { flex: 1; min-width: 0; }
.message.user .message-body { text-align: right; }
.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-color-3);
}
.message.user .message-header {
    justify-content: flex-end;
}
.message-name { font-weight: 500; color: var(--text-color-2); }
.message-content {
    display: inline-block;
    padding: 14px 18px;
    background: var(--bg-color);
    border-radius: 16px;
    color: var(--text-color);
    line-height: 1.7;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: left;
}
.message.user .message-content {
    background: var(--user-bubble);
    color: #fff;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
}
.message.user .message-actions {
    justify-content: flex-end;
}
.message.user .message-content {
    background: var(--user-bubble);
    color: #fff;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
}
.message-content p { margin: 0 0 10px 0; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6 {
    margin: 14px 0 8px 0;
    font-weight: 600;
    line-height: 1.4;
}
.message-content h1 { font-size: 1.6em; }
.message-content h2 { font-size: 1.4em; }
.message-content h3 { font-size: 1.2em; }
.message-content ul, .message-content ol { margin: 8px 0 8px 24px; }
.message-content li { margin: 4px 0; }
.message-content code {
    font-family: "JetBrains Mono", Consolas, Monaco, monospace;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    font-size: 0.9em;
}
.message.user .message-content code { background: rgba(255, 255, 255, 0.2); }
.message-content pre {
    margin: 10px 0;
    padding: 14px;
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: 10px;
    overflow-x: auto;
    font-family: "JetBrains Mono", Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.5;
}
.message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}
.message-content blockquote {
    margin: 10px 0;
    padding: 8px 16px;
    border-left: 3px solid var(--accent);
    background: rgba(94, 114, 228, 0.06);
    color: var(--text-color-2);
    border-radius: 0 8px 8px 0;
}
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}
.message-content table th,
.message-content table td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}
.message-content table th {
    background: rgba(0, 0, 0, 0.04);
    font-weight: 600;
}
[data-theme="dark"] .message-content table th { background: rgba(255, 255, 255, 0.04); }
.message-content a { color: var(--accent); text-decoration: underline; }

.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-color);
    border-radius: 16px;
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-color-3);
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.cursor-blink {
    display: inline-block;
    color: var(--accent);
    font-weight: 700;
    animation: blink 1s infinite;
    margin-left: 2px;
}
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.thinking-block {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding: 10px 14px;
    margin-bottom: 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-color-2);
    white-space: pre-wrap;
    word-break: break-word;
}
.thinking-block .thinking-title {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.thinking-block .thinking-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.message-error {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(245, 54, 92, 0.08);
    color: var(--danger);
    border-radius: 12px;
    border-left: 3px solid var(--danger);
}

.message-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message:hover .message-actions { opacity: 1; }
.message-action-btn {
    background: var(--bg-color);
    border: none;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-color-3);
    cursor: pointer;
    box-shadow:
        2px 2px 4px var(--shadow-dark),
        -2px -2px 4px var(--shadow-light);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.message-action-btn:hover { color: var(--accent); }
.message-action-btn:active {
    box-shadow:
        inset 2px 2px 4px var(--shadow-dark),
        inset -2px -2px 4px var(--shadow-light);
}
.message-action-btn.danger:hover { color: var(--danger); }

.thinking-block {
    margin: 8px 0 10px;
    padding: 10px 14px;
    background: var(--bg-color-2);
    border-radius: 10px;
    border-left: 3px solid var(--warning);
    color: var(--text-color-2);
    font-size: 13px;
    font-style: italic;
    box-shadow:
        inset 2px 2px 4px var(--shadow-dark),
        inset -2px -2px 4px var(--shadow-light);
}

/* 打字光标 */
.cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--accent);
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: middle;
}
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ---------- 输入区域 ---------- */
.input-area {
    padding: 16px 32px 24px;
    background: var(--bg-color);
}
.input-box {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-color);
    border-radius: 20px;
    padding: 16px;
    box-shadow:
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light);
}
.input-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.toolbar-btn {
    background: var(--bg-color);
    border: none;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-color-3);
    cursor: pointer;
    box-shadow:
        2px 2px 4px var(--shadow-dark),
        -2px -2px 4px var(--shadow-light);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.toolbar-btn:hover { color: var(--accent); }
.toolbar-btn:active, .toolbar-btn.active {
    box-shadow:
        inset 2px 2px 4px var(--shadow-dark),
        inset -2px -2px 4px var(--shadow-light);
    color: var(--accent);
}
.toolbar-spacer { flex: 1; }

.input-textarea {
    width: 100%;
    min-height: 60px;
    max-height: 240px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 4px 0;
    color: var(--text-color);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    outline: none;
}
.input-textarea:focus { box-shadow: none; }
.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}
.input-hint {
    font-size: 11px;
    color: var(--text-color-3);
}
.send-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow:
        4px 4px 8px var(--shadow-dark),
        -4px -4px 8px var(--shadow-light);
    transition: all 0.2s;
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(0.96); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn.stop-mode { background: var(--danger); }

/* ---------- 模态框 ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal {
    background: var(--bg-color);
    border-radius: 20px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow:
        10px 10px 30px var(--shadow-dark),
        -10px -10px 30px var(--shadow-light);
    transform: scale(0.95);
    transition: transform 0.2s;
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-lg { max-width: 720px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
}
.modal-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg-color);
    border: none;
    cursor: pointer;
    color: var(--text-color-3);
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:active {
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ---------- 设置项 ---------- */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-color);
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.setting-label {
    flex: 1;
}
.setting-label-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 2px;
}
.setting-label-desc {
    font-size: 12px;
    color: var(--text-color-3);
}
.setting-control {
    flex-shrink: 0;
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--bg-color);
    color: var(--text-color);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    animation: slideIn 0.3s ease;
    min-width: 200px;
}
@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.toast.success { color: var(--success); }
.toast.danger { color: var(--danger); }
.toast.warning { color: var(--warning); }
.toast.info { color: var(--info); }

/* ---------- 登录/注册 ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-color);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow:
        15px 15px 30px var(--shadow-dark),
        -15px -15px 30px var(--shadow-light);
}
.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo-icon {
    width: 64px; height: 64px;
    background: var(--primary-gradient);
    border-radius: 18px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
}
.auth-title {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-color-3);
    font-size: 13px;
    margin-bottom: 28px;
}
.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-color-3);
    font-size: 13px;
}

/* ---------- 后台管理 ---------- */
.admin-layout {
    display: flex;
    height: 100vh;
    background: var(--bg-color);
}
.admin-sidebar {
    width: 240px;
    background: var(--bg-color);
    padding: 20px 16px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}
.admin-logo {
    padding: 10px 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.admin-logo-icon {
    width: 40px; height: 40px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.admin-logo-text {
    font-size: 16px;
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.admin-menu { flex: 1; }
.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: 10px;
    color: var(--text-color-2);
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 6px;
    transition: all 0.2s;
    text-decoration: none;
}
.admin-menu-item:hover {
    color: var(--accent);
    background: var(--bg-color);
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.admin-menu-item.active {
    color: var(--accent);
    background: var(--bg-color);
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    font-weight: 500;
}
.admin-menu-item-icon { font-size: 16px; width: 20px; text-align: center; }
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.admin-header {
    height: 64px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}
.page-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}
.page-subtitle {
    color: var(--text-color-3);
    font-size: 13px;
    margin-bottom: 24px;
}

/* 卡片 */
.admin-card {
    background: var(--bg-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
    margin-bottom: 20px;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}
.stat-label { color: var(--text-color-3); font-size: 12px; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 600; color: var(--text-color); }

/* 表格 */
.table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    background: var(--bg-color);
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    padding: 4px;
}
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    font-weight: 600;
    color: var(--text-color-2);
    background: var(--bg-color-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.table th:first-child { border-top-left-radius: 10px; }
.table th:last-child { border-top-right-radius: 10px; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* 状态标签 */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}
.tag-success { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.tag-danger { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.tag-warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.tag-info { background: rgba(59, 130, 246, 0.12); color: var(--info); }
.tag-default { background: rgba(0, 0, 0, 0.06); color: var(--text-color-3); }
[data-theme="dark"] .tag-default { background: rgba(255, 255, 255, 0.06); }

/* 分页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}
.pagination-item {
    min-width: 36px; height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-color-2);
    font-size: 13px;
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}
.pagination-item:hover { color: var(--accent); }
.pagination-item.active {
    color: var(--accent);
    font-weight: 600;
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
}
.pagination-item:disabled { opacity: 0.4; cursor: not-allowed; }

/* 工具栏 */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.toolbar .form-control,
.toolbar input,
.toolbar select {
    width: auto;
    min-width: 160px;
}
.toolbar-spacer { flex: 1; }

/* 空状态 */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-color-3);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.empty-text { font-size: 14px; }

/* 工具提示 */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-color);
    color: var(--bg-color);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; visibility: visible; }

/* 响应式 */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .chat-container { padding: 16px; }
    .input-area { padding: 12px 16px 16px; }
    .admin-sidebar { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--shadow-dark);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.typing-dots span {
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingDot 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { transform: scale(0.6); opacity: 0.4; }
    30% { transform: scale(1); opacity: 1; }
}
