/* ==========================================================
   fantashao.com.cn —— CloudBase 前后台最小验证
   ========================================================== */

:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --ink: #1b1a18;
  --ink-2: #4c4943;
  --muted: #8b8681;
  --line: #e5e2dc;
  --line-strong: #d3cfc7;
  --accent: #1f5f4b;
  --accent-soft: #eaf3ef;
  --danger: #b3382c;
  --danger-soft: #fbecea;
  --warn: #9a6b1a;
  --warn-soft: #fdf4e3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 26, 22, 0.04), 0 8px 24px -12px rgba(28, 26, 22, 0.14);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* 必须放在最前面并加 !important：
   .login-shell 用了 display:flex，会盖掉浏览器默认的 [hidden]{display:none}，
   导致 hidden 属性的元素仍然显示出来。 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------- 布局骨架 ---------------- */

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 站点标题区。原先是正文顶部的 hero 块，现在整块挪到顶栏左侧，
   取代了原来那个域名样式的品牌链接。 */
.brand { display: block; min-width: 0; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand:hover .brand__name { opacity: 0.75; }
.brand__name {
  display: block;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.brand__tagline {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navlink {
  font-size: 14px;
  color: var(--ink-2);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}
.navlink:hover { text-decoration: none; border-color: var(--line-strong); color: var(--ink); }

.wrap { max-width: 880px; margin: 0 auto; padding: 40px 24px 96px; }

.wrap--wide { max-width: 1180px; }

/* ---------------- 前台 ---------------- */

/* 原 .hero 已移入顶栏（见 .brand__name / .brand__tagline），规则一并移除。 */

.post-list { list-style: none; margin: 0; padding: 0; }

.post-item {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  display: block;
  color: inherit;
}
.post-item:first-child { border-top: none; padding-top: 8px; }
.post-item:hover { text-decoration: none; }
.post-item:hover .post-item__title { color: var(--accent); }

.post-item__date {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.post-item__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 4px 0 6px;
  transition: color 0.15s;
}
.post-item__summary { color: var(--ink-2); font-size: 15px; margin: 0; }

.article__back { font-size: 14px; display: inline-block; margin-bottom: 24px; }
.article__title {
  font-size: 32px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  font-weight: 650;
}
.article__meta {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.article__body { font-size: 16.5px; }
.article__body p { margin: 0 0 1.2em; }
.article__body strong { font-weight: 650; }
.article__body ul,
.article__body ol { margin: 0 0 1.2em; padding-left: 1.5em; }
.article__body li { margin: 0.25em 0; }
.article__body h2 { font-size: 21px; margin: 1.8em 0 0.6em; letter-spacing: -0.01em; }
.article__body pre {
  background: #f2f0ec;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
}
.article__body code { font-family: var(--mono); font-size: 0.92em; }
.article__body blockquote {
  margin: 1.4em 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
}

/* ---------------- 通用状态块 ---------------- */

.state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background: #fff;
}
.state--error {
  border-style: solid;
  border-color: #efc9c4;
  background: var(--danger-soft);
  color: var(--danger);
  text-align: left;
}
.state__title { font-weight: 600; margin-bottom: 4px; }
.state code { font-family: var(--mono); font-size: 13px; word-break: break-all; }

/* ---------------- 后台 ---------------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -0.01em; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font: inherit;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: #17493a; border-color: #17493a; }

.btn--danger { color: var(--danger); border-color: #e6c4bf; background: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn--block { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

.alert {
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #efc9c4;
}
.alert[hidden] { display: none; }

.adminbar {
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.adminbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.adminbar__title { font-weight: 620; letter-spacing: -0.01em; }
.adminbar__user {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.admin-grid {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .admin-grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card__title { font-size: 14px; font-weight: 620; margin: 0; }
.card__body { padding: 16px; }

.list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }

.list__item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s;
}
.list__item:last-child { border-bottom: none; }
.list__item:hover { background: #faf9f7; }
.list__item.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.list__title {
  font-size: 14px;
  font-weight: 550;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list__meta {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.pill--published { background: var(--accent-soft); color: var(--accent); }
.pill--draft { background: var(--warn-soft); color: var(--warn); }

.editor__actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
  flex-wrap: wrap;
}
.editor__hint { font-size: 12.5px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-err { background: var(--danger); }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 40px 24px 32px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--ink-2); }

/* ============================================================
   工具类
   这些规则用来替换原先散落在 HTML 里的内联 style 属性。
   页面现在使用不带 'unsafe-inline' 的严格 CSP，
   内联 style 属性会被浏览器直接拒绝，因此必须收敛到 CSS 里。
   ============================================================ */

.grow { flex: 1; }

.foot__license { margin-top: 4px; }

.state__hint { margin-top: 6px; }

.login-foot { margin-top: 18px; font-size: 13px; text-align: center; }

.list__item--empty { cursor: default; color: #8b8681; }
