/* ============================================================
 * 微语（memos）样式
 * 两处使用，由 header.php 按 pageType 条件加载：
 *   1) 首页「微语」状态条（.memo-strip*）—— 最新 1 条的轻量横条
 *   2) /memos/ 归档页卡片列表（.memo-card*）
 * ============================================================ */

/* ---------- 1. 首页「微语」状态条 ---------- */
.memo-strip-wrap {
    margin: 0 0 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.memo-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #eee;
    /* 左侧强调竖线：不用标题也能一眼识别「这是一条动态」 */
    border-left: 3px solid #c0392b;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.memo-strip:hover {
    background: #fffaf9;
    border-color: #f2d4ce;
    border-left-color: #c0392b;
    box-shadow: 0 2px 10px rgba(192, 57, 43, 0.07);
}

.memo-strip-badge {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    color: #c0392b;
    background: #fdeeeb;
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing: 0.5px;
}

.memo-strip-time {
    flex: 0 0 auto;
    font-size: 12px;
    color: #9a9a9a;
    white-space: nowrap;
}

.memo-strip-text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.6;
    color: #444;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memo-strip-thumb {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}
.memo-strip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.memo-strip-arrow {
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1;
    color: #c9c9c9;
    transition: transform 0.18s ease, color 0.18s ease;
}
.memo-strip:hover .memo-strip-arrow {
    color: #c0392b;
    transform: translateX(3px);
}

/* 窄屏：第一行「微语 · 时间 · 缩略图 ›」，正文折到第二行并限两行 */
@media (max-width: 640px) {
    .memo-strip {
        flex-wrap: wrap;
        row-gap: 7px;
        padding: 11px 13px;
    }
    .memo-strip-badge { order: 1; }
    .memo-strip-time  { order: 2; }
    .memo-strip-thumb { order: 3; }
    .memo-strip-arrow { order: 4; margin-left: auto; }
    .memo-strip-text {
        order: 5;
        flex: 1 1 100%;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
}

/* ---------- 2. 归档页卡片 ---------- */
.memo-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.memo-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.memo-pinned {
    border-color: #f0c9c0;
    background: #fffaf8;
}
.memo-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
}
.memo-pin {
    background: #c0392b;
    color: #fff;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
}
.memo-content {
    font-size: 15px;
    line-height: 1.7;
    color: #333;
    word-break: break-word;
}
.memo-content a {
    color: #c0392b;
    text-decoration: none;
}
.memo-content a:hover {
    text-decoration: underline;
}

/* ---------- 配图九宫格（微信风格：多图等宽方格，单图按原比例） ---------- */
.memo-images {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}
.memo-images-1 { grid-template-columns: minmax(0, 60%); max-width: 360px; }
.memo-images-2,
.memo-images-4 { grid-template-columns: repeat(2, 1fr); max-width: 320px; }
.memo-images-3,
.memo-images-5,
.memo-images-6,
.memo-images-7,
.memo-images-8,
.memo-images-9 { grid-template-columns: repeat(3, 1fr); max-width: 360px; }
.memo-image {
    display: block;
    overflow: hidden;
    border-radius: 6px;
    background: #f5f5f5;
}
/* 多图：统一 1:1 方格 + cover 裁切（九宫格） */
.memo-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    aspect-ratio: 1 / 1;
    transition: transform 0.2s ease;
}
/* 单图：按原始宽高比展示，限高避免长图过长（不裁成方块） */
.memo-images-1 .memo-image { aspect-ratio: auto; }
.memo-images-1 .memo-image img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 420px;
    aspect-ratio: auto;
    object-fit: contain;
}
/* UI-2（2026-11-06）：新数据带 width/height 属性，浏览器按宽高比预留空间；
   历史数据没有尺寸属性时给一个最小占位高度，减轻加载完成时的布局跳动。 */
.memo-images-1 img:not([width]) { min-height: 120px; }
.memo-image:hover img {
    transform: scale(1.03);
}
/* 窄屏：缩小方格间距，九宫格保持 2/3 列不变（自适应） */
@media (max-width: 480px) {
    .memo-images { gap: 4px; }
    .memo-images-1 { max-width: 70%; }
    .memo-images-2,
    .memo-images-4 { max-width: 78%; }
    .memo-images-3,
    .memo-images-5,
    .memo-images-6,
    .memo-images-7,
    .memo-images-8,
    .memo-images-9 { max-width: 84%; }
}

/* ---------- 卡片底部回链（仅配了独立 memos 站点时渲染） ---------- */
.memo-footer {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: #999;
}
.memo-link {
    margin-left: auto;
    color: #c0392b;
    text-decoration: none;
    font-weight: 600;
}
.memo-link:hover {
    text-decoration: underline;
}

