/* 我家日记 —— 古雅淡彩主题
   所有页面共用这一份样式表，而不是像之前那样每个页面自己写一份 <style>——
   颜色、字体这些"整站视觉身份"如果散落在七八个文件里，改一次配色就要改七八处，
   很容易漏改导致页面之间风格不一致。这份文件就是唯一的样式来源。 */

:root {
    --color-bg: #f2e9da;          /* 页面背景：暖调宣纸色 */
    --color-paper: #fffbf3;       /* 内容卡片背景：更浅的米白 */
    --color-ink: #3b2f27;         /* 正文墨色 */
    --color-ink-soft: #7a6a58;    /* 次要文字（时间、说明文字） */
    --color-border: #e2d3b8;      /* 淡雅的分隔线/边框色 */
    --color-accent: #a2592f;      /* 赭石色，用于链接、标题 */
    --color-accent-dark: #7c4420;
    --color-gold: #b58a4a;        /* 淡金，用于头像描边等点缀 */
    --color-danger: #a1503f;      /* 柔和的朱红，代替刺眼的纯红 */
    --color-danger-bg: #f8ece7;
    --color-success: #5f7a52;     /* 柔和的墨绿 */
    --color-success-bg: #eef2e6;
    --font-serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif;
}

* { box-sizing: border-box; }

html { background: var(--color-bg); }

body {
    font-family: var(--font-serif);
    color: var(--color-ink);
    line-height: 1.75;
    max-width: 640px;
    margin: 40px auto;
    padding: 34px 44px 44px;
    background: var(--color-paper);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(90, 60, 30, 0.08);
}

/* 登录、注册、个人资料这几个表单页版心比较窄，看起来更像一张小卡片 */
body.narrow { max-width: 440px; padding: 32px 36px 40px; }

h1 {
    font-size: 1.7em;
    font-weight: 600;
    color: var(--color-accent-dark);
    letter-spacing: 0.04em;
    margin: 0 0 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--color-border);
}

h2 {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--color-ink);
    margin: 28px 0 8px;
}

p { margin: 0 0 12px; }

a {
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--color-accent);
}
a:hover { color: var(--color-accent-dark); }

label {
    display: block;
    margin-top: 16px;
    font-weight: 600;
    color: var(--color-ink-soft);
    font-size: 0.92em;
}

input, textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    margin-top: 4px;
    font-size: 1em;
    font-family: var(--font-serif);
    color: var(--color-ink);
    background: #fffefb;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(181, 138, 74, 0.15);
}
input[readonly] { background: #f1e9db; color: var(--color-ink-soft); }
textarea { height: 140px; line-height: 1.6; }

button {
    margin-top: 20px;
    padding: 9px 24px;
    font-size: 0.95em;
    font-family: var(--font-serif);
    letter-spacing: 0.03em;
    color: #fff8ee;
    background: var(--color-accent);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}
button:hover { background: var(--color-accent-dark); }

hr { border: none; border-top: 1px solid var(--color-border); margin: 28px 0; }

.error {
    color: var(--color-danger);
    background: var(--color-danger-bg);
    border: 1px solid #e6c7bd;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 12px;
    font-size: 0.9em;
}
.success {
    color: var(--color-success);
    background: var(--color-success-bg);
    border: 1px solid #cddcbe;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 12px;
    font-size: 0.9em;
}
.hint { color: var(--color-ink-soft); font-size: 0.85em; margin-top: 4px; }

/* 头像点了能直接跳去和这个人的私信对话——包一层 <a> 时去掉链接默认的虚线下划线，
   头像本来就是圆形图案，不需要再套一条线 */
.avatar-link { border-bottom: none; display: inline-block; line-height: 0; }

/* 头像统一加一圈细金边，是整套设计里唯一的"装饰性"元素，不铺张 */
.nav-avatar, .post-avatar, .comment-avatar, .avatar-cell, .avatar-current, .avatar-preview img {
    border-radius: 50%;
    object-fit: cover;
    background: #e6d9c3;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--color-gold);
}
.nav-avatar { width: 26px; height: 26px; vertical-align: middle; display: inline-block; }
.post-avatar { width: 34px; height: 34px; vertical-align: middle; display: inline-block; margin-right: 10px; }
.comment-avatar { width: 26px; height: 26px; vertical-align: middle; display: inline-block; margin-right: 8px; }
.avatar-cell { width: 30px; height: 30px; display: block; }
.avatar-current, .avatar-preview img { width: 84px; height: 84px; display: block; margin-top: 8px; }

/* 文章/头像上传时的临时预览图——不是圆形头像，是矩形缩略图，跟上面那组分开一条规则 */
.preview-img { max-width: 200px; max-height: 200px; display: block; margin-top: 8px; border-radius: 4px; border: 1px solid var(--color-border); }

/* 文章列表 / 详情页 */
article { border-bottom: 1px solid var(--color-border); padding-bottom: 24px; margin-bottom: 24px; }
article:last-child { border-bottom: none; margin-bottom: 0; }
article img { max-width: 100%; border-radius: 6px; margin-bottom: 14px; display: block; border: 1px solid var(--color-border); }
.meta { color: var(--color-ink-soft); font-size: 0.88em; margin-bottom: 10px; display: flex; align-items: center; }

/* 首页文章卡片：缩略图 + 标题/摘要，点进去才看完整内容和所有大图——
   卡片本身不整个包一层 <a>，是因为里面头像还要单独链到私信对话，
   两个 <a> 不能互相嵌套，所以缩略图和标题各自链到详情页，头像链接留在 .meta 里独立存在。 */
.post-card { display: flex; gap: 14px; align-items: flex-start; }
.post-card-thumb-link { flex-shrink: 0; border-bottom: none; }
.post-card-thumb, .post-card-thumb.placeholder {
    width: 100px;
    height: 100px;
    border-radius: 6px;
    display: block;
}
.post-card-thumb { object-fit: cover; border: 1px solid var(--color-border); background: #e6d9c3; }
.post-card-thumb.placeholder { border: 1px dashed var(--color-border); background: #f1e9db; }
.post-card-body { flex: 1; min-width: 0; }
.post-card-body h2 { margin: 0 0 6px; font-size: 1.1em; }
.post-card-body h2 a { border-bottom: none; color: var(--color-ink); }
.post-card-body h2 a:hover { color: var(--color-accent); }
.post-card-excerpt {
    color: var(--color-ink-soft);
    font-size: 0.92em;
    margin: 6px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 编辑文章页：已有配图列表，每张图配一个"删除"复选框 */
.existing-images { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.existing-image-item { display: block; margin-top: 0; font-weight: normal; }
.existing-image-item span { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 0.85em; color: var(--color-ink-soft); }
.existing-image-item input[type="checkbox"] { width: auto; margin: 0; }
.actions { margin-top: 10px; }
.actions form { display: inline; }
.actions a, .actions button {
    font-size: 0.88em;
    margin-right: 14px;
    margin-top: 0;
    background: none;
    border: none;
    padding: 0;
    color: var(--color-ink-soft);
    text-decoration: underline;
    cursor: pointer;
    font-family: var(--font-serif);
}
.actions a:hover, .actions button:hover { color: var(--color-accent); }

/* 评论区 */
.comments { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--color-border); }
.comment { display: flex; align-items: flex-start; margin-top: 12px; }
.comment-body { flex: 1; font-size: 0.92em; background: #faf3e5; border-radius: 6px; padding: 8px 12px; }
.comment-meta { color: var(--color-ink-soft); font-size: 0.85em; margin-bottom: 2px; }
.comment-meta strong { color: var(--color-ink); font-weight: 600; }
.comment-meta button {
    font-size: 0.85em; margin-top: 0; background: none; border: none; padding: 0;
    margin-left: 8px; color: #a98b6f; text-decoration: underline; cursor: pointer;
    font-family: var(--font-serif);
}
.comment-form { margin-top: 14px; }
.comment-form textarea { height: 56px; }
.comment-form button { margin-top: 8px; padding: 7px 18px; font-size: 0.9em; }

/* 未读私信提醒——首页导航栏"私信"链接旁边的小信封，有未读消息时才显示并闪烁 */
.unread-badge {
    display: inline-block;
    margin-left: 2px;
    color: var(--color-danger);
    animation: unread-blink 1s ease-in-out infinite;
}
.unread-badge.hidden { display: none; }
@keyframes unread-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* 私信列表 */
.conversation-item {
    display: flex;
    align-items: center;
    padding: 10px 4px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-ink);
    text-decoration: none;
}
.conversation-item:last-child { border-bottom: none; }
.conversation-item:hover { color: var(--color-ink); background: #faf3e5; }
.conversation-info {
    margin-left: 10px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.conversation-info strong { font-weight: 600; }
.conversation-preview {
    color: var(--color-ink-soft);
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 私信对话 */
.message-list {
    max-height: 420px;
    overflow-y: auto;
    padding: 10px;
    margin: 14px 0;
    background: #faf3e5;
    border-radius: 6px;
    border: 1px solid var(--color-border);
}
.message-bubble { max-width: 75%; margin-bottom: 10px; }
.message-bubble.theirs { margin-right: auto; }
.message-bubble.mine { margin-left: auto; text-align: right; }
.message-content {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.92em;
    text-align: left;
    background: #fffbf3;
    border: 1px solid var(--color-border);
}
.message-bubble.mine .message-content {
    background: var(--color-accent);
    color: #fff8ee;
    border-color: var(--color-accent-dark);
}
.message-time { color: var(--color-ink-soft); font-size: 0.75em; margin-top: 2px; }
.message-form textarea { height: 70px; }
.message-form button { padding: 7px 20px; font-size: 0.9em; }

/* 家人账号列表 */
table { width: 100%; border-collapse: collapse; margin-top: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--color-border); font-size: 0.92em; }
th { color: var(--color-ink-soft); font-weight: 600; font-size: 0.82em; letter-spacing: 0.03em; }
.pending { color: #af7a2f; font-weight: 600; }
.approved { color: var(--color-success); font-weight: 600; }
.approve-form, .reset-form { display: inline-block; }
.approve-form button, .reset-form button { margin-top: 0; padding: 5px 12px; font-size: 0.82em; white-space: nowrap; }
