/* 博客样式：配色与音乐屋保持一致，主题由 localStorage 的 music.theme 决定 */
* { box-sizing: border-box; }

/* 粉色（默认） */
:root, html[data-theme="pink"] {
  color-scheme: light;
  --bg: #fff5f7;
  --bg-overlay: rgba(255, 245, 247, .68);
  --panel: #ffffff;
  --text: #3f2a31;
  --muted: #a07884;
  --soft: #6b4250;
  --border: #f2d7e0;
  --hover: #ffeef3;
  --accent: #ffc0cb;
  --accent-ink: #5a2434;
  --link: #c04a68;
  --chip: #ffe9ef;
  --code-bg: #fff0f4;
  --topbar: rgba(255, 245, 247, .9);
  --shadow: rgba(90, 36, 52, .14);
  --err-bg: #fdecef;
  --err-text: #b22b45;
  --err-border: #f3c3cd;
  --ok-bg: #eaf8ef;
  --ok-text: #1f7a4a;
  --ok-border: #c4e8d3;
}

/* 浅色 */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --bg-overlay: rgba(245, 246, 248, .68);
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --soft: #3a3f47;
  --border: #e2e5ea;
  --hover: #eef1f5;
  --accent: #4c8dff;
  --accent-ink: #ffffff;
  --link: #2f6fd0;
  --chip: #eef2f8;
  --code-bg: #f2f4f7;
  --topbar: rgba(245, 246, 248, .9);
  --shadow: rgba(15, 23, 42, .12);
  --err-bg: #fdecec;
  --err-text: #c02b2b;
  --err-border: #f5c2c2;
  --ok-bg: #e9f8ef;
  --ok-text: #1a7f4b;
  --ok-border: #bfe8d2;
}

/* 深色 */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --bg-overlay: rgba(20, 22, 27, .82);
  --panel: #1b1f27;
  --text: #e8eaed;
  --muted: #8b93a3;
  --soft: #cfd4dd;
  --border: #262a33;
  --hover: #242a35;
  --accent: #4c8dff;
  --accent-ink: #ffffff;
  --link: #7aa7ff;
  --chip: #222834;
  --code-bg: #141821;
  --topbar: rgba(20, 22, 27, .9);
  --shadow: rgba(0, 0, 0, .45);
  --err-bg: #33191c;
  --err-text: #ff9a9a;
  --err-border: #5a2a2e;
  --ok-bg: #14301f;
  --ok-text: #7ee2a8;
  --ok-border: #1f5236;
}

html { background: var(--bg); }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  /* 背景交给固定的 .bg-layer，内容层滚动时背景保持不动 */
  background: transparent;
  transition: color .2s;
}

/* 固定背景层：与音乐屋相同的遮罩比例，兼顾可见度与可读性 */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-overlay), var(--bg-overlay)), var(--bg-art, none);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  pointer-events: none;
  transition: background-color .2s;
}

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

/* 右上角浮动按钮：与音乐屋同款胶囊 */
.top-actions {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 40;
  display: flex;
  gap: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--shadow);
  transition: background .15s, border-color .15s, color .15s;
}
.pill:hover { background: var(--hover); text-decoration: none; }
.pill:disabled { cursor: default; opacity: .75; }
/* 图标与音乐屋一致：14px 线性 SVG，随主题切换花/太阳/月亮 */
.pill svg { width: 14px; height: 14px; flex: 0 0 auto; }
.theme-icon { display: inline-flex; align-items: center; }
.theme-icon svg { display: none; }
html:not([data-theme]) .theme-icon .i-flower,
html[data-theme="pink"] .theme-icon .i-flower,
html[data-theme="light"] .theme-icon .i-sun,
html[data-theme="dark"] .theme-icon .i-moon { display: block; }
/* 换背景请求期间让图标转圈，和音乐屋的按钮反馈一致 */
.pill.loading .bg-icon { animation: pill-spin .9s linear infinite; }
@keyframes pill-spin { to { transform: rotate(360deg); } }
.inline-form { display: inline; }

