/* ========== 基础 ========== */
:root {
  --bg: #f7f7f9;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e7e8ee;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --primary-dark: #4338ca;
  --accent: #f59e0b;
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 10px 28px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .16);
  --maxw: 1000px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); }

/* ========== 导航 ========== */
.nav {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  height: 60px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  font-size: 19px; font-weight: 800; letter-spacing: .5px;
  color: var(--text); text-decoration: none;
}
.brand b { color: var(--primary); font-weight: 800; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 7px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none;
  font-size: 14px; transition: all .2s;
}
.nav-links a:hover { color: var(--text); background: var(--bg); }
.nav-links a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }

/* ========== 布局 ========== */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px 80px; }
.narrow { max-width: 780px; }

/* ========== Hero ========== */
.hero { padding: 76px 20px 46px; text-align: center; }
.hero .badge {
  display: inline-block; padding: 5px 14px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 13px; font-weight: 600; margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 800; letter-spacing: 1px; line-height: 1.25;
}
.hero .sub { margin-top: 14px; color: var(--muted); font-size: 17px; }
.hero .desc { margin-top: 8px; color: var(--muted); font-size: 14px; }

/* ========== 文章卡片 ========== */
.post-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 22px; margin-top: 8px;
}
@media (max-width: 720px) { .post-grid { grid-template-columns: 1fr; } }

.post-card {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column;
  transition: transform .22s, box-shadow .22s;
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.post-cover {
  height: 130px; position: relative; display: flex; align-items: flex-end;
  padding: 14px 18px;
}
.post-cover .cat {
  font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(0, 0, 0, .28); backdrop-filter: blur(4px);
  padding: 3px 10px; border-radius: 999px;
}
.post-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-body h2 { font-size: 18px; font-weight: 700; line-height: 1.45; }
.post-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.post-meta .tag { color: var(--primary); }
.post-summary { font-size: 13.5px; color: var(--muted); flex: 1; }
.post-new-tip {
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--accent); padding: 2px 8px; border-radius: 999px; margin-left: 8px;
  vertical-align: 2px;
}

/* ========== 文章阅读页 ========== */
.article { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(24px, 4vw, 44px); margin-top: 26px; }
.article-head { text-align: center; margin-bottom: 28px; }
.article-head .cat {
  display: inline-block; font-size: 12.5px; font-weight: 600;
  color: var(--primary); background: var(--primary-soft);
  padding: 4px 14px; border-radius: 999px; margin-bottom: 14px;
}
.article-head h1 { font-size: clamp(24px, 4vw, 32px); font-weight: 800; line-height: 1.35; }
.article-head .meta { margin-top: 14px; font-size: 13px; color: var(--muted); display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* Markdown 正文 */
.markdown { font-size: 16px; }
.markdown h2, .markdown h3, .markdown h4 {
  margin: 30px 0 12px; line-height: 1.4; font-weight: 700;
}
.markdown h2 { font-size: 22px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.markdown h3 { font-size: 18px; }
.markdown p { margin: 14px 0; }
.markdown ul, .markdown ol { margin: 14px 0; padding-left: 26px; }
.markdown li { margin: 6px 0; }
.markdown blockquote {
  margin: 18px 0; padding: 12px 18px;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #37415a;
}
.markdown blockquote p { margin: 4px 0; }
.markdown code {
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  background: #f1f2f6; color: #b45309;
  padding: 2px 6px; border-radius: 6px; font-size: 13.5px;
}
.markdown pre {
  background: #14171f; color: #e5e7eb;
  padding: 18px 20px; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 18px 0;
}
.markdown pre code { background: transparent; color: inherit; padding: 0; font-size: 13.5px; line-height: 1.7; }
.markdown img { border-radius: var(--radius-sm); margin: 18px auto; }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 30px 0; }
.markdown a { text-decoration: underline; text-underline-offset: 3px; }

.article-nav {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.article-nav a { text-decoration: none; color: var(--muted); max-width: 45%; }
.article-nav a:hover { color: var(--primary); }
.article-nav .dir { font-size: 11.5px; opacity: .7; display: block; }
.article-del { text-align: center; margin-top: 22px; }

/* ========== 按钮 ========== */
.btn {
  display: inline-block; border: none; cursor: pointer;
  padding: 10px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: all .2s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text); border-color: #c9ccd6; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(220, 38, 38, .35); }
.btn-danger:hover { background: rgba(220, 38, 38, .08); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ========== 表单（写文章） ========== */
.editor-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(22px, 4vw, 36px); margin-top: 26px;
}
.editor-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.editor-card .hint { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
.field input[type="text"], .field select, .field textarea {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: inherit; background: #fbfbfd;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); background: #fff;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* 色板选择 */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  border: 3px solid transparent; transition: transform .15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 0 0 5px rgba(31,36,48,.35); }

.editor-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.preview-box {
  margin-top: 22px; border: 1px dashed #d4d6df; border-radius: var(--radius-sm);
  padding: 20px 24px; background: #fbfbfd;
}
.preview-box[hidden] { display: none; }
.preview-box h3 { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* 已保存文章列表 */
.saved-list { margin-top: 30px; }
.saved-list h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.saved-item {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 10px;
}
.saved-item .t { font-weight: 600; font-size: 14.5px; }
.saved-item .d { font-size: 12.5px; color: var(--muted); }
.saved-item .ops { display: flex; gap: 8px; }
.empty-tip { font-size: 13.5px; color: var(--muted); }

/* ========== 相册 ========== */
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 18px; margin-top: 8px;
}
@media (max-width: 900px) { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .photo-grid { grid-template-columns: 1fr; } }
.photo-card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  cursor: zoom-in; box-shadow: var(--shadow);
  aspect-ratio: 4 / 3; background: #eef0f5;
  transition: transform .22s, box-shadow .22s;
}
.photo-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.photo-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.photo-card:hover img { transform: scale(1.05); }
.photo-card figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 14px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.62));
  color: #fff; font-size: 13.5px; font-weight: 600;
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 12, 18, .92);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; padding: 30px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 78vh; border-radius: 12px; box-shadow: var(--shadow-lg); }
.lightbox .cap { color: #fff; margin-top: 14px; font-size: 15px; }
.lightbox .cap small { display: block; color: rgba(255,255,255,.6); font-size: 12.5px; margin-top: 4px; }
.lb-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 48px; height: 48px; border-radius: 50%; cursor: pointer;
  font-size: 20px; transition: background .2s;
}
.lb-btn:hover { background: rgba(255,255,255,.24); }
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
.lb-close {
  position: absolute; top: 20px; right: 24px;
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 18px;
}
.lb-close:hover { background: rgba(255,255,255,.24); }

