/* ===== 全局样式 ===== */
:root {
    --bg: #fdf6f0;
    --bg-card: #fffbf7;
    --bg-input: #fffefb;
    --text: #4a3f35;
    --text-light: #8b7e6e;
    --text-muted: #b0a496;
    --accent: #d4946a;
    --accent-hover: #c07a50;
    --accent-light: #f5e1d4;
    --border: #e8ddd0;
    --shadow: 0 2px 8px rgba(74, 63, 53, 0.08);
    --shadow-hover: 0 4px 16px rgba(74, 63, 53, 0.14);
    --radius: 12px;
    --radius-sm: 8px;
    --bubble-user: #f0e4d8;
    --bubble-ai: #e8f0f8;
    --danger: #d4786a;
    --success: #7aab8c;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
        'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 16px 80px;
}

/* ===== 头部 ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.app-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.app-nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-light);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
}

.btn-back {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.btn-back:hover {
    background: var(--accent-light);
}

/* ===== 按钮 ===== */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
}

.btn-outline:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.85rem;
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

/* ===== 发帖表单 ===== */
.post-form-section {
    margin: 16px 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.form-select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    min-width: 110px;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===== 筛选栏 ===== */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 12px 0;
}

.filter-tag {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-family: inherit;
}

.filter-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-tag.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== 倒计时条 ===== */
.countdowns-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px 0;
    scrollbar-width: none;
}

.countdowns-bar::-webkit-scrollbar {
    display: none;
}

.countdown-card {
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 10px 16px;
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 100px;
    cursor: default;
}

.countdown-card .cd-emoji {
    font-size: 1.5rem;
}

.countdown-card .cd-title {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

.countdown-card .cd-days {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 2px;
}

.countdown-card.countup .cd-days {
    color: var(--success);
}

/* ===== 信件提示 ===== */
.letters-alert {
    background: var(--accent-light);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.letters-alert .alert-icon {
    font-size: 1.3rem;
}

.letters-alert .alert-text {
    font-size: 0.9rem;
    color: var(--accent-hover);
}

/* ===== 帖子卡片 ===== */
.posts-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
    position: relative;
}

.post-card:hover {
    box-shadow: var(--shadow-hover);
}

.post-card.pinned {
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-type-badge {
    font-size: 0.78rem;
    padding: 2px 10px;
    border-radius: 12px;
    background: var(--accent-light);
    color: var(--accent-hover);
    font-weight: 600;
}

.post-author {
    font-size: 0.85rem;
    color: var(--text-light);
}

.post-time {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.post-actions {
    display: flex;
    gap: 6px;
}

.post-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.post-actions button:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.post-content {
    font-size: 0.95rem;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.post-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    cursor: pointer;
}

/* 评论区域 */
.comments-section {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.comment-item {
    padding: 6px 0;
    font-size: 0.88rem;
    display: flex;
    gap: 8px;
}

.comment-author {
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
}

.comment-content {
    color: var(--text);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.comment-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.comment-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-size: 0.88rem;
    font-family: inherit;
}

.comment-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===== 聊天样式 ===== */
.chat-app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-title {
    flex: 1;
    text-align: center;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
}

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

.chat-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
}

.chat-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

/* 消息气泡 */
.message-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.93rem;
    line-height: 1.6;
    word-break: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    align-self: flex-end;
    background: var(--bubble-user);
    border-bottom-right-radius: 4px;
}

.message-ai {
    align-self: flex-start;
    background: var(--bubble-ai);
    border-bottom-left-radius: 4px;
}

.message-avatar {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.message-user .message-avatar {
    text-align: right;
}

.message-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.message-user .message-meta {
    text-align: right;
}

.message-image {
    max-width: 240px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

/* 思考展开 */
.message-thinking {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.03);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-left: 2px solid var(--border);
    cursor: pointer;
    display: none;
}

.message-thinking.show {
    display: block;
}

.thinking-toggle {
    font-size: 0.78rem;
    color: var(--accent);
    cursor: pointer;
    margin-top: 4px;
}

/* 聊天输入 */
.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 680px;
    background: var(--bg);
    padding: 10px 16px 20px;
    border-top: 1px solid var(--border);
}

.image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
}

.image-preview img {
    max-height: 80px;
    border-radius: var(--radius-sm);
}

.btn-remove-img {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.btn-img-upload {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-img-upload:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.chat-textarea {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: 0.93rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-send {
    background: var(--accent);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-6px); }
}

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

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.modal-content img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
}

/* ===== 加载更多 ===== */
.load-more {
    text-align: center;
    padding: 20px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ===== 响应式 ===== */
@media (max-width: 500px) {
    .app-container {
        padding: 0 10px 60px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-select {
        width: 100%;
    }

    .message-bubble {
        max-width: 92%;
    }

    .chat-input-area {
        padding: 8px 10px 16px;
    }
}

/* ===== 模型选择器 ===== */
.model-selector {
    flex-shrink: 0;
}

.model-select {
    padding: 4px 8px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--accent);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    font-weight: 600;
}

.model-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-light);
}

@media (max-width: 500px) {
    .model-select {
        font-size: 0.75rem;
        padding: 3px 7px;
    }
}

/* ===== 底部导航 ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    z-index: 200;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 0.7rem;
    gap: 2px;
}

.nav-item .nav-icon { font-size: 1.3rem; }
.nav-item .nav-label { font-size: 0.68rem; }

.nav-item:hover { color: var(--accent); }
.nav-item.active { color: var(--accent); font-weight: 600; }

.app-container { padding-bottom: 90px; }

/* ===== 方块网格 ===== */
.block-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0;
}

.block-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    aspect-ratio: 1 / 1;
    box-shadow: var(--shadow);
}

.block-btn:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.block-btn .block-icon { font-size: 1.8rem; margin-bottom: 4px; }
.block-btn .block-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.block-btn .block-desc { font-size: 0.7rem; color: var(--text-light); margin-top: 2px; }

/* ===== 发帖弹窗 ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.modal-card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 24px; width: 90%; max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-card h3 { margin-bottom: 12px; color: var(--text); }
.modal-card .form-textarea { width: 100%; margin-bottom: 12px; }
.modal-card .btn-row { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== 模型切换栏（底部） ===== */
.model-bar {
    text-align: center;
    margin-top: 6px;
}
.model-bar .model-select {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-light);
    font-size: 0.78rem;
    cursor: pointer;
}
.model-bar .model-select:focus { outline: none; border-color: var(--accent); }

/* ===== 区块标题 ===== */
.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    margin: 16px 0 8px;
    padding-left: 4px;
}

/* 调整聊天页底部间距 */
.chat-input-area { padding-bottom: 4px; }
