/* ==========================================================================
   X — 高仿 X（Twitter）的 Halo 2.x 主题
   配色 / 尺寸 / 圆角均对齐 X 官方 Web 端。
   ========================================================================== */

/* ---------- 1. 变量 ---------- */
:root {
  --x-blue: #1d9bf0;
  --x-blue-hover: #1a8cd8;
  --x-red: #f91880;
  --x-green: #00ba7c;
  --x-yellow: #ffd400;

  --x-accent: #1d9bf0;
  --x-fs: 15px;
  --x-radius: 16px;

  --x-left-w: 275px;
  --x-main-w: 600px;
  --x-rail-w: 350px;

  --x-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Arial,
    sans-serif;
  --x-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* Lights out —— X 默认
   :not([data-theme]) 是 JS 未执行时的兜底：否则 --x-bg 等变量全部未定义，
   页面会回退成浏览器默认的白底，看起来就像「强制切回亮色」。 */
html:not([data-theme]),
html[data-theme="dark"] {
  color-scheme: dark;
  --x-bg: var(--x-bg-dark-set, #000000);
  --x-bg-blur: rgba(0, 0, 0, 0.65);
  --x-bg-hover: rgba(255, 255, 255, 0.03);
  --x-bg-active: rgba(255, 255, 255, 0.06);
  --x-card: #16181c;
  --x-card-hover: #1c1f23;
  --x-border: #2f3336;
  --x-text: #e7e9ea;
  --x-dim: #71767b;
  --x-dimmer: #565a5d;
  --x-field: #202327;
  --x-code-bg: #16181c;
  --x-code-border: #2f3336;
  --x-shadow: rgba(255, 255, 255, 0.2);
}

/* Dim */
html[data-theme="dim"] {
  color-scheme: dark;
  --x-bg: var(--x-bg-dim-set, #15202b);
  --x-bg-blur: rgba(21, 32, 43, 0.75);
  --x-bg-hover: rgba(255, 255, 255, 0.03);
  --x-bg-active: rgba(255, 255, 255, 0.07);
  --x-card: #1e2732;
  --x-card-hover: #253341;
  --x-border: #38444d;
  --x-text: #f7f9f9;
  --x-dim: #8b98a5;
  --x-dimmer: #6e7c88;
  --x-field: #273340;
  --x-code-bg: #1e2732;
  --x-code-border: #38444d;
  --x-shadow: rgba(255, 255, 255, 0.2);
}

/* Light */
html[data-theme="light"] {
  color-scheme: light;
  --x-bg: var(--x-bg-light-set, #ffffff);
  --x-bg-blur: rgba(255, 255, 255, 0.85);
  --x-bg-hover: rgba(0, 0, 0, 0.03);
  --x-bg-active: rgba(0, 0, 0, 0.06);
  --x-card: #f7f9f9;
  --x-card-hover: #eff3f4;
  --x-border: #eff3f4;
  --x-text: #0f1419;
  --x-dim: #536471;
  --x-dimmer: #8b98a5;
  --x-field: #eff3f4;
  --x-code-bg: #f7f9f9;
  --x-code-border: #eff3f4;
  --x-shadow: rgba(0, 0, 0, 0.08);
}

/* ---------- 2. 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--x-bg);
  color: var(--x-text);
  font-family: var(--x-font);
  font-size: var(--x-fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4,
p,
figure,
ul,
ol {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

::selection {
  background: var(--x-accent);
  color: #fff;
}

/* 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--x-border) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: var(--x-border);
  border-radius: 999px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* 图标 */
.x-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.x-icon {
  width: 1.25em;
  height: 1.25em;
  display: block;
  fill: currentColor;
  flex-shrink: 0;
}
/* 线条 / 实心两态。
   <use> 引用的内容位于 shadow DOM，外部 CSS 无法选中其内部节点，
   因此两态拆成两个 <svg>（x-icon--o / x-icon--f），由外层切换显示。 */
.x-icon--f {
  display: none;
}
.x-nav__icon > .x-icon,
.x-tabbar__item > .x-icon,
.x-action__icon > .x-icon {
  grid-area: 1 / 1;
}
.x-nav__item.is-active .x-icon--o,
.x-nav__item:hover .x-icon--o,
.x-tabbar__item.is-active .x-icon--o,
.x-tabbar__item:hover .x-icon--o,
.x-action--like.is-liked .x-icon--o,
.x-action--bookmark.is-active .x-icon--o {
  display: none;
}
.x-nav__item.is-active .x-icon--f,
.x-nav__item:hover .x-icon--f,
.x-tabbar__item.is-active .x-icon--f,
.x-tabbar__item:hover .x-icon--f,
.x-action--like.is-liked .x-icon--f,
.x-action--bookmark.is-active .x-icon--f {
  display: block;
}
.x-verified {
  color: var(--x-accent);
  width: 18.75px;
  height: 18.75px;
}

/* 图标尺寸：由容器显式决定，避免 em 层层叠加导致大小漂移。
   下列数值对齐 X 官方 Web 端实测尺寸。 */
.x-logo .x-icon {
  width: 30px;
  height: 30px;
}
.x-nav__icon .x-icon,
.x-tabbar__item .x-icon {
  width: 26px;
  height: 26px;
}
.x-iconbtn .x-icon {
  width: 20px;
  height: 20px;
}
.x-post-btn__icon {
  width: 22px;
  height: 22px;
}
.x-account__more,
.x-search__icon {
  width: 19px;
  height: 19px;
}
.x-search__clear .x-icon {
  width: 14px;
  height: 14px;
}
.x-composer__icon .x-icon {
  width: 19px;
  height: 19px;
}
.x-post__badge .x-icon {
  width: 15px;
  height: 15px;
}
.x-post__reading .x-icon {
  width: 13px;
  height: 13px;
}
.x-post__more .x-icon,
.x-action__icon .x-icon,
.x-follow__name .x-icon,
.x-profile__name .x-icon {
  width: 18.75px;
  height: 18.75px;
}
.x-profile__meta-item .x-icon {
  width: 18px;
  height: 18px;
}
.x-grid__cover--hash .x-icon {
  width: 42px;
  height: 42px;
}
.x-theme-menu__item .x-icon {
  width: 20px;
  height: 20px;
}

/* ---------- 3. 骨架 ---------- */
.x-app {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  max-width: 1265px;
  margin: 0 auto;
  min-height: 100vh;
}

.x-main {
  width: var(--x-main-w);
  max-width: 100%;
  min-height: 100vh;
  min-width: 0;
  flex-shrink: 1;
  border-left: 1px solid var(--x-border);
  border-right: 1px solid var(--x-border);
}

/* ---------- 4. 头像 ---------- */
.x-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  object-fit: cover;
  background: var(--x-field);
  color: var(--x-dim);
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}
.x-avatar--40 {
  width: 40px;
  height: 40px;
  font-size: 16px;
}
.x-avatar--32 {
  width: 32px;
  height: 32px;
  font-size: 13px;
}
.x-avatar--96 {
  width: 96px;
  height: 96px;
  font-size: 34px;
  border: 4px solid var(--x-bg);
}

/* ---------- 5. 按钮 ---------- */
.x-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--x-dur) var(--x-ease), color var(--x-dur) var(--x-ease), border-color var(--x-dur) var(--x-ease),
    opacity var(--x-dur) var(--x-ease), transform var(--x-dur-fast) var(--x-ease);
}
.x-btn--primary {
  background: var(--x-accent);
  color: #fff;
}
.x-btn--primary:hover {
  background: var(--x-blue-hover);
}
.x-btn--outline {
  border: 1px solid var(--x-border);
  color: var(--x-text);
  background: transparent;
}
.x-btn--outline:hover {
  background: var(--x-bg-active);
}
.x-btn--sm {
  height: 32px;
  padding: 0 16px;
  font-size: 14px;
}
.x-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--x-text);
  font-size: 19px;
  transition: background var(--x-dur) var(--x-ease), transform var(--x-dur-fast) var(--x-ease);
}
.x-iconbtn:hover {
  background: var(--x-bg-active);
}