/* ---------- /memos/ 独立页 ---------- */
.page-title {
    font-size: 24px;
    margin: 4px 0 6px;
}
.memo-page-desc {
    color: #888;
    font-size: 14px;
    margin: 0 0 22px;
}

/* ---------- 暗色模式 ---------- */
body.dark .memo-strip,
body[data-theme="dark"] .memo-strip {
    background: #1e1e1e;
    border-color: #333;
    border-left-color: #c0392b;
}
body.dark .memo-strip:hover,
body[data-theme="dark"] .memo-strip:hover {
    background: #241f1f;
    border-color: #5a3a34;
    border-left-color: #c0392b;
}
body.dark .memo-strip-badge,
body[data-theme="dark"] .memo-strip-badge {
    background: #3a2522;
    color: #e8786a;
}
body.dark .memo-strip-text,
body[data-theme="dark"] .memo-strip-text {
    color: #d8d8d8;
}
body.dark .memo-strip-thumb,
body[data-theme="dark"] .memo-strip-thumb {
    background: #2a2a2a;
}
body.dark .memo-strip-arrow,
body[data-theme="dark"] .memo-strip-arrow {
    color: #666;
}

body.dark .memo-card,
body[data-theme="dark"] .memo-card {
    background: #1e1e1e;
    border-color: #333;
    box-shadow: none;
}
body.dark .memo-pinned,
body[data-theme="dark"] .memo-pinned {
    background: #2a1f1d;
    border-color: #5a3a34;
}
body.dark .memo-content,
body[data-theme="dark"] .memo-content {
    color: #e6e6e6;
}
body.dark .memo-meta,
body.dark .memo-footer,
body.dark .memo-time,
body[data-theme="dark"] .memo-meta,
body[data-theme="dark"] .memo-footer,
body[data-theme="dark"] .memo-time {
    color: #999;
}

/* ---------- 卡片底部操作行（时间左 · 点赞右） ---------- */
.memo-actions {
    position: relative;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.memo-time-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.memo-time {
    font-size: 12px;
    color: #999;
}
.memo-like-msg {
    display: none;
    position: absolute;
    left: 50%;
    top: -24px;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12px;
    color: #c0392b;
    background: #fff;
    border: 1px solid #f0c9c0;
    border-radius: 4px;
    padding: 2px 9px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    z-index: 5;
}
.memo-like-msg.show {
    display: block;
}
.memo-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e6e6e6;
    background: #fafafa;
    color: #8a8a8a;
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
    font-family: inherit;
}
.memo-like-btn:hover {
    border-color: #f0b9b0;
    color: #c0392b;
    background: #fff5f3;
}
.memo-like-btn:focus-visible {
    outline: 2px solid #c0392b;
    outline-offset: 2px;
}
/* 未赞：空心桃心；已赞：实心桃心（由 CSS 内容切换，无需二张图） */
.memo-like-icon::before {
    content: "\2661"; /* ♡ */
    font-size: 15px;
    line-height: 1;
}
.memo-like-btn.liked {
    color: #c0392b;
    border-color: #e9a89e;
    background: #fdeeeb;
}
.memo-like-btn.liked .memo-like-icon::before {
    content: "\2665"; /* ♥ */
}
.memo-like-btn.busy {
    opacity: 0.6;
    cursor: progress;
}
/* 操作失败短暂抖动反馈 */
@keyframes memo-like-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}
.memo-like-btn.memo-like-error {
    animation: memo-like-shake 0.3s ease 2;
    color: #c0392b;
    border-color: #e9a89e;
}

/* 暗色模式下的点赞按钮 */
body.dark .memo-like-btn,
body[data-theme="dark"] .memo-like-btn {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #a8a8a8;
}
body.dark .memo-like-btn:hover,
body[data-theme="dark"] .memo-like-btn:hover {
    color: #e8786a;
    border-color: #5a3a34;
    background: #2f2321;
}
body.dark .memo-like-btn.liked,
body[data-theme="dark"] .memo-like-btn.liked {
    color: #e8786a;
    border-color: #5a3a34;
    background: #3a2522;
}
body.dark .memo-like-btn.memo-like-error,
body[data-theme="dark"] .memo-like-btn.memo-like-error {
    color: #e8786a;
    border-color: #5a3a34;
}

/* 暗色模式下的评论按钮（与点赞按钮保持一致外形） */
body.dark .memo-comment-toggle,
body[data-theme="dark"] .memo-comment-toggle {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #a8a8a8;
}
body.dark .memo-comment-toggle:hover,
body[data-theme="dark"] .memo-comment-toggle:hover {
    color: #e8786a;
    border-color: #5a3a34;
    background: #2f2321;
}

