/* ==================== 基础变量 ==================== */
:root {
    --primary: #7FA99C;       /* 柔和青绿色 - 自然、平静 */
    --primary-dark: #5C8A7D;
    --secondary: #B89F94;     /* 暖棕色强调 */
    --background: #F9F6F1;     /* 米白色背景 - 温暖不刺眼 */
    --surface: #FFFFFF;       /* 卡片白色 */
    --text: #4A4A4A;          /* 深棕色文字 - 柔和易读 */
    --text-light: #7A7A7A;
    --border: #E8E4DF;
    --shadow: rgba(0, 0, 0, 0.06);
    --danger: #C17B7B;
    --success: #7FA97C;
}

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

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* ==================== 头部导航 ==================== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    box-shadow: 0 1px 3px var(--shadow);
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-name {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--primary);
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.3rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.user-info {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ==================== 消息提示 ==================== */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.flash-success {
    background: #E8F5E8;
    color: #3D7A3D;
    border-left: 4px solid var(--success);
}

.flash-error {
    background: #FDECEC;
    color: #A05555;
    border-left: 4px solid var(--danger);
}

.flash-info {
    background: #EDF4F2;
    color: var(--primary-dark);
    border-left: 4px solid var(--primary);
}

/* ==================== 登录页 ==================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 1.8rem;
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.login-form .form-group {
    margin-bottom: 1.2rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.login-form input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

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

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ==================== 按钮 ==================== */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-small {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--primary);
    color: white;
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

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

/* ==================== 信件列表 ==================== */
.letters-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.letters-header h1 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.greeting {
    color: var(--text-light);
}

.letters-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.letter-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
    color: inherit;
}

.letter-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow);
}

.letter-card.draft {
    border-left: 4px solid var(--secondary);
}