/* ---------- 6. 左栏 ---------- */
.x-left__inner {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: var(--x-left-w);
  height: 100vh;
  padding: 4px 12px 20px;
  flex-shrink: 0;
  /* 这个 z-index 不能省。sticky 元素一定会创建层叠上下文，而左栏在 DOM 里排在主栏之前，
     于是整个左栏（连同里面的「更多」菜单、账号菜单、通知面板）都被主栏里那些
     position: relative 的卡片压住 —— 内部浮层自己设多高的 z-index 都没用，
     因为它们是在左栏这个层叠上下文内部比较的。
     取 35：高于主栏顶栏的 30，低于移动端底栏/悬浮按钮的 40，也低于
     主题菜单 80、账号菜单 90、Toast 90、弹层 200。 */
  z-index: 35;
}

.x-logo {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin: 2px 0 4px;
  border-radius: 50%;
  font-size: 28px;
  color: var(--x-text);
  transition: background var(--x-dur) var(--x-ease);
}
.x-logo:hover {
  background: var(--x-bg-active);
}
.x-logo .x-icon {
  width: 30px;
  height: 30px;
}

/* Logo：文字模式（可带副标题） */
.x-logo--text {
  width: auto;
  max-width: 100%;
  padding: 0 14px;
  border-radius: 14px;
  justify-content: flex-start;
}
.x-logo__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
  text-align: left;
}
.x-logo__main {
  font-size: 19px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-logo__sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--x-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-logo__img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

/* 被折叠进「更多」的导航项 */
.x-nav > li {
  position: relative;
}
.x-nav-more {
  position: absolute;
  left: 0;
  /* 向下弹出：从「更多」按钮下沿展开 */
  top: 100%;
  z-index: 60;
  min-width: 190px;
  margin-top: 8px;
  padding: 4px 0;
  border-radius: 16px;
  background: var(--x-bg);
  border: 1px solid var(--x-border);
  box-shadow: 0 8px 28px var(--x-shadow);
  overflow: hidden;
}
.x-nav-more__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  transition: background var(--x-dur) var(--x-ease);
}
.x-nav-more__item:hover {
  background: var(--x-bg-active);
}
.x-nav-more__item .x-icon {
  width: 20px;
  height: 20px;
}

.x-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

.x-nav__item {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  /* 行高对齐 X 原版：图标 26 + 上下各 16 ≈ 58px/项（X 实测约 58.5） */
  padding: 16px 22px 16px 12px;
  border-radius: 9999px;
  font-size: 20px;
  font-weight: 400;
  color: var(--x-text);
  transition: background var(--x-dur) var(--x-ease), transform var(--x-dur-fast) var(--x-ease);
  max-width: 100%;
}
.x-nav__item:hover {
  background: var(--x-bg-active);
}
.x-nav__item.is-active {
  font-weight: 700;
}
.x-nav__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font-size: 26px;
}
.x-nav__label {
  font-size: 20px;
  line-height: 24px;
  white-space: nowrap;
}

.x-post-btn {
  margin-top: 16px;
  width: 90%;
  height: 52px;
  font-size: 17px;
  transition: transform var(--x-dur-fast) var(--x-ease);
}
.x-post-btn__icon {
  display: none;
  font-size: 22px;
}

.x-account {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: auto;
  padding: 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background var(--x-dur) var(--x-ease), transform var(--x-dur-fast) var(--x-ease);
}
.x-account:hover {
  background: var(--x-bg-active);
}
.x-account__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 20px;
}
.x-account__name {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-account__handle {
  color: var(--x-dim);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-account__more {
  margin-left: auto;
  font-size: 19px;
}

/* 顶栏账号区：登录 / 注册入口，或登录用户头像 */
.x-account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 顶栏里的账号区推到最右（原来和标题挤在一起） */
.x-topbar__row .x-account-bar {
  margin-left: auto;
}
.x-account-bar__cta {
  height: 32px;
}
.x-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 2px;
  border-radius: 9999px;
  transition: background var(--x-dur) var(--x-ease), transform var(--x-dur-fast) var(--x-ease);
}
.x-avatar-btn:hover {
  background: var(--x-bg-active);
}
.x-avatar-btn__name {
  font-size: 14px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 左栏底部的登录 / 注册按钮 */
.x-account-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: auto;
}
.x-account-actions__btn {
  width: 100%;
  height: 42px;
}

/* ---------- 7. 顶栏 ---------- */
.x-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--x-bg-blur);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--x-border);
}
.x-topbar__row {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 53px;
  padding: 0 16px;
}
.x-topbar__title {
  font-size: 20px;
  font-weight: 800;
  line-height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-topbar__headline {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.x-topbar__headline .x-topbar__title {
  font-size: 17px;
  line-height: 21px;
}
.x-topbar__sub {
  display: block;
  padding: 0 16px 12px;
  color: var(--x-dim);
  font-size: 13px;
  line-height: 16px;
}
.x-topbar__headline .x-topbar__sub {
  padding: 0;
}
.x-topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tabs */
.x-tabs {
  display: flex;
  border-top: 1px solid transparent;
}
.x-tab {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  height: 53px;
  color: var(--x-dim);
  font-size: 15px;
  font-weight: 500;
  transition: background var(--x-dur) var(--x-ease), color var(--x-dur) var(--x-ease);
  cursor: pointer;
}
.x-tab:hover {
  background: var(--x-bg-hover);
  color: var(--x-text);
}
.x-tab.is-active {
  color: var(--x-text);
  font-weight: 700;
}
.x-tab.is-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 4px;
  border-radius: 9999px;
  background: var(--x-accent);
}

/* 作者页的 tab 栏独立于顶栏之外（在资料区之后），需要自己吸顶：
   粘在顶栏下沿（53px 行高 + 1px 边框 = 54px），与归档页年份标题同一套路。
   主页 / 瞬间页的 tabs 在 .x-topbar 内部，跟随顶栏整体 sticky，不加这个类。 */
.x-tabs--sticky {
  position: sticky;
  top: 54px;
  z-index: 10;
  background: var(--x-bg-blur);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--x-border);
}

