/* ==========================================================================
   文章广场 · 样式
   ========================================================================== */

:root {
  --bg: #f7f7fb;
  --bg-soft: #ffffff;
  --bg-sunken: #eeeef5;
  --text: #1b1b23;
  --text-soft: #5d5d6e;
  --text-faint: #8b8b9c;
  --line: #e4e4ee;
  --line-strong: #d2d2e0;
  --accent: #5b5bd6;
  --accent-soft: #ececfb;
  --accent-strong: #4646c4;
  --danger: #d14343;
  --ok: #1f9d63;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, .05), 0 2px 8px rgba(20, 20, 40, .04);
  --shadow-md: 0 4px 14px rgba(20, 20, 40, .07), 0 12px 32px rgba(20, 20, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101018;
    --bg-soft: #17171f;
    --bg-sunken: #1e1e28;
    --text: #ececf3;
    --text-soft: #a8a8bb;
    --text-faint: #74748a;
    --line: #2a2a36;
    --line-strong: #383846;
    --accent: #8b8bff;
    --accent-soft: #23233a;
    --accent-strong: #a5a5ff;
    --danger: #ff7b7b;
    --ok: #4fd18b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

.wrap {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

/* ------------------------------ 顶栏 ------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6a6af5, #b06af0 60%, #f06aa8);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 3px 10px rgba(106, 106, 245, .35);
}

.topbar-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search svg {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.search input {
  width: 190px;
  height: 36px;
  padding: 0 30px 0 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: width .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus {
  width: 240px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search kbd {
  position: absolute;
  right: 9px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  line-height: 15px;
  pointer-events: none;
}

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(91, 91, 214, .3);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-ghost { background: transparent; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; }

.btn.icon-only { padding: 0; width: 36px; }
.btn.icon-only svg { width: 16px; height: 16px; }

/* ------------------------------ 首屏 ------------------------------ */
.hero { padding: 46px 0 26px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 800;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, #6a6af5, #b06af0 55%, #f06aa8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15.5px;
  max-width: 560px;
}
.hero-stats {
  display: flex;
  gap: 22px;
  margin-top: 20px;
  color: var(--text-faint);
  font-size: 13px;
}
.hero-stats b {
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}

/* ------------------------------ 列表 ------------------------------ */
.list-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 26px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.list-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-soft);
}
.list-head .count { font-size: 13px; color: var(--text-faint); font-family: var(--mono); }
.list-head .spacer { margin-left: auto; }

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  display: block;
  padding: 20px 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.card:hover {
  text-decoration: none;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card-title {
  margin: 0 0 7px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -.01em;
}
.card-excerpt {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.75;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 12.5px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  flex: none;
}
.dot::before { content: "·"; margin: 0 2px; }

/* ------------------------------ 空态 / 骨架 ------------------------------ */
.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-faint);
}
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .8; }
.empty p { margin: 6px 0; }

.skeleton {
  height: 108px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-soft) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border: 1px solid var(--line);
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ------------------------------ 文章详情 ------------------------------ */
.article { padding: 34px 0 60px; }

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-soft);
  margin-bottom: 22px;
}
.article-back:hover { color: var(--accent); text-decoration: none; }

.article-head { border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 30px; }
.article-title {
  margin: 0 0 16px;
  font-size: clamp(26px, 4.4vw, 36px);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  color: var(--text-faint);
  font-size: 13px;
}

.prose {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
  color: var(--text);
  overflow-wrap: break-word;
}
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--sans);
  line-height: 1.4;
  margin: 1.8em 0 .7em;
  letter-spacing: -.01em;
}
.prose h1 { font-size: 1.62em; }
.prose h2 { font-size: 1.38em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.2em; }
.prose h4 { font-size: 1.05em; }
.prose h5, .prose h6 { font-size: 1em; color: var(--text-soft); }
.prose p { margin: 0 0 1.1em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.5em; }
.prose li { margin: .3em 0; }
.prose li > ul, .prose li > ol { margin: .3em 0; }
.prose blockquote {
  margin: 1.4em 0;
  padding: .2em 1.1em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.2em 0;
}
.prose img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: .6em 0;
  display: block;
}
.prose code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .12em .38em;
}
.prose pre {
  position: relative;
  margin: 1.4em 0;
  padding: 16px 18px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.6;
}
.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: .84em;
  white-space: pre;
}
.prose .code-block { margin: 1.4em 0; }
.prose .code-block pre { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.prose .code-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: lowercase;
}
.prose .code-bar .copy {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--text-faint);
  font: inherit;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.prose .code-bar .copy:hover { background: var(--bg-soft); color: var(--accent); }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-family: var(--sans);
  font-size: .93em;
}
.prose th, .prose td {
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
}
.prose th { background: var(--bg-sunken); font-weight: 600; }
.prose tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-sunken) 45%, transparent); }
.prose .task-list { list-style: none; padding-left: .2em; }
.prose .task-list li { display: flex; gap: 8px; align-items: flex-start; }
.prose input[type="checkbox"] { margin-top: .45em; accent-color: var(--accent); }

/* ------------------------------ 编辑器 ------------------------------ */
.compose { padding: 30px 0 60px; }
.compose-head { margin-bottom: 20px; }
.compose-head h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.01em; }
.compose-head p { margin: 0; color: var(--text-faint); font-size: 13.5px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: .02em;
}
.field input[type="text"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  overflow-x: auto;
}
.editor-bar .tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.editor-bar .tool:hover { background: var(--bg-sunken); color: var(--text); }
.editor-bar .tool b { font-weight: 800; }
.editor-bar .tool i { font-family: Georgia, serif; }
.editor-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 5px; flex: none; }
.editor-bar .grow { margin-left: auto; }
.tabs { display: inline-flex; background: var(--bg-sunken); border-radius: 8px; padding: 2px; }
.tabs button {
  border: 0;
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  background: var(--bg-soft);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.editor-body { position: relative; }
.editor textarea {
  display: block;
  width: 100%;
  min-height: 420px;
  padding: 20px 22px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  tab-size: 2;
}
.editor textarea::placeholder { color: var(--text-faint); }

.preview {
  min-height: 420px;
  padding: 20px 22px;
  overflow-wrap: break-word;
}
.preview:empty::before {
  content: "预览会显示在这里";
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 14px;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-faint);
  font-size: 12.5px;
  font-family: var(--mono);
}
.editor-foot .grow { margin-left: auto; }

.compose-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.compose-actions .hint { color: var(--text-faint); font-size: 12.5px; }
.compose-actions .grow { margin-left: auto; }

/* ------------------------------ Toast ------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 11px 18px;
  border-radius: 999px;
  background: #22222c;
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* ------------------------------ 页脚 ------------------------------ */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 22px;
  padding-bottom: 40px;
  border-top: 1px solid var(--line);
  margin-top: 30px;
  color: var(--text-faint);
  font-size: 12.5px;
}
.mono { font-family: var(--mono); }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .topbar-inner { height: 56px; gap: 10px; }
  .brand-text { display: none; }
  .search input { width: 140px; }
  .search input:focus { width: 170px; }
  .search kbd { display: none; }
  .hero { padding: 30px 0 18px; }
  .card { padding: 16px 16px; }
  .card-title { font-size: 17px; }
  .editor textarea { min-height: 320px; padding: 16px; }
  .preview { min-height: 320px; padding: 16px; }
  .prose { font-size: 16px; }
  .footer { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
