* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: #0a0c11;
  color: #e6e9f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea { font-family: inherit; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232a36; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #333c4d; }

/* ================= 入口 ================= */
/* 入口整页滚动。居中交给 .gate-inner 的 margin:auto —— 不能用 place-items:center：
   内容比视口高时它对半裁掉上下、上面那截滚不到（角色多了就会踩）。 */
.gate {
  height: 100%;
  overflow-y: auto;
  display: grid;
  padding: 40px 20px;
  background:
    radial-gradient(circle at 22% 18%, rgba(107,166,255,.09), transparent 45%),
    radial-gradient(circle at 80% 78%, rgba(63,214,168,.07), transparent 45%);
}

.gate-inner { width: 100%; max-width: 700px; margin: auto; }

.logo {
  font-size: 38px;
  font-weight: 500;
  letter-spacing: 12px;
  text-indent: 12px;
  color: #eef2f8;
  text-shadow: 0 0 26px rgba(107,166,255,.35);
}

.tagline {
  margin: 16px 0 34px;
  color: #7d8698;
  line-height: 1.9;
  letter-spacing: .5px;
}

.gate-grid {
  display: grid;
  grid-template-columns: 176px 1fr;
  gap: 30px;
  align-items: start;
}

/* 宫格现在整页滚动，左栏预览要跟着粘住 —— 不然scroll到女生第二行时选人看不见大图 */
.preview-box {
  position: sticky;
  top: 0;
  background: #10141c;
  border: 1px solid #222936;
  border-radius: 10px;
  padding: 12px 12px 10px;
  text-align: center;
}
#preview { display: block; margin: 0 auto; image-rendering: pixelated; }
.preview-cap { margin-top: 8px; font-size: 11px; letter-spacing: 2px; color: #4d5666; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 11px;
  color: #6d7688;
  letter-spacing: 1.5px;
  margin-bottom: 7px;
}

