/* 言诺 · 网页聊天，QQ 式布局 */

/* hidden 属性必须真的隐藏：下面很多块写了 display:flex/grid，
   作者样式优先级高于浏览器默认的 [hidden]{display:none}，不加这条就会一直显示着。 */
[hidden] { display: none !important; }

/* 颜色都取 ui-kit.css 的共用配色（和安卓 2.7 同一套，跟随系统深浅色，PD-CLIENT-014）；
   括号里的兜底值是浅色，ui-kit.css 没加载到时页面照旧是浅色 */
:root {
  --bg: var(--y-bg, #faf0ef);
  --panel: var(--y-surface, #fffaf8);
  --panel-2: var(--y-bar, #fdf4f3);
  --line: var(--y-line, #f1dfdd);
  --text: var(--y-text, #3b2a2e);
  --sub: var(--y-text2, #8a6c72);
  --me: var(--y-control-accent, #d58099);
  --me-text: var(--y-bubble-mine-text, #ffffff);
  --peer: var(--y-bubble-peer, #ffffff);
  --peer-text: var(--y-bubble-peer-text, #3b2a2e);
  --danger: var(--y-danger, #d9435f);
  --hover: var(--y-hover, #f9ebea);
  --active: var(--y-primary-soft, rgba(201, 108, 138, .12));
  --shadow: var(--y-shadow, 0 1px 2px rgba(122, 64, 84, .07));
  --pink: var(--y-pink, #d6336c);
  --pink-soft: var(--y-pink-soft, rgba(214, 51, 108, .08));
  --radius: 12px;
  /* 宽屏时聊天内容最多这么宽、居中（PD-CLIENT-015） */
  --read-width: 880px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor;
      stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.app { display: flex; height: 100%; }

/* ---------------- 左栏：好友列表 ---------------- */

.sidebar {
  width: 288px;
  flex: 0 0 288px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  /* 侧栏最下面一块（额度包按钮或额度那一行）让开手机底部的横条 */
  padding-bottom: env(safe-area-inset-bottom);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
  padding-top: max(16px, env(safe-area-inset-top));
}

.side-tabs {
  display: flex;
  flex: 1;
  gap: 4px;
  min-width: 0;
  margin-right: 10px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel-2);
}
.side-tab {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 9px;
  color: var(--sub);
  font-size: 14px;
  font-weight: 650;
}
.side-tab:hover { background: var(--hover); color: var(--text); }
.side-tab[aria-selected="true"] { background: var(--active); color: var(--y-primary-text, #ad4f72); }
.side-tab:focus-visible { outline: 2px solid var(--me); outline-offset: 1px; }
.side-characters { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.side-characters > .friends { min-height: 0; }
.side-characters > .side-quota { padding-top: 10px; border-top: 1px solid var(--line); }
.side-characters > .side-quota,
.side-characters > .side-credits { flex-shrink: 0; }
.side-settings { flex: 1; min-height: 0; overflow-y: auto; }
.side-settings .side-user > .side-user-out { flex: 1 1 100%; padding: 10px 0; text-align: left; }
.side-settings .side-user-out:hover { color: var(--text); }
.side-settings .side-user-out:focus-visible { outline: 2px solid var(--me); outline-offset: 1px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--sub);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
/* 读角色列表时刷新图标转起来（代替侧栏底部原来的「刷新中…」） */
.icon-btn.is-spinning svg { animation: side-spin .8s linear infinite; }
@keyframes side-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.is-spinning svg { animation-duration: 2.4s; } }

.friends {
  flex: 1;
  margin: 0; padding: 4px 8px 12px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.friend {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 9px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .13s;
}
.friend:hover { background: var(--hover); }
.friend.on { background: var(--active); }

.friend .ava {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 12px;
  object-fit: cover;
  object-position: center 18%;
  background: var(--panel-2);
}

.friend .meta { flex: 1; min-width: 0; }
.friend .row1 { display: flex; align-items: baseline; gap: 6px; }
.friend .name {
  font-size: 14.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.friend .time { margin-left: auto; font-size: 11px; color: var(--sub); flex: 0 0 auto; }
.friend .snippet {
  margin-top: 2px;
  font-size: 12.5px; color: var(--sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dot {
  min-width: 17px; height: 17px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px; line-height: 17px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 只在连不上服务时显示原因（PD-CLIENT-005）；底部横条的空当由 .sidebar 统一让开 */
.side-foot {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--danger);
}

/* ---------------- 右栏：聊天 ---------------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--sub);
}
.empty-mark {
  font-size: 26px; font-weight: 700; letter-spacing: .18em;
  color: var(--text); opacity: .12;
  margin-bottom: 10px;
}
.empty p { margin: 0; font-size: 13.5px; }

.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.chat-head .back { display: none; margin-left: -6px; }
.chat-head .peer-ava {
  width: 34px; height: 34px;
  border-radius: 10px;
  object-fit: cover;
  object-position: center 18%;
  background: var(--panel-2);
}
.peer { line-height: 1.25; min-width: 0; }
.peer-name { font-size: 15px; font-weight: 650; }
.peer-status { font-size: 11.5px; color: var(--sub); }
/* 只有右上角的「⋯」靠右；返回键（窄窗口才出现）必须留在最左边 */
.chat-head #menuBtn { margin-left: auto; }

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* 约会回复写完后补在列表最底下的空白，正式消息停在草稿原来的位置（app.js 的 setStreamPad） */
.messages.stream-pad::after {
  content: '';
  flex: none;
  height: var(--stream-pad, 0px);
}

.divider {
  align-self: center;
  margin: 14px 0 10px;
  padding: 2px 9px;
  border-radius: 7px;
  background: rgba(160, 110, 125, .14);
  color: var(--sub);
  font-size: 11.5px;
}

.row { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; }
.row.me { flex-direction: row-reverse; justify-content: flex-start; }

.row .ava {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 10px;
  object-fit: cover; object-position: center 18%;
  background: var(--panel-2);
}
/* 连续消息也各自带头像，像真人一条一条发 */

.bubbles { display: flex; flex-direction: column; gap: 5px; max-width: min(72%, 560px); }
.row.me .bubbles { align-items: flex-end; }

.bubble {
  padding: 9px 12px;
  border-radius: 4px 13px 13px 13px;
  background: var(--peer);
  color: var(--peer-text);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  animation: pop .18s ease-out both;
}
.row.me .bubble {
  border-radius: 13px 4px 13px 13px;
  background: var(--y-bubble-mine, #12b7f5);
  color: var(--me-text);
  box-shadow: none;
}

.cont .bubble { animation: none; }

@keyframes pop {
  from { opacity: 0; transform: translateY(4px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.bubble.pic {
  padding: 0;
  overflow: hidden;
  background: var(--panel-2);
  line-height: 0;
}
.bubble.pic img {
  display: block;
  width: 100%;
  max-width: 340px;
  height: auto;
  border-radius: inherit;
}
.bubble.pic .cap { padding: 6px 10px 8px; font-size: 11.5px; color: var(--sub); line-height: 1.4; }

.note {
  align-self: center;
  margin: 10px 0;
  padding: 6px 12px;
  border-radius: 9px;
  background: var(--y-danger-soft, rgba(217, 67, 95, .08));
  color: var(--danger);
  font-size: 12.5px;
  max-width: 88%;
  text-align: center;
}
/* 本地提示（比如切了模式），不是报错 */
.note.info { background: var(--hover); color: var(--sub); }
/* 约好了、见面开始结束、放鸽子、取消 */
.note.event { background: var(--pink-soft); color: var(--pink); }
.note.event.missed, .note.event.cancelled { background: var(--hover); color: var(--sub); }

/* ---------------- 约会横幅 ---------------- */

.meet-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--pink);
  background: var(--pink-soft);
  border-bottom: 1px solid var(--line);
}
.meet-bar.on { background: color-mix(in srgb, var(--pink) 16%, transparent); font-weight: 600; }
.meet-bar .meet-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-bar .meet-btn {
  flex: none;
  border: 1px solid var(--y-pink-line, rgba(214, 51, 108, .35)); border-radius: 999px;
  padding: 2px 10px;
  background: transparent; color: var(--pink);
  font-size: 12px; cursor: pointer;
}
.meet-bar .meet-btn:hover { background: var(--pink-soft); }
/* 剧情模式的 *动作* */
.bubble .act { font-style: italic; opacity: .72; }
/* 旁白写法里引号中的对白（PD-CHAT-007） */
.bubble .say { color: var(--y-dialogue, #a0620a); }

.typing {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 12px 14px;
}
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sub);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ---------------- 输入区 ---------------- */

.composer {
  display: flex; align-items: flex-end; gap: 9px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.composer textarea {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  min-height: 40px;
  max-height: 132px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  resize: none;
  outline: 0;
  transition: border-color .15s;
}
.composer textarea:focus { border-color: var(--me); }
.composer textarea::placeholder { color: var(--sub); }

.send {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 18px;
  border-radius: 11px;
  background: var(--y-bubble-mine, #12b7f5);
  color: var(--y-on-primary, #ffffff);
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.send:active { transform: scale(.97); }
.send:disabled { opacity: .45; cursor: default; }

/* 输入框左边的表情、图片按钮（PD-CLIENT-004）；图片也可以直接粘贴或拖进聊天区 */
.composer { position: relative; }
.composer .tool {
  flex: 0 0 auto;
  width: 38px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--sub);
  transition: background .15s, color .15s;
}
.composer .tool:hover { background: var(--hover); color: var(--text); }
.composer .tool[aria-expanded="true"] { color: var(--me); }
.composer .tool:disabled { opacity: .45; cursor: default; }
.composer .tool svg { width: 22px; height: 22px; }
.composer .tool .dotfill { fill: currentColor; stroke: none; }

/* 表情：点按钮在输入框上方弹出，点一个就插到光标处 */
.emoji-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(8, 40px);
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--y-shadow-pop, 0 12px 34px rgba(122, 64, 84, .2));
  animation: pop .14s ease-out both;
}
.emoji-pop button {
  height: 38px;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
}
.emoji-pop button:hover { background: var(--hover); }

/* 拖图片进聊天区时的提示 */
.drop-hint {
  position: absolute;
  inset: 10px;
  z-index: 26;
  display: grid;
  place-items: center;
  border: 2px dashed var(--me);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  color: var(--me);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

/* ---------------- 底部弹层 ---------------- */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: var(--y-overlay, rgba(47, 24, 32, .38));
  opacity: 0;
  transition: opacity .2s;
  z-index: 20;
}
.sheet-backdrop.in { opacity: 1; }

.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  width: min(460px, 100%);
  transform: translate(-50%, 100%);
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  z-index: 21;
  transition: transform .24s cubic-bezier(.32, .72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.sheet.in { transform: translate(-50%, 0); }

.sheet-handle {
  width: 36px; height: 4px;
  margin: 9px auto 0;
  border-radius: 2px;
  background: var(--line);
}
.sheet-title {
  padding: 12px 20px 8px;
  font-size: 13px; color: var(--sub);
}
.sheet-body { overflow-y: auto; padding-bottom: 10px; }

.item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 20px;
  font-size: 15px;
  cursor: pointer;
}
.item:hover { background: var(--hover); }
.item .hint { margin-left: auto; font-size: 12.5px; color: var(--sub); }
.item.danger { color: var(--danger); }
.item .check { margin-left: auto; color: var(--me); font-weight: 700; }

.facts { padding: 4px 20px 12px; }
.facts li {
  margin: 0 0 7px;
  padding-left: 14px;
  position: relative;
  font-size: 13.5px;
  color: var(--text);
  list-style: none;
}
.facts li::before {
  content: '';
  position: absolute; left: 2px; top: 8px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--sub);
}
.facts .none { color: var(--sub); font-size: 13px; }
.facts h4 { margin: 12px 0 7px; font-size: 12.5px; font-weight: 600; color: var(--sub); }
.facts h4:first-child { margin-top: 2px; }
.facts li { display: flex; align-items: baseline; gap: 6px; }
.facts li .ft { flex: 1; min-width: 0; }
.facts li .tag {
  flex: none; font-size: 11px; line-height: 16px; padding: 0 4px;
  color: var(--sub); border: 1px solid var(--line); border-radius: 4px;
}
.facts li .ops { flex: none; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.facts li:hover .ops { opacity: 1; }
.facts li .ops button {
  border: 0; background: none; padding: 0 4px;
  font-size: 12.5px; color: var(--sub); cursor: pointer;
}
.facts li .ops button:hover { color: var(--text); }
.facts li .ops button:last-child:hover { color: var(--danger); }
.facts .tip { margin-top: 10px; font-size: 12px; }
/* ---------------- 关系 ---------------- */

.rel-chip {
  flex: none;
  border: 0; cursor: pointer;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px; line-height: 18px;
  color: var(--pink);
  background: var(--pink-soft);
  white-space: nowrap;
}
.rel-chip:hover { background: color-mix(in srgb, var(--pink) 16%, transparent); }

/* 标题行的游戏时间：纯时刻，无前缀，和亲密度同一排 */
.game-chip {
  flex: none;
  font-style: normal;
  font-size: 12px; line-height: 18px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rel { padding: 2px 20px 10px; font-size: 13.5px; }
.rel-top { display: flex; align-items: baseline; gap: 8px; }
.rel-top b { font-size: 20px; font-weight: 700; }
.rel-top .rel-score { margin-left: auto; font-size: 20px; font-weight: 700; color: var(--pink); }
.rel-top .rel-max { font-size: 12px; color: var(--sub); }
.rel-bar {
  position: relative;
  height: 6px; margin: 8px 0 6px;
  border-radius: 3px;
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.rel-bar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #f7a1c0, #d6336c);
}
.rel-bar u {
  position: absolute; top: -2px; bottom: -2px; width: 1px;
  background: var(--sub); opacity: .45;
}
.rel-meta { font-size: 12px; color: var(--sub); line-height: 1.6; }
.rel-att {
  margin-top: 10px; padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  line-height: 1.6;
}
.rel h4 { margin: 14px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--sub); }
.rel ul { margin: 0; padding: 0; list-style: none; }
.rel-events li { margin: 0 0 4px; }
.rel-log li {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.rel-log li:last-child { border-bottom: 0; }
.rel-log .d { flex: none; width: 38px; font-weight: 650; color: var(--sub); font-variant-numeric: tabular-nums; }
.rel-log .d.up { color: var(--pink); }
.rel-log .d.down { color: var(--y-down, #3b7dd8); }
.rel-log .b { flex: 1; min-width: 0; line-height: 1.55; }
.rel-log q { display: block; color: var(--sub); font-size: 12.5px; }
.rel-log q::before { content: '原话：「'; }
.rel-log q::after { content: '」'; }
/* 英文版（PD-CLIENT-018） */
html[lang="en"] .rel-log q::before { content: 'Quote: “'; }
html[lang="en"] .rel-log q::after { content: '”'; }
.rel-log small { display: block; color: var(--y-warn-text, #8a5a00); font-size: 12px; }
.rel-log button {
  flex: none; border: 0; background: none; padding: 0 2px;
  font-size: 12.5px; color: var(--sub); cursor: pointer;
}
.rel-log button:hover { color: var(--danger); }
.rel-log .tag, .tl .tag {
  flex: none; font-size: 11px; line-height: 16px; padding: 0 4px;
  color: var(--sub); border: 1px solid var(--line); border-radius: 4px;
}
.rel-log li.undone .b, .rel-log li.undone .d { text-decoration: line-through; opacity: .55; }
.rel .none, .tl .none { color: var(--sub); font-size: 13px; }
.rel .tip, .tl .tip { margin-top: 10px; font-size: 12px; }

/* ---------------- 回忆 ---------------- */

.tl { padding: 2px 20px 10px; }
.tl ol { margin: 0; padding: 0; list-style: none; }
.tl-item {
  position: relative;
  padding: 0 0 12px 16px;
  border-left: 2px solid var(--line);
  margin-left: 4px;
}
.tl-item::before {
  content: '';
  position: absolute; left: -5px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--me);
}
.tl-item.star::before { border-color: var(--pink); background: var(--pink); }
.tl-item.gap::before { border-color: var(--line); }
.tl-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--sub); }
.tl-item.gap .tl-label { font-weight: 400; font-style: italic; }
.tl-label .imp { font-size: 8px; letter-spacing: 1px; color: var(--me); opacity: .75; font-weight: 400; }
.tl-label .mstar { color: var(--pink); }
.tl-label .ops { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.tl-item:hover .ops { opacity: 1; }
.tl-label .ops button {
  border: 0; background: none; padding: 0 4px;
  font-size: 12.5px; font-weight: 400; color: var(--sub); cursor: pointer;
}
.tl-label .ops button:hover { color: var(--text); }
.tl-label .ops button:last-child:hover { color: var(--danger); }
.tl-text { margin-top: 3px; font-size: 13.5px; line-height: 1.65; color: var(--text); }
.tl-att { margin-top: 2px; font-size: 12.5px; color: var(--sub); }

/* 触屏没有悬停：按钮一直显示 */
@media (hover: none) { .facts li .ops, .tl-label .ops { opacity: 1; } }

/* ---------------- 移动端 ---------------- */

@media (max-width: 760px) {
  .sidebar {
    width: 100%;
    flex: 1 1 100%;
    border-right: 0;
  }
  .chat { display: none; }

  body.in-chat .sidebar { display: none; }
  body.in-chat .chat { display: flex; }

  .chat-head .back { display: grid; }
  .bubbles { max-width: 78%; }
  .messages { padding: 10px 12px 6px; }
}

/* ---------------- 登录 ---------------- */

/* 服务端在 <html data-gate> 上写明登录状态：没登录时第一帧就是登录页，
   主页骨架连一帧都不画，避免「先进主页再跳登录页」。 */
html[data-gate="login"] #app { display: none !important; }
html[data-gate="login"] #gate { display: flex !important; }

.gate {
  position: fixed; inset: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.gate-box {
  width: min(320px, 100%);
  text-align: center;
}

.gate-mark {
  font-size: 30px; font-weight: 700; letter-spacing: .2em;
  margin-bottom: 6px;
}
.gate-sub {
  margin: 0 0 22px;
  font-size: 13.5px;
  color: var(--sub);
}

.gate-box input[type="text"],
.gate-box input[type="password"] {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: 0;
  text-align: center;
  letter-spacing: .08em;
}
.gate-box input[type="text"]:focus,
.gate-box input[type="password"]:focus { border-color: var(--me); }

.gate-box input[type="text"] + input[type="password"] { margin-top: 10px; }
#gateReferral { margin-top: 10px; }

/* 注册时选性别：两个并排的圆角块，选中的高亮 */
.gate-gender {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.gate-gender[hidden] { display: none; }
.gate-gender label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--sub);
  font-size: 14.5px;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, color .12s, background .12s;
}
.gate-gender label:hover { color: var(--text); }
.gate-gender input { accent-color: var(--me); width: 15px; height: 15px; margin: 0; }
.gate-gender label:has(input:checked) {
  border-color: var(--me);
  color: var(--text);
  font-weight: 600;
}

/* 注册时必勾的「我已年满 18 岁」（PD-ACCT-001） */
.gate-adult {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--sub);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.gate-adult[hidden] { display: none; }
.gate-adult input { accent-color: var(--me); width: 15px; height: 15px; margin: 0; }

/* 推荐码默认收起（PD-ADMIN-015）：注册时先只露一行字，点了才出输入框，不再紧跟在密码框下面 */
.gate-ref-toggle {
  margin: 8px 0 0;
  font-size: 13px;
  text-align: left;
}
.gate-ref-toggle span {
  color: var(--sub);
  text-decoration: underline;
  cursor: pointer;
  user-select: none;
}

.gate-switch {
  margin: 10px 0 0;
  font-size: 13px;
}
.gate-switch span,
.gate-forgot span {
  color: var(--sub);
  text-decoration: underline;
  cursor: pointer;
  user-select: none;
}
/* 忘记密码（PD-ACCT-015）：登录按钮下面一行小字 */
.gate-forgot {
  margin: 4px 0 0;
  font-size: 13px;
}

/* Telegram 交流群（PD-CLIENT-017）：侧栏设置页、账号那一行上面，登录后才显示 */
.side-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  color: var(--y-primary-text, #ad4f72);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}
.side-group[hidden] { display: none; }
.side-group svg { width: 16px; height: 16px; flex: 0 0 16px; stroke-width: 1.8; }
.side-group:hover { background: var(--hover); }
/* 「玩法介绍」（PD-CLIENT-022）是按钮，样子和交流群那一行一样 */
button.side-group { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; font-family: inherit; text-align: left; cursor: pointer; }
.side-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 2px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
/* 头像和名字占第一行，按钮在下面一行（英文、日文按钮长，放不下再折一行）；否则名字会被挤没、最后一个按钮被截掉 */
.side-user > .side-user-name.clickable { flex: 1 1 calc(100% - 34px); }
.side-user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-user-out {
  border: none;
  background: none;
  color: var(--sub);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  flex: none;
}
.side-user-out:active { color: var(--text); }
/* 一次性剩余额度（PD-ACCT-008）：不限额的账号不显示 */
.side-quota {
  padding: 0 16px 8px;
  color: var(--sub);
  font-size: 12px;
}
.side-quota[hidden] { display: none; }
/* 购买额度包（PD-CLIENT-005）：免费额度下面的实心按钮，比淡底的「添加角色」显眼；颜色只取配色变量，跟着主题走 */
.side-credits {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 2px 12px 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--me);
  color: var(--me-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: filter .15s, transform .1s;
}
.side-credits svg { width: 16px; height: 16px; flex: 0 0 16px; fill: currentColor; stroke-width: 1.2; }
.side-credits:hover { filter: brightness(1.06); }
.side-credits:active { transform: scale(.98); filter: brightness(.95); }
.side-credits:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }

.gate-box button {
  width: 100%;
  height: 44px;
  margin-top: 12px;
  border-radius: 11px;
  background: var(--y-primary-grad, var(--me));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.gate-box button:disabled { opacity: .5; }

.gate-err {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}

/* 亲密度变化仅附在这一轮回复的最后一段后。 */
.relation-change { display:inline-block; margin-left:8px; font-size:.9em; font-weight:700; white-space:nowrap; }
.relation-change.increase { color:var(--y-rel-up, #d73545); }
.relation-change.decrease { color:var(--y-rel-down, #16834b); }

/* 轻提示：保存失败这类一次性反馈，不打断操作也不弹 alert */
.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  z-index: 90;
  max-width: min(420px, 76vw);
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--y-notice-bg, rgba(47, 32, 36, .9));
  color: var(--y-notice-text, #ffffff);
  font-size: 13.5px;
  line-height: 1.4;
  text-align: center;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }


/* 引用：输入框上方的引用条，和气泡里的引用块 */
.quote-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border-top: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--sub);
    font-size: 12.5px;
}
.quote-bar[hidden] { display: none; }
.quote-bar-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.quote-bar-close {
    flex: 0 0 auto;
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--sub);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.quote-bar-close:hover { color: var(--text); }

.bubble .quote {
    margin: -2px 0 6px;
    padding: 5px 8px;
    border-left: 2px solid var(--y-quote-peer-line, #e5c9cf);
    border-radius: 6px;
    background: var(--y-quote-peer, rgba(122, 64, 84, .06));
    color: var(--y-quote-peer-text, #8a6c72);
    font-size: 12.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    max-height: 4.4em;
    overflow: hidden;
}
.bubble .quote .quote-name {
    margin-right: 4px;
    font-weight: 600;
    opacity: 0.85;
}
.row.me .bubble .quote {
    border-left-color: var(--y-quote-mine-line, rgba(255, 255, 255, .65));
    background: var(--y-quote-mine, rgba(255, 255, 255, .2));
    color: var(--y-quote-mine-text, #fff0f4);
}
/* 头像加载失败（离线、隧道抖动、没有立绘）时显示名字的第一个字，不显示破图标 */
.ava-fallback { display: grid; place-items: center; background: var(--y-placeholder, #f2e3e3); color: var(--sub); font-size: 16px; font-weight: 600; user-select: none; }

/* ---------------- 宽屏（PD-CLIENT-015） ---------------- */

/* 聊天内容限宽居中：自己的气泡和她的气泡不再分在屏幕两头，输入框、引用条跟着对齐 */
@media (min-width: 761px) {
  .messages { padding-left: max(16px, calc((100% - var(--read-width)) / 2)); padding-right: max(16px, calc((100% - var(--read-width)) / 2)); }
  .composer { padding-left: max(14px, calc((100% - var(--read-width)) / 2)); padding-right: max(14px, calc((100% - var(--read-width)) / 2)); }
  .quote-bar { padding-left: max(12px, calc((100% - var(--read-width)) / 2)); padding-right: max(12px, calc((100% - var(--read-width)) / 2)); }
}

.sheet-close { display: none; }

/* 设置改成右侧抽屉：遮罩很淡，打开时聊天还看得见，点外面或 Esc 收起 */
@media (min-width: 1000px) {
  .sheet-backdrop { background: rgba(47, 24, 32, .12); }
  .sheet {
    left: auto; right: 0; top: 0; bottom: 0;
    width: 400px;
    max-height: none;
    border-radius: 0;
    border-left: 1px solid var(--line);
    box-shadow: -14px 0 36px rgba(122, 64, 84, .14);
    transform: translateX(100%);
    padding-bottom: 0;
  }
  .sheet.in { transform: none; }
  .sheet-handle { display: none; }
  .sheet-title {
    display: flex; align-items: center;
    min-height: 55px;
    padding: 10px 56px 10px 20px;
    border-bottom: 1px solid var(--line);
    font-size: 15px; font-weight: 650; color: var(--text);
  }
  .sheet-close {
    position: absolute; top: 10px; right: 12px;
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border-radius: 9px;
    color: var(--sub);
    font-size: 16px;
  }
  .sheet-close:hover { background: var(--hover); color: var(--text); }
  .sheet-body { flex: 1; padding-top: 6px; }
}
/* 日文版（PD-CLIENT-018） */
html[lang="ja"] .rel-log q::before { content: "発言：「"; }
html[lang="ja"] .rel-log q::after { content: "」"; }
