/* ============================================================
   WLB 管理后台 · 视觉系统
   与前端博客同源的暖纸美学 + 现代后台的层次与微交互
   ============================================================ */
:root {
  --paper: #f4f1ea;
  --paper-2: #fbfaf6;
  --paper-3: #ffffff;
  --ink: #14110d;
  --ink-soft: #4a453d;
  --ink-faint: #9b9384;
  --line: #e4dfd3;
  --line-soft: #eeeae0;
  --accent: #b3402e;
  --accent-deep: #7d2a1d;
  --accent-wash: #f5e4df;
  --gold: #c99a3f;
  --serif-en: "Playfair Display", Georgia, serif;
  --serif-cn: "Noto Serif SC", serif;
  --sans: "Inter", -apple-system, "PingFang SC", sans-serif;
  --shadow-sm: 0 1px 2px rgba(20,17,13,.04), 0 1px 3px rgba(20,17,13,.06);
  --shadow-md: 0 4px 12px rgba(20,17,13,.05), 0 8px 28px rgba(20,17,13,.06);
  --shadow-lg: 0 12px 40px rgba(20,17,13,.10), 0 24px 60px rgba(20,17,13,.08);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  background: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 100% -10%, rgba(201,154,63,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(179,64,46,.05), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: var(--sans); cursor: pointer; border: none; background: none; }
::selection { background: var(--accent-wash); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: content-box; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--line);
  background: var(--paper-3); color: var(--ink);
  padding: .55rem 1.1rem; border-radius: 100px;
  font-size: .84rem; font-weight: 500; letter-spacing: .01em;
  transition: all .2s var(--ease);
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper-3); box-shadow: var(--shadow-sm); }
.btn-mini { padding: .4rem .85rem; font-size: .78rem; border-radius: 8px; box-shadow: none; background: var(--paper); }
.btn-mini:hover { background: var(--paper-3); border-color: var(--ink-faint); transform: none; box-shadow: var(--shadow-sm); }
.btn-ico { font-size: .95em; opacity: .9; }

/* ============================================================
   登录
   ============================================================ */
