/* ============================================================
   简洁博客 · 主题样式
   - 所有可定制颜色都放在 :root 变量里，后台修改后实时生效
   - 圆角统一使用 iPhone 风格的大圆角
   - 按钮/卡片点击有缩放反馈
   ============================================================ */

:root {
    /* ---- 后台可自定义部分（对应 AdminPanel 的每一项） ---- */
    --primary: #007aff;            /* 主按钮颜色（iOS 蓝） */
    --secondary: #5856d6;          /* 次按钮颜色（iOS 紫） */
    --danger: #ff3b30;             /* 危险按钮颜色 */
    --bg: #f2f2f7;                 /* 页面背景色 */
    --card-bg: #ffffff;            /* 卡片背景色 */
    --text: #1c1c1e;               /* 主文字颜色 */
    --text-sub: #8e8e93;           /* 次要文字颜色 */
    --nav-bg: rgba(249, 249, 249, 0.94); /* 顶栏背景 */
    --radius: 20px;                /* 全局圆角 */
    --radius-sm: 12px;             /* 小圆角 */
    --radius-img: 16px;            /* 图片圆角 */
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06); /* 卡片阴影 */
    --font-scale: 1;               /* 字体大小缩放 */
    /* 背景图片由 JS 写入 :root 的 --bg-image 变量 */
    --bg-image: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: calc(16px * var(--font-scale));
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:active { opacity: 0.6; }
img { max-width: 100%; display: block; }

/* ============================================================
   通用按钮（全局颜色由后台控制）
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
    user-select: none;
    -webkit-user-select: none;
}
.btn:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn:active { transform: scale(0.94); }          /* 点击缩放反馈 */

.btn.secondary { background: var(--secondary); }
.btn.secondary:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--secondary) 35%, transparent); }
.btn.danger { background: var(--danger); }
.btn.ghost {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn.ghost:active { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.btn.small { padding: 6px 14px; font-size: 0.85rem; }

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}
.topbar-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar .site-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.3px;
}
.topbar .nav { display: flex; gap: 4px; align-items: center; }
.topbar .nav-item {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}
.topbar .nav-item:active { transform: scale(0.92); background: rgba(0,0,0,0.05); }
.topbar .nav-item.active { color: var(--primary); font-weight: 700; }

/* ============================================================
   公告条（可关闭，带彩色流动背景）
   ============================================================ */
.notice-bar {
    margin: 12px 16px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    background: linear-gradient(90deg, #ff4d4d, #ff9a3d, #ffd93d, #3dd68c, #3d9dff, #8a3dff, #ff4d9a, #ff4d4d);
    background-size: 400% 100%;
    animation: colorFlow 8s ease infinite;
    box-shadow: var(--shadow);
}
@keyframes colorFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.notice-bar .notice-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
}
.notice-bar .notice-icon { flex-shrink: 0; font-size: 1rem; }
.notice-bar .notice-scroll {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}
.notice-bar .notice-scroll span {
    display: inline-block;
    padding-left: 100%;
    animation: noticeScroll 18s linear infinite;
}
@keyframes noticeScroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-100%); }
}
.notice-bar .notice-close {
    flex-shrink: 0;
    border: none;
    background: rgba(255,255,255,0.25);
    color: #fff;
    width: 24px; height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
}
.notice-bar .notice-close:active { transform: scale(0.85); }

/* ============================================================
   首页文章列表
   ============================================================ */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 16px 16px 100px;
}
.article-list { display: flex; flex-direction: column; gap: 14px; }

.article-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}
.article-card:active { transform: scale(0.97); }
.article-card:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); }

.article-card .card-cover {
    width: 100%;
    aspect-ratio: 16 / 7;
    object-fit: cover;
    background: var(--bg);
}
.article-card .card-body { padding: 16px 18px 18px; }
.article-card .card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}
.article-card .card-meta {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-sub);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.article-card .card-excerpt {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* 置顶徽章 */
.pin-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    margin-right: 8px;
    vertical-align: middle;
}

/* ============================================================
   文章详情页
   ============================================================ */
.article-detail { padding-bottom: 40px; }
.article-detail .detail-cover {
    width: 100%;
    aspect-ratio: 16 / 7;
    object-fit: cover;
    border-radius: var(--radius);
}
.article-detail h1.detail-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 18px 0 8px;
    color: var(--text);
    line-height: 1.4;
}
.article-detail .detail-meta {
    font-size: 0.85rem;
    color: var(--text-sub);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    margin-bottom: 18px;
}
.article-detail .detail-content {
    font-size: 1rem;
    color: var(--text);
    line-height: 1.85;
}
.article-detail .detail-content p { margin-bottom: 1em; }
.article-detail .detail-content img {
    border-radius: var(--radius-img);
    margin: 14px 0;
}
.article-detail .detail-content h2,
.article-detail .detail-content h3 {
    margin: 1.4em 0 0.6em;
    color: var(--text);
}

