.space-page {
  min-height: 100vh;
  background: var(--bg);
}

/* 组件上设了 display 之后 hidden 会失效（.post-tabs 就是 flex），统一强制一次 */
.space-page [hidden] {
  display: none !important;
}

.space-header {
  width: min(1100px, calc(100% - 64px));
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.space-header .back-link,
.space-header .article-brand {
  display: inline-flex;
  align-items: center;
}

.space-header .back-link {
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.space-header .back-link:hover {
  color: var(--pink);
}

.space-header .back-link svg {
  width: 16px;
}

.space-header .icon-tool {
  width: 34px;
  height: 34px;
  justify-self: end;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}

.space-header .icon-tool:hover {
  color: var(--pink);
  border-color: var(--pink);
}

.space-header .icon-tool svg {
  width: 15px;
}

.space-hero {
  position: relative;
  width: min(1100px, calc(100% - 64px));
  min-height: 302px;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 62px 34px 34px;
  margin: 30px auto 0;
  color: #fff;
  background: var(--mint-deep);
  border-radius: 8px;
}

/* 背景是照片，压暗层要比纯渐变时更实一点，保证白字可读 */
.space-hero::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(100deg, rgb(21 42 39 / .9) 0%, rgb(21 42 39 / .68) 46%, rgb(21 42 39 / .34) 100%),
    var(--space-cover) center / cover;
}

.space-profile {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  max-width: 760px;
}

.space-avatar {
  width: 110px;
  height: 132px;
  padding: 6px;
  overflow: hidden;
  background: rgb(255 255 255 / .94);
  border: 1px solid rgb(255 255 255 / .8);
  border-radius: 7px;
  transform: rotate(-4deg);
}

.space-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.space-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 5px;
  color: #f5ced8;
  font-family: var(--mono);
  font-size: 9px;
}

.space-role svg {
  width: 12px;
}

.space-profile h1 {
  margin: 0;
  font-size: 39px;
  line-height: 1.25;
}

.space-profile p:not(.space-role) {
  max-width: 520px;
  margin: 8px 0 0;
  color: rgb(255 255 255 / .85);
  font-size: 13px;
  line-height: 1.8;
}

.space-stats {
  width: min(1040px, calc(100% - 112px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  margin: -1px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
}

.space-stats div {
  display: grid;
  gap: 1px;
  min-height: 74px;
  align-content: center;
  padding: 11px 18px;
  border-right: 1px solid var(--line);
}

.space-stats div:last-child {
  border-right: 0;
}

.space-stats span,
.side-kicker,
#post-total {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.space-stats strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
}

.space-layout {
  width: min(1040px, calc(100% - 112px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 205px;
  gap: 42px;
  margin: 54px auto 80px;
}

.space-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.space-section-heading h1 {
  margin: 4px 0 0;
  font-size: 26px;
}

#post-total {
  padding-bottom: 3px;
}

.space-post-list {
  display: grid;
}

.space-post-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  padding: 15px 0;
  color: var(--ink);
  border-bottom: 1px dashed var(--line);
}

.space-post-image {
  aspect-ratio: 1.22 / 1;
  overflow: hidden;
  background: var(--soft);
  border-radius: 6px;
}

.space-post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(.75);
  transition: transform .25s ease;
}

.space-post-card:hover .space-post-image img {
  transform: scale(1.04);
}

.space-post-meta {
  color: var(--mint-deep);
  font-family: var(--mono);
  font-size: 9px;
}

.space-post-card h2 {
  margin: 6px 0 5px;
  font-size: 17px;
  line-height: 1.45;
}

.space-post-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.75;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.space-post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.space-post-tags span,
.space-tags span {
  padding: 3px 6px;
  color: var(--mint-deep);
  background: var(--soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
}

.space-sidebar {
  align-self: start;
  display: grid;
  gap: 12px;
}

.space-side-section {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.side-kicker {
  margin: 0 0 10px;
}

.space-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.space-about dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.space-about div {
  display: grid;
  gap: 1px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.space-about div:last-child {
  padding-bottom: 0;
  border: 0;
}

.space-about dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
}

.space-about dd {
  margin: 0;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

.space-back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  padding-bottom: 2px;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 10px;
  font-weight: 700;
}

.space-back-home svg {
  width: 14px;
}

.space-back-home:hover {
  color: var(--pink);
  border-color: var(--pink);
}

@media (max-width: 720px) {
  .space-header,
  .space-hero,
  .space-stats,
  .space-layout {
    width: min(100% - 32px, 590px);
  }

  .space-header {
    grid-template-columns: 1fr auto;
  }

  .space-header .article-brand {
    display: none;
  }

  .space-hero {
    min-height: 0;
    padding: 62px 20px 24px;
  }

  .space-actions {
    top: 16px;
    right: 16px;
    left: 16px;
    flex-wrap: wrap;
  }

  .space-action {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    font-size: 10px;
  }

  .space-profile {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 14px;
  }

  .space-avatar {
    width: 78px;
    height: 94px;
  }

  .space-profile h1 {
    font-size: 29px;
  }

  .space-profile p:not(.space-role) {
    font-size: 11px;
  }

  .space-stats div {
    min-height: 67px;
    padding: 10px;
  }

  .space-stats strong {
    font-size: 16px;
  }

  .space-layout {
    display: block;
    margin-top: 34px;
  }

  .space-sidebar {
    grid-template-columns: 1fr 1fr;
    margin-top: 24px;
  }

  .space-back-home {
    grid-column: 1 / -1;
  }

  .space-post-card {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 11px;
  }

  .space-post-card h2 {
    margin-top: 4px;
    font-size: 14px;
  }

  .space-post-card p {
    font-size: 10px;
  }
}

/* ---------- 真实名片数据下的补充样式 ---------- */

/* 没有头像时用昵称首字，和头像图占同样的位置 */
.space-avatar .avatar-initial {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--mint-deep);
  background: var(--soft);
  font-size: 40px;
  font-weight: 700;
}

/* 访问自己的空间时的操作区，放在 hero 右上角 */
.space-actions {
  position: absolute;
  z-index: 2;
  top: 22px;
  right: 24px;
  display: flex;
  gap: 8px;
}

.space-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  color: var(--ink);
  background: rgb(255 255 255 / .94);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.space-action:hover:not(:disabled) {
  color: #fff;
  background: var(--pink);
}

/* 登出用描边样式，避免和「编辑资料」抢主次 */
.space-action.is-ghost {
  color: #fff;
  background: rgb(255 255 255 / .14);
  border-color: rgb(255 255 255 / .5);
}

.space-action.is-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: rgb(255 255 255 / .92);
  border-color: transparent;
}

