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

:root {
  /* 淡雅阳光配色（低饱和 / 奶油感） */
  --bg: #fffdf9;
  --panel: #ffffff;
  --panel-2: #fffaf1;
  --line: #ffeeda;
  --line-strong: #ffe2bd;
  --text: #4d443c;
  --muted: #b7a795;
  --accent: #ffc79b;
  --accent-2: #ffe7b8;
  --accent-deep: #d98f56;
  --me-a: #ffe0c2;
  --me-b: #ffd0a8;
  --err: #e07b7b;
  --ok: #7fbf8f;
  --shadow-soft: 0 4px 14px rgba(217, 143, 86, .07);
  --shadow-card: 0 8px 24px rgba(217, 143, 86, .09);
}

html, body { height: 100%; }

body {
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
  background:
    radial-gradient(900px 460px at 12% -8%, #fff8dc 0%, rgba(255, 248, 220, 0) 62%),
    radial-gradient(720px 420px at 88% -6%, #eaf6ff 0%, rgba(234, 246, 255, 0) 58%),
    radial-gradient(600px 420px at 50% 118%, #fff3e2 0%, rgba(255, 243, 226, 0) 65%),
    var(--bg);
}

.app { height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }

/* ---------- 角色背景图层（只有配了背景的角色才显示） ---------- */
.bg-photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center 28%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .9s ease;
  filter: saturate(.94) brightness(1.03);
}
/* 一层极淡的奶油色薄纱，让照片和页面底色"贴合" */
.bg-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, .42) 0%, rgba(255, 253, 249, .18) 45%, rgba(255, 253, 249, .50) 100%);
}