/* ---------- 8. 发帖框 ---------- */
.x-composer {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--x-border);
}
.x-composer__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.x-composer__placeholder {
  padding: 10px 0 4px;
  font-size: 20px;
  line-height: 24px;
  color: var(--x-dim);
  transition: color var(--x-dur) var(--x-ease);
}
.x-composer__placeholder:hover {
  color: var(--x-text);
}
/* 未登录时提示先登录 */
.x-composer__placeholder--guest {
  font-size: 17px;
  line-height: 22px;
}
.x-composer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.x-composer__icons {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: -8px;
}
.x-composer__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  /* 对齐 X：图标默认灰、hover 才亮蓝 */
  color: var(--x-dim);
  font-size: 19px;
  transition: color var(--x-dur) var(--x-ease), background var(--x-dur) var(--x-ease);
}
.x-composer__icon:hover {
  color: var(--x-accent);
  background: rgba(29, 155, 240, 0.12);
}

/* ---------- 9. 推文卡片 ---------- */
.x-timeline {
  display: flex;
  flex-direction: column;
}

.x-post {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--x-border);
  cursor: pointer;
  transition: background var(--x-dur) var(--x-ease);
  position: relative;
  text-align: left;
}
.x-post:hover {
  background: var(--x-bg-hover);
}
.x-post__avatar {
  flex-shrink: 0;
}
.x-post__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.x-post__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 15px;
  line-height: 20px;
  min-height: 20px;
}
.x-post__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin-bottom: 2px;
  color: var(--x-dim);
  font-size: 13px;
  font-weight: 700;
}
.x-post__badge .x-icon {
  font-size: 15px;
}
.x-post__name {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  color: var(--x-text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-post__name:hover {
  text-decoration: underline;
}
.x-post__handle,
.x-post__dot {
  color: var(--x-dim);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-post__handle {
  max-width: 40%;
}
.x-post__time {
  color: var(--x-dim);
  font-size: 15px;
  white-space: nowrap;
}
.x-post__time:hover {
  text-decoration: underline;
}
.x-post__reading {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--x-dim);
  font-size: 12px;
  white-space: nowrap;
}
.x-post__reading .x-icon {
  font-size: 13px;
}
.x-post__more {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: -8px;
  border-radius: 50%;
  color: var(--x-dim);
  font-size: 18px;
  opacity: 0;
  transition: background var(--x-dur) var(--x-ease), color var(--x-dur) var(--x-ease), opacity var(--x-dur) var(--x-ease);
}
.x-post:hover .x-post__more {
  opacity: 1;
}
.x-post__more:hover {
  background: rgba(29, 155, 240, 0.12);
  color: var(--x-accent);
}

.x-post__content {
  margin-top: 2px;
  min-width: 0;
}
.x-post__title {
  font-size: var(--x-fs);
  font-weight: 700;
  line-height: 20px;
  color: var(--x-text);
  word-break: break-word;
}
.x-post__title-link:hover .x-post__title {
  text-decoration: underline;
}
.x-post__excerpt {
  margin-top: 2px;
  font-size: var(--x-fs);
  line-height: 20px;
  color: var(--x-text);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.x-post__cover {
  display: block;
  margin-top: 12px;
  border: 1px solid var(--x-border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--x-field);
}
html[data-round-media="false"] .x-post__cover,
html[data-round-media="false"] .x-detail__cover,
html[data-round-media="false"] .x-prose img,
html[data-round-media="false"] .x-prose video,
html[data-round-media="false"] .x-prose iframe,
html[data-round-media="false"] .x-grid__item {
  border-radius: 4px;
}
html[data-timeline-mode="compact"] .x-post__cover,
html[data-timeline-mode="compact"] .x-post__excerpt {
  display: none;
}
.x-post__cover img {
  width: 100%;
  height: auto;
  max-height: 510px;
  object-fit: cover;
  transition: opacity var(--x-dur) var(--x-ease);
}
.x-post__cover:hover img {
  opacity: 0.92;
}

.x-post__topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- 瞬间媒体（对应 X 的推文配图 / 视频） ---------- */
.x-media {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
}
.x-media--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}
.x-media--detail {
  margin: 12px 0 0;
}
html[data-round-media="false"] .x-media--detail {
  border-radius: 4px;
}
.x-media__item {
  display: block;
  width: 100%;
  height: auto;
  max-height: 510px;
  object-fit: cover;
  background: var(--x-field);
}
.x-media--grid .x-media__item {
  aspect-ratio: 1 / 1;
  max-height: none;
}
.x-media__audio {
  width: 100%;
  margin-top: 6px;
}
.x-media__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--x-border);
  border-radius: 12px;
  color: var(--x-accent);
  font-size: 15px;
  transition: background var(--x-dur) var(--x-ease);
}
.x-media__link:hover {
  background: var(--x-bg-active);
}
.x-media__link .x-icon {
  width: 18px;
  height: 18px;
}

/* 瞬间正文：内容本身就是推文，第一段不要额外上边距 */
.x-post__text > *:first-child,
.x-prose--moment > *:first-child {
  margin-top: 0;
}
.x-post__text > *:last-child,
.x-prose--moment > *:last-child {
  margin-bottom: 0;
}
.x-post__topic {
  color: var(--x-accent);
  font-size: 14px;
  font-weight: 400;
}
.x-post__topic:hover {
  text-decoration: underline;
}
.x-post__topic--cat {
  color: var(--x-dim);
}

/* 互动栏：前四项在 425px 区间内均分，右侧固定书签与分享（对齐 X 结构） */
.x-post__actions,
.x-detail__actions {
  display: flex;
  align-items: center;
  margin-top: 12px;
  margin-left: -8px;
}
.x-action--reply,
.x-action--repost,
.x-action--like,
.x-action--views {
  flex: 1 1 0;
  max-width: 106px;
}
.x-action__spacer {
  flex: 1 1 auto;
  min-width: 4px;
}
.x-action {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--x-dim);
  font-size: 13px;
  transition: color var(--x-dur) var(--x-ease);
}
.x-action__icon {
  display: grid;
  place-items: center;
  width: 34.75px;
  height: 34.75px;
  border-radius: 50%;
  transition: background var(--x-dur) var(--x-ease);
}
.x-action__count {
  min-width: 14px;
  padding-right: 6px;
  font-size: 13px;
  line-height: 16px;
  text-align: left;
}

.x-action--reply:hover {
  color: var(--x-accent);
}
.x-action--reply:hover .x-action__icon {
  background: rgba(29, 155, 240, 0.12);
}
.x-action--repost:hover {
  color: var(--x-green);
}
.x-action--repost:hover .x-action__icon {
  background: rgba(0, 186, 124, 0.12);
}
.x-action--like:hover,
.x-action--like.is-liked {
  color: var(--x-red);
}
.x-action--like:hover .x-action__icon,
.x-action--like.is-liked .x-action__icon {
  background: rgba(249, 24, 128, 0.12);
}
.x-action--like.is-liked .x-action__icon {
  animation: x-pop 0.4s cubic-bezier(0.2, 0, 0.2, 1.4);
}
@keyframes x-pop {
  0% {
    transform: scale(0.85);
  }
  55% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}