.space-action:disabled {
  cursor: not-allowed;
  opacity: .65;
}

.space-action svg {
  width: 14px;
}

/* 身份区块：签名与简介分两行，比挤在一段里更好读 */
.space-identity {
  min-width: 0;
}

.space-headline {
  font-weight: 600;
}

.space-bio {
  max-width: 560px;
  color: rgb(255 255 255 / .78) !important;
}

.space-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.85;
}

.space-empty code {
  padding: 1px 5px;
  background: var(--soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
}

/* ---------- 我的文章：状态筛选与操作（只有看自己的空间时出现） ---------- */

.post-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.post-tab {
  padding: 6px 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.post-tab:hover {
  color: var(--pink);
  border-color: var(--pink);
}

.post-tab.is-active {
  color: #fff;
  background: var(--mint-deep);
  border-color: var(--mint-deep);
}

.post-hint {
  margin: 0 0 14px;
  padding: 9px 12px;
  color: var(--muted);
  background: var(--soft);
  border-left: 3px solid var(--mint-deep);
  border-radius: 0 5px 5px 0;
  font-size: 11px;
  line-height: 1.7;
}

.post-hint.is-error {
  color: #8f3a56;
  background: #fdeef2;
  border-left-color: #c2506e;
}

body.is-dark .post-hint.is-error {
  color: #f6c3d2;
  background: #4a2c36;
}

/* 状态徽标 */
.post-status {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
}

.post-status.is-draft {
  color: #8a6a12;
  background: #fdf3d7;
}

.post-status.is-published {
  color: #1a6b52;
  background: #dff3ea;
}

.post-status.is-archived {
  color: var(--muted);
  background: var(--soft);
}

body.is-dark .post-status.is-draft {
  color: #f2dca0;
  background: #4a4022;
}

body.is-dark .post-status.is-published {
  color: #a8e6cf;
  background: #22483c;
}

.post-visibility {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 2px 7px;
  color: var(--pink);
  background: var(--pink-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
}

/* 管理态的行：封面 + 内容 + 操作按钮 */
.space-post-card.is-manage {
  align-items: start;
}

/* 管理态不是链接，别跟着做封面缩放 */
.space-post-card.is-manage:hover .space-post-image img {
  transform: none;
}

.space-post-card.is-manage .post-body {
  display: block;
  min-width: 0;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.post-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
}

.post-action:hover {
  color: var(--pink);
  border-color: var(--pink);
}

.post-action.is-primary {
  color: #fff;
  background: var(--pink);
  border-color: var(--pink);
}

.post-action.is-primary:hover {
  background: var(--mint-deep);
  border-color: var(--mint-deep);
}

.post-action:disabled {
  cursor: not-allowed;
  opacity: .6;
}

/* ---------- 删除按钮 ---------- */

/* 删除是破坏性操作，用描边红而不是实心，避免和「发布」抢视觉 */
.post-action.is-danger {
  color: #b23b52;
  border-color: #e8bcc6;
}

.post-action.is-danger:hover {
  color: #fff;
  background: #c2506e;
  border-color: #c2506e;
}

body.is-dark .post-action.is-danger {
  color: #f0a8ba;
  border-color: #6b3a48;
}

/* ---------- 回收站 ---------- */

/* 回收站响应里没有封面，所以去掉封面那一列，让内容占满 */
.space-post-card.is-trash {
  grid-template-columns: minmax(0, 1fr);
}

.post-status.is-deleted {
  color: #8f3a56;
  background: #fbe6ec;
}

body.is-dark .post-status.is-deleted {
  color: #f6c3d2;
  background: #4a2c36;
}

/* 「还剩 N 天可恢复」 */
.trash-countdown {
  margin-left: 8px;
  padding: 2px 7px;
  color: var(--muted);
  background: var(--soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
}

.trash-countdown.is-expired {
  color: #8f3a56;
  background: #fbe6ec;
}

body.is-dark .trash-countdown.is-expired {
  color: #f6c3d2;
  background: #4a2c36;
}
