/* me.css — the whole site's styling.
   Replaces bootstrap.min.css + bootstrap-grid + bootstrap-reboot + clean-blog.css.

   Design notes: this is a personal blog ("明镜台的尘埃" / dust on a bright mirror),
   so the palette stays quiet and the layout stays generous with whitespace.
   Reading width is capped around 760px because that is comfortable for CJK text.

   Sections:
     1. variables & reset
     2. layout
     3. nav & footer
     4. typography
     5. buttons & forms
     6. cards / post list
     7. table (back office)
     8. pagination
     9. toast & modal
    10. markdown body
    11. editor
    12. responsive
*/

/* ---------- 1. variables & reset ---------- */
:root {
    --bg: #ffffff;
    --bg-soft: #f7f8fa;
    --text: #2c3035;
    --text-soft: #6b7280;
    --text-faint: #9aa1ab;
    --border: #e5e7eb;
    --border-soft: #f0f1f3;
    --accent: #4a6fa5;
    --accent-hover: #3d5d8a;
    --accent-soft: #eef2f7;
    --danger: #c0392b;
    --ok: #2e7d52;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .12);
    --mono: Consolas, Monaco, "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    /* 整页浅灰，正文区是白色（.panel）。这层对比让全宽头图下面
       不至于是一大片没有边界的白。 */
    background: #f4f5f7;
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 2. layout ---------- */
.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 20px;
}
.container-wide {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 20px;
}
.stack > * + * { margin-top: 16px; }
.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.muted { color: var(--text-soft); }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- 3. nav & footer ---------- */
.nav {
    border-bottom: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.nav-inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.nav-brand {
    font-weight: 600;
    font-size: 17px;
    color: var(--text);
    letter-spacing: .02em;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.nav-links {
    display: flex;
    gap: 18px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}
.nav-links a { color: var(--text-soft); font-size: 15px; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.nav-search {
    display: flex;
    gap: 6px;
    margin-left: auto;
}
.nav-search input { width: 160px; }

/* 全站统一：一张全宽头图。每个页面都用它，不再混用卡片式头图。 */
.masthead {
    position: relative;
    padding: 96px 0 80px;
    text-align: center;
    color: #fff;
    background: #3a4a5a center/cover no-repeat;
    margin-bottom: 40px;
    overflow: hidden;
}
.masthead::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(20, 24, 30, .30) 0%,
        rgba(20, 24, 30, .58) 100%);
}
.masthead-inner { position: relative; max-width: 720px; margin: 0 auto; padding: 0 20px; }
.masthead h1 {
    font-size: 38px;
    margin: 0 0 10px;
    letter-spacing: .03em;
    font-weight: 500;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .28);
}
.masthead .sub {
    font-size: 16px;
    opacity: .93;
    margin: 0;
    font-weight: 300;
    letter-spacing: .04em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .22);
}
.masthead .eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: .15em;
    font-size: 12px;
    margin-bottom: 16px;
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 999px;
    color: #fff;
}

/* 页面底色是浅灰，footer 比它再深一点，作为整页的收口。 */
.site-footer {
    margin-top: 48px;
    padding: 30px 0 34px;
    background: #eceef1;
    color: var(--text-faint);
    font-size: 14px;
    text-align: center;
}
.site-footer a { color: var(--text-soft); }
.site-footer p { margin: 6px 0; }

/* ---------- 4. typography ---------- */
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
.page-title { font-size: 28px; margin-bottom: 4px; }
.page-sub { color: var(--text-soft); margin-top: 0; font-size: 15px; }

/* ---------- 5. buttons & forms ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: 15px;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f0d5d1; }
.btn-danger:hover { background: #fdf3f2; }
.btn-sm { padding: 5px 11px; font-size: 14px; }
.btn-link {
    border: 0; background: none; color: var(--accent); padding: 4px 6px;
}
.btn-link:hover { background: var(--accent-soft); }

.input,
.textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field > label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-soft);
    font-weight: 500;
}
.textarea { resize: vertical; min-height: 90px; }

/* ---------- 6. cards / post list ---------- */

/* 内容区与页面背景区分开：整页是很浅的灰，正文落在白色卡片上。
   没有这层对比，全宽头图下面会显得一大片空白。

   关键：卡片**只控制阅读宽度**（内部 padding），不控制自己的宽度。
   卡片本身要尽量贴近头图边沿，否则头图和卡片像两张互不相干的纸。 */
.panel {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 36px 56px;
    box-shadow: var(--shadow);
    max-width: 1080px;
    margin: 0 auto;
}
.panel-inner {
    max-width: 720px;
    margin: 0 auto;
}

.post-list { list-style: none; margin: 0; padding: 0; }
.post-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-soft);
    transition: padding-left .18s ease;
}
.post-item:first-child { padding-top: 4px; }
.post-item:last-child { border-bottom: 0; }
.post-item:hover { padding-left: 6px; }
.post-item h2 { margin-bottom: 6px; font-size: 23px; }
.post-item h2 a { color: var(--text); transition: color .15s; }
.post-item h2 a:hover { color: var(--accent); text-decoration: none; }
.post-sub {
    color: var(--text-soft);
    font-size: 16px;
    font-weight: 400;
    margin: 0 0 8px;
}
.post-meta {
    color: var(--text-faint);
    font-size: 14px;
    margin: 0;
}
.post-excerpt {
    color: var(--text-soft);
    margin: 8px 0 0;
    font-size: 15px;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}
.empty {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-faint);
}
.empty p { margin: 0 0 8px; }
.empty .lead {
    color: var(--text-soft);
    font-size: 17px;
    margin-bottom: 6px;
}
.empty-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 22px;
    flex-wrap: wrap;
}