.x-action--views:hover {
  color: var(--x-accent);
}
.x-action--views:hover .x-action__icon {
  background: rgba(29, 155, 240, 0.12);
}
.x-action--bookmark:hover,
.x-action--bookmark.is-active {
  color: var(--x-accent);
}
.x-action--bookmark:hover .x-action__icon,
.x-action--bookmark.is-active .x-action__icon {
  background: rgba(29, 155, 240, 0.12);
}
.x-action--share:hover {
  color: var(--x-accent);
}
.x-action--share:hover .x-action__icon {
  background: rgba(29, 155, 240, 0.12);
}
.x-action.is-disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------- 10. 详情页 ---------- */
.x-detail {
  padding: 12px 16px 4px;
  border-bottom: 1px solid var(--x-border);
}
.x-detail__head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.x-detail__head-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 20px;
}
.x-detail__head-meta .x-post__name {
  font-size: 15px;
}
/* 详情页头部空间充足，用户名无需截断 */
.x-detail__head-meta .x-post__handle {
  max-width: none;
}
.x-detail__title {
  margin: 12px 0 2px;
  font-size: 23px;
  font-weight: 800;
  line-height: 28px;
  word-break: break-word;
}
.x-detail__content {
  margin-top: 12px;
  font-size: 17px;
  line-height: 26px;
  word-break: break-word;
}
.x-detail__cover {
  margin: 12px 0 0;
  border: 1px solid var(--x-border);
  border-radius: 16px;
  overflow: hidden;
}
.x-detail__cover img {
  width: 100%;
  height: auto;
}
.x-detail__topics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: 15px;
}
.x-detail__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 16px 0 4px;
  color: var(--x-dim);
  font-size: 15px;
  line-height: 20px;
}
.x-detail__actions {
  margin: 4px 0 0;
  padding: 12px 0;
  border-top: 1px solid var(--x-border);
}
.x-detail--longform .x-detail__content {
  font-size: 19px;
  line-height: 30px;
}
.x-detail--page {
  padding-bottom: 32px;
}

/* ---------- 11. 正文排版 ---------- */
.x-prose > *:first-child {
  margin-top: 0;
}
.x-prose p {
  margin: 0 0 16px;
}
.x-prose h1,
.x-prose h2,
.x-prose h3,
.x-prose h4,
.x-prose h5,
.x-prose h6 {
  margin: 24px 0 12px;
  font-weight: 800;
  line-height: 1.3;
}
.x-prose h2 {
  font-size: 1.35em;
}
.x-prose h3 {
  font-size: 1.18em;
}
.x-prose h4 {
  font-size: 1.05em;
}
.x-prose a {
  color: var(--x-accent);
}
.x-prose a:hover {
  text-decoration: underline;
}
.x-prose img {
  margin: 16px auto;
  border-radius: 16px;
  border: 1px solid var(--x-border);
}
.x-prose ul,
.x-prose ol {
  margin: 0 0 16px;
  padding-left: 1.4em;
}
.x-prose ul {
  list-style: disc;
}
.x-prose ol {
  list-style: decimal;
}
.x-prose li {
  margin: 6px 0;
}
.x-prose blockquote {
  margin: 16px 0;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--x-accent);
  color: var(--x-dim);
}
.x-prose code {
  font-family: var(--x-mono);
  font-size: 0.9em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--x-code-bg);
  border: 1px solid var(--x-code-border);
}
.x-prose pre {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--x-code-bg);
  border: 1px solid var(--x-code-border);
  overflow-x: auto;
}
.x-prose pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  line-height: 22px;
}
.x-prose hr {
  margin: 24px 0;
  border: 0;
  border-top: 1px solid var(--x-border);
}
.x-prose table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 15px;
}
.x-prose th,
.x-prose td {
  padding: 10px 12px;
  border: 1px solid var(--x-border);
  text-align: left;
}
.x-prose th {
  background: var(--x-card);
  font-weight: 700;
}
.x-prose video,
.x-prose iframe {
  width: 100%;
  margin: 16px 0;
  border-radius: 16px;
  border: 1px solid var(--x-border);
}

/* ---------- 12. 回复区 ---------- */
.x-replies {
  border-bottom: 1px solid var(--x-border);
}
.x-replies__title {
  padding: 16px;
  font-size: 20px;
  font-weight: 800;
  border-bottom: 1px solid var(--x-border);
}
.x-replies__body {
  padding: 16px;
}
.x-replies__empty {
  color: var(--x-dim);
  font-size: 15px;
  padding: 16px 0;
}

/* ---------- 13. 个人主页 ---------- */
.x-profile {
  border-bottom: 1px solid var(--x-border);
}
.x-profile__banner {
  height: 200px;
  overflow: hidden;
  background: var(--x-field);
}
.x-profile__banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.x-profile__banner-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1d9bf0 0%, #7856ff 100%);
  opacity: 0.85;
}
.x-profile__bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 16px;
  min-height: 68px;
}
.x-profile__avatar {
  margin-top: -48px;
  position: relative;
  z-index: 1;
}
.x-profile__bar .x-btn {
  margin-top: 12px;
}
.x-profile__info {
  padding: 4px 16px 16px;
}
.x-profile__name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 20px;
  font-weight: 800;
  line-height: 24px;
}
.x-profile__handle {
  display: block;
  color: var(--x-dim);
  font-size: 15px;
  line-height: 20px;
}
.x-profile__bio {
  margin-top: 12px;
  font-size: 15px;
  line-height: 20px;
  white-space: pre-wrap;
}
.x-profile__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--x-dim);
  font-size: 15px;
}
.x-profile__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.x-profile__meta-item .x-icon {
  font-size: 18px;
}

/* ---------- 14. 网格（探索 / 话题） ---------- */
.x-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 16px 16px;
}
.x-grid__item {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--x-border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--x-bg);
  transition: background var(--x-dur) var(--x-ease);
}
.x-grid__item:hover {
  background: var(--x-bg-active);
}
.x-grid__cover {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--x-field);
}
.x-grid__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.x-grid__cover--hash {
  color: var(--x-dim);
  font-size: 42px;
}
.x-grid__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
}
.x-grid__name {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-grid__count {
  color: var(--x-dim);
  font-size: 14px;
}

/* ---------- 15. 归档 ---------- */
.x-archive__year-title {
  position: sticky;
  top: 54px;
  z-index: 10;
  padding: 8px 16px;
  background: var(--x-bg-blur);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--x-border);
  font-size: 20px;
  font-weight: 800;
}
.x-archive__month-title {
  padding: 10px 16px 6px;
  color: var(--x-dim);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- 16. 右栏 ---------- */
.x-rail__inner {
  width: var(--x-rail-w);
  padding-left: 30px;
  flex-shrink: 0;
  /* ⚠️ 这行不能省：.x-app 是 align-items: flex-start 的 flex 容器，
     不写 stretch 的话这层壳只有内容那么高，里面 .x-rail__sticky 的
     包含块跟着变矮，sticky 根本粘不住 —— 表现为「右栏跟着帖子一起滚走」。
     stretch 后壳撑到与主栏等高，sticky 才能全程生效。
     （≤1005px 时右栏整栏 display: none，不受影响。） */
  align-self: stretch;
}
.x-rail__sticky {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 8px 0 20px;
  scrollbar-width: none;
}
.x-rail__sticky::-webkit-scrollbar {
  display: none;
}

.x-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9999px;
  background: var(--x-field);
  transition: border-color var(--x-dur) var(--x-ease), background var(--x-dur) var(--x-ease);
}
.x-search:focus-within {
  border-color: var(--x-accent);
  background: var(--x-bg);
}
.x-search__icon {
  font-size: 19px;
  color: var(--x-dim);
}
.x-search:focus-within .x-search__icon {
  color: var(--x-accent);
}
.x-search__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--x-text);
  font-family: inherit;
  font-size: 15px;
}
.x-search__input::placeholder {
  color: var(--x-dim);
}
.x-search__input::-webkit-search-cancel-button {
  display: none;
}
.x-search__clear {
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--x-accent);
  color: #fff;
  font-size: 14px;
}
.x-search__input:not(:placeholder-shown) ~ .x-search__clear {
  display: grid;
}
.x-search--inline {
  margin: 0 16px 12px;
}