/* 布局 */
.wrap { max-width: 720px; margin: 0 auto; padding: 32px 16px 72px; }
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.count { margin: -10px 0 18px; font-size: 13px; color: var(--muted); }
.site-foot {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 44px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* 提示条 */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert.error { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }

/* 筛选 */
.filters {
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 3px 0; }
.filter-label { margin-right: 2px; font-size: 12px; color: var(--muted); }
.chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--soft);
  font-size: 12px;
  line-height: 1.5;
}
.chip:hover { background: var(--hover); text-decoration: none; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip em { font-style: normal; font-size: 11px; opacity: .65; }

/* 列表：整体一张白色圆角卡片，与音乐屋的歌曲列表一致 */
.post-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}
.post-card {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.post-card:last-child { border-bottom: none; }
.post-card:hover { background: var(--hover); }
/* 文字区占满剩余宽度，保证没有封面图的文章排版不变 */
.post-body { flex: 1 1 auto; min-width: 0; }
/* 右侧封面缩略图：固定 160×110，object-fit 裁切保证不变形 */
.post-cover {
  flex: 0 0 auto;
  display: block;
  width: 160px;
  height: 110px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--hover);
  border: 1px solid var(--border);
}
.post-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}
.post-cover:hover img { transform: scale(1.04); }
.post-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); }
.badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
}
.post-title { margin: 6px 0 8px; font-size: 19px; line-height: 1.45; font-weight: 600; }
.post-title a { color: var(--text); }
.post-excerpt { margin: 0 0 10px; font-size: 14px; color: var(--soft); }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12px; color: var(--link); }
.empty {
  padding: 52px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

/* 通用白色面板 */
.panel {
  padding: 26px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
  font-size: 13px;
  color: var(--muted);
}
.pager .disabled { opacity: .45; }

/* 文章详情 */
.article-head { margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.article-head h1 { margin: 0 0 10px; font-size: 24px; line-height: 1.4; font-weight: 600; }
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.tags-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
.back-link { margin-top: 36px; font-size: 13px; }

/* 正文排版 */
.prose { font-size: 16px; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  margin: 1.6em 0 .6em;
  line-height: 1.4;
  font-weight: 600;
}
.prose h1 { font-size: 1.6em; }
.prose h2 { font-size: 1.35em; }
.prose h3 { font-size: 1.15em; }
.prose h4, .prose h5, .prose h6 { font-size: 1em; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.6em; }
.prose li { margin: .3em 0; }
.prose blockquote {
  margin: 1em 0;
  padding: .2em 1em;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--chip);
  color: var(--soft);
}
.prose blockquote p { margin: .6em 0; }
.prose code {
  padding: .15em .4em;
  border-radius: 5px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", monospace;
  font-size: .9em;
}
.prose pre {
  margin: 0 0 1.2em;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  overflow-x: auto;
}
.prose pre code { padding: 0; background: none; font-size: 13px; line-height: 1.6; }
.prose img { display: block; max-width: 100%; height: auto; margin: 1.2em auto; border-radius: 10px; }
/* 视频嵌入：B 站 iframe 固定 16:9，外链 mp4 按原始比例 */
.prose .video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1.4em 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.prose .video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.prose .video-embed.video-file { aspect-ratio: auto; background: none; }
.prose .video-embed video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  border-radius: 10px;
  background: #000;
}
.prose hr { margin: 2em 0; border: none; border-top: 1px solid var(--border); }
.prose a { border-bottom: 1px solid transparent; }
.prose a:hover { border-bottom-color: currentColor; text-decoration: none; }

/* 登录 */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 55vh; padding: 40px 18px; }
.auth-card {
  width: 100%;
  max-width: 360px;
  padding: 26px 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 40px var(--shadow);
}
.auth-card h1 { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.auth-card .sub { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.auth-card .foot { margin: 16px 0 0; font-size: 12px; text-align: center; color: var(--muted); }

/* 编辑器 */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }
.field input[type="text"],
.field input[type="password"],
.field input[type="datetime-local"],
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--chip); }
.field-row { display: flex; flex-wrap: wrap; gap: 18px; }
.field-row .field { flex: 1 1 220px; }
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-top: 26px;
  font-size: 13.5px;
  color: var(--soft);
  cursor: pointer;
}
textarea {
  min-height: 320px;
  line-height: 1.7;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", monospace;
  font-size: 13.5px;
}
.editor-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.editor-status { font-size: 12px; color: var(--muted); }
.editor-status.error { color: var(--err-text); }
.editor-actions { display: flex; gap: 10px; margin-top: 18px; }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--soft);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, filter .15s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.primary:hover { filter: brightness(.97); }
.btn.danger { color: var(--err-text); border-color: var(--err-border); background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.delete-form { margin-top: 20px; }
.preview { min-height: 320px; padding: 16px; border: 1px dashed var(--border); border-radius: 10px; }

/* 宽屏时给右上角按钮留出空间，避免标题被压住 */
@media (min-width: 641px) {
  .page-head h1, .article-head h1 { padding-right: 300px; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  /* 按钮可能换行成两排，内容整体下移让开 */
  .wrap { padding: 64px 14px 56px; }
  .top-actions {
    max-width: calc(100vw - 28px);
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
  }
  .article-head h1 { font-size: 22px; }
  .post-title { font-size: 17px; }
  /* 手机上缩略图缩小，避免把标题挤成一行两三个字 */
  .post-card { gap: 12px; padding: 14px 14px; }
  .post-cover { width: 96px; height: 72px; }
  .field-row { gap: 0; }
  .field-row .field { flex-basis: 100%; }
  .checkbox { padding-top: 0; }
  .prose { font-size: 15.5px; }
  .panel { padding: 20px 16px; }
}
