/* ============ 页面通用 ============ */
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: fade .3s both; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 14px calc(18px + var(--safe-b)) 18px; }

.page-head { padding: calc(var(--safe-t) + 16px) 18px 10px; flex: none; }
.page-title { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: .02em; }
.page-desc { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); letter-spacing: .02em; }

/* ============ 登录 ============ */
.auth {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--safe-t) + 20px) 26px calc(var(--safe-b) + 30px);
  position: relative;
  background:
    linear-gradient(180deg, rgba(253,251,243,.28) 0%, rgba(253,251,243,.72) 38%, rgba(253,251,243,.96) 72%, var(--paper) 100%),
    url('../assets/bg-campus.jpg') center 30% / cover no-repeat;
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-crest {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; position: relative; overflow: hidden;
  background: rgba(255,255,255,.9);
  border: 2px solid rgba(211,47,47,.32);
  box-shadow: 0 6px 22px rgba(0,0,0,.14);
}
.auth-crest img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.auth-crest span { font-size: 30px; color: var(--brown); font-weight: 300; }
.auth-crest::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 1px solid rgba(139,69,19,.1);
}
.auth-name {
  font-family: var(--title-font);
  font-size: 30px; letter-spacing: .14em; font-weight: 400; margin: 0 0 4px; padding-left: .14em;
  color: var(--red); text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.auth-en { font-size: 10px; letter-spacing: .3em; color: var(--ink-3); margin: 0; }

.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
  background: rgba(0,0,0,.04); border-radius: 14px; margin-bottom: 22px;
  border: 1px solid var(--line);
}
.seg button {
  border: none; background: transparent; color: var(--ink-3); font-family: inherit;
  font-size: 14px; font-weight: 500; padding: 10px; border-radius: 11px; cursor: pointer;
  transition: .22s;
}
.seg button.on { background: linear-gradient(150deg, rgba(255,255,255,.95), rgba(0,0,0,.04)); color: var(--ink); box-shadow: inset 0 1px 0 rgba(0,0,0,.1); }

.auth-foot { text-align: center; font-size: 11px; color: var(--ink-3); margin-top: 22px; line-height: 1.7; }

/* ============ API Key ============ */
.hero-note {
  padding: 16px 16px; border-radius: var(--r-md);
  background: linear-gradient(150deg, rgba(139,69,19,.09), rgba(139,69,19,.04));
  border: 1px solid rgba(139,69,19,.18);
  font-size: 13px; color: var(--ink-2); line-height: 1.75;
  margin-bottom: 18px;
}
.hero-note b { color: var(--gold); }
.privacy-list { margin: 0 0 18px; padding: 0; list-style: none; }
.privacy-list li {
  display: flex; gap: 10px; font-size: 12.5px; color: var(--ink-2);
  padding: 9px 0; border-bottom: 1px dashed var(--line); line-height: 1.6;
}
.privacy-list li i {
  flex: none; width: 18px; height: 18px; border-radius: 6px; margin-top: 1px;
  background: rgba(139,69,19,.13); color: var(--gold);
  display: grid; place-items: center; font-size: 10px; font-style: normal;
}
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px; color: var(--ink-2); margin: 16px 0 20px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--gold); margin: 1px 0 0; }

/* ============ 角色创建 ============ */
.steps { display: flex; align-items: center; gap: 6px; margin: 6px 0 20px; }
.steps i { flex: 1; height: 3px; border-radius: 3px; background: rgba(0,0,0,.08); }
.steps i.on { background: linear-gradient(90deg, var(--gold-2), var(--gold)); box-shadow: 0 0 12px rgba(139,69,19,.34); }

.opt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opt-grid button {
  padding: 11px 6px; border-radius: 12px; font-family: inherit; font-size: 13px;
  color: var(--ink-2); background: rgba(0,0,0,.035); border: 1px solid var(--line);
  cursor: pointer; transition: .2s;
}
.opt-grid button.on {
  color: var(--gold); border-color: rgba(139,69,19,.4);
  background: rgba(139,69,19,.08); box-shadow: inset 0 1px 0 rgba(0,0,0,.07);
}