.x-card {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  /* X 风格卡片：与页面同底 + 1px 细边框（灰底无边框是旧版 X 的样子） */
  background: transparent;
  border: 1px solid var(--x-border);
  overflow: hidden;
}
.x-card__title {
  font-size: 20px;
  font-weight: 800;
  line-height: 24px;
  margin-bottom: 8px;
}
.x-card__text {
  color: var(--x-dim);
  font-size: 14px;
  line-height: 19px;
  margin-top: 10px;
}
/* 站长自定义卡片的正文：保留换行（textarea 里的回车按原样显示） */
.x-card__text--multiline {
  white-space: pre-line;
  overflow-wrap: break-word;
}
.x-card__more {
  display: block;
  margin-top: 10px;
  color: var(--x-accent);
  font-size: 15px;
}
.x-card__more:hover {
  text-decoration: underline;
}

.x-follow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.x-follow__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 19px;
}
.x-follow__name {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-follow__handle {
  color: var(--x-dim);
  font-size: 15px;
}
.x-follow__btn {
  margin-left: auto;
  flex-shrink: 0;
}

.x-trends__item + .x-trends__item {
  border-top: 1px solid var(--x-border);
}
.x-trends__link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
}
.x-trends__link:hover .x-trends__name {
  text-decoration: underline;
}
.x-trends__meta,
.x-trends__count {
  color: var(--x-dim);
  font-size: 13px;
  line-height: 16px;
}
.x-trends__name {
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
}

/* 右栏底部账号卡片内的站点入口 */
.x-account-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--x-border);
  color: var(--x-dim);
  font-size: 13px;
  line-height: 18px;
}
.x-account-links a:hover {
  text-decoration: underline;
}

/* ---------- 17. 移动端底栏 ---------- */
.x-tabbar__inner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 53px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--x-bg-blur);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--x-border);
}
.x-tabbar__item {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--x-dim);
  font-size: 26px;
  transition: color var(--x-dur) var(--x-ease), transform var(--x-dur-fast) var(--x-ease);
}
.x-tabbar__item.is-active {
  color: var(--x-text);
}
.x-tabbar__item .x-icon {
  width: 26px;
  height: 26px;
}

.x-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 69px;
  z-index: 40;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: var(--x-accent);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 14px rgba(29, 155, 240, 0.4);
  transition: transform var(--x-dur-fast) var(--x-ease);
}

.x-site-footer {
  max-width: 1265px;
  margin: 0 auto;
  padding: 16px;
  color: var(--x-dim);
  font-size: 12px;
  text-align: center;
}

/* ---------- 18. 空状态 / 错误 / 加载 ---------- */
.x-empty {
  padding: 40px 32px;
  text-align: center;
  color: var(--x-dim);
}
.x-empty h2 {
  color: var(--x-text);
  font-size: 23px;
  font-weight: 800;
  margin-bottom: 8px;
}
.x-empty p {
  font-size: 15px;
}

.x-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 60px 32px;
}
.x-error__code {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  color: var(--x-dim);
}
.x-error__title {
  font-size: 31px;
  font-weight: 800;
  line-height: 36px;
}
.x-error__desc {
  color: var(--x-dim);
  font-size: 15px;
  margin-bottom: 8px;
}

.x-loadmore {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 16px 40px;
}
.x-loadmore__page {
  color: var(--x-dim);
  font-size: 14px;
}

.x-topic-desc {
  padding: 16px;
  color: var(--x-dim);
  font-size: 15px;
  line-height: 21px;
  border-bottom: 1px solid var(--x-border);
}
.x-category-hero {
  aspect-ratio: 3 / 1;
  overflow: hidden;
  background: var(--x-field);
}
.x-category-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.x-search-status {
  padding: 12px 16px;
  color: var(--x-dim);
  font-size: 14px;
  border-bottom: 1px solid var(--x-border);
}

/* 搜索结果卡片用与时间线一致的样式，仅高亮差异 */
.x-post mark,
.x-post__excerpt mark,
.x-post__title mark {
  background: transparent;
  color: var(--x-accent);
  font-weight: 700;
}

/* ---------- 19. Toast ---------- */
.x-toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  z-index: 90;
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--x-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--x-dur) var(--x-ease), transform var(--x-dur) var(--x-ease);
}
.x-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 主题切换菜单 */
.x-theme-menu {
  position: fixed;
  z-index: 80;
  min-width: 220px;
  padding: 4px 0;
  border-radius: 16px;
  background: var(--x-bg);
  border: 1px solid var(--x-border);
  box-shadow: 0 0 0 1px var(--x-border), 0 8px 28px var(--x-shadow);
  overflow: hidden;
}
.x-theme-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  text-align: left;
  transition: background var(--x-dur) var(--x-ease);
}
.x-theme-menu__item:hover {
  background: var(--x-bg-active);
}
.x-theme-menu__label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.x-theme-menu__item .x-icon {
  font-size: 20px;
}
.x-theme-menu__check {
  color: var(--x-accent);
  font-size: 18px;
  opacity: 0;
}
.x-theme-menu__item.is-active .x-theme-menu__check {
  opacity: 1;
}

/* ---------- 20. 响应式 ---------- */
/* 宽屏（≥1300px）：右栏对齐 X 宽屏规格。
   X 在宽屏下是 275 + 600 + 400 = 1275 的分配（常规宽度下右栏 350），
   容器同步加宽 40px（1275 + 左右各 20 留白 = 1315），内容列 326 ≈ X 实测 326.5。 */
@media (min-width: 1300px) {
  :root {
    --x-rail-w: 400px;
  }
  .x-app,
  .x-site-footer {
    max-width: 1315px;
  }
  .x-rail__inner {
    padding-left: 56px;
    padding-right: 18px;
  }
}

