/* ===========================================================
   梦境：黑底粒子圣诞树
   =========================================================== */

:root {
  --dream-ink: #e9f3f8;
  --dream-soft: rgba(233, 243, 248, 0.62);
  --dream-faint: rgba(233, 243, 248, 0.4);
  --dream-glass: rgba(255, 255, 255, 0.07);
  --dream-line: rgba(255, 255, 255, 0.16);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body.dream {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #0a1219 0%, #050a0e 55%, #020507 100%);
  color: var(--dream-ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

.dream-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 42%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.55) 78%, rgba(0, 0, 0, 0.82) 100%),
    linear-gradient(180deg, rgba(4, 8, 12, 0.6) 0%, rgba(0, 0, 0, 0) 22%);
}

/* ---------- 顶栏 ---------- */

.dream-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) clamp(14px, 3vw, 28px) 14px;
  pointer-events: none;
}

.dream-back,
.dream-tool {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dream-ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--dream-line);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.25s ease, transform 0.25s ease;
}

.dream-back:hover,
.dream-tool:hover {
  background: rgba(255, 255, 255, 0.13);
  transform: translateY(-1px);
}

.dream-tool[disabled] {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.dream-tools {
  display: flex;
  gap: 8px;
}

.dream-now {
  position: fixed;
  top: calc(58px + env(safe-area-inset-top));
  right: clamp(14px, 3vw, 28px);
  z-index: 5;
  margin: 0;
  max-width: 62vw;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--dream-faint);
  pointer-events: none;
  text-align: right;
}

/* ---------- 漂浮在树旁的文章 ---------- */

.dream-labels {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.dream-label {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 46vw;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 14, 20, 0.42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.95);
  color: var(--dream-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  pointer-events: auto;
  opacity: 0;
  will-change: transform, opacity;
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease,
    color 0.22s ease;
}

.dream-label-in {
  display: block;
  animation: label-in 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes label-in {
  from {
    opacity: 0;
    filter: blur(7px);
  }
  to {
    opacity: 1;
    filter: none;
  }
}

.dream-label:hover,
.dream-label:focus-visible {
  background: rgba(18, 30, 40, 0.82);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08), 0 14px 30px -14px rgba(0, 0, 0, 0.95);
  color: #ffffff;
}

/* ---------- 底部提示 ---------- */

  .dream-tip {
    position: fixed;
    left: clamp(14px, 3vw, 28px);
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 4;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--dream-faint);
    pointer-events: none;
  }

  .dream-tip #dreamCount {
    color: var(--dream-ink);
    font-weight: 700;
  }

@media (max-width: 760px) {
  .dream-tip {
    right: 14px;
    left: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    font-size: 9px;
    line-height: 1.8;
    text-align: center;
  }

  .dream-now {
    top: calc(56px + env(safe-area-inset-top));
  }

  .dream-back,
  .dream-tool {
    padding: 8px 13px;
    font-size: 11.5px;
  }

  .dream-label {
    max-width: 52vw;
    padding: 5px 10px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dream-back,
  .dream-tool,
  .dream-post {
    transition: none;
  }
}

/* ---------- 梦里的文章浮窗 ---------- */

.avatar-slot {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
}

.avatar {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.96);
}

.avatar img,
.avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar svg {
  display: block;
  width: 64%;
  height: 64%;
}

.dream-reader-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 30px);
  overflow-y: auto;
  animation: layer-in 0.3s ease both;
}

.dream-reader-layer[hidden],
.dream-reader[hidden] {
  display: none !important;
}

@keyframes layer-in {
  from {
    opacity: 0;
  }
}

.dream-reader-scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 10, 0.62);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
}

.dream-reader {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: min(84vh, 920px);
  margin: auto;
  padding: clamp(18px, 3vw, 34px);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(20, 29, 38, 0.9), rgba(9, 15, 21, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.17);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  backdrop-filter: blur(26px) saturate(140%);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: sheet-up 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }
}

.dream-reader:focus,
.dream-reader:focus-visible {
  outline: none;
}

.dream-reader-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dream-reader-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--dream-faint);
}

.dream-reader-author {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0;
  color: #cfe4f2;
}

.dream-reader-title {
  margin: 0 0 14px;
  font-size: clamp(21px, 3.4vw, 30px);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--dream-ink);
}

.dream-reader-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  font-size: clamp(14.5px, 1.5vw, 16px);
  line-height: 1.95;
  color: rgba(233, 243, 248, 0.88);
  overflow-wrap: break-word;
}

.dream-reader-body::-webkit-scrollbar {
  width: 6px;
}

.dream-reader-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.dream-reader-body p {
  margin: 0 0 1.1em;
}

.dream-reader-body p:last-child {
  margin-bottom: 0;
}

.dream-reader-body img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 0 auto 1.2em;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.dream-reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.dream-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 30;
  margin: 0;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dream-ink);
  background: rgba(16, 24, 32, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.dream-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 760px) {
  .dream-reader-layer {
    padding: 0;
    align-items: stretch;
  }

  .dream-reader {
    width: 100%;
    max-width: none;
    max-height: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: calc(14px + env(safe-area-inset-top)) 16px
      calc(20px + env(safe-area-inset-bottom));
  }

  .dream-reader-top {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -14px -16px 14px;
    padding: 14px 16px 12px;
    background: linear-gradient(
      180deg,
      rgba(16, 24, 32, 0.98) 0%,
      rgba(13, 20, 27, 0.92) 80%,
      rgba(13, 20, 27, 0) 100%
    );
  }

  .dream-reader-actions .dream-tool {
    flex: 1 1 auto;
    justify-content: center;
  }
}