.attr-row { margin-bottom: 14px; }
.attr-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.attr-top b { color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }
.attr-bar {
  position: relative; height: 8px; border-radius: 8px; background: rgba(0,0,0,.05); overflow: hidden;
}
.attr-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 8px; background: linear-gradient(90deg, rgba(139,69,19,.45), var(--gold)); transition: width .2s; }
.attr-ctl { display: flex; gap: 6px; align-items: center; }
.attr-ctl button {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--glass); color: var(--ink); font-size: 16px; cursor: pointer; font-family: inherit;
}
.attr-ctl button:disabled { opacity: .3; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.switch-row .txt b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.switch-row .txt span { font-size: 12px; color: var(--ink-3); }
.switch {
  width: 48px; height: 28px; border-radius: 28px; background: rgba(0,0,0,.1);
  border: 1px solid var(--line-2); position: relative; cursor: pointer; flex: none; transition: .24s;
}
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #ffffff; transition: .24s; }
.switch.on { background: linear-gradient(135deg, var(--gold), var(--gold-2)); border-color: transparent; }
.switch.on i { left: 23px; background: #ffffff; }

/* ============ 游戏主界面 ============ */
.game { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.game-top {
  flex: none; padding: calc(var(--safe-t) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(253,251,243,.97), rgba(253,251,243,.9) 82%, rgba(253,251,243,.82));
  border-bottom: 1px solid rgba(0,0,0,.04);
}
.hud { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-2); flex-wrap: wrap; }
.hud .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); }
.hud-time { color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.spacer { flex: 1; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); cursor: pointer; color: var(--ink-2); flex: none;
}
.icon-btn:active { background: var(--glass-2); }
.icon-btn svg { width: 17px; height: 17px; }

.scene {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px 6px 16px;
  display: flex; flex-direction: column; gap: 14px;
}

.msg { display: flex; gap: 9px; animation: rise .4s cubic-bezier(.22,.9,.32,1) both; }
.msg .avatar { width: 32px; height: 32px; border-radius: 11px; font-size: 13px; }
.msg-body { max-width: 82%; }
.msg-name { font-size: 11px; color: var(--ink-3); margin-bottom: 4px; letter-spacing: .03em; }
.bubble {
  padding: 11px 13px; border-radius: 14px; font-size: 14px; line-height: 1.72;
  background: rgba(0,0,0,.045); border: 1px solid var(--line);
  word-break: break-word;
}
.msg.me { flex-direction: row-reverse; }
.msg.me .msg-body { text-align: right; }
.msg.me .bubble {
  background: linear-gradient(140deg, rgba(139,69,19,.16), rgba(139,69,19,.06));
  border-color: rgba(139,69,19,.24); text-align: left;
}
.narr {
  position: relative; padding: 3px 0 3px 13px;
  font-size: 13.5px; line-height: 1.85; color: #3d3d3d;
  white-space: pre-wrap; word-break: break-word; /* 服务端已分段：保留换行显示段落 */
}
.narr-tag {
  display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; letter-spacing: .04em; color: var(--gold);
  background: rgba(139,69,19,.1); border: 1px solid rgba(139,69,19,.18);
}
.narr-txt { white-space: pre-wrap; }
.narr::before {
  content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 2px;
  border-radius: 2px; background: linear-gradient(180deg, rgba(139,69,19,.62), rgba(139,69,19,.1));
}
.msg-sys { align-self: center; font-size: 11.5px; color: var(--ink-3); padding: 5px 12px; border-radius: 99px; background: rgba(0,0,0,.04); border: 1px solid var(--line); }

.delta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.typing { display: flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); opacity: .4; animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,100% { opacity: .25; transform: translateY(0); } 50% { opacity: .95; transform: translateY(-3px); } }

.composer {
  flex: none; padding: 8px 14px calc(var(--safe-b) + 8px);
  background: linear-gradient(0deg, var(--paper) 0%, #fffdf6 70%, rgba(253, 251, 243, 0.94) 100%);
  border-top: 1px solid rgba(139, 69, 19, 0.1);
}
.composer-inner { display: flex; gap: 9px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-height: 46px; max-height: 120px; resize: none; font-family: inherit; font-size: 15px;
  color: var(--ink); background: rgba(0,0,0,.05); border: 1px solid var(--line-2);
  border-radius: 16px; padding: 12px 15px; outline: none; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--ink-3); }