/* 内容中的"接入网址"按钮（_button 标记渲染） */
.article-detail .detail-content .btn-link {
    display: inline-flex;
    margin: 8px 0;
}

/* ============================================================
   评论区
   ============================================================ */
.comment-section { margin-top: 36px; }
.comment-section h3 {
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 14px;
}
.comment-input-wrap { display: flex; flex-direction: column; gap: 10px; }
.comment-input-wrap textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    outline: none;
    transition: border-color 0.15s;
}
.comment-input-wrap textarea:focus { border-color: var(--primary); }
.comment-list { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.comment-item {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow);
}
.comment-item .c-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}
.comment-item .c-user { font-weight: 700; color: var(--primary); }
.comment-item .c-time { color: var(--text-sub); font-size: 0.75rem; }
.comment-item .c-text { margin-top: 6px; font-size: 0.92rem; color: var(--text); }
.comment-item .c-del {
    border: none;
    background: transparent;
    color: var(--danger);
    font-size: 0.75rem;
    cursor: pointer;
}
.comment-item .c-del:active { transform: scale(0.9); }
.comment-empty {
    color: var(--text-sub);
    font-size: 0.9rem;
    text-align: center;
    padding: 20px 0;
}

/* ============================================================
   登录 / 注册
   ============================================================ */
.auth-wrap {
    max-width: 400px;
    margin: 60px auto 0;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px 24px;
}
.auth-wrap h2 {
    font-size: 1.3rem;
    color: var(--text);
    margin-bottom: 6px;
    text-align: center;
}
.auth-wrap .auth-sub {
    text-align: center;
    color: var(--text-sub);
    font-size: 0.85rem;
    margin-bottom: 22px;
}
.auth-wrap .field { margin-bottom: 14px; }
.auth-wrap .field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.auth-wrap .field input {
    width: 100%;
    border: 1.5px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s;
}
.auth-wrap .field input:focus { border-color: var(--primary); }
.auth-wrap .btn { width: 100%; margin-top: 6px; }
.auth-wrap .auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-sub);
}
.auth-wrap .auth-switch a { font-weight: 600; }
.auth-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
    min-height: 1.2em;
}

/* ============================================================
   后台管理（抽屉式，桌面端居中弹层）
   ============================================================ */
.admin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}
.admin-overlay.show { display: flex; }
.admin-panel {
    background: var(--card-bg);
    width: min(520px, 94vw);
    max-height: 88vh;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: popIn 0.2s ease;
}
@keyframes popIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.07);
}
.admin-header h2 { font-size: 1.1rem; color: var(--text); }
.admin-close {
    border: none;
    background: var(--bg);
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-sub);
}
.admin-close:active { transform: scale(0.88); }
.admin-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 20px 0;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    overflow-x: auto;
}
.admin-tab {
    border: none;
    background: transparent;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    border-bottom: 2.5px solid transparent;
    white-space: nowrap;
}
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-body {
    padding: 18px 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.admin-pane { display: none; }
.admin-pane.show { display: block; }

/* 后台表单 */
.af { margin-bottom: 16px; }
.af label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 6px;
}
.af input[type="text"],
.af input[type="password"],
.af input[type="url"],
.af textarea,
.af select {
    width: 100%;
    border: 1.5px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
}
.af input:focus, .af textarea:focus, .af select:focus { border-color: var(--primary); }
.af textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.af .hint { font-size: 0.72rem; color: var(--text-sub); margin-top: 4px; }
.af-color-row { display: flex; align-items: center; gap: 10px; }
.af-color-row input[type="color"] {
    width: 44px; height: 36px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
}
.af-color-row input[type="text"] { flex: 1; }

/* 后台文章管理列表 */
.admin-article-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    margin-bottom: 8px;
}
.admin-article-item .aa-title {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-article-item .aa-badge {
    font-size: 0.68rem;
    color: #fff;
    background: var(--danger);
    padding: 1px 7px;
    border-radius: 999px;
}
.admin-article-item .aa-ops { display: flex; gap: 6px; }
.admin-article-item .aa-ops .btn { padding: 4px 10px; font-size: 0.75rem; }

/* ============================================================
   Toast 提示
   ============================================================ */
.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    z-index: 300;
    opacity: 0;
    transition: all 0.25s ease;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   空状态 / 加载
   ============================================================ */
.empty-state {
    text-align: center;
    color: var(--text-sub);
    padding: 60px 20px;
    font-size: 0.95rem;
}
.empty-state .emoji { font-size: 2.4rem; display: block; margin-bottom: 10px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 640px) {
    .container { padding: 12px 12px 90px; }
    .topbar-inner { padding: 0 12px; }
    .article-detail h1.detail-title { font-size: 1.3rem; }
}

/* 支持文章内容中的 Markdown 粗体/斜体 */
.detail-content strong { font-weight: 700; }
.detail-content em { font-style: italic; }
.detail-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 14px;
    color: var(--text-sub);
    margin: 14px 0;
}
.detail-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.88em;
    color: var(--danger);
}