@media (max-width: 1265px) {
  .x-left__inner {
    width: 88px;
    align-items: center;
    padding: 4px 8px 20px;
  }
  .x-nav {
    align-items: center;
  }
  .x-nav__item {
    padding: 12px;
    justify-content: center;
  }
  .x-nav__label,
  .x-account__meta,
  .x-account__more {
    display: none;
  }
  .x-account {
    padding: 8px;
    justify-content: center;
  }
  .x-post-btn {
    width: 52px;
    padding: 0;
  }
  .x-post-btn__full {
    display: none;
  }
  .x-post-btn__icon {
    display: block;
  }
  .x-rail__inner {
    width: 300px;
    padding-left: 20px;
  }
}

@media (max-width: 1005px) {
  .x-rail__inner {
    display: none;
  }
}

@media (max-width: 705px) {
  .x-app {
    display: block;
  }
  .x-left__inner {
    display: none;
  }
  .x-main {
    width: 100%;
    border-left: 0;
    border-right: 0;
    padding-bottom: 60px;
  }
  .x-tabbar__inner {
    display: flex;
  }
  .x-fab {
    display: grid;
  }
  .x-post__reading {
    display: none !important;
  }
  .x-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .x-profile__banner {
    height: 140px;
  }
  .x-detail__title {
    font-size: 20px;
    line-height: 25px;
  }
  .x-detail__content {
    font-size: 16px;
    line-height: 24px;
  }
  .x-topbar__row,
  .x-post,
  .x-detail,
  .x-composer,
  .x-replies__body,
  .x-grid,
  .x-topic-desc,
  .x-topbar__sub {
    padding-left: 12px;
    padding-right: 12px;
  }
  .x-toast {
    bottom: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   18. 弹层（发瞬间 / 编辑个人资料）
   ========================================================================== */
body.x-has-modal {
  overflow: hidden;
}

.x-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* flex 居中 + 面板比视口高时，溢出的部分会被裁掉且滚不动（顶部和底部都够不着）。
     让它自己可滚，配合面板上的 margin: auto，既保持居中又不会裁切。 */
  overflow-y: auto;
}
/* hidden 属性必须压过上面的 display:flex，否则关不掉 */
.x-modal[hidden] {
  display: none !important;
}
.x-modal__mask {
  position: absolute;
  inset: 0;
  background: rgba(91, 112, 131, 0.4);
}
.x-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(600px, 100%);
  max-height: min(90vh, 720px);
  background: var(--x-bg);
  border: 1px solid var(--x-border);
  border-radius: 16px;
  box-shadow: 0 12px 40px var(--x-shadow);
  overflow: hidden;
  /* 见上面 .x-modal 的说明：flex 里用 margin: auto 居中，内容超高时不会被裁 */
  margin: auto;
  animation: x-modal-in 0.16s ease-out;
}
@keyframes x-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.x-modal__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  flex-shrink: 0;
}
.x-modal__title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 22px;
}
.x-modal__body {
  padding: 4px 16px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* flex 子项默认 min-height: auto，不会被压到触发滚动 —— 内容一高就把面板撑出去，
     超出部分被 .x-modal__panel 的 overflow: hidden 裁掉，于是底部的按钮既看不到也划不到。
     必须显式 min-height: 0 才能真正滚动。移动端最容易踩到。 */
  flex: 1 1 auto;
  min-height: 0;
}
/* 头部（含「保存」按钮）固定住，别被内容挤扁 */
.x-modal__head {
  flex-shrink: 0;
}

/* ---------- 发瞬间 ---------- */
.x-compose {
  display: flex;
  gap: 12px;
}
.x-compose__main {
  flex: 1;
  min-width: 0;
}
.x-compose__input {
  display: block;
  width: 100%;
  min-height: 76px;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--x-text);
  font-family: inherit;
  font-size: 20px;
  line-height: 26px;
  resize: none;
  outline: none;
}
.x-compose__input::placeholder {
  color: var(--x-dim);
}
.x-compose__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--x-border);
}
.x-compose__icons {
  display: flex;
  align-items: center;
  gap: 2px;
}
.x-compose__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--x-accent);
  font-size: 19px;
}
.x-compose__count {
  color: var(--x-dim);
  font-size: 13px;
  line-height: 16px;
}
.x-compose__hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--x-border);
  color: var(--x-accent);
  font-size: 13px;
  line-height: 16px;
}
.x-compose__hint .x-icon {
  font-size: 16px;
}

/* ---------- 编辑个人资料 ---------- */
.x-edit__cover {
  position: relative;
  height: 120px;
  margin: -4px -16px 56px;
  border-bottom: 1px solid var(--x-border);
  background: var(--x-bg-hover);
}
.x-edit__cover-fallback {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1d9bf0 0%, #7856ff 100%);
  opacity: 0.85;
}
.x-edit__avatar {
  position: absolute;
  left: 16px;
  bottom: -48px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 4px solid var(--x-bg);
  background: var(--x-bg);
  cursor: pointer;
  overflow: hidden;
}
.x-edit__avatar-box {
  display: block;
  width: 100%;
  height: 100%;
}
.x-edit__avatar-box .x-avatar {
  display: block;
  width: 100%;
  height: 100%;
  font-size: 34px;
}
.x-edit__avatar-mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.15s;
}
.x-edit__avatar:hover .x-edit__avatar-mask,
.x-edit__avatar:focus-within .x-edit__avatar-mask {
  opacity: 1;
}
.x-edit__file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.x-field {
  display: block;
  position: relative;
  margin-bottom: 16px;
  padding: 8px 12px;
  border: 1px solid var(--x-border);
  border-radius: 6px;
  transition: border-color var(--x-dur) var(--x-ease), box-shadow var(--x-dur) var(--x-ease);
}
.x-field:focus-within {
  border-color: var(--x-accent);
  box-shadow: 0 0 0 1px var(--x-accent);
}
.x-field__label {
  display: block;
  color: var(--x-dim);
  font-size: 13px;
  line-height: 16px;
}
.x-field__input {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--x-text);
  font-family: inherit;
  font-size: 17px;
  line-height: 24px;
  outline: none;
}
.x-field__input:disabled {
  color: var(--x-dim);
  cursor: not-allowed;
}
.x-field__input--area {
  min-height: 56px;
  padding-top: 4px;
  resize: vertical;
}
.x-field__note {
  display: block;
  margin-top: 2px;
  color: var(--x-dim);
  font-size: 13px;
  line-height: 16px;
}

/* ---------- 弹层内的提示条 ---------- */
.x-hint {
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--x-bg-hover);
  color: var(--x-dim);
  font-size: 13px;
  line-height: 18px;
}
.x-hint[hidden] {
  display: none !important;
}
.x-hint.is-error {
  background: rgba(244, 33, 46, 0.12);
  color: #f4212e;
}

/* ---------- 作者主页上的补充件 ---------- */
.x-profile__meta-link {
  color: var(--x-accent);
  text-decoration: none;
}
.x-profile__meta-link:hover {
  text-decoration: underline;
}
.x-follow__name a {
  color: inherit;
  text-decoration: none;
}
.x-follow__name a:hover {
  text-decoration: underline;
}

