/* ====================================
   AI 角色扮演聊天室 - 古风主题样式
   ==================================== */

/* ===== 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: #f5f0eb;
    color: #2c2c2c;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: inherit; }
input, textarea, select { font-family: inherit; outline: none; }

/* ===== 容器 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 头部导航 ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 2px solid #e8ddd2;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.site-title {
    font-size: 28px;
    color: #3d2b1f;
    font-weight: 700;
}

.site-subtitle {
    font-size: 14px;
    color: #8b7355;
    margin-top: 4px;
}

.back-link {
    color: #8b7355;
    font-size: 15px;
    transition: color 0.2s;
}
.back-link:hover { color: #3d2b1f; }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ===== 玩家信息 ===== */
.player-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-badge {
    background: #3d2b1f;
    color: #f5f0eb;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.name-form {
    display: flex;
    gap: 8px;
}

.name-input {
    padding: 10px 16px;
    border: 2px solid #d4c5b2;
    border-radius: 8px;
    font-size: 15px;
    width: 180px;
    background: white;
    transition: border-color 0.2s;
}
.name-input:focus { border-color: #8b7355; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: #3d2b1f;
    color: #f5f0eb;
}
.btn-primary:hover { background: #5c4a3a; }

.btn-secondary {
    background: #e8ddd2;
    color: #3d2b1f;
}
.btn-secondary:hover { background: #d4c5b2; }

.btn-chat {
    background: #6b8f71;
    color: white;
}
.btn-chat:hover { background: #5a7a5f; }

.btn-view {
    background: transparent;
    color: #8b7355;
    border: 1px solid #d4c5b2;
}
.btn-view:hover { background: #f0ebe5; }

.btn-large {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: #c0392b;
    color: white;
}
.btn-danger:hover { background: #a93226; }

.btn-edit {
    background: #8b7355;
    color: white;
}
.btn-edit:hover { background: #6d5a42; }

/* ===== 主要内容 ===== */
.main-content {
    flex: 1;
    padding: 24px 0;
}

.section-title {
    font-size: 22px;
    color: #3d2b1f;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e8ddd2;
}

.section-hint {
    color: #8b7355;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ===== 世界观网格 ===== */
.worlds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.world-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid #e8ddd2;
}
.world-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border-color: #8b7355;
}

.world-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.world-icon { font-size: 28px; }

.world-name {
    font-size: 18px;
    color: #3d2b1f;
}

.world-desc {
    color: #6d5a42;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
    min-height: 42px;
}

.world-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #8b7355;
    margin-bottom: 16px;
}

.world-card-actions {
    display: flex;
    gap: 8px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    border: 2px dashed #d4c5b2;
}

.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { color: #3d2b1f; margin-bottom: 8px; }
.empty-state p { color: #8b7355; margin-bottom: 20px; }
.empty-hint { color: #a09280; font-size: 13px; padding: 8px; }
.loading-text { color: #a09280; font-size: 13px; padding: 8px; }

/* ===== 快速入门 ===== */
.guide-section { margin-top: 40px; }

.guide-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.guide-step {
    display: flex;
    gap: 16px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.step-number {
    width: 36px;
    height: 36px;
    background: #3d2b1f;
    color: #f5f0eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h4 { color: #3d2b1f; margin-bottom: 4px; }
.step-content p { color: #8b7355; font-size: 14px; }

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 24px;
    color: #a09280;
    font-size: 13px;
    border-top: 1px solid #e8ddd2;
    margin-top: 40px;
}

/* ===== 表单编辑 ===== */
.editor-form { max-width: 800px; }

.form-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #3d2b1f;
    margin-bottom: 8px;
    font-size: 15px;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0d5c8;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
    background: #faf8f6;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: #8b7355;
}

.form-textarea {
    resize: vertical;
    line-height: 1.6;
}

.form-textarea-mono {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
}

.form-actions {
    text-align: center;
    padding: 20px 0;
}

/* ===== 角色卡片 ===== */
.character-card {
    background: #faf8f6;
    border: 1px solid #e8ddd2;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.char-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b8f71, #8b7355);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.char-info { flex: 1; min-width: 0; }

.char-name {
    font-size: 16px;
    color: #3d2b1f;
}

.char-desc {
    font-size: 13px;
    color: #8b7355;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-actions { display: flex; gap: 8px; }

.char-preview {
    margin-top: 8px;
    font-size: 12px;
    color: #a09280;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e8ddd2;
    border-radius: 4px;
    font-size: 12px;
    color: #6d5a42;
    margin: 2px;
}

/* ===== 模态框 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e8ddd2;
}

.modal-header h3 { color: #3d2b1f; }

.modal-close {
    background: none;
    font-size: 24px;
    color: #8b7355;
    line-height: 1;
}
.modal-close:hover { color: #3d2b1f; }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e8ddd2;
}

/* ===== 世界详情页 ===== */
.world-info-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
}

.info-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.info-card h2 {
    font-size: 18px;
    color: #3d2b1f;
    margin-bottom: 12px;
}

.info-card p {
    color: #6d5a42;
    line-height: 1.6;
    white-space: pre-wrap;
}

.info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ===== 角色展示网格 ===== */
.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.character-profile-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s;
}
.character-profile-card:hover { transform: translateY(-2px); }

.char-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b8f71, #8b7355);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    font-weight: 600;
    margin: 0 auto 12px;
}

.char-tags { margin: 12px 0; }

.char-card-actions { margin-top: 16px; }

/* ====================================
   聊天室布局
   ==================================== */

.chat-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 左侧边栏 */
.chat-sidebar {
    width: 280px;
    background: #3d2b1f;
    color: #e8ddd2;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #5c4a3a;
}
.sidebar-header h2 { font-size: 18px; }
.sidebar-header .back-link {
    display: block;
    color: #a09280;
    margin-bottom: 8px;
    font-size: 13px;
}
.sidebar-header .back-link:hover { color: #f5f0eb; }

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid #5c4a3a;
}

.sidebar-section h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: #d4c5b2;
    font-weight: 600;
}

.sidebar-text {
    font-size: 13px;
    line-height: 1.5;
    color: #c4b5a2;
}

.character-list { display: flex; flex-direction: column; gap: 8px; }

.character-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}
.character-item:hover { background: #5c4a3a; }

.char-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #6b8f71;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.char-name-sm { flex: 1; font-size: 14px; }
.char-priv-link { font-size: 16px; opacity: 0.7; transition: opacity 0.2s; }
.char-priv-link:hover { opacity: 1; }

.sidebar-actions {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-actions .btn {
    background: #5c4a3a;
    color: #e8ddd2;
    width: 100%;
    justify-content: center;
}
.sidebar-actions .btn:hover { background: #6d5a42; }

/* 关系概览侧边栏 */
.relationship-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.rel-char-name { flex: 0 0 60px; font-size: 13px; }

.rel-bar {
    flex: 1;
    height: 6px;
    background: #5c4a3a;
    border-radius: 3px;
    overflow: hidden;
}
.rel-fill {
    height: 100%;
    background: linear-gradient(90deg, #6b8f71, #a3c9a9);
    border-radius: 3px;
    transition: width 0.3s;
}
.rel-level { font-size: 11px; color: #a09280; flex: 0 0 40px; text-align: right; }

/* 剧情进度侧边栏 */
.plot-stage-name {
    font-size: 14px;
    font-weight: 600;
    color: #e8ddd2;
    margin-bottom: 8px;
}
.plot-progress-bar {
    height: 6px;
    background: #5c4a3a;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}
.plot-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c9a96e, #d4b97a);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.plot-progress-label {
    font-size: 11px;
    color: #a09280;
    text-align: right;
    margin-bottom: 6px;
}
.plot-stage-desc {
    font-size: 12px;
    color: #c4b5a2;
    line-height: 1.5;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #5c4a3a;
    border-radius: 6px;
}
.plot-timeline {
    margin-top: 8px;
}
.plot-timeline small {
    font-size: 11px;
    color: #a09280;
    display: block;
    margin-bottom: 4px;
}
.plot-timeline-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
    color: #c4b5a2;
}
.plot-timeline-item.current { color: #d4b97a; font-weight: 600; }
.plot-tl-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #5c4a3a;
    flex-shrink: 0;
}
.plot-tl-dot.active { background: #d4b97a; box-shadow: 0 0 4px #d4b97a; }
.plot-tl-title { flex: 1; }

/* ===== 主聊天区 ===== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #faf8f6;
}

/* 聊天头部 */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #e8ddd2;
}

.chat-header h2 { font-size: 18px; color: #3d2b1f; }

.chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #8b7355;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6b8f71;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* 消息流 */
.message-stream {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-loading {
    text-align: center;
    padding: 40px;
    color: #a09280;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e8ddd2;
    border-top: 3px solid #8b7355;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 单条消息 */
.message {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    max-width: 85%;
}
.message:hover { background: #f0ebe5; }

.message.player { align-self: flex-end; flex-direction: row-reverse; }
.message.system { align-self: center; max-width: 70%; }

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}
.msg-avatar.player { background: #3d2b1f; }
.msg-avatar.character { background: #6b8f71; }
.msg-avatar.system { background: #8b7355; }

.msg-content { flex: 1; min-width: 0; }

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.msg-sender { font-weight: 600; color: #3d2b1f; font-size: 14px; }
.msg-time { color: #a09280; font-size: 12px; }

.msg-text {
    color: #2c2c2c;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #8b7355;
}

.welcome-icon { font-size: 64px; margin-bottom: 16px; }

.welcome-message h3 {
    color: #3d2b1f;
    font-size: 22px;
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 8px;
}

/* 消息动画 */
.message-animate {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 输入区 ===== */
.chat-input-area {
    background: white;
    border-top: 1px solid #e8ddd2;
    padding: 12px 24px;
}

.input-tools {
    position: relative;
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.tool-btn {
    background: none;
    color: #8b7355;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.tool-btn:hover { background: #f0ebe5; }

.at-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #e8ddd2;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    min-width: 160px;
}

.at-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.at-item:hover { background: #f0ebe5; }

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0d5c8;
    border-radius: 8px;
    font-size: 15px;
    resize: none;
    transition: border-color 0.2s;
    background: #faf8f6;
    line-height: 1.5;
}
.chat-input:focus { border-color: #8b7355; }

.send-btn {
    padding: 12px 24px;
    background: #3d2b1f;
    color: white;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
}
.send-btn:hover { background: #5c4a3a; }

/* ====================================
   私聊布局
   ==================================== */

.private-chat-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.private-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: white;
    border-bottom: 1px solid #e8ddd2;
}

.private-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    margin-left: 16px;
}

.char-avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b8f71, #8b7355);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.char-subtitle { color: #a09280; font-size: 14px; }

.private-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 关系面板 */
.relationship-panel {
    width: 260px;
    background: white;
    border-right: 1px solid #e8ddd2;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

.panel-section {
    margin-bottom: 24px;
}

.panel-section h3 {
    font-size: 15px;
    color: #3d2b1f;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0ebe5;
}

.relationship-display { text-align: center; }

.rel-level-badge {
    display: inline-block;
    padding: 6px 16px;
    background: #6b8f71;
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.rel-progress {
    height: 12px;
    background: #f0ebe5;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.rel-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6b8f71, #a3c9a9);
    border-radius: 6px;
    transition: width 0.5s;
}

.rel-affection {
    font-size: 18px;
    font-weight: 700;
    color: #3d2b1f;
}

.stat-list { display: flex; flex-direction: column; gap: 8px; }

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}
.stat-label { color: #8b7355; }
.stat-value { color: #3d2b1f; font-weight: 500; }

.secret-item {
    padding: 8px;
    background: #faf8f6;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 6px;
    color: #6d5a42;
}

.char-info-panel {
    font-size: 13px;
}

.info-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.info-label { color: #8b7355; flex-shrink: 0; }

/* 私聊主区 */
.private-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.private-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* 私聊消息气泡 */
.private-message {
    display: flex;
    margin-bottom: 16px;
}

.private-message.sent { justify-content: flex-end; }
.private-message.received { justify-content: flex-start; }

.priv-msg-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
}

.sent .priv-msg-content {
    background: #3d2b1f;
    color: #f5f0eb;
    border-bottom-right-radius: 4px;
}

.received .priv-msg-content {
    background: #f0ebe5;
    color: #2c2c2c;
    border-bottom-left-radius: 4px;
}

.priv-msg-sender {
    font-size: 12px;
    margin-bottom: 4px;
    opacity: 0.7;
}

.priv-msg-text {
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.priv-msg-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.5;
    text-align: right;
}

.private-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e8ddd2;
}

.private-input-area .chat-input {
    flex: 1;
}

/* ====================================
   API 设置页面样式
   ==================================== */

.settings-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 15px;
    background: #f0f4ff;
    border: 1px solid #c8d8f0;
}
.settings-status.status-ok {
    background: #e8f8e8;
    border-color: #b0d8b0;
    color: #2a6a2a;
}
.settings-status.status-warn {
    background: #fff8e0;
    border-color: #e8d080;
    color: #8a6a00;
}
.status-icon { font-size: 20px; }

/* 双栏布局 */
.settings-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    align-items: start;
}

/* 侧边栏 */
.settings-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 区域块 */
.settings-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e8ddd2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.section-title-sm {
    font-size: 16px;
    color: #5a4a3a;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0e8e0;
}

/* 服务商按钮网格 */
.provider-grid {
    display: grid;
    gap: 10px;
}
.provider-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
    background: #faf8f5;
    border: 1px solid #e8ddd2;
    border-radius: 8px;
    text-align: left;
    transition: all 0.2s;
}
.provider-btn:hover {
    background: #f0ece6;
    border-color: #c8b8a8;
}
.provider-btn.selected {
    background: #e8e0f0;
    border-color: #8a7aaa;
    box-shadow: 0 0 0 2px rgba(138, 122, 170, 0.2);
}
.provider-name {
    font-size: 14px;
    font-weight: 600;
    color: #3a2a1a;
}
.provider-url {
    font-size: 11px;
    color: #8a7a6a;
    margin-top: 2px;
}

/* 已保存配置列表 */
.saved-configs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #faf8f5;
    border: 1px solid #e8ddd2;
    border-radius: 8px;
    transition: all 0.2s;
}
.config-item:hover { background: #f5f0e8; }
.config-item.active {
    background: #e8f8e8;
    border-color: #b0d8b0;
}
.config-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.config-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #3a2a1a;
}
.config-item-model {
    font-size: 11px;
    color: #8a7a6a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.config-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.active-badge {
    font-size: 12px;
    color: #2a8a2a;
    font-weight: 600;
}
.empty-tip {
    text-align: center;
    color: #aaa;
    padding: 20px;
    font-size: 14px;
}

/* 小按钮 */
.btn-tiny {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-activate {
    background: #4a8a4a;
    color: white;
}
.btn-activate:hover { background: #3a7a3a; }
.btn-delete {
    background: #e8d0d0;
    color: #8a3a3a;
    padding: 4px 8px;
}
.btn-delete:hover { background: #d8b0b0; }

/* 配置表单 */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #5a4a3a;
}
.required { color: #cc4444; }
.form-input {
    padding: 10px 14px;
    border: 1px solid #d8d0c8;
    border-radius: 8px;
    font-size: 14px;
    background: #faf8f5;
    transition: border-color 0.2s;
}
.form-input:focus {
    border-color: #8a7aaa;
    background: white;
    box-shadow: 0 0 0 2px rgba(138, 122, 170, 0.1);
}
.form-hint {
    font-size: 11px;
    color: #9a8a7a;
    margin-top: 2px;
}

/* API Key 显示/隐藏 */
.input-with-toggle {
    display: flex;
    gap: 0;
}
.input-with-toggle .form-input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.btn-toggle-visibility {
    padding: 10px 14px;
    background: #f0ece6;
    border: 1px solid #d8d0c8;
    border-left: none;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    font-size: 16px;
}
.btn-toggle-visibility:hover { background: #e8e0d8; }

/* 行内表单 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* 滑块 */
.range-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}
.form-range {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0d8d0;
    border-radius: 3px;
    outline: none;
}
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #8a7aaa;
    border-radius: 50%;
    cursor: pointer;
}
.range-value {
    font-size: 14px;
    font-weight: 600;
    color: #5a4a3a;
    min-width: 30px;
    text-align: center;
}

/* 模型选择 */
.model-select-wrapper {
    display: flex;
    gap: 0;
}
.model-select-wrapper select,
.model-select-wrapper input {
    flex: 1;
}

/* 表单按钮 */
.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

/* 测试结果 */
.test-result {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 8px;
}
.test-result.testing {
    background: #f0f4ff;
    border: 1px solid #c8d8f0;
    color: #4a6aaa;
}
.test-result.test-success {
    background: #e8f8e8;
    border: 1px solid #b0d8b0;
    color: #2a6a2a;
}
.test-result.test-fail {
    background: #fff0f0;
    border: 1px solid #e0b0b0;
    color: #8a2a2a;
}

/* ===== 设置页面响应式 ===== */
@media (max-width: 900px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-actions {
        flex-direction: column;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .chat-sidebar { display: none; }
    .relationship-panel { display: none; }
    .message { max-width: 95%; }
    .priv-msg-content { max-width: 85%; }
    .info-row { grid-template-columns: 1fr; }
    .worlds-grid { grid-template-columns: 1fr; }
    .guide-steps { grid-template-columns: 1fr; }
    .characters-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .header { flex-direction: column; align-items: stretch; text-align: center; }
    .header-right { justify-content: center; }
    .site-title { font-size: 22px; }
    .characters-grid { grid-template-columns: 1fr; }
    .send-btn { padding: 12px 16px; }
}

/* ====================================
   角色行为设置样式
   ==================================== */

.behavior-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.behavior-group {
    margin-top: 20px;
}

.behavior-group-title {
    font-size: 16px;
    color: #3d2b1f;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0ebe5;
}

.behavior-card {
    background: #faf8f6;
    border: 1px solid #e8ddd2;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.behavior-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.behavior-info {
    flex: 1;
}

.behavior-label {
    font-size: 15px;
    font-weight: 600;
    color: #3d2b1f;
    display: block;
    margin-bottom: 4px;
}

.behavior-desc {
    font-size: 13px;
    color: #8b7355;
}

.behavior-slider-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0ebe5;
}

.slider-label {
    font-size: 13px;
    color: #8b7355;
    min-width: 70px;
}

.behavior-range {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e8ddd2;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.behavior-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3d2b1f;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.behavior-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3d2b1f;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d4c5b2;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #6b8f71;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Speed Selector */
.speed-selector-wrapper {
    flex-shrink: 0;
    margin-left: 16px;
}

.speed-selector {
    padding: 8px 14px;
    border: 2px solid #e8ddd2;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    color: #3d2b1f;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    min-width: 200px;
}

.speed-selector:hover {
    border-color: #6b8f71;
}

.speed-selector:focus {
    border-color: #6b8f71;
    box-shadow: 0 0 0 3px rgba(107, 143, 113, 0.2);
}

.speed-selector option {
    padding: 4px;
}

/* ====================================
   头像上传样式
   ==================================== */

.char-avatar-lg {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b8f71, #8b7355);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    font-weight: 600;
    margin: 0 auto 12px;
    overflow: hidden;
}

.char-avatar-clickable {
    cursor: pointer;
    transition: transform 0.2s;
}
.char-avatar-clickable:hover {
    transform: scale(1.05);
}

.char-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* 头像上传 */
.avatar-upload-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b8f71, #8b7355);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 42px;
    font-weight: 600;
    margin: 0 auto;
    overflow: hidden;
    border: 3px solid #e8ddd2;
    transition: border-color 0.2s;
}

.avatar-upload-overlay {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(61, 43, 31, 0.85);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.avatar-upload-wrapper:hover .avatar-upload-overlay {
    opacity: 1;
}

.avatar-upload-wrapper:hover .avatar-preview {
    border-color: #6b8f71;
}

/* 小头像（侧边栏用） */
.char-avatar-img-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* 中头像（私聊标题用） */
.char-avatar-img-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

/* 旁白历史消息样式 */
.message.narrator {
    align-self: center;
    max-width: 90%;
    background: linear-gradient(135deg, #2c1810, #3d2218);
    border: 1px solid #6b4226;
    border-radius: 10px;
    padding: 8px 16px;
    margin: 4px 0;
    animation: narratorFadeIn 0.5s ease-out;
}

@keyframes narratorFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.narrator .msg-avatar {
    background: #4a2c1a;
    color: #d4a574;
    font-size: 14px;
}

.message.narrator .msg-sender {
    color: #d4a574;
}

.message.narrator .msg-text {
    color: #e8ddd2;
    font-style: italic;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== 旁白置顶条 ===== */
.narrator-banner {

    background: linear-gradient(135deg, #2c1810, #4a2c1a);
    border: 1px solid #6b4226;
    border-radius: 12px;
    margin: 8px 16px;
    overflow: hidden;
    animation: narratorSlideIn 0.5s ease-out;
    flex-shrink: 0;
}

@keyframes narratorSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.narrator-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.narrator-icon {
    font-size: 20px;
}

.narrator-title {
    color: #d4a574;
    font-weight: bold;
    font-size: 14px;
    flex: 1;
}

.narrator-toggle {
    background: none;
    border: none;
    color: #8b7355;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.narrator-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #d4a574;
}

.narrator-body {
    padding: 12px 16px;
}

.narrator-text {
    color: #e8ddd2;
    font-size: 14px;
    line-height: 1.8;
    font-style: italic;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== 故事编辑器 ===== */
.event-card {
    background: #faf6f0;
    border: 1px solid #e8ddd2;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.event-card:hover {
    border-color: #c4a882;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.event-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.event-type-badge {
    font-size: 12px;
    padding: 2px 8px;
    background: #e8ddd2;
    border-radius: 4px;
    color: #5a4a3a;
    white-space: nowrap;
}

.event-title {
    font-weight: 600;
    color: #3d2b1f;
    flex: 1;
}

.event-actions {
    display: flex;
    gap: 4px;
}

.event-content {
    color: #5a4a3a;
    font-size: 14px;
    line-height: 1.6;
    margin: 8px 0;
    padding: 8px;
    background: #fdfcfa;
    border-radius: 4px;
    border-left: 3px solid #c4a882;
}

.event-meta {
    color: #8b7355;
    font-size: 12px;
    margin-top: 4px;
}

/* ===== 设置页面旁白区域 ===== */
.behavior-section-narrator {
    border-top: 2px solid #4a2c1a;
    margin-top: 10px;
    padding-top: 10px;
}

.section-subtitle {
    font-size: 14px;
    color: #4a2c1a;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}


/* ====================================
   双端适配 - 移动端响应式样式
   ==================================== */

/* ---- 通用触摸优化 ---- */
@media (hover: none) and (pointer: coarse) {
    .avatar-upload-overlay { opacity: 1; }
    .btn, .btn-sm, .btn-tiny, button, a.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    input, textarea, select { font-size: 16px !important; } /* 防止iOS缩放 */
}

/* ---- 移动端安全区域 ---- */
@supports (padding: env(safe-area-inset-top)) {
    body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
    .chat-layout { padding-bottom: env(safe-area-inset-bottom); }
    .private-chat-layout { padding-bottom: env(safe-area-inset-bottom); }
}

/* =========================================
   1. 通用响应式（所有页面共用）
   ========================================= */
@media (max-width: 768px) {
    .container { padding: 0 12px; }
    .header { padding: 14px 0; gap: 10px; }
    .site-title { font-size: 20px; }
    .site-subtitle { font-size: 12px; }
    .back-link { font-size: 13px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 6px 12px; font-size: 12px; }
    .main-content { margin-top: 10px; }
    .header-left { gap: 8px; }
    .header-right { gap: 8px; }
}

@media (max-width: 480px) {
    .site-title { font-size: 18px; }
    .container { padding: 0 8px; }
}

/* ---- 首页菜单折叠 ---- */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    color: #3d2b1f;
}
@media (max-width: 768px) {
    .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
    .header-right .user-menu .btn, 
    .header-right .user-menu .btn-logout, 
    .header-right .user-menu .btn-admin,
    .header-right .user-menu .player-badge {
        display: none;
    }
    .header-right .user-menu.mobile-open .btn,
    .header-right .user-menu.mobile-open .btn-logout,
    .header-right .user-menu.mobile-open .btn-admin,
    .header-right .user-menu.mobile-open .player-badge {
        display: flex;
    }
    .header-right .user-menu {
        position: absolute;
        top: 60px;
        right: 12px;
        background: white;
        flex-direction: column;
        padding: 12px;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        z-index: 100;
        min-width: 180px;
        display: none;
        gap: 8px;
    }
    .header-right .user-menu.mobile-open {
        display: flex;
    }
    .header-right { position: relative; }
}

/* ---- 引导步骤 ---- */
@media (max-width: 768px) {
    .guide-steps { grid-template-columns: 1fr; gap: 12px; }
    .guide-step { padding: 14px; }
}

/* =========================================
   2. 聊天室 - 左侧滑出抽屉
   ========================================= */
.chat-drawer-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.chat-drawer-overlay.open { display: block; opacity: 1; }

.chat-drawer {
    position: fixed;
    top: 0; left: -300px;
    width: 280px; height: 100%;
    background: #faf8f5;
    z-index: 201;
    overflow-y: auto;
    transition: left 0.3s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
    padding-bottom: env(safe-area-inset-bottom);
}
.chat-drawer.open { left: 0; }
.chat-drawer .sidebar-header { padding: 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #e8ddd2; }
.chat-drawer .sidebar-header h2 { font-size: 16px; }
.chat-drawer .sidebar-section { padding: 12px 16px; border-bottom: 1px solid #e8ddd2; }
.chat-drawer .sidebar-section h3 { font-size: 14px; margin-bottom: 10px; }
.chat-drawer-close {
    font-size: 22px; background: none; border: none; color: #8b7355; cursor: pointer; padding: 4px; margin-left: auto;
}
.chat-drawer .sidebar-actions { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-drawer .sidebar-actions .btn { width: 100%; justify-content: center; }

/* 移动端汉堡按钮 */
.mobile-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    padding: 8px;
    cursor: pointer;
    color: #3d2b1f;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
}
@media (max-width: 768px) {
    .mobile-hamburger { display: inline-flex; }
    .chat-sidebar { display: none !important; } /* PC侧边栏隐藏，用抽屉代替 */
    .chat-header h2 { font-size: 16px; }
    .chat-header { padding: 10px 12px; }
    .chat-input-area { padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
    .input-row { gap: 8px; }
    .chat-input { font-size: 15px; padding: 10px 12px; }
    .send-btn { padding: 10px 16px; font-size: 14px; min-width: 60px; }
    .message-stream { padding: 12px; }
    .message { max-width: 98%; margin-bottom: 12px; }
    .msg-text { font-size: 14px; }
    .narrator-banner { margin: 4px 8px; }
    .narrator-header { padding: 8px 12px; }
    .narrator-body { padding: 8px 12px; }
    .narrator-text { font-size: 13px; }
    .msg-avatar { width: 32px; height: 32px; font-size: 14px; flex-shrink: 0; }
}

/* =========================================
   3. 私聊 - 可滑动Tab
   ========================================= */
@media (max-width: 768px) {
    .private-chat-layout { flex-direction: column; }
    .private-content { flex-direction: column; }
    .private-header { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
    .private-header .back-link { font-size: 13px; }
    .private-header-info h2 { font-size: 15px; }
    .private-header-info .char-subtitle { font-size: 11px; }
    .char-avatar-img-md { width: 36px; height: 36px; }
    .private-messages { padding: 12px; }
    .priv-msg-content { max-width: 88%; padding: 10px 12px; }
    .priv-msg-text { font-size: 14px; }
    .private-input-area { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
    
    /* 关系面板变成可滑动的Tab */
    .relationship-panel {
        display: block !important;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e8ddd2;
        flex-shrink: 0;
        overflow: hidden;
        max-height: 0;
        transition: max-height 0.3s ease;
    }
    .relationship-panel.tab-open { max-height: 300px; }

    .private-tab-bar {
        display: flex;
        border-bottom: 1px solid #e8ddd2;
        background: white;
    }
    .private-tab-item {
        flex: 1;
        padding: 10px;
        text-align: center;
        font-size: 13px;
        color: #8b7355;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        transition: all 0.2s;
        background: none;
    }
    .private-tab-item.active {
        color: #3d2b1f;
        border-bottom-color: #3d2b1f;
        font-weight: 600;
    }
    .private-main-area {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
}
@media (min-width: 769px) {
    .private-tab-bar { display: none; }
}

/* =========================================
   4. 好友 - 微信风格
   ========================================= */
@media (max-width: 768px) {
    .friends-layout { flex-direction: column; height: calc(100vh - 60px); margin: 0; padding: 0; gap: 0; }
    .friends-sidebar { width: 100%; border-radius: 0; flex-shrink: 0; height: 100%; display: flex; }
    .friends-main { width: 100%; border-radius: 0; display: none; height: 100%; }
    .friends-main.mobile-show { display: flex; }
    .friends-sidebar.mobile-hide { display: none; }
    
    .friend-item { padding: 12px 15px; }
    .friend-avatar { width: 44px; height: 44px; font-size: 18px; }
    .friend-name { font-size: 15px; }
    .friend-status { font-size: 13px; }
    .sidebar-tab { padding: 12px 8px; font-size: 14px; }
    
    .chat-area-header { padding: 12px 15px; }
    .chat-area-header h3 { font-size: 15px; }
    .chat-messages { padding: 10px 15px; }
    .chat-msg-bubble { max-width: 80%; font-size: 14px; padding: 8px 12px; }
    .chat-input-area { padding: 10px 15px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .chat-input-area textarea { font-size: 15px; min-height: 40px; }
    .chat-send-btn { padding: 8px 18px; font-size: 14px; }

    /* 好友返回按钮 */
    .friend-back-btn {
        display: inline-flex;
        background: none;
        border: none;
        font-size: 20px;
        padding: 4px 8px;
        cursor: pointer;
        color: #6c5ce7;
        align-items: center;
    }
}
@media (min-width: 769px) {
    .friend-back-btn { display: none; }
}

/* =========================================
   5. 世界详情
   ========================================= */
@media (max-width: 768px) {
    .world-info-section .info-row { grid-template-columns: 1fr; gap: 12px; }
    .characters-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .character-profile-card { padding: 14px; }
    .character-profile-card .char-name { font-size: 14px; }
    .character-profile-card .char-desc { font-size: 12px; }
    .char-card-actions { flex-direction: column; gap: 6px; }
    .char-card-actions .btn { width: 100%; }
    .world-info-section .info-card { padding: 14px; }
    .world-info-section .info-card h2 { font-size: 15px; }
    .world-info-section .info-card p { font-size: 13px; }
    .header-right .btn-chat { font-size: 13px; padding: 6px 12px; }
}
@media (max-width: 480px) {
    .characters-grid { grid-template-columns: 1fr; }
}

/* =========================================
   6. 世界编辑器 + 故事编辑器
   ========================================= */
@media (max-width: 768px) {
    .editor-form { padding: 0; }
    .form-section { padding: 14px; margin-bottom: 12px; }
    .form-section .section-title { font-size: 16px; }
    .form-input, .form-textarea, .form-select { font-size: 15px; padding: 10px 12px; }
    .form-group { margin-bottom: 14px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
    .character-card { padding: 12px; }
    .char-header { flex-wrap: wrap; gap: 8px; }
    .char-actions { width: 100%; display: flex; gap: 8px; }
    .char-actions .btn { flex: 1; }
    
    /* 故事编辑器 */
    .event-card { padding: 12px; }
    .event-card-header { flex-wrap: wrap; }
    .event-actions { width: 100%; margin-top: 8px; justify-content: flex-end; }
    .event-content { font-size: 13px; }
    
    /* 模态框 */
    .modal-content { width: 92%; margin: 20px auto; padding: 16px; max-height: 85vh; overflow-y: auto; }
    .modal-header h3 { font-size: 16px; }
    .modal-body .form-group { margin-bottom: 12px; }
}

/* =========================================
   7. 设置页面
   ========================================= */
@media (max-width: 768px) {
    .settings-layout { grid-template-columns: 1fr; gap: 16px; }
    .settings-section { padding: 14px; }
    .settings-status { flex-direction: column; text-align: center; padding: 12px 14px; font-size: 13px; }
    .provider-btn { padding: 10px 14px; }
    .provider-name { font-size: 13px; }
    .config-item { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
    .config-item-actions { width: 100%; justify-content: flex-end; }
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
    .config-form { gap: 12px; }
}

/* =========================================
   8. 登录/注册页
   ========================================= */
@media (max-width: 768px) {
    .auth-container { max-width: 100%; margin: 30px auto; padding: 0 16px; }
    .auth-card { padding: 28px 20px; border-radius: 12px; }
    .auth-title { font-size: 20px; }
    .auth-icon { font-size: 36px; }
    .auth-form input { font-size: 15px; padding: 10px 14px; }
    .auth-btn { padding: 12px; font-size: 15px; }
}

/* =========================================
   9. 管理员用户管理页
   ========================================= */
@media (max-width: 768px) {
    .admin-container { max-width: 100%; margin: 16px auto; padding: 0 8px; }
    .admin-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    .admin-title { font-size: 18px; }
    .admin-card { border-radius: 8px; overflow-x: auto; }
    .admin-table { min-width: 600px; }
    .admin-table th, .admin-table td { padding: 8px 10px; font-size: 12px; }
    .btn-danger { padding: 4px 10px; font-size: 12px; }
    .confirm-box { width: 85%; padding: 24px; }
}

/* =========================================
   10. 首页世界卡片
   ========================================= */
@media (max-width: 768px) {
    .worlds-grid { grid-template-columns: 1fr; gap: 12px; }
    .world-card { padding: 14px; }
    .world-card-header .world-name { font-size: 15px; }
    .world-desc { font-size: 12px; }
    .world-card-actions { flex-direction: column; gap: 6px; }
    .world-card-actions .btn { width: 100%; justify-content: center; }
    .world-meta { font-size: 11px; gap: 8px; }

    .empty-state { padding: 30px 16px; }
    .empty-state .empty-icon { font-size: 40px; }
    .empty-state h3 { font-size: 16px; }
    .empty-state p { font-size: 13px; }

    /* 邀请横幅在手机端 */
    #invitationsBanner > div > div { flex-direction: column; align-items: stretch !important; }
    #invitationsBanner > div > div > div { justify-content: center !important; }
}