/* 竖版人像模式：左边缘渐隐，让人物自然融进背景 */
.bg-photo.mask-left {
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 42%);
  mask-image: linear-gradient(to right, transparent 0%, #000 42%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(217, 143, 86, .05);
}
.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  background: linear-gradient(100deg, #d98f56, #ffbe86 60%, #ffd88f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.status { font-size: 12px; color: var(--muted); }
.status.ok::before { content: "● "; color: var(--ok); }
.status.err { color: var(--err); }
.status.err::before { content: "● "; color: var(--err); }

.logout-btn {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.logout-btn:hover {
  color: var(--accent-deep);
  border-color: var(--line-strong);
  background: #fff7ea;
}

/* ---------- 主体 ---------- */
.main { flex: 1 1 auto; display: flex; min-height: 0; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 196px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, .70);
  backdrop-filter: blur(6px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 12px;
}
.sidebar-title {
  font-size: 12px;
  color: var(--muted);
  padding: 0 8px;
  letter-spacing: 1.5px;
}
.persona-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  overflow-y: auto;
}
.persona {
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  transition: transform .12s, background .15s, border-color .15s;
  user-select: none;
}
.persona:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: #fffdf8;
}
.persona.active {
  background: linear-gradient(135deg, #fff0dc, #ffe3c2);
  border-color: #ffd9a8;
  color: var(--accent-deep);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(217, 143, 86, .12);
}

.clear-btn {
  flex: 0 0 auto;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(224, 123, 123, .07);
  color: var(--err);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.clear-btn:hover {
  background: rgba(224, 123, 123, .13);
  border-color: rgba(224, 123, 123, .25);
}

/* ---------- 聊天区 ---------- */
.chat { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { display: flex; }
.msg.me { justify-content: flex-end; }
.msg.her { justify-content: flex-start; }

.bubble {
  max-width: min(74%, 700px);
  padding: 11px 15px;
  border-radius: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
}
.msg.her .bubble {
  background: var(--her, #ffffff);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  color: var(--text);
}
.msg.me .bubble {
  background: linear-gradient(135deg, var(--me-a), var(--me-b));
  border: 1px solid #ffdfc0;
  border-bottom-right-radius: 5px;
  color: var(--me-text, #7a5233);
  box-shadow: 0 4px 14px rgba(217, 143, 86, .10);
}

.bubble.typing::after {
  content: "▋";
  animation: blink 1s steps(2, start) infinite;
  color: var(--accent-deep);
  margin-left: 2px;
}
@keyframes blink { to { visibility: hidden; } }

.bubble.error {
  color: var(--err);
  border-color: rgba(224, 123, 123, .35);
  background: #fffaf9;
}

.empty-hint {
  color: var(--muted);
  text-align: center;
  margin: auto;
  font-size: 13px;
  background: rgba(255, 255, 255, .8);
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px dashed var(--line-strong);
}

/* ---------- 输入区 ---------- */
.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
}
.composer textarea {
  flex: 1 1 auto;
  resize: none;
  max-height: 140px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer textarea:focus {
  border-color: #ffd6a8;
  box-shadow: 0 0 0 3px rgba(255, 199, 155, .22);
}
.composer button {
  flex: 0 0 auto;
  width: 92px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffcda3, #ffe7b8);
  color: #a1622f;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(217, 143, 86, .14);
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.composer button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(217, 143, 86, .20);
}
.composer button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb {
  background: #ffe6cc;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: #ffd9b3; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
  .sidebar { width: 128px; }
  .bubble { max-width: 88%; }
  .brand { font-size: 14px; }
}

/* ---------- 登录遮罩 ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(700px 380px at 20% 0%, rgba(255, 236, 190, .55), transparent 60%),
    radial-gradient(600px 360px at 85% 10%, rgba(224, 242, 255, .55), transparent 60%),
    rgba(255, 253, 249, .90);
  backdrop-filter: blur(8px);
}
.login-overlay[hidden] { display: none; }

.login-box {
  width: 330px;
  padding: 30px 28px 26px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.login-title {
  font-size: 19px;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(100deg, #d98f56, #ffbe86 60%, #ffd88f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-sub { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 2px; }

.login-box input {
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdfa;
  color: var(--text);
  font-size: 14px;
  outline: none;
  letter-spacing: 1px;
  transition: border-color .15s, box-shadow .15s;
}
.login-box input:focus {
  border-color: #ffd6a8;
  box-shadow: 0 0 0 3px rgba(255, 199, 155, .22);
}

.login-box button {
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffcda3, #ffe7b8);
  color: #a1622f;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(217, 143, 86, .15);
  transition: transform .12s, opacity .15s;
}
.login-box button:hover:not(:disabled) { transform: translateY(-1px); }
.login-box button:disabled { opacity: .55; cursor: not-allowed; }

.login-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--err);
  text-align: center;
}

/* ---------- 自定义确认弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(77, 68, 60, .30);
  backdrop-filter: blur(3px);
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  width: 342px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  text-align: center;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 11px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  transition: background .15s, border-color .15s, transform .1s;
}
.modal-actions button:hover { transform: translateY(-1px); }
.modal-cancel:hover {
  background: #fff7ea;
  border-color: var(--line-strong);
  color: var(--accent-deep);
}
.modal-ok {
  background: linear-gradient(135deg, #ffcda3, #ffe7b8);
  color: #a1622f;
  font-weight: 700;
  border-color: #ffdfc0;
  box-shadow: 0 4px 14px rgba(217, 143, 86, .16);
}
.modal-ok:hover { box-shadow: 0 6px 18px rgba(217, 143, 86, .22); }

/* ---------- 登录/注册：Tab ---------- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  margin-bottom: 2px;
}
.tabs .tab {
  flex: 1;
  padding: 9px 0 !important;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: none !important;
  transition: background .15s, color .15s;
}
.tabs .tab:hover:not(.active) { color: var(--accent-deep); }
.tabs .tab.active {
  background: #fff;
  color: #a1622f;
  box-shadow: 0 2px 8px rgba(217, 143, 86, .12) !important;
}

/* 注册面板内的提示 */
.reg-hint {
  font-size: 12px;
  line-height: 1.6;
  color: #b4602a;
  background: #fff4e4;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 2px;
}

/* 顶栏用户名 */
.who {
  font-size: 12px;
  color: var(--accent-deep);
  font-weight: 700;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 身份切换（输入框左侧，向上弹出） ---------- */
.ident-wrap { position: relative; flex: 0 0 auto; display: flex; align-items: flex-end; }

.ident-btn {
  min-width: 72px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: #6b6157;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.ident-btn:hover { transform: translateY(-1px); }
.ident-btn.open { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 199, 155, .18); }

/* 三种身份的配色 */
.ident-btn[data-ident="liked"]    { background: #fff0f5; border-color: #ffd0e0; color: #c0567f; }
.ident-btn[data-ident="stranger"] { background: #f6f6f4; border-color: #e6e3de; color: #6b6157; }
.ident-btn[data-ident="hated"]    { background: #eef3f9; border-color: #d5e2f2; color: #4a6b8a; }

.ident-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 132px;
  padding: 6px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(120, 96, 72, .18);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 50;
}
.ident-menu[hidden] { display: none; }

.ident-item {
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.ident-item:hover { background: var(--panel-2); }
.ident-item.active { background: linear-gradient(135deg, #fff0dc, #ffe3c2); color: var(--accent-deep); font-weight: 700; }
.ident-item.active::after { content: " ✓"; }

/* 弹窗文案支持换行 */
.modal-text { white-space: pre-wrap; }

/* ---------- 免责声明 ---------- */
.disc-link {
  flex: 0 0 auto;
  margin-top: 2px;
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: color .15s;
}
.disc-link:hover { color: var(--accent-deep); text-decoration: underline; }

.disc-box { width: min(560px, 92vw); max-height: 84vh; }

.disc-title {
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  color: var(--accent-deep);
}

.disc-body {
  overflow-y: auto;
  max-height: 62vh;
  padding-right: 6px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}
.disc-body h4 {
  margin: 14px 0 4px;
  font-size: 13.5px;
  color: #a1622f;
}
.disc-body h4:first-child { margin-top: 0; }
.disc-body p { margin: 0 0 4px; color: #5a5148; }
.disc-body .mail { color: #c0567f; font-weight: 700; }

/* 注册页的同意勾选 */
.agree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 2px 0;
}
.agree-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #ffb877;
  cursor: pointer;
}
.agree-row label { cursor: pointer; }
.disc-inline {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent-deep);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}