@media (max-width: 705px) {
  .x-modal {
    align-items: flex-end;
    padding: 0;
  }
  .x-modal__panel {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
  .x-compose__input {
    font-size: 18px;
    line-height: 24px;
  }
}

.x-theme-menu__foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--x-border);
  color: var(--x-dim);
  font-size: 13px;
  line-height: 17px;
}


/* ==========================================================================
   19. 动效：统一缓动 + 补齐缺失的过渡
   ========================================================================== */

/* 收敛成一套时长/缓动，后面所有动画都引用它，改一处全站生效 */
:root {
  --x-ease: cubic-bezier(0.2, 0, 0, 1);
  --x-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --x-dur-fast: 0.12s;
  --x-dur: 0.2s;
  --x-dur-slow: 0.32s;
}

/* hidden 属性必须压得住组件自己的 display。
   否则 .x-post { display: flex } 会盖掉 UA 的 [hidden]{display:none}，
   首页「精选」这类靠 hidden 切换的标签页会直接失效。 */
[hidden] {
  display: none !important;
}

@keyframes x-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes x-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes x-pop-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes x-sheet-in {
  from {
    opacity: 0.4;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 列表 / 内容入场 ---------- */
.x-timeline > .x-post,
.x-replies__body,
.x-rail__sticky > .x-card,
.x-detail__body {
  animation: x-rise var(--x-dur-slow) var(--x-ease-out) backwards;
}
/* 只给前 8 项错峰，长列表不拖时间 */
.x-timeline > .x-post:nth-child(2) { animation-delay: 0.02s; }
.x-timeline > .x-post:nth-child(3) { animation-delay: 0.04s; }
.x-timeline > .x-post:nth-child(4) { animation-delay: 0.06s; }
.x-timeline > .x-post:nth-child(5) { animation-delay: 0.08s; }
.x-timeline > .x-post:nth-child(6) { animation-delay: 0.1s; }
.x-timeline > .x-post:nth-child(7) { animation-delay: 0.12s; }
.x-timeline > .x-post:nth-child(8) { animation-delay: 0.14s; }

/* ---------- 浮层：主题菜单 / 「更多」折叠菜单 ---------- */
.x-theme-menu,
.x-nav-more {
  animation: x-pop-in var(--x-dur) var(--x-ease-out);
  transform-origin: top center;
}

/* ---------- 弹层 ---------- */
.x-modal__mask {
  animation: x-fade var(--x-dur) var(--x-ease);
}
.x-modal__panel {
  animation: x-pop-in var(--x-dur) var(--x-ease-out);
}

/* ---------- 悬浮按钮 ---------- */
.x-fab:hover {
  transform: scale(1.06);
}

/* ---------- 导航图标 hover 微放大（对齐 X 的手感） ---------- */
.x-nav__icon {
  transition: transform var(--x-dur) var(--x-ease);
}
.x-nav__item:hover .x-nav__icon {
  transform: scale(1.08);
}

/* ---------- 卡片 / 封面 hover ---------- */
.x-grid__item:hover {
  transform: translateY(-2px);
}
.x-post__cover img {
  transition: opacity var(--x-dur) var(--x-ease),
    transform var(--x-dur-slow) var(--x-ease);
}
.x-post:hover .x-post__cover img {
  transform: scale(1.02);
}

/* ---------- 按压反馈 ---------- */
.x-btn:active { transform: scale(0.97); }
.x-iconbtn:active { transform: scale(0.92); }
.x-nav__item:active { transform: scale(0.97); }
.x-tabbar__item:active { transform: scale(0.94); }
.x-account:active { transform: scale(0.98); }
.x-avatar-btn:active { transform: scale(0.94); }
.x-post-btn:active { transform: scale(0.9); }
.x-fab:active { transform: scale(0.94); }

/* ---------- 图片载入淡入（.x-img--pending 由 main.js 打上） ---------- */
.x-avatar,
.x-logo__img,
.x-profile__avatar,
.x-post__cover img,
.x-detail__cover img,
.x-prose img,
.x-media img,
.x-media video,
.x-grid__item img,
.x-edit__avatar-box img {
  transition: opacity var(--x-dur) var(--x-ease);
}
.x-img--pending {
  opacity: 0;
}

/* ---------- 移动端：弹层从底部滑入 ---------- */
@media (max-width: 705px) {
  .x-modal__panel {
    animation: x-sheet-in var(--x-dur-slow) var(--x-ease-out);
    /* 移动端浏览器地址栏会占掉一截 vh，用 dvh 让面板始终落在可视区内 */
    max-height: min(90vh, 720px);
    max-height: min(88dvh, 720px);
    width: 100%;
  }
  .x-modal {
    padding: 10px;
  }
}

/* reduced-motion 下把这些装饰性位移全部关掉，别只压时长 */
@media (prefers-reduced-motion: reduce) {
  .x-timeline > .x-post,
  .x-replies__body,
  .x-rail__sticky > .x-card,
  .x-detail__body,
  .x-theme-menu,
  .x-nav-more,
  .x-modal__mask,
  .x-modal__panel {
    animation: none !important;
  }
  .x-fab:hover,
  .x-grid__item:hover,
  .x-post:hover .x-post__cover img,
  .x-nav__item:hover .x-nav__icon {
    transform: none !important;
  }
}

/* ==========================================================================
   20. 账号菜单（左下角账号卡片右侧「…」弹出的那个）
   ========================================================================== */
.x-account-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  /* 左栏是 align-items: flex-start，flex 子项不会自动撑满宽度 */
  width: 100%;
  margin-top: auto;
}
/* .x-account 原本自己带 margin-top:auto，现在由外层 wrap 负责贴底 */
.x-account-wrap .x-account {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
.x-account-wrap .x-account__more {
  font-size: 19px;
}

.x-account-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 90;
  min-width: 260px;
  padding: 4px 0;
  border-radius: 16px;
  background: var(--x-bg);
  border: 1px solid var(--x-border);
  box-shadow: 0 0 0 1px var(--x-border), 0 8px 28px var(--x-shadow);
  animation: x-pop-in var(--x-dur) var(--x-ease-out);
  transform-origin: bottom left;
}
.x-account-menu[hidden] {
  display: none !important;
}

.x-account-menu__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--x-border);
}
.x-account-menu__ident {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 20px;
}
.x-account-menu__name {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-account-menu__handle {
  color: var(--x-dim);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.x-account-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--x-text);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--x-dur) var(--x-ease);
}
.x-account-menu__item:hover {
  background: var(--x-bg-active);
}
.x-account-menu__item .x-icon {
  flex-shrink: 0;
  font-size: 19px;
}


