/* ============ 基础 ============ */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --bg: #f5f6f8;
    --card: #fff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; display: block; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ============ 头部 ============ */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 56px; flex-wrap: wrap; }
.logo { font-size: 20px; font-weight: 700; color: var(--text); }
.logo:hover { color: var(--primary); }
.cat-nav { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cat-nav a {
    padding: 6px 12px; border-radius: 999px; color: var(--muted);
    white-space: nowrap; font-size: 14px;
}
.cat-nav a:hover { background: #eef2f7; color: var(--primary); }
.cat-nav a.active { background: var(--primary); color: #fff; }

/* ============ 首页列表 ============ */
main.wrap { padding-top: 20px; padding-bottom: 40px; }
.filter-bar { margin-bottom: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 80px 0; }
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.post-card {
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.card-link { color: inherit; display: block; }
.card-cover { position: relative; aspect-ratio: 4/3; background: #eceef1; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.no-img { display: flex; align-items: center; justify-content: center; height: 100%; color: #b6bcc5; }
.badge {
    position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.55); color: #fff;
    font-size: 12px; padding: 2px 8px; border-radius: 999px;
}
.card-body { padding: 12px 14px 14px; }
.card-title { font-size: 16px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-desc { font-size: 13px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }

.chip {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    background: #eef2f7; color: var(--muted); font-size: 13px;
}
.chip:hover { background: #dfe7f0; color: var(--primary); }
.chip-active { background: var(--primary); color: #fff; }
.chip-sm { font-size: 12px; padding: 1px 8px; }

/* ============ 分页 ============ */
.pagination { display: flex; justify-content: center; gap: 8px; margin: 32px 0 8px; flex-wrap: wrap; }
.pagination a {
    min-width: 36px; padding: 6px 12px; text-align: center; border-radius: 8px;
    background: #fff; border: 1px solid var(--border); color: var(--text); font-size: 14px;
}
.pagination a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============ 标签云 ============ */
.tag-cloud { margin-top: 48px; padding: 16px 0; border-top: 1px dashed var(--border); }
.tag-cloud h3 { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.tag-cloud .chip { margin: 0 6px 6px 0; }

/* ============ 文章页 ============ */
.post-page { padding-top: 24px; padding-bottom: 40px; }
.post-detail { max-width: 820px; margin: 0 auto; }
.post-title { font-size: 26px; line-height: 1.35; margin-bottom: 10px; }
.post-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.post-desc { background: #fff; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 20px; color: #374151; }
.post-images .post-fig {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 20px; overflow: hidden;
}
.post-fig img { width: 100%; }
.post-fig figcaption { padding: 10px 14px 14px; font-size: 13px; color: var(--muted); }
.fig-desc { color: var(--text); margin-bottom: 4px; }
.fig-exif a { word-break: break-all; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 24px; }
.post-nav { display: flex; justify-content: space-between; gap: 12px; border-top: 1px dashed var(--border); padding-top: 16px; font-size: 14px; }
.post-nav a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48%; }

/* ============ 页脚 ============ */
.site-footer { background: #111827; color: #9ca3af; text-align: center; padding: 20px 0; font-size: 13px; }
.site-footer a { color: #d1d5db; }

/* 懒加载占位 */
img.lazy { opacity: 0; transition: opacity .35s ease; background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
img.lazy.loaded { opacity: 1; animation: none; background: none; }
@keyframes shimmer { to { background-position-x: -200%; } }

/* ============ 手机端 m/ 页面 ============ */
.m-page { max-width: 640px; margin: 0 auto; padding: 16px; }
.m-upload-btn {
    display: block; text-align: center; background: var(--primary); color: #fff;
    border-radius: var(--radius); padding: 14px; font-size: 17px; font-weight: 600; margin-bottom: 20px;
}
.m-upload-btn:active { opacity: .85; }
.m-list-item {
    display: flex; gap: 12px; background: #fff; border-radius: var(--radius);
    padding: 10px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.m-list-item img { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; flex: none; }
.m-list-item h2 { font-size: 15px; line-height: 1.4; }
.m-list-item .meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.m-form { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.m-form input[type=text], .m-form textarea, .m-form select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 16px; margin-bottom: 12px; font-family: inherit;
}
.m-form textarea { min-height: 90px; resize: vertical; }
.m-file-label {
    display: block; border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 26px 12px; text-align: center; color: var(--muted); margin-bottom: 12px; cursor: pointer;
}
.m-previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.m-previews img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.m-submit { width: 100%; padding: 13px; border: 0; border-radius: var(--radius); background: var(--primary); color: #fff; font-size: 17px; font-weight: 600; }
.m-submit:disabled { opacity: .6; }
.msg-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

/* ============ 手机端登录卡片 ============ */
.m-login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    background: linear-gradient(160deg, #667eea 0%, #764ba2 55%, #6b8dd6 100%);
}
.m-login-card {
    width: 100%; max-width: 360px;
    background: rgba(255, 255, 255, .96);
    border-radius: 20px;
    padding: 34px 26px 28px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    text-align: center;
    animation: mLoginIn .35s ease;
}
@keyframes mLoginIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}
.m-login-logo {
    width: 62px; height: 62px; line-height: 62px; margin: 0 auto 14px;
    font-size: 32px; border-radius: 18px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 8px 20px rgba(102, 126, 234, .4);
}
.m-login-title { font-size: 21px; color: #1f2937; }
.m-login-sub { font-size: 13px; color: #9ca3af; margin: 6px 0 24px; letter-spacing: 2px; }
.m-login-form { text-align: left; }
.m-login-field {
    display: flex; align-items: center;
    background: #f3f4f6; border-radius: 12px;
    margin-bottom: 14px; padding: 0 14px;
    border: 1.5px solid transparent;
    transition: border-color .15s ease, background .15s ease;
}
.m-login-field:focus-within {
    border-color: #667eea; background: #fff;
}
.m-login-field span { font-size: 17px; margin-right: 10px; }
.m-login-field input {
    flex: 1; border: 0; outline: none; background: transparent;
    padding: 14px 0; font-size: 16px; font-family: inherit; color: #1f2937;
    min-width: 0;
}
.m-login-field input::placeholder { color: #b6bcc5; }
.m-login-btn {
    width: 100%; padding: 14px; margin-top: 4px;
    border: 0; border-radius: 12px; cursor: pointer;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff; font-size: 16px; font-weight: 600; letter-spacing: 6px;
    box-shadow: 0 8px 18px rgba(102, 126, 234, .35);
    transition: opacity .15s ease;
}
.m-login-btn:active { opacity: .85; }
.m-login-err {
    background: #fef2f2; color: #b91c1c;
    border: 1px solid #fecaca; border-radius: 10px;
    padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}
.m-login-back {
    display: inline-block; margin-top: 18px;
    font-size: 13px; color: #9ca3af;
}

/* ============ 手机端裁剪浮层（Cropper.js） ============ */
.crop-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: #000; display: flex; flex-direction: column;
}
.crop-area {
    flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
    padding: 12px;
}
.crop-area img { display: block; max-width: 100%; max-height: 100%; }
.crop-tip {
    padding: 6px 12px; font-size: 12px; color: #fbbf24; background: rgba(0, 0, 0, .6);
    text-align: center;
}
.crop-bar {
    display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #111; overflow-x: auto;
}
.crop-btn {
    flex: 1; min-width: 56px; padding: 10px 12px; border: 0; border-radius: 8px;
    background: #374151; color: #fff; font-size: 14px;
}
.crop-btn.primary { background: var(--primary); }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .header-inner { height: auto; padding: 8px 0; }
    .post-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .card-title { font-size: 14px; }
    .post-title { font-size: 21px; }
    .post-nav { flex-direction: column; gap: 8px; }
    .post-nav a { max-width: 100%; white-space: normal; }
}
@media (max-width: 420px) {
    .post-grid { grid-template-columns: 1fr; }
}