.login-view {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.6rem;
  padding: 2rem;
}
.login-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 3.2rem 2.8rem 2.8rem;
  width: 360px; max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: rise .6s var(--ease) both;
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.login-mark { display: flex; justify-content: center; margin-bottom: 1.2rem; }
.login-dot {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c2620, #14110d);
  border: 2px solid var(--gold);
  position: relative;
}
.login-dot::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 8px; height: 8px; border-radius: 50%; background: var(--paper);
}
.login-brand { font-family: var(--serif-en); font-size: 2.8rem; font-weight: 700; letter-spacing: .06em; line-height: 1; }
.login-sub { font-family: var(--serif-cn); color: var(--ink-faint); margin: .5rem 0 2rem; letter-spacing: .28em; font-size: .82rem; }
#login-form { display: flex; flex-direction: column; gap: .7rem; }
#login-form input {
  padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: .98rem; background: var(--paper-3); transition: all .2s var(--ease);
  text-align: center; letter-spacing: .05em;
}
#login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
#login-form button {
  padding: .8rem; background: var(--accent); color: #fff; border-radius: var(--r-sm);
  font-size: .92rem; letter-spacing: .3em; font-weight: 500; transition: all .2s var(--ease);
}
#login-form button:hover { background: var(--accent-deep); }
.login-error { color: var(--accent); font-size: .82rem; margin-top: 1rem; min-height: 1rem; }
.login-foot { font-size: .74rem; letter-spacing: .2em; color: var(--ink-faint); text-transform: uppercase; }

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(251,250,246,.8);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  padding: .9rem 1.8rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.topbar-brand { display: flex; align-items: baseline; gap: .55rem; text-decoration: none; color: inherit; }
.topbar-dot {
  width: 10px; height: 10px; border-radius: 50%; align-self: center;
  background: radial-gradient(circle at 35% 30%, #2c2620, #14110d);
  border: 1.5px solid var(--gold);
}
.topbar-name { font-family: var(--serif-en); font-size: 1.3rem; font-weight: 700; letter-spacing: .03em; }
.topbar-tag { font-size: .72rem; letter-spacing: .22em; color: var(--ink-faint); text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: .7rem; }
.oss-status {
  font-size: .72rem; color: var(--ink-faint);
  padding: .3rem .7rem; border-radius: 100px; background: var(--paper);
  border: 1px solid var(--line-soft);
  display: inline-flex; align-items: center; gap: .4rem;
}
.oss-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

/* ============================================================
   主区 / 面板
   ============================================================ */
.admin-main { max-width: 1120px; margin: 0 auto; padding: 2.4rem 1.8rem 4rem; }
.panel { animation: fade .4s var(--ease) both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }
.panel-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.8rem; padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.panel-head-text h2 { font-family: var(--serif-en); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.panel-sub { color: var(--ink-faint); font-size: .84rem; margin-top: .3rem; }
.panel-head-actions { display: flex; gap: .6rem; align-items: center; }

/* ---------- 文章列表 ---------- */
.post-search {
  padding: .5rem .95rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--paper-3);
  font-size: .84rem;
  font-family: var(--sans);
  color: var(--ink);
  width: 220px;
  transition: all .2s var(--ease);
}
.post-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.post-search::placeholder { color: var(--ink-faint); }
.post-list { display: flex; flex-direction: column; gap: .7rem; }
.post-item {
  display: flex; align-items: center; gap: 1.1rem;
  padding: 1rem 1.2rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: all .2s var(--ease);
  position: relative;
  animation: fade .4s var(--ease) both;
}
.post-item::before {
  content: ""; position: absolute; left: 0; top: 12%; bottom: 12%;
  width: 3px; border-radius: 3px; background: var(--accent);
  opacity: 0; transition: opacity .2s;
}
.post-item:hover { border-color: var(--ink-faint); box-shadow: var(--shadow-md); transform: translateX(2px); }
.post-item:hover::before { opacity: 1; }
.post-item-cat { min-width: 80px; }
.post-item-badge {
  font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; display: block;
}
.post-item-sub { color: var(--ink-faint); font-size: .74rem; margin-top: .1rem; }
.post-item-title { font-family: var(--serif-cn); font-weight: 600; font-size: 1.08rem; flex: 1; letter-spacing: .01em; }
.post-item-meta { font-size: .78rem; color: var(--ink-faint); display: flex; gap: .7rem; align-items: center; }
.post-item-actions { display: flex; gap: .4rem; opacity: .5; transition: opacity .2s; }
.post-item:hover .post-item-actions { opacity: 1; }
.badge-music { color: var(--accent); font-size: 1rem; }
.badge-draft { background: var(--gold); color: #fff; padding: .12rem .5rem; border-radius: 100px; font-size: .66rem; letter-spacing: .05em; }

/* ============================================================
   编辑器
   ============================================================ */
.editor-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.8rem; align-items: start; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.2rem; }
.field.no-mb { margin-bottom: 0; }
.field > span { font-size: .76rem; letter-spacing: .06em; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; }
.span-with-ico { display: flex; align-items: center; gap: .4rem; }
.note-ico { color: var(--accent); font-style: normal; }
.field input, .field select, .field textarea {
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: .92rem; font-family: var(--sans); background: var(--paper-3);
  transition: all .2s var(--ease); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.input-title { font-family: var(--serif-cn) !important; font-size: 1.15rem !important; font-weight: 600; }
.mt-half { margin-top: .5rem; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239b9384' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9rem center;
  padding-right: 2.2rem;
}

/* ---------- 正文 + 实时预览 ---------- */
.body-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.body-toolbar > span { font-size: .76rem; letter-spacing: .06em; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; }
.body-tabs { display: flex; gap: .15rem; background: var(--paper); border: 1px solid var(--line); border-radius: 100px; padding: .2rem; }
.body-tab { padding: .35rem .95rem; font-size: .78rem; border-radius: 100px; color: var(--ink-faint); transition: all .2s var(--ease); font-weight: 500; }
.body-tab:hover { color: var(--ink-soft); }
.body-tab.is-active { background: var(--paper-3); color: var(--accent); box-shadow: var(--shadow-sm); }
.body-panes { display: grid; gap: 1rem; }
.body-panes[data-mode="write"] { grid-template-columns: 1fr; }
.body-panes[data-mode="write"] .body-preview { display: none; }
.body-panes[data-mode="split"] { grid-template-columns: 1fr 1fr; }
.body-panes[data-mode="preview"] { grid-template-columns: 1fr; }
.body-panes[data-mode="preview"] #f-body { display: none; }
@media (max-width: 680px) { .body-panes[data-mode="split"] { grid-template-columns: 1fr; } }
.body-panes textarea {
  width: 100%; min-height: 480px;
  padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", monospace;
  font-size: .9rem; line-height: 1.8; resize: vertical; background: var(--paper-3);
  transition: all .2s var(--ease); color: var(--ink);
}
.body-panes textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.body-preview {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.6rem 1.8rem; background: var(--paper-2);
  overflow-y: auto; max-height: 640px; font-family: var(--serif-cn);
  line-height: 1.85; color: var(--ink);
}
.body-preview:empty::before { content: "预览区 · 开始写作后实时渲染"; color: var(--ink-faint); font-size: .85rem; font-family: var(--sans); }

/* 预览内部排版，贴近前端文章样式 */
.body-preview h1, .body-preview h2 { font-family: var(--serif-en); font-weight: 700; margin: 1.4rem 0 .7rem; line-height: 1.2; }
.body-preview h1 { font-size: 1.7rem; }
.body-preview h2 { font-size: 1.45rem; }
.body-preview h3 { font-family: var(--serif-cn); font-weight: 700; font-size: 1.15rem; margin: 1.1rem 0 .5rem; }
.body-preview p { margin: .85rem 0; }
.body-preview a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
.body-preview blockquote { border-left: 3px solid var(--accent); padding: .3rem 0 .3rem 1.1rem; margin: 1.1rem 0; color: var(--ink-soft); font-style: italic; }
.body-preview img { max-width: 100%; border: 1px solid var(--line); margin: 1.1rem 0; border-radius: var(--r-sm); }
.body-preview code { background: var(--line-soft); padding: .12em .4em; border-radius: 4px; font-size: .86em; font-family: ui-monospace, monospace; }
.body-preview pre { background: #1c1915; color: #f2ede2; padding: 1.1rem; overflow-x: auto; border-radius: var(--r-sm); margin: 1.1rem 0; }
.body-preview pre code { background: none; padding: 0; }
.body-preview ul, .body-preview ol { padding-left: 1.5rem; margin: .85rem 0; }
.body-preview li { margin: .3rem 0; }
.body-preview hr { border: none; border-top: 1px solid var(--line); margin: 1.6rem 0; }
.body-preview .gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1.3rem 0; }
.body-preview .gallery-item { margin: 0; }
.body-preview .gallery-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; margin: 0; border-radius: 6px; }
.body-preview .gallery-item figcaption, .body-preview .video-embed figcaption { font-size: .74rem; color: var(--ink-faint); text-align: center; margin-top: .35rem; font-family: var(--sans); }
.body-preview .video-embed { margin: 1.3rem 0; }
.body-preview .video-embed video { width: 100%; border-radius: var(--r-sm); background: #000; }
.body-preview .video-ratio { position: relative; padding-top: 56.25%; background: #000; border-radius: var(--r-sm); overflow: hidden; }
.body-preview .video-ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- 侧栏卡片 ---------- */
.editor-side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 5.5rem; }
.side-card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 1.3rem;
  box-shadow: var(--shadow-sm);
}
.upload-row, .insert-row { display: flex; gap: .5rem; }
.upload-row input { flex: 1; }
.insert-row { flex-wrap: wrap; }
.insert-row .btn-mini { flex: 1; justify-content: center; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ink-soft); cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.draft-check { padding: .9rem 1.3rem; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.hint { font-size: .72rem; color: var(--ink-faint); margin-top: .5rem; }

/* ============================================================
   设置页
   ============================================================ */
.settings-wrap { max-width: 560px; }
.settings-card { padding: 1.6rem 1.8rem; }
.settings-actions { display: flex; align-items: center; gap: .8rem; margin-top: 1.2rem; }
.settings-test-result { font-size: .85rem; margin-left: .3rem; }
.settings-test-result.ok { color: #3f7d4e; }
.settings-test-result.err { color: var(--accent); }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; bottom: 1.8rem; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--paper-2);
  padding: .85rem 1.5rem; border-radius: 100px;
  font-size: .88rem; box-shadow: var(--shadow-lg); z-index: 50;
  display: flex; align-items: center; gap: .5rem;
  animation: toast-in .3s var(--ease);
}
.toast::before { content: "✓"; color: var(--gold); font-weight: 700; }
.toast.err { background: var(--accent-deep); }
.toast.err::before { content: "!"; color: #ffd9d1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }
