/* p2-home-x-feed-upgrade — persist/counts/toast/media on collapse
 * Warm gold #dfcaaa locked. art=94 / streaming / hosting CTA untouched.
 * A) × collapse (top-right) + expand pill; localStorage home-x-feed-collapsed
 * B) Density: ~58vh/520 default; wide floating ≤54vh/500 (not half-screen stretch)
 *    1280×800 still ≥2 cards, media uncapped-crop policy kept (max-height 110)
 * Base: tall-fix (tab hint, 四字动作). Preview only — no live push.
 */
:root {
  --home-accent: #dfcaaa;
  --home-x-gold: #dfcaaa;
  --home-x-gold-soft: rgba(223, 202, 170, 0.22);
  --home-x-gold-line: rgba(223, 202, 170, 0.36);
  --home-x-ink: #f7f3ec;
  --home-x-muted: #c9c0b4;
  --home-x-glass: rgba(18, 15, 12, 0.62);
  --home-x-card: rgba(28, 24, 20, 0.72);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---- shell: desktop right / lower safe zone ----
 * z-index 43 > CTA/scene (41) / rail (40) so in-panel clicks land here;
 * still << music panel (9500). pointer-events auto explicit.
 */
.home-x-feed {
  --home-accent: #dfcaaa;
  position: fixed;
  z-index: 43;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
  top: auto;
  left: auto;
  width: min(380px, calc(100vw - 100px));
  max-height: min(58vh, 520px);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 10px 12px;
  border: 1px solid var(--home-x-gold-line);
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(42, 34, 26, 0.55), var(--home-x-glass));
  color: var(--home-x-ink);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(28px) saturate(1.3);
  -webkit-backdrop-filter: blur(28px) saturate(1.3);
  font: 13.5px/1.45 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: auto;
  isolation: isolate;
}

.home-x-feed[hidden] { display: none !important; }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .home-x-feed { background: rgba(18, 15, 12, 0.92); }
}

/* ---- tabs ---- */
.home-x-tabs {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
  padding: 2px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.home-x-tab {
  flex: 1 1 0;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 8px 10px;
  min-height: 36px;
  background: transparent;
  color: var(--home-x-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
  pointer-events: auto;
}

.home-x-tab:hover { color: var(--home-x-ink); background: var(--home-x-gold-soft); }
.home-x-tab:focus-visible { outline: 2px solid var(--home-x-gold); outline-offset: 1px; }

.home-x-tab.is-active,
.home-x-tab[aria-selected="true"] {
  color: #1a1612;
  background: var(--home-x-gold);
  border-color: rgba(223, 202, 170, 0.55);
}

/* ---- composer (logged-in + guest CTA bar) ---- */
.home-x-composer {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--home-x-gold-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.home-x-composer[hidden] { display: none !important; }

.home-x-composer-input {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--home-x-ink);
  font: inherit;
  padding: 6px 4px;
  outline: none;
}

.home-x-composer-input[hidden] { display: none !important; }
.home-x-composer-input::placeholder { color: var(--home-x-muted); }
.home-x-composer:focus-within {
  border-color: var(--home-x-gold);
  box-shadow: 0 0 0 1px rgba(223, 202, 170, 0.35);
}

.home-x-composer-submit {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--home-x-gold-line);
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 32px;
  background: var(--home-x-gold-soft);
  color: var(--home-x-gold);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.home-x-composer-submit[hidden] { display: none !important; }
.home-x-composer-submit:disabled { opacity: 0.4; cursor: not-allowed; }
.home-x-composer-submit:not(:disabled):hover {
  background: var(--home-x-gold);
  color: #1a1612;
}

/* guest compose CTA (replaces input when logged out) */
.home-x-composer--guest {
  justify-content: center;
  padding: 4px;
}
.home-x-guest-compose {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px dashed var(--home-x-gold-line);
  background: var(--home-x-gold-soft);
  color: var(--home-x-gold);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
}
.home-x-guest-compose:hover {
  background: var(--home-x-gold);
  color: #1a1612;
  border-style: solid;
}
.home-x-guest-compose:focus-visible { outline: 2px solid var(--home-x-gold); outline-offset: 1px; }
.home-x-guest-compose[hidden] { display: none !important; }

/* ---- timeline ---- */
.home-x-timeline {
  flex: 1 1 auto;
  min-height: 168px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(223, 202, 170, 0.35) transparent;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.home-x-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  padding: 8px 10px 6px;
  border: 1px solid rgba(223, 202, 170, 0.18);
  border-radius: 16px;
  background: var(--home-x-card);
  transition: border-color 140ms ease, background 140ms ease;
  pointer-events: auto;
}

.home-x-card:hover {
  border-color: var(--home-x-gold-line);
  background: rgba(36, 30, 24, 0.82);
}

.home-x-card--system {
  grid-template-columns: 1fr;
  border-style: dashed;
  color: var(--home-x-muted);
}

.home-x-card--radio {
  border-color: rgba(223, 202, 170, 0.32);
  cursor: pointer;
}

.home-x-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(223, 202, 170, 0.16);
  color: var(--home-x-gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
  pointer-events: auto;
  touch-action: manipulation;
}
.home-x-avatar[data-bridge-action] { cursor: pointer; }
.home-x-avatar[data-bridge-action]:hover {
  background: rgba(223, 202, 170, 0.32);
  box-shadow: 0 0 0 2px rgba(223, 202, 170, 0.35);
}
.home-x-avatar img { width: 100%; height: 100%; object-fit: cover; }

.home-x-meta {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  margin-bottom: 4px;
}
.home-x-name { font-weight: 700; color: var(--home-x-ink); }
.home-x-name[data-bridge-action] { cursor: pointer; }
.home-x-name[data-bridge-action]:hover { color: var(--home-x-gold); text-decoration: underline; }
.home-x-qid { color: var(--home-x-muted); font-size: 12px; }
.home-x-ts { color: var(--home-x-muted); font-size: 12px; margin-left: auto; }

.home-x-body {
  margin: 0;
  color: var(--home-x-ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.home-x-media {
  margin-top: 8px;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 110px;
  border-radius: 12px;
  object-fit: cover;
  object-position: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(223, 202, 170, 0.14);
  display: block;
  pointer-events: none; /* don't steal action clicks */
  flex-shrink: 0;
}

.home-x-quote {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--home-x-gold);
  border-radius: 0 10px 10px 0;
  background: rgba(0, 0, 0, 0.28);
  color: var(--home-x-muted);
  font-size: 12.5px;
}
.home-x-quote strong { color: var(--home-x-ink); font-weight: 600; }

.home-x-radio-row {
  display: flex; align-items: center; gap: 10px;
}
.home-x-radio-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--home-x-gold);
  box-shadow: 0 0 0 3px rgba(223, 202, 170, 0.22);
  flex-shrink: 0;
}
.home-x-radio-dot[data-status="idle"] {
  background: var(--home-x-muted);
  box-shadow: none;
}

.home-x-actions {
  display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}
.home-x-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--home-x-muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  min-height: 32px;
  min-width: 44px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}
.home-x-action:hover {
  color: var(--home-x-gold);
  background: var(--home-x-gold-soft);
}
.home-x-action:focus-visible { outline: 2px solid var(--home-x-gold); outline-offset: 1px; }

.home-x-empty {
  margin: 12px 4px;
  text-align: center;
  color: var(--home-x-muted);
  font-size: 13px;
}
.home-x-empty a,
.home-x-empty .home-x-empty-cta,
.home-x-card--system .home-x-empty-cta {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--home-x-gold-line);
  background: var(--home-x-gold-soft);
  color: var(--home-x-gold);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  box-sizing: border-box;
  line-height: 1.4;
}
.home-x-empty a:hover,
.home-x-empty .home-x-empty-cta:hover,
.home-x-card--system .home-x-empty-cta:hover {
  background: var(--home-x-gold);
  color: #1a1612;
}


/* ---- guest following-tab login hint ---- */
.home-x-follow-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 2px 4px;
  padding: 16px 14px;
  border: 1px dashed var(--home-x-gold-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  text-align: center;
  color: var(--home-x-muted);
  font-size: 13px;
  line-height: 1.5;
}
.home-x-follow-hint strong {
  color: var(--home-x-ink);
  font-weight: 650;
  font-size: 13.5px;
}
.home-x-follow-hint .home-x-empty-cta {
  margin-top: 2px;
}


/* ---- collapse control (top-right ×) ---- */
.home-x-feed {
  /* room for absolute × without overlapping tabs */
  padding-top: 12px;
}
.home-x-collapse {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 32px;
  height: 32px;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--home-x-muted);
  font: 18px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.home-x-collapse:hover {
  color: var(--home-x-ink);
  background: var(--home-x-gold-soft);
  border-color: var(--home-x-gold-line);
}
.home-x-collapse:focus-visible {
  outline: 2px solid var(--home-x-gold);
  outline-offset: 1px;
}

