/* ==================== 基础样式 ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4A90D9;
    --primary-dark: #3A7BC8;
    --secondary: #F5A623;
    --bg: #F5F6FA;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #E8E8E8;
    --success: #52C41A;
    --warning: #F5A623;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 12px;
}

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

/* ==================== 顶部导航 ==================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary) 0%, #5BA0E8 100%);
    color: white;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(74, 144, 217, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    max-width: 600px;
    margin: 0 auto;
}

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

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

.logo-text {
    font-size: 18px;
    font-weight: 600;
}

.btn-post {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-post:hover {
    background: rgba(255,255,255,0.3);
}

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

.btn-user {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-user:hover {
    background: rgba(255,255,255,0.3);
}

.btn-user.logged-in {
    background: white;
    color: var(--primary);
}

/* ==================== 页面容器 ==================== */
.main {
    max-width: 600px;
    margin: 0 auto;
    padding-top: 60px;
}

.page {
    display: none;
    padding: 16px;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* ==================== 话题卡片 ==================== */
.topic-card {
    background: linear-gradient(135deg, var(--primary) 0%, #5BA0E8 100%);
    color: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

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

.topic-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.topic-date {
    font-size: 12px;
    opacity: 0.8;
}

.topic-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.topic-desc {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.btn-join {
    width: 100%;
    background: white;
    color: var(--primary);
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-join:hover {
    transform: scale(1.02);
}

/* ==================== 区块样式 ==================== */
.section {
    margin-bottom: 20px;
}

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

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.section-more {
    font-size: 13px;
    color: var(--primary);
    cursor: pointer;
}

/* ==================== 故事列表 ==================== */
.story-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.story-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.story-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.story-card:active {
    transform: scale(0.98);
}

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

.story-type {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-light);
}

.story-type.story { background: #E6F7FF; color: #1890FF; }
.story-type.case { background: #FFF7E6; color: #FA8C16; }
.story-type.proposal { background: #F6FFED; color: #52C41A; }

.story-identity {
    font-size: 11px;
    color: var(--text-muted);
}

.story-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-content {
    font-size: 13px;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.story-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.story-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.story-tag {
    padding: 2px 6px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 11px;
}

.story-selected {
    color: var(--warning);
    font-weight: 500;
}

/* ==================== 快捷入口 ==================== */
.quick-links {
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 20px;
    box-shadow: var(--shadow);
}

.quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.2s;
}

.quick-item:hover {
    transform: scale(1.05);
}

.quick-icon {
    font-size: 24px;
}

.quick-item span:last-child {
    font-size: 12px;
    color: var(--text-light);
}

/* ==================== 列表页 ==================== */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-top: 8px;
}

.page-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-back {
    background: var(--card-bg);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex-shrink: 0;
    padding: 8px 16px;
    border: none;
    background: var(--card-bg);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* ==================== 投稿表单 ==================== */
.submit-form {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

/* 类型选择 */
.type-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.type-option input {
    display: none;
}

.type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.type-option input:checked + .type-card {
    border-color: var(--primary);
    background: rgba(74, 144, 217, 0.05);
}

.type-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.type-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.type-desc {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* 标签选择 */
.tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-option {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.tag-option input {
    margin-right: 4px;
}

.tag-option span {
    padding: 6px 12px;
    background: var(--bg);
    border-radius: 16px;
    font-size: 13px;
    transition: all 0.2s;
}

.tag-option input:checked + span {
    background: var(--primary);
    color: white;
}

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* 提交按钮 */
.form-actions {
    margin-top: 24px;
}

.btn-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #5BA0E8 100%);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-submit:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(74, 144, 217, 0.4);
}

.btn-submit:active {
    transform: scale(0.98);
}

.btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==================== 详情页 ==================== */
.detail-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.detail-header {
    margin-bottom: 16px;
}

.detail-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.detail-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 12px;
}

.detail-body {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
}

.detail-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ==================== 个人中心 ==================== */
.profile-card {
    background: linear-gradient(135deg, var(--primary) 0%, #5BA0E8 100%);
    color: white;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-level {
    font-size: 13px;
    opacity: 0.9;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.my-posts {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.my-posts .section-title {
    margin-bottom: 12px;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ==================== Toast 提示 ==================== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    white-space: nowrap;
}

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

.toast.success {
    background: var(--success);
}

.toast.error {
    background: #FF4D4F;
}

/* ==================== 响应式 ==================== */
@media (max-width: 375px) {
    .type-selector {
        grid-template-columns: 1fr;
    }
    
    .topic-title {
        font-size: 18px;
    }
    
    .header-content {
        padding: 10px 16px;
    }
    
    .logo-text {
        font-size: 16px;
    }
}

/* ==================== 登录模态框 ==================== */
.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.login-modal.show {
    display: flex;
}

.login-content {
    background: white;
    border-radius: 16px;
    width: 320px;
    max-width: 90%;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

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

.login-header h3 {
    font-size: 16px;
    font-weight: 600;
}

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

.login-body {
    padding: 24px 20px;
}

.login-tip {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
}

.login-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
}

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

.login-guest {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    text-align: center;
}

.login-guest:hover {
    color: var(--text);
}

/* ==================== 用户信息 ==================== */
.user-info-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
}

.user-info-modal.show {
    display: flex;
}

.user-info-content {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.3s ease;
}

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

.user-info-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.user-info-header button {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.user-info-body {
    padding: 32px 20px;
    text-align: center;
}

.user-avatar-big {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
}

.user-nickname {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.user-stat {
    font-size: 14px;
    color: var(--text-muted);
}

.user-stat span {
    color: var(--primary);
    font-weight: 600;
}

.user-info-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    width: 100%;
    background: #FFF1F0;
    color: #FF4D4F;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
}

.btn-logout:hover {
    background: #FFCCC7;
}