/* ---------- 正文内自动链接的 #标签 ---------- */
.memo-content .memo-hashtag {
    color: #c0392b;
    background: #fdeeeb;
    border-radius: 4px;
    padding: 0 4px;
    margin: 0 1px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.memo-content .memo-hashtag:hover {
    background: #fbe0db;
}
body.dark .memo-content .memo-hashtag,
body[data-theme="dark"] .memo-content .memo-hashtag {
    color: #e8786a;
    background: #2f2321;
}
body.dark .memo-content .memo-hashtag:hover,
body[data-theme="dark"] .memo-content .memo-hashtag:hover {
    background: #3a2522;
}

/* ---------- 标签筛选条（/memos/ 进入标签归档页时显示） ---------- */
.memo-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: #fff7f5;
    border: 1px solid #f3d9d2;
    border-radius: 10px;
    padding: 10px 14px;
    margin: 0 0 16px;
    font-size: 14px;
    color: #555;
}
.memo-filter-label strong {
    color: #c0392b;
}
.memo-filter-clear {
    font-size: 13px;
    color: #c0392b;
    text-decoration: none;
    border: 1px solid #f0c9c0;
    background: #fff;
    padding: 4px 12px;
    border-radius: 999px;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.memo-filter-clear:hover {
    background: #fdeeeb;
    border-color: #e9a89e;
}
body.dark .memo-filter-bar,
body[data-theme="dark"] .memo-filter-bar {
    background: #2a2020;
    border-color: #4a3531;
    color: #bbb;
}
body.dark .memo-filter-label strong,
body[data-theme="dark"] .memo-filter-label strong {
    color: #e8786a;
}
body.dark .memo-filter-clear,
body[data-theme="dark"] .memo-filter-clear {
    color: #e8786a;
    border-color: #5a3a34;
    background: #1e1e1e;
}
body.dark .memo-filter-clear:hover,
body[data-theme="dark"] .memo-filter-clear:hover {
    background: #2f2321;
    border-color: #5a3a34;
}

/* ---------- 标签切换条（标签归档页：切换到其它话题） ---------- */
.memo-tag-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    font-size: 13px;
    color: #888;
}
.memo-tag-nav-label {
    color: #999;
    margin-right: 2px;
}
.memo-tag-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    line-height: 1.4;
    color: #555;
    background: #f5f6f8;
    border: 1px solid #eceef1;
    border-radius: 999px;
    padding: 4px 11px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.memo-tag-nav-item:hover {
    background: #fdeeeb;
    border-color: #f0c9c0;
    color: #c0392b;
}
.memo-tag-nav-item:focus-visible {
    outline: 2px solid #c0392b;
    outline-offset: 2px;
}
/* 当前正在筛选的标签：实心高亮态（不可再点） */
.memo-tag-nav-item.is-active {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
    font-weight: 600;
    cursor: default;
}
.memo-tag-nav-item.is-active:hover {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}
.memo-tag-nav-count {
    font-size: 11px;
    color: #aaa;
    background: #fff;
    border-radius: 999px;
    padding: 0 6px;
    min-width: 18px;
    text-align: center;
}
.memo-tag-nav-item.is-active .memo-tag-nav-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}
body.dark .memo-tag-nav,
body[data-theme="dark"] .memo-tag-nav {
    color: #777;
}
body.dark .memo-tag-nav-label,
body[data-theme="dark"] .memo-tag-nav-label {
    color: #777;
}
body.dark .memo-tag-nav-item,
body[data-theme="dark"] .memo-tag-nav-item {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #bbb;
}
body.dark .memo-tag-nav-item:hover,
body[data-theme="dark"] .memo-tag-nav-item:hover {
    background: #2f2321;
    border-color: #5a3a34;
    color: #e8786a;
}
body.dark .memo-tag-nav-count,
body[data-theme="dark"] .memo-tag-nav-count {
    background: #1e1e1e;
    color: #888;
}
body.dark .memo-tag-nav-item.is-active,
body[data-theme="dark"] .memo-tag-nav-item.is-active {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

/* ============================================================
 * 卡片社交化头部（#9）：头像 + 昵称 + 相对时间
 * ============================================================ */
.memo-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.memo-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #c0392b, #e67e22);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    font-family: "KaiTi", "STKaiti", "PingFang SC", serif;
    overflow: hidden;
    user-select: none;
}
.memo-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memo-card-head .memo-author {
    font-size: 14.5px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}