input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%;
  background: #10141c;
  border: 1px solid #222936;
  border-radius: 8px;
  color: #e6e9f0;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, background .15s;
  resize: none;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, textarea:focus { border-color: #3d5580; background: #12171f; }
input::placeholder, textarea::placeholder { color: #454e60; }

/* 年龄那个数字框：去掉上下小箭头，跟旁边的文字框长得一样 */
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.sw {
  width: 26px; height: 26px; border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s;
}
.sw:hover { transform: translateY(-2px); }
.sw.active { border-color: #6ba6ff; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }

/* 角色宫格不再框内滚动 —— 22 个角色一屏看全，别让人在小框里抠。
   外层已经有滚动：入口页靠 .gate（整页），「我的角色」面板靠 .me-body。 */
.char-picker { padding-right: 2px; }
.char-group { margin-bottom: 12px; }
.char-group:last-child { margin-bottom: 0; }
.char-group-cap {
  font-size: 11px;
  color: #6d7688;
  letter-spacing: 1.5px;
  margin-bottom: 7px;
}
.char-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}
.char-cell {
  background: #10141c;
  border: 1px solid #222936;
  border-radius: 8px;
  padding: 3px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-cell:hover { border-color: #3d5580; transform: translateY(-2px); }
.char-cell.active { border-color: #6ba6ff; background: #141c2c; }
.char-cell canvas { image-rendering: pixelated; display: block; }
.char-picker .none { color: #4d5666; font-size: 12px; }
.chip {
  padding: 6px 13px;
  border-radius: 6px;
  border: 1px solid #222936;
  background: #10141c;
  color: #7d8698;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.chip:hover { color: #c9d1e0; }
.chip.active { border-color: #6ba6ff; color: #e6e9f0; background: #141c2c; }

.primary {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  border: none;
  border-radius: 9px;
  background: #6ba6ff;
  color: #07101d;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.primary:hover { background: #86b7ff; }
.primary:active { transform: scale(.99); }
.primary:disabled { background: #252c39; color: #5d6579; cursor: default; }

.fineprint {
  margin-top: 14px;
  font-size: 12px;
  color: #4d5666;
  line-height: 1.75;
}

/* 「去哪儿拿 Key」那行小字：跟着选的厂商变，带一个可点的链接。
   这一步是新手最容易卡住的地方，所以给它单独一行的位置。 */
.field-note {
  margin: -8px 0 16px;
  font-size: 12px;
  line-height: 1.65;
  color: #5b6577;
}
.field-note a { color: #6ba6ff; text-decoration: none; white-space: nowrap; }
.field-note a:hover { text-decoration: underline; }

/* 「更多设置」折叠区：默认收起来，别让只想赶紧进门的人多滑两屏 */
.adv {
  margin: 4px 0 16px;
  padding: 0 12px;
  border: 1px solid #1d2430;
  border-radius: 8px;
  background: #0d1119;
}
.adv > summary {
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #6d7688;
}
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::before { content: '▸ '; }
.adv[open] > summary::before { content: '▾ '; }
.adv[open] > summary { margin-bottom: 12px; border-bottom: 1px solid #1a212c; }
.adv .field:last-of-type { margin-bottom: 4px; }
.adv .fineprint { margin-top: 0; padding-bottom: 12px; }

/* ================= 世界 ================= */
.world { height: 100%; display: flex; flex-direction: column; }

.topbar {
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #1c2230;
  background: #0c1017;
}
.brand { font-size: 13px; letter-spacing: 5px; color: #b9c2d2; }
.meta { display: flex; align-items: center; gap: 9px; font-size: 12px; color: #6d7688; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #3fd6a8; }
.dot.bad { background: #e2564f; }

.stage { flex: 1; display: flex; min-height: 0; }

.view {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #12161f 0%, #080a0f 72%);
}
#scene { display: block; }

/* 镜头跟随的提示条：右下角一个胶囊，点它就松开 */
.follow-chip {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 6;
  font-size: 11px;
  letter-spacing: 1px;
  color: #cddcf0;
  background: rgba(12, 18, 28, .74);
  border: 1px solid rgba(90, 118, 156, .40);
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.follow-chip:hover { background: rgba(20, 30, 46, .88); color: #eaf2ff; }

.corner-hint {
  position: absolute;
  left: 16px;
  bottom: 13px;
  font-size: 11px;
  letter-spacing: 3px;
  color: #2f3745;
  pointer-events: none;
}

.toast {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #1b2130;
  border: 1px solid #2c3547;
  padding: 8px 15px;
  border-radius: 8px;
  font-size: 12px;
  color: #c9d1e0;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

/* ---------- 侧栏 ---------- */
.side {
  flex: 0 0 322px;
  width: 322px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid #1c2230;
  background: #0c1017;
}

.tabs { display: flex; border-bottom: 1px solid #1c2230; }
.tab {
  flex: 1;
  padding: 12px 0;
  background: none;
  border: none;
  color: #6d7688;
  font-size: 13px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: color .15s;
}
.tab:hover { color: #a8b2c4; }
.tab.active { color: #e6e9f0; box-shadow: inset 0 -2px 0 #6ba6ff; }

.pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}

.msg { font-size: 13px; line-height: 1.62; word-break: break-word; }
.msg .who { color: #7ca9e0; margin-right: 6px; }
.msg.me .who { color: #3fd6a8; }
.msg.sys {
  color: #4d5666;
  font-size: 12px;
  text-align: center;
  letter-spacing: 1px;
  padding: 2px 0;
}
.msg.dm .who { color: #c58fe0; }

.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #1c2230; }
.composer input { flex: 1; padding: 9px 12px; font-size: 13px; }
.composer button {
  padding: 0 15px;
  border: none;
  border-radius: 8px;
  background: #6ba6ff;
  color: #07101d;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.composer button:hover:not(:disabled) { background: #86b7ff; }
.composer button:disabled { background: #1c2230; color: #4d5666; cursor: default; }

.roster { flex: 0 0 auto; max-height: 156px; overflow-y: auto; border-bottom: 1px solid #1c2230; }
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s;
}
.person:hover { background: #11161f; }
.person.active { background: #151c28; }
.person .nm { font-size: 13px; }
.person .st { font-size: 11px; color: #4d5666; }
.person.off { opacity: .42; }
.person .av { width: 26px; height: 34px; image-rendering: pixelated; }

.empty-tip { padding: 18px 14px; font-size: 12px; color: #4d5666; line-height: 1.8; }

/* ---------- 它在想什么 ---------- */
.ghost {
  background: none;
  border: 1px solid #2a3242;
  color: #8f99ac;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.ghost:hover { border-color: #3d5580; color: #d7dfec; }

.memory-panel {
  position: fixed;
  top: 54px;
  right: 334px;
  width: 316px;
  max-height: 72%;
  display: flex;
  flex-direction: column;
  background: #10151e;
  border: 1px solid #232c3a;
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  z-index: 40;
  overflow: hidden;
}
.mp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #1c2230;
  font-size: 12px;
  letter-spacing: 2px;
  color: #9aa4b6;
}
.mp-head button {
  background: none;
  border: none;
  color: #5d6579;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.mp-head button:hover { color: #d7dfec; }
.mp-body {
  padding: 12px 14px 16px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: #c9d1e0;
}
.mp-sec { margin-bottom: 15px; }
.mp-sec > h4 {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 1.5px;
  color: #5d6579;
  margin-bottom: 6px;
}
.mp-sec ul { list-style: none; }
.mp-sec li { padding: 3px 0; color: #c9d1e0; }
.mp-sec li .nm { color: #7ca9e0; margin-right: 6px; }
.mp-sec li .mt { color: #4d5666; font-size: 11px; margin-left: 6px; }
.mp-sec .none { color: #4d5666; }

/* 关系一览 / 交情 / 成长时间线 —— 让"它在变"这件事看得见。
   温度用琥珀（暖）和灰蓝（冷），刻意不用红绿，免得跟涨跌那套混淆。 */
.mp-sec li .wm { font-size: 11px; margin-left: 7px; }
.mp-sec li .wm.warm { color: #e0b070; }
.mp-sec li .wm.cold { color: #7f8ba3; }
.mp-sec li .chg { display: block; margin-top: 2px; font-size: 11px; color: #6b7488; }
.mp-sec li .chg b { color: #99a3b8; font-weight: 400; }
.mp-sec li .qt { display: block; margin-top: 2px; font-size: 11px; color: #7c869c; }
/* 交情里织出来的"那件事"：和原句区分开，偏暖，像回忆而不像聊天记录 */
.mp-sec li .st { display: block; margin-top: 3px; font-size: 12px; color: #b9a684; }
.mp-sec li .st::before { content: '· '; color: #6d6455; }
.mp-sec ul.hist li { display: flex; gap: 8px; align-items: baseline; }
.mp-sec ul.hist li .d { flex: 0 0 auto; font-size: 11px; color: #4d5666; }

.me-body { padding: 14px 16px 18px; max-height: 68vh; overflow-y: auto; }
.me-state {
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 14px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #10141c;
  color: #7d8698;
}
.me-state.ok { color: #7fd8a8; background: #0d1a15; }
.me-state.off { color: #d8a87f; background: #1a1610; }
.me-body .field { margin-bottom: 14px; }
.me-body .fineprint { margin: 2px 0 14px; font-size: 11px; color: #5f6a7d; line-height: 1.75; }

@media (max-width: 860px) {
  .memory-panel { left: 12px; right: 12px; width: auto; }
}

@media (max-width: 860px) {
  .stage { flex-direction: column; }
  .side {
    flex: 0 0 46%;
    width: 100%;
    border-left: none;
    border-top: 1px solid #1c2230;
  }
  .gate-grid { grid-template-columns: 1fr; }
  .preview-box { max-width: 176px; margin: 0 auto; }
}

/* 云端读回来的旧聊天记录：压暗一点，跟眼前正在发生的区分开 */
.msg.hist { opacity: 0.6; }
.msg.hist-sep {
  text-align: center;
  font-size: 10px;
  letter-spacing: 1px;
  color: #3a4354;
  background: none;
  padding: 6px 0;
}
#stat-cloud.bad { color: #c96a6a; }
