/* ───────── 基础 ───────── */
:root {
  --bg: #08080a;
  --ink: #ece9e3;
  --dim: rgba(236, 233, 227, 0.52);
  --faint: rgba(236, 233, 227, 0.32);
  --line: rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.055);
  --surface: rgba(255, 255, 255, 0.038);
  --accent: #e0455a;
  --maxw: 1180px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: rgba(224, 69, 90, 0.3); }

/* ───────── 氛围层 ───────── */
.glow {
  position: fixed;
  top: -30vh; left: -10vw;
  width: 70vw; height: 70vw;
  max-width: 900px; max-height: 900px;
  background: radial-gradient(circle, rgba(176, 40, 60, 0.16), transparent 62%);
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
  animation: drift 26s ease-in-out infinite alternate;
}
.glow-b {
  top: auto; left: auto;
  bottom: -35vh; right: -15vw;
  background: radial-gradient(circle, rgba(78, 84, 150, 0.16), transparent 62%);
  animation-delay: -8s;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4vw, 3vh, 0) scale(1.12); }
}
.grain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.view { position: relative; z-index: 2; }

/* ───────── 导航 ───────── */
.nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand-mark {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #f0eae0, #b9b2a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text { font-size: 13px; letter-spacing: 0.34em; color: var(--dim); }
.nav-note {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--faint);
  text-align: right;
}

/* ───────── Hero ───────── */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 92px 32px 56px;
}
.eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.42em;
  color: var(--faint);
  margin-bottom: 26px;
}
.display {
  font-size: clamp(42px, 6.6vw, 82px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.022em;
  margin-bottom: 26px;
}
.display em {
  font-style: normal;
  background: linear-gradient(100deg, #f2ece2 12%, #cf8272 52%, #9c7db8 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede {
  max-width: 470px;
  font-size: 15px;
  color: var(--dim);
  line-height: 1.9;
}

/* ───────── 角色墙 ───────── */
.grid {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 32px 40px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.card {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: #101013;
  border: 1px solid var(--line-soft);
  isolation: isolate;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.4s, box-shadow 0.5s;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 24px 60px -22px color-mix(in srgb, var(--accent) 65%, transparent);
}
.card img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 45%;
  filter: saturate(0.88) brightness(0.9) contrast(1.03);
  transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.6s;
}
.card:hover img { transform: scale(1.055); filter: saturate(1) brightness(1); }

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(125% 95% at 50% 14%, transparent 28%, rgba(8, 8, 10, 0.28) 66%, rgba(8, 8, 10, 0.62) 100%);
}
.card::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(6, 6, 8, 0.95) 2%, rgba(6, 6, 8, 0.6) 30%, rgba(6, 6, 8, 0.06) 62%, transparent 78%);
  z-index: 1;
}
.card-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 20px 18px 18px;
}
.card-line {
  width: 22px; height: 2px;
  background: var(--accent);
  margin-bottom: 11px;
  transition: width 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card:hover .card-line { width: 40px; }
.card-name { font-size: 20px; font-weight: 600; letter-spacing: 0.01em; }
.card-book {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--faint);
  margin-top: 5px;
}
.card-tag {
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.6;
  margin-top: 9px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(6px);
  transition: 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card:hover .card-tag { max-height: 48px; opacity: 1; transform: translateY(0); }

.card-skeleton {
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  background: linear-gradient(100deg, #101013 30%, #17171b 50%, #101013 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

/* ───────── 页脚 ───────── */
.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px 32px 70px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--faint);
  line-height: 1.9;
}
.foot-dim { margin-top: 6px; color: rgba(236, 233, 227, 0.22); }

/* ───────── 对话页 ───────── */
.chat-view {
  display: grid;
  grid-template-columns: 236px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.rail {
  border-right: 1px solid var(--line-soft);
  padding: 26px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: rgba(255, 255, 255, 0.012);
  backdrop-filter: blur(8px);
}
.rail-back {
  font-size: 12.5px;
  color: var(--dim);
  padding: 4px 10px;
  display: inline-flex;
  gap: 8px;
  transition: color 0.25s;
}
.rail-back:hover { color: var(--ink); }
.rail-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.25s;
  border-left: 2px solid transparent;
}
.rail-item:hover { background: rgba(255, 255, 255, 0.04); }
.rail-item.on {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--c);
}
.rail-item img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.rail-item span { font-size: 13.5px; color: var(--dim); }
.rail-item.on span { color: var(--ink); }
.rail-foot { margin-top: auto; font-size: 10.5px; color: rgba(236, 233, 227, 0.2); line-height: 1.8; padding-left: 10px; }