.send-btn {
  width: 48px; height: 48px; border-radius: 16px; border: none; flex: none; cursor: pointer;
  background: linear-gradient(140deg, #ff6659, var(--red)); color: #ffffff;
  display: grid; place-items: center;
  box-shadow: 0 10px 24px -10px rgba(139,69,19,.62), inset 0 1px 0 rgba(255,255,255,.5);
}
.send-btn:active { transform: scale(.94); }
.send-btn svg { width: 20px; height: 20px; }
/* 行动建议：改为自动换行，窄屏/矮屏不再把后面的建议横向裁掉 */
.quick-row {
  display: flex; gap: 7px; flex-wrap: wrap; padding: 0 0 9px 0;
}
.quick-row .chip { cursor: pointer; }

/* ============ 底部 Tab ============ */
.tabbar {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr);
  position: sticky; bottom: 0; z-index: 5;
  padding: 8px 10px calc(var(--safe-b) + 7px);
  background: #fdfbf3;
  border-top: 1px solid rgba(0,0,0,.05);
}
.tabbar button {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 0; color: var(--ink-3); font-size: 11px; transition: .2s;
}
.tabbar button.on { color: var(--gold); }
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button.on svg { filter: drop-shadow(0 0 8px rgba(139,69,19,.45)); }

/* ============ 世界 ============ */
.world-hero {
  border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px; position: relative; overflow: hidden;
  background: linear-gradient(150deg, rgba(25,118,210,.12), rgba(25,118,210,.04) 60%);
  border: 1px solid rgba(25,118,210,.16);
}
.world-hero::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px;
  border-radius: 50%; background: radial-gradient(circle, rgba(25,118,210,.22), transparent 70%);
}
.world-clock { font-size: 30px; font-weight: 300; letter-spacing: .06em; color: var(--ink); font-variant-numeric: tabular-nums; }
.world-meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.section-title {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2);
  margin: 20px 0 10px; letter-spacing: .06em;
}
.section-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: linear-gradient(180deg, var(--gold), transparent); }
.section-title .more { margin-left: auto; font-size: 11.5px; color: var(--ink-3); }

.event-item {
  display: flex; gap: 12px; padding: 13px 14px; border-radius: 14px; margin-bottom: 9px;
  background: rgba(0,0,0,.032); border: 1px solid var(--line);
}
.event-item .bar { width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--sakura), rgba(211,47,47,.16)); flex: none; }
.event-item h4 { margin: 0 0 3px; font-size: 14px; font-weight: 600; }
.event-item p { margin: 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

.player-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-radius: 14px; margin-bottom: 9px;
  background: rgba(0,0,0,.028); border: 1px solid var(--line);
}
.player-item .info { flex: 1; min-width: 0; }
.player-item .info b { font-size: 14px; display: flex; align-items: center; gap: 7px; }
.player-item .info span { font-size: 11.5px; color: var(--ink-3); display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.offline-dot { width: 6px; height: 6px; border-radius: 50%; background: #bdb6a8; }

/* ============ 社交 ============ */
.seg-tabs { display: flex; gap: 6px; padding: 4px; background: rgba(0,0,0,.038); border-radius: 12px; margin-bottom: 16px; }
.seg-tabs button {
  flex: 1; border: none; background: transparent; color: var(--ink-3); font-family: inherit;
  font-size: 13px; padding: 9px; border-radius: 9px; cursor: pointer; transition: .2s;
}
.seg-tabs button.on { background: rgba(255,255,255,.95); color: var(--ink); }

.post {
  padding: 15px 15px 12px; border-radius: 16px; margin-bottom: 11px;
  background: linear-gradient(160deg, rgba(0,0,0,.05), rgba(0,0,0,.02));
  border: 1px solid var(--line);
}
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.post-head .nm { font-size: 13.5px; font-weight: 600; }
.post-head .tm { font-size: 11px; color: var(--ink-3); margin-left: auto; }
.post-body { font-size: 13.5px; line-height: 1.75; color: #333333; white-space: pre-wrap; word-break: break-word; }
.post-foot { display: flex; gap: 16px; margin-top: 11px; font-size: 12px; color: var(--ink-3); }
.post-foot button { border: none; background: none; color: inherit; font: inherit; cursor: pointer; display: flex; align-items: center; gap: 5px; }

/* ============ 我的 ============ */
.profile-card {
  border-radius: var(--r-lg); padding: 20px 18px; margin-bottom: 16px;
  background: linear-gradient(150deg, rgba(139,69,19,.12), rgba(211,47,47,.05) 55%, rgba(0,0,0,.016));
  border: 1px solid rgba(139,69,19,.18);
  position: relative; overflow: hidden;
}
.profile-card::after {
  content: ""; position: absolute; right: -40px; bottom: -50px; width: 150px; height: 150px;
  border-radius: 50%; background: radial-gradient(circle, rgba(139,69,19,.15), transparent 70%);
}
.profile-top { display: flex; align-items: center; gap: 14px; position: relative; }
.profile-top .meta b { font-size: 19px; font-weight: 600; letter-spacing: .02em; }
.profile-top .meta span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 16px; position: relative; }
.stat-box {
  padding: 11px 13px; border-radius: 13px; background: rgba(0,0,0,.035); border: 1px solid var(--line);
}
.stat-box .k { font-size: 11px; color: var(--ink-3); display: flex; justify-content: space-between; }
.stat-box .v { font-size: 18px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-box .v small { font-size: 11px; color: var(--ink-3); font-weight: 400; margin-left: 2px; }
.stat-box .bar { height: 3px; border-radius: 3px; background: rgba(0,0,0,.07); margin-top: 7px; overflow: hidden; }
.stat-box .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }

.kv-list { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.kv-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.03); }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--ink-2); }
.kv-row .v { color: var(--gold); font-variant-numeric: tabular-nums; }

