/* 青梦 · 角色大厅 —— 深灰底 + 卡片网格 */
:root {
  --bg: #1a1a1a;
  --bg-side: #141414;
  --panel: #242424;
  --panel-2: #2b2b2b;
  --panel-3: #333;
  --line: #303030;
  --text: #eaeaea;
  --dim: #9a9a9a;
  --dim-2: #6e6e6e;
  --accent: #8b5cf6;
  --accent-2: #a855f7;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); overflow: hidden; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 76px;
  background: var(--bg-side);
  border-right: 1px solid #262626;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  z-index: 20;
}
.brand { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 22px; }
.brand img { width: 44px; height: 44px; border-radius: 13px; }

.side-nav { display: flex; flex-direction: column; gap: 14px; }
.side-button {
  width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: #262626; color: #cfcfcf; cursor: pointer;
  display: grid; place-items: center; transition: .18s;
}
.side-button:hover { background: #333; color: #fff; }
.side-button.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .16);
}
.side-button svg { width: 20px; height: 20px; stroke-width: 1.9; }

.memory-label {
  margin-top: 30px;
  writing-mode: vertical-rl;
  font-size: 12px;
  color: var(--dim-2);
  letter-spacing: .16em;
}
.mini-avatar { margin-top: auto; }
.mini-avatar img {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  border: 2px solid #2a2a2a; display: block;
}

