:root {
  --bg: #14110f;
  --panel: #1c1815;
  --panel-2: #251f1b;
  --line: #332b26;
  --text: #ece5e0;
  --muted: #94887f;
  --faint: #6b615a;
  --her: #262120;
  --me: #8f3f4e;
  --me-text: #fdf1f3;
  --accent: #c86b7c;
  --danger: #c25a52;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

body { display: flex; justify-content: center; }

.app {
  width: 100%; max-width: 480px; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ---------- header ---------- */

.top {
  flex: none; height: 54px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(20,17,15,.92);
  backdrop-filter: blur(12px);
}

.who { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.who b { font-size: 15px; font-weight: 500; letter-spacing: .2px; }
.who em { font-size: 11px; color: var(--muted); font-style: normal; margin-top: 2px; }

.icon {
  flex: none; width: 34px; height: 34px; border: 0; background: none;
  color: var(--text); display: grid; place-items: center;
  border-radius: 10px; cursor: pointer; opacity: .82;
}
.icon:hover { background: var(--panel-2); opacity: 1; }

/* ---------- chat ---------- */

.chat {
  flex: 1; overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 0; }

.day {
  align-self: center; margin: 12px 0 8px;
  font-size: 11px; color: var(--faint);
  padding: 2px 10px; border-radius: 20px; background: var(--panel);
}

.msg {
  display: flex; gap: 8px; align-items: flex-end;
  max-width: 100%;
  animation: pop .18s ease-out;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.msg.her { align-self: flex-start; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(140deg, #4a3a34, #2a211d);
  display: grid; place-items: center;
  font-size: 12px; color: #b9a89e;
  margin-bottom: 2px; user-select: none;
}
.msg.me .avatar { background: var(--me); color: #fff; }

.bubble {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 17px;
  background: var(--her);
  color: var(--text);
  font-size: 15px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
}
.msg.her .bubble { border-bottom-left-radius: 5px; }
.msg.me .bubble { background: var(--me); color: var(--me-text); border-bottom-right-radius: 5px; }

.bubble img {
  display: block; max-width: 200px; max-height: 260px;
  border-radius: 12px; margin: 2px 0;
}

.bubble.recalled { font-style: italic; color: var(--faint); background: transparent; border: 1px dashed var(--line); }
.bubble.recalled .inner { opacity: .5; }

/* ---------- 语音条 ---------- */

.bubble.voice {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px;
  min-height: 42px;
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  transition: background .18s ease, transform .12s ease;
}
.bubble.voice:active { transform: scale(.98); }
.bubble.voice.playing { background: #302826; }

.vwaves { flex: none; width: 15px; height: 14px; color: #b6a396; }
.bubble.voice.playing .vwaves { color: var(--accent); }
.bubble.voice.playing .vwaves path { animation: vwave 1.05s ease-in-out infinite; }
.bubble.voice.playing .vwaves path:nth-child(2) { animation-delay: .14s; }
.bubble.voice.playing .vwaves path:nth-child(3) { animation-delay: .28s; }

@keyframes vwave {
  0%, 100% { opacity: .35; }
  45% { opacity: 1; }
}

.vsec {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  margin-left: 1px;
}

.vdot {
  position: absolute; top: -3px; right: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  display: none;
}
.bubble.voice.unread .vdot { display: block; animation: vpulse 1.6s ease-in-out infinite; }

@keyframes vpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.vtrans {
  position: absolute; left: 0; top: calc(100% + 7px);
  width: max-content; max-width: 250px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px; line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  z-index: 6;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: pop .16s ease-out;
}

.time {
  font-size: 10px; color: var(--faint);
  align-self: flex-end; padding-bottom: 4px;
}

/* ---------- typing ---------- */

.typing {
  flex: none; padding: 4px 14px 8px;
  display: flex; gap: 4px; align-items: center;
  align-self: flex-start;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint);
  animation: blink 1.25s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .16s; }
.typing span:nth-child(3) { animation-delay: .32s; }
@keyframes blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- 额度提示（不是她的气泡，是一行系统灰字） ---------- */

.quota-note {
  flex: none;
  align-self: center;
  margin: 2px 14px 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--chip, rgba(255,255,255,.06));
  color: var(--faint);
  font-size: 12px;
  letter-spacing: .02em;
}

/* 危机干预提示：颜色比额度提示重一点，但不做成对话框 —— 那会像客服弹窗 */
.quota-note.care {
  max-width: 86%;
  border-radius: 12px;
  padding: 10px 14px;
  line-height: 1.7;
  color: #e3b993;
  background: rgba(200, 107, 124, .10);
  text-align: left;
}

/* ---------- 首次进入的指路条（一次性） ---------- */

.first-run {
  flex: none;
  margin: 10px 14px 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
.first-run p { margin: 0 0 10px; }
.first-run .btn { display: block; margin-left: auto; }

.ver { display: block; margin-top: 8px; opacity: .55; font-size: 11px; }

/* ---------- composer ---------- */

.composer {
  position: relative;
  flex: none;
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(20,17,15,.96);
}

#input {
  flex: 1;
  resize: none; max-height: 120px;
  padding: 10px 13px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit; font-size: 15px;
  outline: none;
  line-height: 1.4;
}
#input:focus { border-color: #4a3a34; }

.send {
  flex: none; height: 38px; padding: 0 16px;
  border: 0; border-radius: 19px;
  background: var(--accent); color: #21100f;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.send:disabled { opacity: .35; cursor: default; }

/* ---------- drawer ---------- */

.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 40; backdrop-filter: blur(2px);
}

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(360px, 88vw);
  background: var(--panel);
  z-index: 50;
  transform: translateX(-102%);
  transition: transform .24s cubic-bezier(.3,.8,.4,1);
  overflow-y: auto;
  padding: 14px 14px 40px;
  border-right: 1px solid var(--line);
}
.drawer.open { transform: none; }
.drawer::-webkit-scrollbar { width: 0; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.drawer-head b { font-size: 15px; font-weight: 500; }

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}

.card-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 10px;
  letter-spacing: .2px;
}

.row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted);
  padding: 5px 0;
}
.row b { color: var(--text); font-weight: 400; font-size: 13px; }

.bar { height: 3px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s; }
/* 额度电池：低于 40% 转黄、低于 15% 转红 —— 比数字更早被注意到 */
.bar i.warn { background: #d8a24a; }
.bar i.low { background: var(--danger); }

/* 输入框占满剩余宽度（钱包兑换码那一行） */
.grow { flex: 1; min-width: 0; }

.mem { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.mem li {
  display: flex; gap: 6px; align-items: flex-start;
  padding: 7px 8px; border-radius: 9px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--line);
  font-size: 12px; line-height: 1.45;
}
.mem li .k { color: var(--faint); flex: none; }
.mem li .v { flex: 1; color: var(--text); cursor: pointer; }
.mem li .x { flex: none; background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.mem li .x:hover { color: var(--danger); }
.mem li.empty { color: var(--faint); justify-content: center; border-style: dashed; }
.mem li .afdot { flex: none; width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; border: 1px solid rgba(255,255,255,.12); }
.mem li .pinmark { flex: none; font-size: 10px; color: var(--accent); border: 1px solid rgba(200,107,124,.35); border-radius: 4px; padding: 0 3px; line-height: 1.4; }

.mem li.mem-edit-wrap { display: block; padding: 0; border: 0; background: none; }
.mem-edit {
  display: flex !important; flex-direction: column; gap: 8px;
  padding: 10px !important; border: 1px solid #4a3a34 !important;
  background: rgba(255,255,255,.035) !important;
}
.mem-edit textarea {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: rgba(0,0,0,.2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 8px; font: inherit; font-size: 12px;
}
.mem-edit-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mem-edit-row select {
  flex: 1; min-width: 72px; font-size: 11px; padding: 4px 5px;
  background: rgba(0,0,0,.2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
}
.mem-pin { display: flex !important; align-items: center; gap: 4px; margin: 0 !important; font-size: 11px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.mem-pin input { margin: 0; accent-color: var(--accent); }
.mem-edit-acts { display: flex; gap: 6px; justify-content: flex-end; }

.hint { font-size: 11px; color: var(--faint); line-height: 1.55; margin: 8px 0 0; }

label {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
label input, label textarea {
  display: block; width: 100%; margin-top: 4px;
  padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px; outline: none; resize: vertical;
}
label input:focus, label textarea:focus { border-color: #4a3a34; }

input.tiny { width: 52px; display: inline-block; margin: 0 4px; text-align: center; }
#cap { width: 56px; display: inline-block; margin: 0; text-align: center; padding: 4px 6px; }

.btn {
  width: 100%; margin-top: 8px; padding: 9px;
  border: 0; border-radius: 10px;
  background: var(--accent); color: #21100f;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: rgba(255,255,255,.03); }
.btn.sm { width: auto; flex: none; padding: 7px 14px; margin: 0; }

.field-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.field-row .hint { margin: 0; flex: 1; min-width: 0; }
.field-row .hint.ok { color: #7fbf9a; }
.field-row .hint.bad { color: var(--danger); }

/* ---------- 渠道列表 ---------- */

.prov-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }

.prov {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2);
}
.prov.off { opacity: .45; }

.prov .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.prov .dot.ok { background: #5fa87e; }
.prov .dot.warn { background: #c9a15a; }

.prov-main { flex: 1; min-width: 0; }
.prov-name { font-size: 12.5px; color: var(--text); }
.prov-sub { font-size: 11px; color: var(--faint); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prov-err { font-size: 10.5px; color: #b8746c; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.prov-acts { display: flex; gap: 4px; flex: none; }

.mini-btn {
  min-width: 26px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 7px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; cursor: pointer;
}
.mini-btn:hover { color: var(--text); border-color: #4a3a34; }
.mini-btn.on { color: var(--accent); border-color: rgba(200,107,124,.55); background: rgba(200,107,124,.1); }
.mini-btn.danger { color: var(--danger); }
.mini-btn.ok { color: #6fbb8f; border-color: rgba(111,187,143,.4); }
.mini-btn:disabled { opacity: .5; }
.btn.danger { color: var(--danger); border-color: rgba(194,90,82,.35); }

.mini { font-size: 11px; color: var(--faint); background: none; border: 0; cursor: pointer; font-family: inherit; }

.disclaimer {
  font-size: 10.5px; color: var(--faint); line-height: 1.6;
  padding: 6px 4px; text-align: center;
}

/* ---------- notice ---------- */

.notice {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10,8,7,.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 32px; text-align: center;
}
.notice p { font-size: 14px; color: var(--muted); line-height: 1.7; max-width: 300px; margin: 0; }
.notice .btn { width: 160px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.presets { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 2px; }
.presets .mini-btn { padding: 4px 8px; }

/* ---------- 登录 ---------- */

.auth {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, #1f1917 0%, #100d0c 70%);
}

.auth-card {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 10px;
}

.auth-card h1 {
  margin: 0 0 2px;
  font-size: 22px; font-weight: 500; letter-spacing: .5px;
  color: var(--text);
}

.auth-card .hint { margin: 0 0 6px; font-size: 12px; color: var(--faint); line-height: 1.6; }
.auth-card .hint.bad { color: var(--danger); min-height: 16px; }
.auth-card .btn { margin-top: 4px; }


/* ---------- emoji 面板 ---------- */

.emoji-panel {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 4px);
  background: #1b1715;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 172px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}

.emoji-panel button {
  border: 0; background: none; cursor: pointer;
  font-size: 21px; line-height: 1;
  padding: 7px 0; border-radius: 9px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emoji-panel button:hover,
.emoji-panel button:active { background: rgba(255,255,255,.07); }

/* ============ 抽屉改版（2026-11-16）：额度置顶 + 折叠分组 ============ */

/* 抽屉本身不再滚动、不再留内边距，由内部两段各自负责 */
.drawer { padding: 0; }

.drawer-head {
  padding: 14px 14px 8px;
  margin-bottom: 0;
  background: var(--panel);
}

/* 额度条：吸顶，滚到哪儿都能看见还剩几条 */
.quota {
  position: sticky; top: 0; z-index: 3;
  padding: 8px 14px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.quota-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.quota-num { display: flex; align-items: baseline; gap: 3px; color: var(--text); }
.quota-num b { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.quota-num em { font-style: normal; font-size: 12px; color: var(--faint); }
.quota-sub { display: flex; gap: 8px; font-size: 11px; color: var(--faint); margin-top: 4px; }
.quota .bar { margin-top: 10px; }
.quota .hint { margin: 8px 0 0; }

/* 升级按钮在额度吃紧时微微发光，提醒但不刺眼 */
.btn.glow {
  box-shadow: 0 0 0 1px rgba(200,107,124,.45), 0 0 14px rgba(200,107,124,.28);
}

.drawer-body { padding: 12px 14px 40px; }

/* 折叠分组：默认收起，只有「她现在」展开 */
details.card { padding: 0; overflow: hidden; }
details.card > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 13px;
  font-size: 12.5px; color: var(--muted);
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: '+'; color: var(--faint); font-size: 15px; line-height: 1; margin-left: 8px;
}
details.card[open] > summary::after { content: '–'; }
details.card[open] > summary { border-bottom: 1px solid var(--line); color: var(--text); }
details.card > *:not(summary) { margin-left: 13px; margin-right: 13px; }
details.card > *:not(summary):first-of-type { margin-top: 10px; }
details.card > *:not(summary):last-child { margin-bottom: 13px; }
details.card .row, details.card label, details.card .bar, details.card .mem,
details.card .hint, details.card .btn, details.card .field-row { margin-left: 0; margin-right: 0; }

/* ============ 升级订阅弹层 ============ */

.sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.5);
}
.sheet[hidden] { display: none !important; }
.sheet-card {
  width: min(420px, 100%);
  max-height: 86vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp .22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.sheet-head b { font-size: 15px; }
.sheet-head .icon { font-size: 18px; line-height: 1; }

.plan-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.plan-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  background: var(--panel-2);
}
.plan-item.on { border-color: rgba(200,107,124,.5); background: rgba(200,107,124,.07); }
.plan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.plan-head b { font-size: 13.5px; }
.plan-head .tag { font-size: 11px; color: var(--faint); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; }
.plan-row { font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.plan-item .btn { margin-top: 8px; }