.rel-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rel-item .nm { font-size: 13.5px; width: 76px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 第四十九批：关系不是一张不动的表格——每条要能看出「见过几次 / 最近什么时候 / 上次相处的印象」 */
.rel-item { flex-direction: column; align-items: stretch; gap: 6px; }
.rel-top { display: flex; align-items: baseline; gap: 8px; }
.rel-top .rel-when { margin-left: auto; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.rel-top .rel-met { font-size: 10.5px; color: var(--gold); opacity: .8; white-space: nowrap; }
.rel-imp { font-size: 11.5px; color: var(--ink-3); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rel-imp::before { content: '“'; color: var(--gold); }
.rel-imp::after { content: '”'; color: var(--gold); }
.rel-bars { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.rel-bars div { height: 5px; border-radius: 4px; background: rgba(0,0,0,.07); overflow: hidden; }
.rel-bars div i { display: block; height: 100%; }
.rel-bars div:nth-child(1) i { background: var(--sakura); }
.rel-bars div:nth-child(2) i { background: var(--blue); }
.rel-bars div:nth-child(3) i { background: var(--gold); }
.rel-bars div:nth-child(4) i { background: var(--danger); }

/* ============ 上帝工作台 ============ */
.admin-gate { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px; }
.admin-head {
  flex: none; padding: calc(var(--safe-t) + 12px) 16px 12px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line); background: rgba(253,251,243,.95);
}
.admin-badge { padding: 3px 9px; border-radius: 6px; font-size: 10.5px; background: rgba(198,40,40,.13); color: var(--danger); border: 1px solid rgba(198,40,40,.26); letter-spacing: .08em; }

.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; overflow-x: auto; padding: 12px 16px 4px; flex: none; }
.admin-tabs button {
  border: 1px solid var(--line); background: rgba(0,0,0,.028); color: var(--ink-3);
  font-family: inherit; font-size: 12.5px; padding: 7px 13px; border-radius: 99px; cursor: pointer; white-space: nowrap;
}
.admin-tabs button.on { color: var(--gold); border-color: rgba(139,69,19,.34); background: rgba(139,69,19,.08); }

.admin-card { padding: 14px; border-radius: 14px; margin-bottom: 10px; background: rgba(0,0,0,.028); border: 1px solid var(--line); }
.admin-card h4 { margin: 0 0 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.admin-card p { margin: 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.65; }
.admin-card .acts { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }

/* ---- 上帝工作台 v2 ---- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat-card {
  padding: 12px 8px 10px; border-radius: 14px; text-align: center;
  background: rgba(0,0,0,.028); border: 1px solid var(--line);
}
.stat-card .stat-val { font-size: 20px; font-weight: 700; color: var(--ink-1); line-height: 1.2; }
.stat-card .stat-label { font-size: 11px; color: var(--ink-2); margin-top: 3px; }
.stat-card .stat-sub { font-size: 10px; color: var(--ink-3); margin-top: 2px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #e91e63; flex: none; animation: tkPulse 1.6s infinite; }
@keyframes tkPulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(233,30,102,.4); } 50% { opacity: .55; box-shadow: 0 0 0 5px rgba(233,30,102,0); } }
.live-item { padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; background: rgba(0,0,0,.028); border: 1px solid var(--line); }
.live-item .t { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.live-item p { margin: 4px 0 2px; font-size: 12px; color: var(--ink-2); line-height: 1.55; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.live-item .time { font-size: 10.5px; color: var(--ink-3); }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 4px; }
.chip-btn {
  border: 1px solid var(--line); background: rgba(0,0,0,.028); color: var(--ink-3);
  font-family: inherit; font-size: 12px; padding: 6px 14px; border-radius: 99px; cursor: pointer;
}
.chip-btn.on { color: var(--gold); border-color: rgba(139,69,19,.34); background: rgba(139,69,19,.08); font-weight: 700; }
.chip.dim { background: rgba(0,0,0,.05); color: var(--ink-3); }
.acts .btn[disabled] { opacity: .4; pointer-events: none; }
@media (max-width: 380px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============ 弹窗 / 抽屉 / Toast ============ */
.mask {
  position: fixed; inset: 0; background: rgba(40,32,22,.52);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .25s both;
}
.modal {
  width: 100%; max-width: 340px; border-radius: var(--r-lg); padding: 24px 22px 20px;
  background: linear-gradient(165deg, #ffffff, #ffffff);
  border: 1px solid rgba(255,255,255,.95);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.9), inset 0 1px 0 rgba(0,0,0,.07);
  animation: rise .35s cubic-bezier(.2,.9,.3,1.1) both;
}
.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal .body { font-size: 13.5px; line-height: 1.8; color: var(--ink-2); white-space: pre-wrap; }
.modal .acts { display: flex; gap: 9px; margin-top: 20px; }
.modal .acts .btn { flex: 1; }

/* 注册 onboarding */
.modal.onboarding { max-width: 420px; max-height: 88dvh; display: flex; flex-direction: column; }
.modal.onboarding .body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.terms-scroll {
  max-height: 34dvh; overflow-y: auto; padding: 4px 2px;
  background: rgba(244,228,196,.28); border-radius: 14px; padding: 12px 14px;
}
.terms-scroll p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.75; }
.terms-scroll b { color: var(--ink); }
.ob-key { margin: 16px 0 4px; }
.ob-key .input { width: 100%; }
.ob-key select {
  width: 100%; padding: 11px 12px; border-radius: var(--r); font-size: 13.5px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}

.sheet-mask { position: fixed; inset: 0; background: rgba(40,32,22,.42); animation: fade .2s both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 430px;
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(var(--safe-b) + 18px);
  background: linear-gradient(180deg, #ffffff, #ffffff);
  border-top: 1px solid rgba(255,255,255,.95);
  box-shadow: 0 -20px 60px -20px rgba(0,0,0,.9);
  animation: up .3s cubic-bezier(.2,.9,.3,1) both;
  max-height: 82dvh; overflow-y: auto;
}
.sheet-grip { width: 36px; height: 4px; border-radius: 4px; background: rgba(0,0,0,.12); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 20px); transform: translateX(-50%);
  padding: 11px 18px; border-radius: 99px; font-size: 13px; z-index: 10000;
  background: rgba(255,255,255,.97); border: 1px solid var(--line-2); color: var(--ink);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.8); animation: rise .3s both;
  max-width: 82vw;
}
.toast.err { border-color: rgba(198,40,40,.4); color: #b71c1c; }
.toast.ok { border-color: rgba(46,125,50,.35); color: #2e7d32; }

/* 空态 */
.empty { text-align: center; padding: 46px 20px; color: var(--ink-3); font-size: 13px; }
.empty .ico { font-size: 34px; opacity: .35; margin-bottom: 10px; }

/* ============ 定数（出身 / 天赋）============ */
.fate-intro {
  border-radius: var(--r-md); padding: 16px 16px 6px;
  background: linear-gradient(160deg, #ffffff, #ffffff);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.fate-line { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 12px; }
.fate-line b {
  flex: 0 0 44px; font-size: 12px; letter-spacing: .06em; color: var(--gold);
  font-weight: 600; padding-top: 2px;
}
.fate-line span { flex: 1; font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.fate-hint { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 12px 0 0; }

.fate-card {
  border-radius: var(--r-md); padding: 15px 16px;
  background: linear-gradient(160deg, #ffffff, #ffffff);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.fate-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.fate-tag {
  font-size: 10px; letter-spacing: .1em; padding: 3px 7px; border-radius: 6px;
  background: rgba(25,118,210,.11); color: #1565c0; border: 1px solid rgba(123,164,255,.26);
}
.fate-tag.gold { background: rgba(139,69,19,.12); color: var(--gold); border-color: rgba(139,69,19,.26); }
.fate-tag.dim { background: rgba(0,0,0,.05); color: var(--ink-3); border-color: var(--line-2); }
.fate-head b { font-size: 14.5px; font-weight: 600; color: var(--ink); letter-spacing: .01em; }
.fate-row { display: flex; gap: 10px; margin-bottom: 9px; }
.fate-row i {
  flex: 0 0 34px; font-style: normal; font-size: 11.5px; color: var(--ink-3); letter-spacing: .06em;
}
.fate-row span { flex: 1; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.fate-row.secret span { color: #ad1457; }
/* 标签不换行、不被压缩 */
.fate-tag { flex: 0 0 auto; white-space: nowrap; }
/* 同场其他玩家的发言：蓝灰左边栏 + 斜体，和金色旁白区分开 */
.narr.peer::before { background: linear-gradient(180deg, rgba(25,118,210,.7), rgba(25,118,210,.08)); }
.narr.peer .narr-tag { color: #1565c0; background: rgba(25,118,210,.1); border-color: rgba(25,118,210,.2); }
.narr.peer .narr-txt { color: #4a4a4a; font-style: italic; }

/* ============ 主菜单（复刻原版樱花校园主界面）============ */
.menu {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  overflow-y: auto; /* 矮屏（小窗/分屏/浏览器工具栏高）时主菜单按钮可滚动到，不裁切 */
  animation: fade .4s both;
}
.menu-bg {
  position: absolute; inset: 0;
  background: url('../assets/bg-campus.jpg') center 42% / cover no-repeat;
}
/* 上下压暗，保证文字与按钮可读（实色渐变，不用 backdrop-filter） */
.menu-bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(28, 16, 8, .42) 0%, rgba(28, 16, 8, .06) 24%, rgba(28, 16, 8, .1) 52%, rgba(24, 14, 6, .62) 88%, rgba(18, 10, 4, .82) 100%);
}
.menu-top {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 12px) 16px 0;
}
.menu-ico {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; cursor: pointer;
  color: #fff6e6;
  background: rgba(122, 84, 52, .62);
  border: 1px solid rgba(255, 246, 230, .22);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  transition: .18s;
}
.menu-ico:active { background: rgba(122, 84, 52, .82); transform: scale(.94); }
.menu-center {
  position: relative; z-index: 2; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 20px; text-align: center;
}
.menu-title {
  margin: 0; font-family: var(--title-font);
  font-size: clamp(28px, 9vw, 40px); font-weight: 400;
  letter-spacing: .1em; line-height: 1.25; padding-left: .1em;
  color: #f6d98d;
  text-shadow: 0 2px 4px rgba(60, 30, 10, .6), 0 0 24px rgba(246, 217, 141, .32);
}
.menu-sub {
  margin: 8px 0 0; font-size: 10px; letter-spacing: .34em;
  color: rgba(255, 248, 235, .78); text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.menu-meta {
  margin: 14px 0 0; font-size: 11.5px; letter-spacing: .06em;
  color: rgba(255, 250, 240, .92);
  background: rgba(40, 24, 12, .46);
  border: 1px solid rgba(255, 246, 230, .16);
  border-radius: 999px; padding: 5px 14px;
}
.menu-btns {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; gap: 12px;
  padding: 0 34px 22px;
}
.menu-btn {
  height: 52px; border-radius: 5px; cursor: pointer;
  font-family: inherit; font-size: 17px; font-weight: 500; letter-spacing: .14em;
  color: #fff8ec;
  background: linear-gradient(180deg, rgba(150, 100, 62, .88), rgba(112, 72, 42, .9));
  border: 1px solid rgba(255, 238, 214, .3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .16);
  transition: .16s;
}
.menu-btn:active { transform: scale(.97); background: linear-gradient(180deg, rgba(122, 80, 48, .95), rgba(92, 58, 32, .95)); }
.menu-btn:nth-child(1) {
  background: linear-gradient(180deg, rgba(190, 58, 46, .92), rgba(150, 36, 28, .92));
  border-color: rgba(255, 232, 220, .28);
}
.menu-foot {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 10px 16px calc(var(--safe-b) + 12px);
  font-size: 11.5px; color: rgba(255, 248, 235, .7);
  background: linear-gradient(180deg, rgba(16, 9, 4, .55), rgba(12, 7, 3, .8));
  border-top: 1px solid rgba(255, 246, 230, .1);
}
.menu-foot #mOut {
  border: none; background: none; color: rgba(255, 248, 235, .85); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; padding: 2px 4px;
}

/* 夜间模式（原版同款切换，只调亮度不反色） */
body.night #phone { filter: brightness(.82) sepia(.12); }
body.night .menu-bg::after {
  background: linear-gradient(180deg, rgba(8, 8, 20, .68) 0%, rgba(8, 8, 20, .35) 30%, rgba(8, 8, 20, .5) 70%, rgba(4, 4, 12, .88) 100%);
}

/* ===== 第十九次会话 · 手机端自适应补丁（390×769 / 69:35）=====
   目标：任何过长页面都能滚到底、弹窗不超出视口、极窄屏与软键盘不裁切按钮。 */
.page-body {
  padding-bottom: calc(30px + var(--safe-b));
  scroll-padding-bottom: calc(30px + var(--safe-b));
}
.mask { padding: clamp(12px, 4vw, 24px); }
.modal, .modal.onboarding {
  width: 100%; max-width: min(420px, 100%);
  max-height: min(92dvh, 92svh);
}
.modal .body { max-height: 70dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.terms-scroll { max-height: min(34dvh, 30svh); }
.sheet { max-height: min(88dvh, 88svh); }
.toast { max-width: min(82vw, 360px); }

/* 创建第三步（定数）内容最长：压缩留白，保证「进入学园」按钮可滚到、可点 */
@media (max-width: 360px) {
  .page-title { font-size: 19px; }
  .page-desc { font-size: 11.5px; }
  .btn { padding: 12px 18px; font-size: 14px; }
  .fate-card { padding: 14px 12px; }
  .attr-row { margin-bottom: 11px; }
  .field { margin-bottom: 13px; }
  .steps { margin-bottom: 14px; }
}
@media (max-height: 680px) {
  .page-head { padding-top: calc(var(--safe-t) + 8px); padding-bottom: 6px; }
  .modal { padding: 16px 16px 14px; }
  .modal .acts { margin-top: 12px; }
  .terms-scroll { max-height: 26dvh; }
  .fate-intro { padding: 12px 12px 2px; }
}
/* 触摸目标下限 */
.tabbar button, .attr-ctl button, .opt-grid button { min-height: 40px; }

/* 第二十一次会话：Key 必填窗口条款较长，靠 .page-body 的可见滚动条与底部留白
   滚到主按钮；刻意不用 sticky/fixed 底栏，避免遮住接口地址/模型/勾选框。 */
/* 角色插画（绘屿 AI 生成）：档案页底部大图，手机端自适应 */
.portrait-card{margin:6px 0 4px;padding:8px;border-radius:14px;background:var(--card,#fffdf7);
  border:1px solid var(--line,#e6dcc8);box-shadow:0 2px 10px rgba(160,130,90,.07)}
.portrait-img{display:block;width:100%;height:auto;border-radius:10px;object-fit:cover}
.portrait-ph{display:flex;align-items:center;justify-content:center;min-height:180px;border-radius:10px;
  background:rgba(160,130,90,.06);color:var(--ink-3,#a08a6c);font-size:12.5px;text-align:center;padding:16px}
.portrait-actions{display:flex;gap:8px;margin-top:8px}
.portrait-actions .btn{flex:1;height:36px;border-radius:999px;font-size:13px}
@media (max-width:768px){
  .portrait-card{padding:7px;border-radius:12px}
  .portrait-actions .btn{height:38px;font-size:13.5px}
}