.memo-card-head .memo-head-time {
    font-size: 12px;
    color: #9a9a9a;
}
body.dark .memo-card-head .memo-author { color: #e6e6e6; }
body.dark .memo-card-head .memo-head-time { color: #888; }

/* ============================================================
 * 评论面板（#1）：可折叠，懒加载
 * ============================================================ */
.memo-comment-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e6e6e6;
    background: #fafafa;
    color: #8a8a8a;
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
    font-family: inherit;
}
.memo-comment-toggle:hover { border-color: #f0b9b0; color: #c0392b; background: #fff5f3; text-decoration: none; }
.memo-comments-panel { margin-top: 10px; border-top: 1px dashed #eee; padding-top: 10px; }
body.dark .memo-comments-panel { border-top-color: #333; }

.memo-comment-list { display: flex; flex-direction: column; gap: 9px; }
.memo-comment-item {
    font-size: 13.5px;
    line-height: 1.6;
    color: #444;
}
.memo-comment-item .mc-meta { color: #9a9a9a; font-size: 12px; margin-bottom: 2px; }
.memo-comment-item .mc-author { color: #c0392b; font-weight: 600; }
.memo-comment-item .mc-floor { color: #bbb; }
.memo-comment-item .mc-text { word-break: break-word; }
.memo-comment-item .mc-text p { margin: 0 0 6px; }
.memo-comment-item .mc-text a { color: #c0392b; }
body.dark .memo-comment-item { color: #c8c8c8; }
body.dark .memo-comment-item .mc-meta { color: #888; }

.memo-comment-form { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.memo-comment-form .mc-row { display: flex; gap: 7px; flex-wrap: wrap; }
.memo-comment-form input,
.memo-comment-form textarea {
    border: 1px solid #ddd;
    border-radius: 7px;
    padding: 7px 9px;
    font-size: 13px;
    font-family: inherit;
    background: #fafbfc;
    color: #333;
}
.memo-comment-form input { flex: 1 1 140px; min-width: 0; }
.memo-comment-form textarea { resize: vertical; min-height: 60px; }
.memo-comment-form input:focus,
.memo-comment-form textarea:focus { outline: none; border-color: #c0392b; background: #fff; }
.memo-comment-form .mc-submit {
    align-self: flex-start;
    border: 0;
    border-radius: 7px;
    background: #c0392b;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 18px;
    cursor: pointer;
}
.memo-comment-form .mc-submit:hover { background: #a93226; }
.memo-comment-form .mc-submit:disabled { opacity: 0.6; cursor: progress; }
.memo-comment-msg { font-size: 12.5px; min-height: 16px; }
.memo-comment-msg.err { color: #c0392b; }
.memo-comment-msg.ok { color: #2e8b57; }
/* 蜜罐：视觉隐藏但保留在 DOM */
.memo-comment-form .mc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
body.dark .memo-comment-form input,
body.dark .memo-comment-form textarea { background: #2a2a2a; border-color: #3a3a3a; color: #ddd; }
body.dark .memo-comment-form input:focus,
body.dark .memo-comment-form textarea:focus { border-color: #e8786a; background: #242424; }

/* ============================================================
 * 图片灯箱（#4）
 * ============================================================ */
.memo-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.86);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    padding: 24px;
}
.memo-lightbox.open { display: flex; }
.memo-lightbox img {
    max-width: 92vw;
    max-height: 82vh;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.memo-lightbox .lb-close {
    position: absolute;
    top: 18px;
    right: 22px;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    background: none;
    border: none;
}
.memo-lightbox .lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 40px;
    line-height: 1;
    cursor: pointer;
    background: none;
    border: none;
    padding: 10px;
    user-select: none;
}
.memo-lightbox .lb-prev { left: 10px; }
.memo-lightbox .lb-next { right: 10px; }
.memo-lightbox .lb-count {
    position: absolute;
    bottom: 20px;
    color: #ddd;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 10px;
    border-radius: 999px;
}

/* ============================================================
 * /memos/ 搜索与排序栏（#6）
 * ============================================================ */
.memo-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    flex-wrap: nowrap;
}
.memo-search {
    flex: 1 1 220px;
    min-width: 0;
    border: 1px solid #e0e3e8;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #333;
}
.memo-search:focus { outline: none; border-color: #c0392b; }
.memo-sort {
    flex: 0 0 auto;
    white-space: nowrap;
    border: 1px solid #e0e3e8;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    background: #fff;
    color: #555;
    font-family: inherit;
    cursor: pointer;
}
.memo-sort:focus { outline: none; border-color: #c0392b; }
.memo-search-empty {
    text-align: center;
    color: #999;
    font-size: 14px;
    padding: 30px 0;
    display: none;
}
body.dark .memo-search,
body.dark .memo-sort { background: #2a2a2a; border-color: #3a3a3a; color: #ddd; }
body.dark .memo-search-empty { color: #888; }