/* ---------- 7. table (back office) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th,
.table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
}
.table th {
    color: var(--text-soft);
    font-weight: 500;
    font-size: 14px;
    background: var(--bg-soft);
}
.table tr:last-child td { border-bottom: 0; }
.table .num { color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { white-space: nowrap; text-align: right; }

/* ---------- 8. pagination ---------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 34px 0 10px;
}
.pager-info { color: var(--text-soft); font-size: 14px; min-width: 90px; text-align: center; }

/* ---------- 9. toast & modal ---------- */
#toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}
.toast-item {
    background: #2c3035;
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 15px;
    animation: toast-in .18s ease-out;
}
.toast-item.ok { background: var(--ok); }
.toast-item.err { background: var(--danger); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 30, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    padding: 20px;
}
.modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    width: 100%;
    padding: 22px;
}
.modal h3 { margin-bottom: 8px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ---------- 10. markdown body ---------- */
.md-body { font-size: 16.5px; line-height: 1.85; }
.md-body h1 { font-size: 26px; margin-top: 34px; }
.md-body h2 { font-size: 22px; margin-top: 30px; }
.md-body h3 { font-size: 18px; margin-top: 24px; }
.md-body p { margin: 0 0 16px; }
.md-body ul,
.md-body ol { margin: 0 0 16px; padding-left: 26px; }
.md-body li { margin-bottom: 6px; }
.md-body blockquote {
    margin: 0 0 16px;
    padding: 4px 16px;
    border-left: 3px solid var(--accent-soft);
    color: var(--text-soft);
}
.md-body code {
    background: var(--bg-soft);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: .9em;
}
.md-body pre {
    background: #f6f7f9;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 14px 16px;
    overflow-x: auto;
    margin: 0 0 16px;
}
.md-body pre code {
    background: none;
    padding: 0;
    font-size: 14px;
    line-height: 1.6;
}
.md-body img { border-radius: var(--radius); margin: 8px 0; display: block; }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.md-body table { border-collapse: collapse; margin-bottom: 16px; }
.md-body th,
.md-body td { border: 1px solid var(--border); padding: 8px 12px; }
.md-body th { background: var(--bg-soft); }

/* ---------- 11. editor ---------- */
.editor { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* 顶栏一行两件事：左边「编辑/源码」模式切换，右边格式工具。
   模式切换只影响正文编辑区，所以必须贴着它，不能放到页面顶上。 */
.editor-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 8px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.editor-modebar { display: flex; gap: 2px; }
.editor-modebar button {
    border: 0;
    background: transparent;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-soft);
    line-height: 1.4;
    cursor: pointer;
}
.editor-modebar button.on {
    background: #fff;
    color: var(--accent);
    box-shadow: var(--shadow);
}
.editor-toolbar {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}
.editor-toolbar button {
    border: 0;
    background: transparent;
    border-radius: 4px;
    padding: 5px 9px;
    font-size: 14px;
    color: var(--text-soft);
    line-height: 1.4;
}
.editor-toolbar button:hover { background: #e6e9ee; color: var(--text); }
.editor-toolbar .sep {
    width: 1px;
    background: var(--border);
    margin: 4px 4px;
}
/* 富文本编辑区：所见即所得，样式与前台正文一致（都挂 .md-body） */
.editor-rich {
    display: block;
    width: 100%;
    min-height: 380px;
    max-height: 70vh;
    border: 0;
    padding: 14px 16px;
    outline: none;
    position: relative;
    overflow-y: auto;
    cursor: text;
}
.editor-rich:focus { outline: none; }
/* 空内容时显示提示。contenteditable 空时常留一个 <p><br></p>，
   所以靠 JS 打 .is-empty，不用 :empty 伪类。 */
.editor-rich.is-empty::before {
    content: attr(data-placeholder);
    color: var(--text-faint);
    position: absolute;
    pointer-events: none;
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16.5px;
}

/* 源码模式：等宽字体看 Markdown */
.editor-source {
    display: block;
    width: 100%;
    min-height: 380px;
    border: 0;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 14.5px;
    line-height: 1.7;
    resize: vertical;
}
.editor-source:focus { outline: none; }

/* 富文本/源码二选一，另一个隐藏 */
.editor-rich.hidden,
.editor-source.hidden { display: none; }

.editor-hint {
    padding: 6px 12px;
    background: var(--bg-soft);
    border-top: 1px solid var(--border-soft);
    color: var(--text-faint);
    font-size: 13px;
}

/* 封面图预览：必须是块级 div（用 background-image 显示）。
   之前误用 <img> —— 它没有 src 时就是一块空白，还可能带破图图标。 */
.cover-preview {
    display: block;
    width: 100%;
    max-width: 420px;
    height: 150px;
    margin-top: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--bg-soft);
    background-size: cover;
    background-position: center;
}
.cover-preview.hidden { display: none; }

/* ---------- 12. responsive ---------- */
@media (max-width: 640px) {
    body { font-size: 15.5px; }
    .masthead { padding: 64px 0 52px; margin-bottom: 28px; }
    .masthead h1 { font-size: 27px; }
    .masthead .sub { font-size: 15px; }
    .panel { padding: 20px 18px; border-radius: 8px; }
    .nav-inner { gap: 12px; padding: 12px 16px; }
    .nav-search { margin-left: 0; width: 100%; }
    .nav-search input { flex: 1; width: auto; }
    .container, .container-wide { padding: 0 16px; }
    h1 { font-size: 25px; }
    .post-item h2 { font-size: 20px; }
    .table { font-size: 14px; }
    .table th, .table td { padding: 9px 8px; }
    .md-body { font-size: 16px; }
}