.stage {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.stage::before {
  content: "";
  position: absolute;
  top: -40%; left: 30%;
  width: 60vw; height: 60vw;
  max-width: 700px; max-height: 700px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 13%, transparent), transparent 65%);
  filter: blur(40px);
  pointer-events: none;
  transition: background 0.8s;
}

.stage-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  z-index: 3;
  position: relative;
}
.stage-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 15%;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
.stage-id h2 { font-size: 15.5px; font-weight: 600; letter-spacing: 0.02em; }
.stage-id p { font-size: 11.5px; color: var(--faint); letter-spacing: 0.05em; }
.ghost-btn {
  margin-left: auto;
  font-size: 12px;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 6px 13px;
  border-radius: 999px;
  transition: 0.25s;
}
.ghost-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.24); }
.icon-btn { font-size: 17px; padding: 4px 8px; color: var(--dim); }
.only-mobile { display: none; }

.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 30px 26px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 2;
}
.msgs::-webkit-scrollbar { width: 6px; }
.msgs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }

.row { display: flex; gap: 10px; align-items: flex-end; animation: pop 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.row.me { flex-direction: row-reverse; }
.row img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: center 15%; flex: none; opacity: 0.9; }
.bubble {
  max-width: min(74%, 560px);
  padding: 12px 16px;
  border-radius: 15px;
  font-size: 14.8px;
  line-height: 1.78;
  white-space: pre-wrap;
  word-break: break-word;
}
.row.them .bubble {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-bottom-left-radius: 5px;
}
.row.me .bubble {
  background: var(--accent);
  color: #0c0b0d;
  border-bottom-right-radius: 5px;
  font-weight: 450;
}

.caret::after {
  content: "";
  display: inline-block;
  width: 6px; height: 14px;
  background: currentColor;
  opacity: 0.6;
  margin-left: 2px;
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.typing { display: flex; gap: 4px; padding: 6px 2px; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--dim);
  animation: bounce 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ───────── 输入区 ───────── */
.dock {
  padding: 10px 26px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  position: relative;
  z-index: 3;
}
.hints {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}
.hints::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  font-size: 12.5px;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: 0.25s;
}
.chip:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 7px 7px 7px 18px;
  transition: border-color 0.3s, background 0.3s;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: rgba(255, 255, 255, 0.06);
}
.composer textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 14.8px;
  line-height: 1.6;
  padding: 8px 0;
  resize: none;
  max-height: 132px;
}
.composer textarea::placeholder { color: var(--faint); }
.send {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #0c0b0d;
  display: grid;
  place-items: center;
  transition: 0.25s;
}
.send:disabled { opacity: 0.3; cursor: default; }
.send:not(:disabled):hover { transform: scale(1.06); }

.err { font-size: 12.5px; color: #e07a7a; padding: 4px 2px 10px; }

/* ───────── 响应式 ───────── */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .hero { padding-top: 68px; }
}
@media (max-width: 860px) {
  .chat-view { grid-template-columns: 1fr; }
  .rail { display: none; }
  .only-mobile { display: block; }
  .stage-head { padding: 14px 16px; }
  .ghost-btn { padding: 5px 11px; }
}
@media (max-width: 720px) {
  .nav { padding: 22px 20px 0; }
  .hero { padding: 56px 20px 40px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 10px 20px 30px; }
  .card { border-radius: 13px; }
  .card-name { font-size: 17px; }
  .card-book { font-size: 9.5px; letter-spacing: 0.14em; }
  .card-body { padding: 14px 13px 13px; }
  .card-tag { display: none; }
  .nav-note { font-size: 9.5px; letter-spacing: 0.1em; }
  .foot { padding: 26px 20px 50px; }
  .msgs { padding: 20px 16px 4px; }
  .bubble { max-width: 84%; font-size: 14.4px; }
  .dock { padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