/* ==========================================================================
   21. 回复区（halo-plugin-comment-widget）
   --------------------------------------------------------------------------
   评论组件是 Lit + Shadow DOM，内部类名从外面盖不到。
   但它把配色全部收敛成了 --halo-cw-* 自定义属性（见插件源码
   packages/comment-widget/var.css），而自定义属性能穿透 Shadow 边界 ——
   这是官方留的定制入口，也是唯一稳定的定制方式。

   为什么必须覆盖：插件靠 .dark 类或 prefers-color-scheme 判断深色，
   而本主题用的是 data-theme 属性，插件识别不到，于是它在深色主题下
   会退回浅色配色 —— 文字偏深、色块发亮，跟正文完全割裂。

   选择器用 html[data-theme] 而不是 :root，是为了压过插件自己的
   :root / .dark 声明（权重 0-1-1 高于 0-1-0）；再补一条作用在
   comment-widget 元素上的同值声明，防止插件往宿主元素上挂 .dark。
   ========================================================================== */
html[data-theme],
html[data-theme] comment-widget {
  /* 强调色：链接、焦点环、按钮 */
  --halo-cw-primary-1-color: var(--x-accent);
  --halo-cw-primary-2-color: var(--x-blue-hover);
  --halo-cw-primary-3-color: var(--x-accent);

  /* 文字三级 */
  --halo-cw-text-1-color: var(--x-text);
  --halo-cw-text-2-color: var(--x-text);
  --halo-cw-text-3-color: var(--x-dim);

  /* 背景 / 边框三级（插件里 muted-* 是 bg 与 border） */
  --halo-cw-muted-1-color: var(--x-border);
  --halo-cw-muted-2-color: var(--x-bg-active);
  --halo-cw-muted-3-color: var(--x-card);

  /* 字体跟主题走，否则评论区会用插件自带的 1rem 系统字体栈 */
  --halo-cw-base-font-family: var(--x-font);
  --halo-cw-base-font-size: var(--x-fs);
}

/* 插件的 :host 是 width:100% + flex 居中，这里保证它撑满回复区 */
.x-replies__body comment-widget {
  display: block;
  width: 100%;
}

/* ---------- 作者主页：常聊话题 ---------- */
.x-profile__topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.x-profile__topic {
  padding: 3px 12px;
  border-radius: 9999px;
  background: var(--x-bg-active);
  color: var(--x-dim);
  font-size: 14px;
  line-height: 20px;
  text-decoration: none;
  transition: background var(--x-dur) var(--x-ease), color var(--x-dur) var(--x-ease);
}
.x-profile__topic:hover {
  background: var(--x-bg-hover);
  color: var(--x-text);
}

/* ==========================================================================
   22. 通知（Halo 原生通知中心）
   ========================================================================== */
.x-nav__notify {
  position: relative;
}
.x-nav__icon {
  position: relative;
}
.x-nav__badge {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: var(--x-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

.x-notify {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 65;
  width: 400px;
  max-width: calc(100vw - 48px);
  max-height: 70vh;
  overflow-y: auto;
  margin-top: 8px;
  border-radius: 16px;
  background: var(--x-bg);
  border: 1px solid var(--x-border);
  box-shadow: 0 0 0 1px var(--x-border), 0 12px 32px var(--x-shadow);
  animation: x-pop-in var(--x-dur) var(--x-ease-out);
  transform-origin: top left;
}
.x-notify[hidden] {
  display: none !important;
}
.x-notify__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--x-border);
}
.x-notify__title {
  font-size: 17px;
  font-weight: 800;
}
.x-notify__readall {
  border: 0;
  padding: 4px 8px;
  border-radius: 9999px;
  background: transparent;
  color: var(--x-accent);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--x-dur) var(--x-ease);
}
.x-notify__readall:hover {
  background: var(--x-bg-active);
}
.x-notify__status {
  padding: 24px 16px;
  color: var(--x-dim);
  font-size: 15px;
  text-align: center;
}
.x-notify__list {
  padding: 0;
  margin: 0;
  list-style: none;
}
.x-notify__item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--x-border);
  cursor: pointer;
  transition: background var(--x-dur) var(--x-ease);
}
.x-notify__item:last-child {
  border-bottom: 0;
}
.x-notify__item:hover {
  background: var(--x-bg-hover);
}
.x-notify__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: transparent;
}
.x-notify__item.is-unread .x-notify__dot {
  background: var(--x-accent);
}
.x-notify__body {
  min-width: 0;
  flex: 1;
}
.x-notify__itemhead {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.x-notify__itemtitle {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-notify__item.is-unread .x-notify__itemtitle {
  color: var(--x-text);
}
.x-notify__time {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--x-dim);
  font-size: 13px;
}
.x-notify__text {
  margin: 4px 0 0;
  color: var(--x-dim);
  font-size: 14px;
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}
.x-notify__all {
  display: block;
  padding: 12px 16px;
  border-top: 1px solid var(--x-border);
  color: var(--x-accent);
  font-size: 15px;
  text-decoration: none;
}
.x-notify__all:hover {
  background: var(--x-bg-hover);
}

/* 左栏收窄时通知面板靠左展开，避免被裁掉 */
@media (max-width: 1265px) {
  .x-notify {
    left: 100%;
    top: 0;
    margin: 0 0 0 8px;
    transform-origin: top left;
  }
}

/* ---------- 编辑资料弹层里的扩展字段（halo-plugin-X） ---------- */
.x-pluginx {
  margin: 4px 0 16px;
  padding: 12px;
  border: 1px solid var(--x-border);
  border-radius: 12px;
  background: var(--x-bg-hover);
}
.x-pluginx__head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--x-text);
  font-size: 14px;
  font-weight: 700;
}
.x-pluginx__head .x-icon {
  font-size: 16px;
  color: var(--x-accent);
}
.x-pluginx__from {
  margin-left: auto;
  color: var(--x-dim);
  font-size: 12px;
  font-weight: 500;
}
.x-pluginx .x-field:last-child {
  margin-bottom: 0;
}

/* ---------- 加载页（开屏） ---------- */
/* 仿 X App 启动画面：一整屏居中大标识，页面就绪后由 main.js 加 .is-done 淡出。
   这里的 3s 动画是兜底 —— 脚本不可用时也必须让路，不能把访客堵在开屏页。 */
.x-splash {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: var(--x-bg);
  animation: x-splash-out 0.35s ease 3s forwards;
}
.x-splash.is-done {
  /* ⚠️ 必须换一个动画名：同名动画只改参数不会重启，换名才会立刻从头播（提前淡出） */
  animation: x-splash-out-now 0.3s ease forwards;
}
/* 「仅首次访问」模式下，会话内二次加载：head 里的脚本会给 <html> 打上标记，直接不渲染 */
html[data-splash-skip] .x-splash {
  display: none;
}
@keyframes x-splash-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}
@keyframes x-splash-out-now {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.x-splash__icon {
  width: 96px;
  height: 96px;
  color: var(--x-text);
}
.x-splash__img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 22px;
}
.x-splash__text {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 0 24px;
  text-align: center;
}
.x-splash__main {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.15;
}
.x-splash__sub {
  color: var(--x-dim);
  font-size: 14px;
}

@media (max-width: 705px) {
  .x-splash__icon,
  .x-splash__img {
    width: 72px;
    height: 72px;
  }
  .x-splash__main {
    font-size: 28px;
  }
}
@media (prefers-reduced-motion: reduce) {
  /* 对减弱动效的用户直接跳过开屏 */
  .x-splash {
    display: none;
  }
}