.letter-title {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.draft-badge {
    font-size: 0.75rem;
    background: var(--secondary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: normal;
}

.letter-preview {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

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

.letter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.delete-form {
    display: inline;
}

/* ==================== 信件详情 ==================== */
.letter-container {
    max-width: 700px;
    margin: 0 auto;
}

.letter-back {
    margin-bottom: 1.5rem;
}

.back-link {
    color: var(--text-light);
    font-size: 0.95rem;
}

.back-link:hover {
    color: var(--primary);
}

.letter-full {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 2px 12px var(--shadow);
}

.letter-full .letter-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.letter-full .letter-title {
    font-size: 1.6rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.letter-full .letter-date {
    color: var(--text-light);
    font-size: 0.9rem;
}

.letter-content {
    font-size: 1.05rem;
    line-height: 2;
    color: var(--text);
    white-space: pre-wrap;
}

/* ==================== 写信/编辑页面 ==================== */
.page-title {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.write-container,
.edit-container {
    max-width: 700px;
    margin: 0 auto;
}

.letter-form .form-group {
    margin-bottom: 1.2rem;
}

.letter-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.letter-form input[type="text"],
.letter-form textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.letter-form input[type="text"]:focus,
.letter-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ==================== 管理页面 ==================== */
.manage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.manage-list .letter-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.manage-list .letter-info {
    flex: 1;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.empty-state a {
    color: var(--primary);
}

/* ==================== 设置页面 ==================== */
.settings-container {
    max-width: 500px;
    margin: 0 auto;
}

.settings-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.settings-section h2 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.section-hint {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.settings-form .form-group {
    margin-bottom: 1rem;
}

.settings-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.settings-form input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

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

.account-info {
    color: var(--text-light);
}

.account-info p {
    margin-bottom: 0.3rem;
}

/* ==================== 视频上传与管理 ==================== */
.video-section,
.video-upload-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.video-section h2,
.video-upload-section h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.video-section h3,
.video-upload-section h4 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.8rem;
}

.attachments-list,
.video-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.attachment-item,
.video-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--background);
    padding: 0.8rem 1rem;
    border-radius: 8px;
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.video-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.attachment-name,
.video-name {
    font-size: 0.95rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size,
.video-size {
    font-size: 0.85rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.no-attachments {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.upload-form {
    background: var(--background);
    padding: 1.2rem;
    border-radius: 8px;
}

.upload-form-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-label {
    display: block;
    cursor: pointer;
}

.file-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.file-input {
    display: block;
    width: 100%;
    padding: 0.8rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s;
}

.file-input:hover {
    border-color: var(--primary);
}

.video-position {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.video-position label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.video-position input {
    width: 60px;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.add-video-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.remove-video {
    flex-shrink: 0;
}

.help-note {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #EDF4F2;
    border-radius: 8px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.help-hint {
    margin-top: 0.5rem;
    padding: 0.8rem;
    background: #F5F0EB;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.85rem;
}

.help-hint code {
    background: var(--surface);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary-dark);
}

/* ==================== 附件网格（编辑页面） ==================== */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.attachment-card {
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
}

.attachment-preview {
    width: 100%;
    height: 120px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-thumbnail {
    color: #666;
    font-size: 0.85rem;
}

.attachment-card .attachment-info {
    padding: 0.8rem;
    display: block;
}

.attachment-card .attachment-name {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.attachment-card .attachment-actions {
    padding: 0 0.8rem 0.8rem;
}

/* ==================== 上传表单 ==================== */
.video-upload-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.video-upload-item input[type="file"] {
    flex: 1;
}

.position-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.position-input label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.position-input input {
    width: 60px;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* ==================== 信件视频播放器 ==================== */
.video-embed {
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-embed video {
    width: 100%;
    max-width: 100%;
    display: block;
}

/* ==================== 收信人选择 ==================== */
.recipient-section {
    margin-top: 1.5rem;
    padding: 1.2rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 4px var(--shadow);
}

.recipient-section h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.recipient-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.recipient-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.recipient-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.recipient-item span {
    font-size: 0.95rem;
    color: var(--text);
}

/* ==================== 回复区域 ==================== */
.reply-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.reply-title {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.replies-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.reply-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px var(--shadow);
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.reply-author {
    font-weight: 600;
    color: var(--primary);
}

.reply-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.reply-content {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}

.no-replies {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.reply-form-wrapper {
    background: var(--surface);
    padding: 1.2rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px var(--shadow);
}

.reply-form-wrapper h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.reply-form .form-group {
    margin-bottom: 1rem;
}

.reply-form textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}

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

/* ==================== 页脚 ==================== */
.site-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .main-nav {
        gap: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }

    .letter-full {
        padding: 1.5rem;
    }

    .manage-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .manage-list .letter-card {
        flex-direction: column;
    }

    .letter-actions {
        margin-top: 1rem;
    }
}

/* ==================== 章节列表页 ==================== */
.letter-meta {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

.chapters-progress {
    margin: 2rem 0;
}

.chapters-progress h2 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--border);
}

.progress-item.current {
    border-left-color: var(--primary);
    background: #EDF4F2;
}

.progress-item.completed {
    border-left-color: var(--success);
}

.progress-icon {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

.icon-done { color: var(--success); }
.icon-current { color: var(--primary); }
.icon-locked { color: var(--text-light); }

.btn-disabled {
    background: var(--border);
    color: var(--text-light);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: not-allowed;
    display: inline-block;
    text-decoration: none;
}

.progress-item.locked {
    border-left-color: var(--border);
    opacity: 0.7;
}

/* 章节锁定 */
.chapter-locked {
    text-align: center;
    padding: 3rem 1.5rem;
    margin: 2rem 0;
    background: #F5F2EE;
    border-radius: 12px;
    border: 2px dashed var(--border);
}

.locked-message {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}
.icon-locked { color: var(--text-light); }

.progress-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.chapter-num {
    font-size: 0.8rem;
    color: var(--text-light);
}

.chapter-title {
    font-size: 0.95rem;
    color: var(--text);
}

.progress-action {
    flex-shrink: 0;
}

.status-done {
    color: var(--success);
    font-size: 0.9rem;
}

.status-locked {
    color: var(--text-light);
    font-size: 0.9rem;
}

.start-reading {
    text-align: center;
    margin-top: 2rem;
}

.reading-complete {
    text-align: center;
    margin-top: 2rem;
    padding: 2rem;
    background: #EDF4F2;
    border-radius: 8px;
}

.complete-message {
    font-size: 1.1rem;
    color: var(--primary);
}

.reread-section {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border);
}

.reread-hint {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ==================== 章节阅读页 ==================== */
.chapter-container {
    max-width: 700px;
    margin: 0 auto;
}

.chapter-nav-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chapter-indicator {
    color: var(--text-light);
    font-size: 0.9rem;
}

.chapter-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px var(--shadow);
}

.chapter-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.chapter-title {
    font-size: 1.5rem;
    color: var(--text);
}

.chapter-text {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text);
    white-space: pre-wrap;
}

.chapter-confirm-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.confirm-prompt {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.btn-confirm {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.next-hint {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.chapter-confirmed-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.confirmed-badge {
    display: inline-block;
    background: var(--success);
    color: white;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.chapter-nav-bottom {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
}

/* ==================== 写信页面 ==================== */
.chapters-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.chapters-section h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.chapter-item {
    background: var(--background);
    padding: 1.2rem;
    border-radius: 8px;
}

.chapter-item .chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: none;
}

.chapter-number {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-remove:hover {
    text-decoration: underline;
}

/* ==================== 编辑信件页面 ==================== */
.chapters-manage-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.chapters-manage-section h2 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.chapters-list-manage {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.chapter-manage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
}

.chapter-manage-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.chapter-manage-info .chapter-order {
    font-size: 0.8rem;
    color: var(--text-light);
}

.chapter-manage-info .chapter-title {
    font-size: 0.95rem;
    color: var(--text);
}

.chapter-manage-info .chapter-preview {
    font-size: 0.8rem;
    color: var(--text-light);
}

.chapter-manage-actions {
    display: flex;
    gap: 0.5rem;
}

.inline-form {
    display: inline;
}

.add-chapter-form {
    background: var(--background);
    padding: 1.2rem;
    border-radius: 8px;
}

.add-chapter-form h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.no-chapters {
    color: var(--text-light);
    text-align: center;
    padding: 1rem;
}

/* ==================== 家人首页（进度卡片） ==================== */
.letters-with-progress {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.letter-progress-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.letter-progress-card.card-thinking {
    border-left: 4px solid var(--secondary);
}

.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.card-link:hover {
    color: inherit;
}

.letter-progress-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow);
}

.letter-progress-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.letter-progress-card .card-title {
    font-size: 1.2rem;
    color: var(--text);
}

.letter-progress-card .card-meta {
    font-size: 0.85rem;
    color: var(--text-light);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

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

.letter-card-btn {
    margin-top: 1rem;
}

.card-saved-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    font-size: 0.85rem;
    color: var(--text-light);
}

.resume-link {
    color: var(--primary);
    font-weight: 500;
}

.resume-link:hover {
    color: var(--primary-dark);
}

/* ==================== 情绪反馈和确认页 ==================== */
.confirm-wrapper {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px var(--shadow);
}

.chapter-summary {
    text-align: center;
    margin-bottom: 2rem;
}

.summary-text {
    color: var(--text-light);
    margin-top: 0.5rem;
}

.emotion-form {
    margin-bottom: 2rem;
}

.emotion-form .form-title,
.pause-section .form-title,
.confirm-section .form-title {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1.5rem;
    text-align: center;
}

.emotion-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.emotion-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--background);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.emotion-item:hover {
    background: #EDF4F2;
}

.emotion-item input {
    display: none;
}

.emotion-item input:checked + .emotion-label {
    color: var(--primary);
    font-weight: 600;
}

.emotion-item:has(input:checked) {
    background: #EDF4F2;
    border: 2px solid var(--primary);
}

.emotion-label {
    font-size: 0.95rem;
    color: var(--text);
}

.pause-section {
    text-align: center;
    margin-bottom: 2rem;
}

.pause-hint {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.countdown-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.countdown-number {
    font-size: 4rem;
    font-weight: bold;
    color: var(--primary);
    line-height: 1;
}

.countdown-label {
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.confirm-section {
    text-align: center;
    margin-bottom: 2rem;
}

.btn-confirm-final {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.next-chapter-hint {
    margin-top: 1rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

.skip-section {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-skip,
.btn-skip-direct {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-skip:hover,
.btn-skip-direct:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ==================== 情绪报告页 ==================== */
.report-container {
    max-width: 800px;
    margin: 0 auto;
}

.report-intro {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.report-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.report-item {
    background: var(--surface);
    padding: 1.2rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px var(--shadow);
}

.report-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

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

.report-chapter {
    color: var(--text-light);
    font-size: 0.9rem;
}

.report-emotions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.emotion-badge {
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    background: var(--background);
}

.emotion-peaceful { color: #4CAF50; }
.emotion-worried { color: #FF9800; }
.emotion-shocked { color: #F44336; }
.emotion-confused { color: #9C27B0; }
.emotion-want_continue { color: #2196F3; }

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

.emotion-history {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-item {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    background: var(--background);
}

.hint {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.back-link {
    margin-top: 2rem;
}

/* ==================== 章节操作栏 ==================== */
.chapter-actions-bar {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.chapter-main-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chapter-pause-action {
    margin-top: 0.5rem;
}

.btn-pause {
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-pause:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

/* ==================== 留言页面 ==================== */
.feedback-wrapper {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px var(--shadow);
}

.chapter-info {
    text-align: center;
    margin-bottom: 2rem;
}

.chapter-info .chapter-title {
    font-size: 1.3rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.chapter-hint {
    color: var(--text-light);
    font-size: 0.9rem;
}

.feedback-form {
    margin-bottom: 2rem;
}

.feedback-form textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

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

.feedback-list {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.feedback-list .list-title {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

.feedback-item {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
}

.feedback-content {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
}

.feedback-time {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* ==================== 读后过渡页 ==================== */
.complete-wrapper {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px var(--shadow);
    text-align: center;
}

.complete-header h1 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.complete-hint {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.complete-content {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.complete-content p {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.complete-actions h2 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.choice-form {
    text-align: left;
}

.choice-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.choice-item:hover {
    background: #EDF4F2;
}

.choice-item input {
    margin-top: 0.3rem;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.choice-content {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.choice-title {
    font-size: 1rem;
    color: var(--text);
    font-weight: 500;
}

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

.choice-form .btn-primary {
    width: 100%;
    margin-top: 1.5rem;
}

.complete-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.complete-footer p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: #a56565;
}

.settings-section select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
    .progress-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .chapter-manage-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .chapter-manage-actions {
        width: 100%;
    }

    .recipients-progress {
        flex-direction: column;
    }
}

/* ==================== 错误页面 ==================== */
.error-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.error-card {
    text-align: center;
    background: var(--surface);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
    max-width: 450px;
    width: 100%;
}

.error-code {
    font-size: 5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.error-hint {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.error-actions {
    margin-top: 1.5rem;
}

/* ==================== 管理端收信人进度 ==================== */
.recipients-progress {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.recipient-progress-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--background);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

.recipient-progress-item .rp-name {
    font-weight: 500;
    color: var(--text);
}

.recipient-progress-item .rp-count {
    color: var(--primary);
    font-weight: 600;
}

.recipient-progress-item .rp-status {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
}

.rp-status-thinking {
    background: #FFF3E0;
    color: #E65100;
}

.rp-status-ready {
    background: #E8F5E9;
    color: #2E7D32;
}

/* ==================== 章节进度条 ==================== */
.chapter-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0.8rem 0;
    overflow: hidden;
}

.chapter-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ==================== 管理页仪表盘 ==================== */
.dashboard-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.dashboard-title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.dashboard-subtitle {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 1.2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.dashboard-card {
    background: var(--background);
    border-radius: 10px;
    padding: 1.2rem;
    border-left: 4px solid var(--border);
    transition: all 0.3s;
}

.dashboard-card.card-reading { border-left-color: var(--primary); }
.dashboard-card.card-ready  { border-left-color: var(--success); background: #F0F7F0; }
.dashboard-card.card-thinking { border-left-color: var(--secondary); background: #FDF8F5; }
.dashboard-card.card-idle { opacity: 0.7; }

.dashboard-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dashboard-user {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.dashboard-badge {
    font-size: 0.78rem;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-weight: 500;
}

.badge-ready { background: #E8F5E9; color: #2E7D32; }
.badge-thinking { background: #FFF3E0; color: #E65100; }
.badge-idle { background: #F5F5F5; color: #9E9E9E; }
.badge-done { background: #E8F5E9; color: #2E7D32; }
.badge-reading { background: #EDF4F2; color: var(--primary-dark); }

.dashboard-progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin: 0.6rem 0;
    overflow: hidden;
}

.dashboard-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.fill-ready { background: var(--success); }
.fill-thinking { background: var(--secondary); }

.dashboard-progress-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.4rem;
}

.dashboard-current {
    font-size: 0.85rem;
    color: var(--primary-dark);
    margin: 0.4rem 0;
    padding: 0.4rem 0.6rem;
    background: #EDF4F2;
    border-radius: 6px;
}

.dashboard-emotion {
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

.emotion-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.emotion-tag-peaceful { background: #E8F5E9; color: #2E7D32; }
.emotion-tag-worried { background: #FFF3E0; color: #E65100; }
.emotion-tag-shocked { background: #FFEBEE; color: #C62828; }
.emotion-tag-confused { background: #F3E5F5; color: #6A1B9A; }
.emotion-tag-want_continue { background: #EDF4F2; color: var(--primary-dark); }

.dashboard-time {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.dashboard-next-step {
    margin-top: 0.8rem;
    padding: 0.6rem 0.8rem;
    background: #E8F5E9;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #2E7D32;
}

.dashboard-next-think {
    background: #FFF3E0;
    color: #E65100;
}

.dashboard-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ==================== 移动端优化 ==================== */
@media (max-width: 768px) {
    body {
        font-size: 17px;
        line-height: 1.85;
    }

    .site-header {
        padding: 0.8rem 1rem;
    }

    .site-name {
        font-size: 1rem;
    }

    .main-content {
        padding: 1rem 0.8rem;
    }

    .chapter-container,
    .letter-container,
    .manage-container,
    .settings-container,
    .report-container {
        max-width: 100%;
        padding: 0;
    }

    .chapter-title {
        font-size: 1.4rem;
        line-height: 1.6;
        margin-bottom: 1rem;
    }

    .chapter-text {
        font-size: 1.08rem;
        line-height: 2;
        letter-spacing: 0.02em;
    }

    .chapter-content {
        padding: 1.2rem 0.8rem;
    }

    .chapter-actions-bar {
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem;
    }

    .chapter-main-actions {
        flex-direction: column;
        width: 100%;
    }

    .chapter-main-actions .btn-confirm,
    .chapter-main-actions .btn-secondary {
        width: 100%;
        text-align: center;
        padding: 0.9rem;
        font-size: 1rem;
    }

    .btn-pause {
        width: 100%;
        text-align: center;
        padding: 0.9rem;
        font-size: 1rem;
    }

    .chapter-nav-bottom {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chapter-nav-bottom .btn-secondary {
        width: 100%;
        text-align: center;
        padding: 0.8rem;
    }

    .progress-item {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.8rem;
    }

    .progress-action {
        width: 100%;
        text-align: right;
    }

    .progress-action .btn-small,
    .progress-action .btn-disabled {
        width: 100%;
        text-align: center;
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-section {
        padding: 1rem;
        border-radius: 8px;
    }

    .dashboard-card {
        padding: 1rem;
    }

    .dashboard-user {
        font-size: 1.05rem;
    }

    .emotion-options {
        flex-direction: column;
        gap: 0.5rem;
    }

    .emotion-item {
        width: 100%;
        padding: 0.7rem;
    }

    .choice-item {
        padding: 1rem;
    }

    .settings-form input,
    .settings-form select {
        font-size: 1rem;
        padding: 0.8rem;
    }

    .btn-primary,
    .btn-secondary,
    .btn-confirm {
        min-height: 44px;
        padding: 0.7rem 1.2rem;
    }

    .letter-title {
        font-size: 1.3rem;
    }

    .flash-messages {
        margin: 0.5rem 0;
    }

    .flash {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }

    .site-footer {
        padding: 1.5rem 1rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 16px;
    }

    .chapter-title {
        font-size: 1.25rem;
    }

    .chapter-text {
        font-size: 1.02rem;
        line-height: 1.95;
    }

    .dashboard-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