/* ---------- 主区 ---------- */
.main-content {
  margin-left: 76px;
  height: 100vh;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶栏 */
.topbar {
  height: 58px;
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.search-box {
  flex: 0 1 360px;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid transparent;
  transition: .18s;
}
.search-box:focus-within { border-color: #4a4a4a; background: #2a2a2a; }
.search-box svg { width: 16px; height: 16px; color: var(--dim-2); flex: 0 0 auto; }
.search-box input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 13.5px;
}
.search-box input::placeholder { color: #6b6b6b; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.round-action {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--panel); color: #b9b9b9;
  display: grid; place-items: center; cursor: pointer; transition: .18s;
}
.round-action:hover { background: var(--panel-3); color: #fff; }
.round-action svg { width: 16px; height: 16px; }

.credits {
  height: 34px; display: flex; align-items: center; gap: 7px;
  padding: 0 4px 0 12px; border-radius: 9px; background: var(--panel);
  color: #d6b8ff; font-size: 13px;
}
.credits svg { width: 14px; height: 14px; }
.credits span { color: var(--text); }
.credits button {
  height: 26px; padding: 0 11px; border: 0; border-radius: 7px; cursor: pointer;
  background: #22c55e; color: #06240f; font-size: 12px; font-weight: 700;
}

.profile {
  height: 38px; display: flex; align-items: center; gap: 8px;
  padding: 0 10px 0 4px; border-radius: 20px;
  border: 1px solid #2c2c2c; background: #202020; color: var(--text); cursor: pointer;
}
.profile img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.profile span { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.profile b { font-size: 12.5px; font-weight: 600; }
.profile small { font-size: 10.5px; color: var(--dim-2); }
.profile > i { font-style: normal; color: var(--dim-2); font-size: 11px; margin-left: 2px; }

/* banner */
.hero-banner {
  flex: 0 0 128px;
  height: 128px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  margin-bottom: 6px;
  background: linear-gradient(110deg, #2b2b2b, #3a3a3a 50%, #262626);
}
.hero-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: #f2f2f2;
  background: linear-gradient(110deg, #2f2f2f, #3d3d3d 48%, #262626);
  font-size: 34px; font-weight: 700; letter-spacing: .06em;
}
.hero-fallback small { font-size: 11px; font-weight: 400; letter-spacing: .32em; color: #b9b9b9; }

/* 角色 / 创作者 */
.mode-switch {
  flex: 0 0 auto;
  display: flex; justify-content: center; gap: 34px;
  padding: 10px 0 12px;
}
.mode {
  border: 0; background: none; cursor: pointer;
  font-size: 15px; color: #7d7d7d; padding: 0 2px 4px;
  border-bottom: 2px solid transparent; transition: .18s;
}
.mode:hover { color: #c9c9c9; }
.mode.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }

/* 筛选行 */
.filter-row {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  height: 32px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 16px;
  background: var(--panel); color: #c2c2c2;
  font-size: 12.5px; cursor: pointer; transition: .18s; white-space: nowrap;
}
.tab svg { width: 14px; height: 14px; stroke-width: 2; }
.tab:hover { background: var(--panel-3); color: #fff; }
.tab.active {
  background: linear-gradient(135deg, #a855f7, #8b5cf6);
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px -4px rgba(139, 92, 246, .8);
}

#genderSelect {
  height: 32px; padding: 0 30px 0 13px;
  border-radius: 16px; border: 1px solid #3a3a3a;
  background: var(--panel) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 11px center;
  color: #c2c2c2; font-size: 12.5px; cursor: pointer; appearance: none; outline: 0;
}
#genderSelect:hover { background-color: var(--panel-3); }

.filter-button {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid #3a3a3a; background: var(--panel); color: #b9b9b9;
  display: grid; place-items: center; cursor: pointer; margin-left: auto; transition: .18s;
}
.filter-button:hover { background: var(--panel-3); color: #fff; }
.filter-button svg { width: 15px; height: 15px; }

/* 子筛选 */
.sub-filters {
  flex: 0 0 auto;
  display: flex; gap: 7px; flex-wrap: nowrap; overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}
.sub-filters::-webkit-scrollbar { display: none; }
.sub-filter {
  flex: 0 0 auto;
  height: 26px; padding: 0 11px;
  border: 1px solid #2f2f2f; border-radius: 13px;
  background: transparent; color: #8d8d8d;
  font-size: 11.5px; cursor: pointer; transition: .16s; white-space: nowrap;
}
.sub-filter:hover { color: #d8d8d8; border-color: #454545; }
.sub-filter.active { background: #333; border-color: #4a4a4a; color: #fff; }

/* 区块标题 */
.recommend-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 0 10px;
}
.recommend-head h1 { margin: 0; font-size: 16px; font-weight: 600; color: #fff; }
#shuffleButton {
  height: 30px; padding: 0 15px;
  border: 1px solid #3a3a3a; border-radius: 15px;
  background: var(--panel); color: #c2c2c2;
  font-size: 12.5px; cursor: pointer; transition: .18s;
}
#shuffleButton:hover { background: var(--panel-3); color: #fff; border-color: #4c4c4c; }
#shuffleButton:active { transform: scale(.97); }

/* ---------- 卡片网格 ---------- */
.card-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  padding-bottom: 24px;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
.card-grid::-webkit-scrollbar { width: 6px; }
.card-grid::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 6px; }
.card-grid::-webkit-scrollbar-track { background: transparent; }

.character-card {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 150%;
  border-radius: 10px;
  overflow: hidden;
  background: #242424;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
}
.character-card:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -8px rgba(0, 0, 0, .85); }

.card-cover {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #242424;
}
.character-card::after {
  content: '';
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, .42) 0%,
    rgba(0, 0, 0, .06) 22%,
    rgba(0, 0, 0, 0) 40%,
    rgba(0, 0, 0, .62) 72%,
    rgba(0, 0, 0, .88) 100%);
}
.img-fail {
  background-image: linear-gradient(155deg, #333, #242424 55%, #2c2c2c) !important;
  display: block;
}

.card-author {
  position: absolute;
  top: 8px; left: 8px; z-index: 3;
  max-width: calc(100% - 44px);
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 11px; color: #e2e2e2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-more {
  position: absolute;
  top: 8px; right: 8px; z-index: 3;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 0; border-radius: 7px;
  background: rgba(0, 0, 0, .38);
  color: #dedede; font-size: 13px; line-height: 1;
  cursor: pointer; opacity: 0; transition: .16s;
}
.character-card:hover .card-more { opacity: 1; }
.card-more:hover { background: rgba(0, 0, 0, .62); }

.card-content {
  position: absolute;
  left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 10px 10px 11px;
  display: flex; flex-direction: column;
}
.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  line-height: 1.32;
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.card-tags {
  font-size: 10.5px;
  color: #b3b3b3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.card-desc {
  font-size: 10.5px;
  color: #969696;
  margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-stats {
  display: flex; align-items: center; gap: 11px;
  font-size: 10.5px; color: #9d9d9d;
}
.card-stats span { display: inline-flex; align-items: center; gap: 3px; }
.card-stats svg { width: 11px; height: 11px; stroke-width: 2; opacity: .8; }

.skeleton-card {
  width: 100%;
  height: 0;
  padding-bottom: 150%;
  border-radius: 10px;
  background: linear-gradient(100deg, #242424 20%, #2e2e2e 40%, #242424 60%);
  background-size: 200% 100%;
  animation: sk 1.3s linear infinite;
}
@keyframes sk {
  0% { background-position: 120% 0; }
  100% { background-position: -20% 0; }
}

.load-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  font-size: 12.5px;
  color: var(--dim-2);
}
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 70px 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--dim);
}

/* ---------- 浮层 ---------- */
.profile-menu {
  position: fixed;
  top: 60px; right: 24px;
  z-index: 30;
  min-width: 150px;
  padding: 6px;
  border-radius: 10px;
  background: #262626;
  border: 1px solid #363636;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .9);
  display: none;
}
.profile-menu.open { display: block; }
.profile-menu button {
  display: block; width: 100%;
  padding: 9px 12px;
  border: 0; border-radius: 7px;
  background: none; color: #d5d5d5;
  font-size: 13px; text-align: left; cursor: pointer;
}
.profile-menu button:hover { background: #333; color: #fff; }

.filter-panel {
  position: fixed;
  top: 96px; right: 24px;
  z-index: 30;
  width: 240px;
  padding: 14px;
  border-radius: 12px;
  background: #262626;
  border: 1px solid #363636;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .9);
  display: none;
}
.filter-panel.open { display: block; }
.panel-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; font-weight: 600; color: #fff;
  margin-bottom: 12px;
}
.panel-title button {
  border: 0; background: none; color: var(--dim);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.filter-panel label {
  display: block; margin-bottom: 11px;
  font-size: 11.5px; color: var(--dim-2);
}
.filter-panel select {
  display: block; width: 100%; margin-top: 5px;
  height: 32px; padding: 0 10px;
  border-radius: 8px; border: 1px solid #3a3a3a;
  background: #1e1e1e; color: var(--text);
  font-size: 12.5px; outline: 0;
}
.apply-filter {
  width: 100%; height: 34px;
  border: 0; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, #a855f7, #8b5cf6);
  color: #fff; font-size: 13px; font-weight: 600;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1400px) { .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 1240px) { .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1000px) {
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sidebar { width: 64px; }
  .main-content { margin-left: 64px; padding: 0 16px; }
  .brand, .brand img { width: 38px; height: 38px; }
  .side-button { width: 38px; height: 38px; }
}
@media (max-width: 760px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-banner { display: none; }
  .top-actions .round-action { display: none; }
  .profile span { display: none; }
  .mode-switch { gap: 24px; padding: 8px 0 10px; }
  .sub-filters { overflow-x: auto; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .filter-row { gap: 8px; }
  #genderSelect { flex: 0 0 auto; }
  .recommend-head h1 { font-size: 14px; }
  #shuffleButton { height: 28px; padding: 0 12px; font-size: 12px; }
}

/* ---------- 对话界面 ---------- */
.chat-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(8, 8, 10, .62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.chat-modal.open { display: flex; animation: chatIn .22s ease; }
@keyframes chatIn { from { opacity: 0 } to { opacity: 1 } }

.chat-panel {
  width: min(820px, 94vw);
  height: min(760px, 88vh);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: #1c1c1c;
  border: 1px solid #333;
  box-shadow: 0 40px 100px -24px rgba(0, 0, 0, .95);
  animation: chatUp .26s cubic-bezier(.2, .9, .3, 1.05);
}
@keyframes chatUp { from { opacity: 0; transform: translateY(12px) scale(.985) } to { opacity: 1; transform: none } }

.chat-head {
  flex: 0 0 62px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 14px;
  background: #222;
  border-bottom: 1px solid #2e2e2e;
}
.chat-back {
  width: 32px; height: 32px; flex: 0 0 32px;
  border: 0; border-radius: 9px;
  background: #2c2c2c; color: #d0d0d0;
  font-size: 20px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: .16s;
}
.chat-back:hover { background: #383838; color: #fff; }
.chat-ava {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 50%; object-fit: cover;
  background: #2a2a2a; border: 1px solid #3a3a3a;
}
.chat-meta { flex: 1; min-width: 0; }
.chat-meta b {
  display: block; font-size: 14px; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-meta small { display: block; margin-top: 2px; font-size: 11px; color: #7d7d7d; }
.chat-clear {
  flex: 0 0 auto;
  height: 28px; padding: 0 12px;
  border: 1px solid #3a3a3a; border-radius: 8px;
  background: transparent; color: #9a9a9a;
  font-size: 11.5px; cursor: pointer; transition: .16s;
}
.chat-clear:hover { background: #2e2e2e; color: #e0e0e0; }

.chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 6px; }

.msg { display: flex; max-width: 86%; }
.msg.ai { align-self: flex-start; }
.msg.me { align-self: flex-end; }
.msg.sys { align-self: center; max-width: 100%; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.ai .bubble { background: #2a2a2a; color: #e8e8e8; border-top-left-radius: 4px; }
.msg.me .bubble {
  background: linear-gradient(135deg, #8b5cf6, #6d4de0);
  color: #fff; border-top-right-radius: 4px;
}
.msg.sys .bubble {
  background: transparent; color: #8a8a8a;
  font-size: 11.5px; padding: 4px 8px; text-align: center;
}
.msg .bubble em { color: #b9a6e8; font-style: italic; }
.msg.me .bubble em { color: #e2d6ff; }

.typing { display: inline-flex; gap: 4px; padding: 12px 15px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #7a7a7a;
  animation: tp 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes tp {
  0%, 60%, 100% { opacity: .3; transform: translateY(0) }
  30% { opacity: 1; transform: translateY(-3px) }
}

.chat-input {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px 14px;
  background: #1c1c1c;
  border-top: 1px solid #2a2a2a;
}
#chatText {
  flex: 1;
  min-height: 42px;
  max-height: 140px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #343434;
  background: #242424;
  color: #eaeaea;
  font-size: 13.5px;
  line-height: 1.5;
  font-family: inherit;
  resize: none;
  outline: 0;
  transition: .16s;
}
#chatText:focus { border-color: #5a4a80; background: #262626; }
#chatText::placeholder { color: #6b6b6b; }
.chat-send {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 20px;
  border: 0; border-radius: 12px;
  background: linear-gradient(135deg, #a855f7, #8b5cf6);
  color: #fff; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: .18s;
  box-shadow: 0 8px 20px -8px rgba(139, 92, 246, .9);
}
.chat-send:hover { transform: translateY(-1px); }
.chat-send:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

@media (max-width: 760px) {
  .chat-modal { padding: 0; }
  .chat-panel { width: 100vw; height: 100vh; border-radius: 0; border: 0; }
  .chat-clear { display: none; }
  .msg { max-width: 92%; }
}