/* tabs leave room for × */
.home-x-tabs {
  padding-right: 36px;
}

/* ---- expand pill (shown when panel collapsed) ---- */
.home-x-expand {
  position: fixed;
  z-index: 44;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
  appearance: none;
  border: 1px solid var(--home-x-gold-line);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 40px;
  background: linear-gradient(135deg, rgba(42, 34, 26, 0.78), rgba(18, 15, 12, 0.88));
  color: var(--home-x-gold);
  font: 600 13px/1.3 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  pointer-events: auto;
}
.home-x-expand[hidden] { display: none !important; }
.home-x-expand:hover {
  background: var(--home-x-gold);
  color: #1a1612;
}
.home-x-expand:focus-visible {
  outline: 2px solid var(--home-x-gold);
  outline-offset: 2px;
}

/* ---- FAB (logged-in) ---- */
.home-x-compose-fab {
  position: fixed;
  z-index: 44;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(100px, calc(env(safe-area-inset-bottom) + 92px));
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--home-x-gold-line);
  background: linear-gradient(135deg, rgba(42, 34, 26, 0.75), rgba(18, 15, 12, 0.85));
  color: var(--home-x-gold);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}
.home-x-compose-fab[hidden] { display: none !important; }
.home-x-compose-fab:hover { background: var(--home-x-gold); color: #1a1612; }
.home-x-compose-fab:focus-visible { outline: 2px solid var(--home-x-gold); outline-offset: 2px; }

/* ---- mobile: above primary CTA, full-ish width, leave face clear ---- */
@media (max-width: 700px) {
  .home-x-feed {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    width: auto;
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 86px));
    top: auto;
    max-height: min(44vh, 400px);
    min-height: 220px;
    border-radius: 18px;
  }
  .home-x-compose-fab,
  .home-x-expand {
    bottom: max(100px, calc(env(safe-area-inset-bottom) + 90px));
    right: max(16px, env(safe-area-inset-right));
  }
  .home-x-action { min-height: 36px; padding: 8px 10px; }
}

/* wide desktop: floating card on right — denser, not half-screen stretch; face clear */
@media (min-width: 1100px) {
  .home-x-feed {
    /* Bottom-anchored floating card; max-height caps so it is not a tall stretch.
       Face stays left-center / upper — panel stays lower-right. */
    top: auto;
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 72px));
    max-height: min(54vh, 500px);
    min-height: 280px;
    width: min(380px, 26vw);
    right: max(24px, env(safe-area-inset-right));
  }
  .home-x-expand {
    right: max(24px, env(safe-area-inset-right));
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 72px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-x-tab,
  .home-x-card,
  .home-x-action,
  .home-x-compose-fab,
  .home-x-collapse,
  .home-x-expand { transition: none; }
}

/* ---- p2-home-x-feed-upgrade additions ---- */

.home-x-action-count {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: inherit;
  opacity: 0.78;
}
.home-x-action.is-active {
  color: var(--home-x-gold);
  font-weight: 650;
}
.home-x-action.is-active .home-x-action-count { opacity: 1; }

.home-x-avatar.is-following,
.home-x-name.is-following {
  box-shadow: 0 0 0 2px rgba(223, 202, 170, 0.55);
}
.home-x-name.is-following { color: var(--home-x-gold); }

.home-x-char-count {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--home-x-muted);
  font-variant-numeric: tabular-nums;
  min-width: 3.2em;
  text-align: right;
}
.home-x-char-count.is-warn { color: #e8b87a; }
.home-x-char-count[hidden] { display: none !important; }

.home-x-refresh {
  position: absolute;
  top: 8px;
  right: 42px;
  z-index: 5;
  width: 32px;
  height: 32px;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--home-x-muted);
  font: 16px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.home-x-refresh:hover {
  color: var(--home-x-ink);
  background: var(--home-x-gold-soft);
  border-color: var(--home-x-gold-line);
}
.home-x-refresh:focus-visible {
  outline: 2px solid var(--home-x-gold);
  outline-offset: 1px;
}

/* leave room for × + ↻ */
.home-x-tabs { padding-right: 72px; }

.home-x-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(8px);
  z-index: 8;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--home-x-gold-line);
  background: rgba(18, 15, 12, 0.92);
  color: var(--home-x-gold);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-x-toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .home-x-toast { transition: none; }
}