/* ========== 音乐 ========== */
.music-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 8px; }
@media (max-width: 860px) { .music-layout { grid-template-columns: 1fr; } }

.player-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px; text-align: center;
  align-self: start; position: sticky; top: 80px;
}
@media (max-width: 860px) { .player-card { position: static; } }
.player-cover {
  width: 210px; height: 210px; margin: 0 auto 22px;
  border-radius: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 84px; font-weight: 800; color: rgba(255,255,255,.92);
  box-shadow: var(--shadow-lg);
}
.player-title { font-size: 18px; font-weight: 700; }
.player-artist { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.player-progress { margin: 24px 0 10px; }
.player-progress input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.player-time { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.player-btns { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 16px; }
.pbtn {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary-soft); color: var(--primary);
  font-size: 17px; transition: all .2s;
}
.pbtn:hover { background: var(--primary); color: #fff; }
.pbtn-play { width: 62px; height: 62px; font-size: 22px; background: var(--primary); color: #fff; }
.pbtn-play:hover { background: var(--primary-dark); transform: scale(1.05); }

.playlist { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.playlist h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.track {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.track:hover { background: var(--bg); }
.track.active { background: var(--primary-soft); }
.track .idx { width: 30px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.track.active .idx { color: var(--primary); font-weight: 700; }
.track .nm { flex: 1; min-width: 0; }
.track .nm .t1 { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .nm .t2 { font-size: 12.5px; color: var(--muted); }
.track .playing { color: var(--primary); font-size: 12px; font-weight: 600; flex-shrink: 0; }

/* ========== 页脚 ========== */
.footer {
  border-top: 1px solid var(--line);
  padding: 26px 20px; text-align: center;
  color: var(--muted); font-size: 13px;
}

/* ========== 提示 ========== */
.tip {
  background: var(--primary-soft); color: #37415a;
  border-radius: var(--radius-sm); padding: 14px 18px;
  font-size: 13.5px; margin-top: 18px;
}
.tip b { color: var(--primary); }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14.5px; }

/* ========== 云端同步 ========== */
.sync-ok { font-size: 13px; color: #059669; margin-bottom: 10px; }
.sync-off { font-size: 13px; color: #b45309; margin-bottom: 10px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-left: 8px;
  vertical-align: 2px;
}
.badge-cloud { background: #eef2ff; color: #4f46e5; }
.badge-local { background: #fef3c7; color: #b45309; }

/* ========== 响应式微调 ========== */
@media (max-width: 560px) {
  .nav-inner { height: 56px; padding: 0 14px; }
  .brand { font-size: 17px; }
  .nav-links a { padding: 6px 10px; font-size: 13px; }
  .hero { padding: 56px 14px 36px; }
  .post-cover { height: 110px; }
}

/* ========== 插入图片弹窗 ========== */
.field-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 7px;
}
.field-head label { margin-bottom: 0; }

.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask[hidden] { display: none; }

.modal {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  padding: 24px 26px; max-height: 86vh; overflow: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: var(--bg); }

.img-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.img-tab {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .2s;
}
.img-tab:hover { color: var(--text); }
.img-tab.sel { background: var(--primary); border-color: var(--primary); color: #fff; }

.img-tip { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.img-tip code {
  background: #f1f2f6; padding: 1px 5px; border-radius: 5px;
  font-size: 12px; color: #b45309;
}

.img-album {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-height: 260px; overflow: auto; padding: 4px;
}
@media (max-width: 520px) { .img-album { grid-template-columns: repeat(2, 1fr); } }
.img-album-item {
  border: 2px solid transparent; border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer; text-align: center;
  background: var(--bg); transition: border-color .15s;
}
.img-album-item img { width: 100%; height: 80px; object-fit: cover; }
.img-album-item span { display: block; font-size: 12px; color: var(--muted); padding: 5px 4px 7px; }
.img-album-item:hover { border-color: #c9ccd6; }
.img-album-item.sel { border-color: var(--primary); }
.img-album-item.sel span { color: var(--primary); font-weight: 600; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
