/* 阿鳞 · 深色/浅色聊天气泡 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f0f13;
  --topbar: #16161c;
  --bubble-her: #23232b;
  --bubble-me: #95ec69;
  --text: #ececf1;
  --text-dim: #8b8b96;
  --accent: #6ea8ff;
  --me-text: #0c1a06;
}
body.light {
  --bg: #f2f3f5;
  --topbar: #ffffff;
  --bubble-her: #ffffff;
  --bubble-me: #95ec69;
  --text: #1b1b1f;
  --text-dim: #8a8a92;
  --accent: #2f7cf6;
  --me-text: #0c1a06;
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* ── 登录 ── */
.login { position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; }
.login.hidden { display: none; }
.login-box { text-align: center; width: min(86vw, 320px); }
.login-avatar { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%;
  background: linear-gradient(135deg, #4a7cff, #7fd6ff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 36px; }
.login-title { font-size: 22px; font-weight: 600; }
.login-sub { color: var(--text-dim); font-size: 13px; margin: 6px 0 18px; }
#pass { width: 100%; padding: 12px 14px; font-size: 16px; text-align: center;
  background: var(--bubble-her); color: var(--text); border: 1px solid rgba(128,128,140,.35);
  border-radius: 12px; outline: none; letter-spacing: 4px; }
#login-btn { width: 100%; margin-top: 12px; padding: 12px; font-size: 15px;
  background: var(--accent); color: #fff; border: none; border-radius: 12px; cursor: pointer; }
.login-err { color: #ff6b6b; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── 顶栏 ── */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--topbar); display: flex; align-items: center; gap: 10px;
  padding: 0 12px; border-bottom: 1px solid rgba(128,128,140,.22); z-index: 10; }
.avatar { width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
  background: linear-gradient(135deg, #4a7cff, #7fd6ff); }
.topinfo { flex: 1; min-width: 0; }
.topname { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.badge { font-size: 11px; font-weight: 400; color: #a7f3a0; background: rgba(95,220,110,.15);
  padding: 1px 8px; border-radius: 99px; }
body.light .badge { color: #1a7f37; background: rgba(26,127,55,.1); }
.topsub { font-size: 11px; color: var(--text-dim); }
.gear { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }

/* ── 聊天区 ── */
#chat { position: fixed; top: 56px; left: 0; right: 0;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto; padding: 12px 14px 18px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.time-sep { text-align: center; margin: 10px 0 6px; }
.time-sep span { font-size: 11px; color: var(--text-dim); background: rgba(128,128,140,.12);
  padding: 2px 10px; border-radius: 99px; }
.row { display: flex; margin: 5px 0; align-items: flex-start; }
.row.me { justify-content: flex-end; }
.row .avatar { width: 34px; height: 34px; font-size: 16px; border-radius: 7px; }
.bubble-wrap { max-width: 72%; display: flex; flex-direction: column; }
.row.her .bubble-wrap { margin-left: 8px; align-items: flex-start; }
.row.me .bubble-wrap { align-items: flex-end; margin-right: 8px; }
.bubble { padding: 8px 12px; border-radius: 8px; font-size: 15px; line-height: 1.45;
  word-break: break-word; white-space: pre-wrap; position: relative; }
.row.her .bubble { background: var(--bubble-her); border-top-left-radius: 2px; }
.row.me .bubble { background: var(--bubble-me); color: var(--me-text); border-top-right-radius: 2px; }
/* QQ 那种小尖角 */
.row.her .bubble::before { content: ''; position: absolute; left: -5px; top: 9px;
  width: 0; height: 0; border: 5px solid transparent; border-left: 0;
  border-right-color: var(--bubble-her); }
.row.me .bubble::after { content: ''; position: absolute; right: -5px; top: 9px;
  width: 0; height: 0; border: 5px solid transparent; border-right: 0;
  border-left-color: var(--bubble-me); }
.row .bubble.image::before, .row .bubble.image::after,
.row .bubble.sticker::before, .row .bubble.sticker::after { display: none; }
.msgtime { display: none; }

/* 语音条 */
.bubble.voice { display: flex; align-items: center; gap: 8px; cursor: pointer;
  min-width: 90px; padding: 10px 14px; }
.bubble.voice .wave { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.bubble.voice .wave i { width: 2px; background: currentColor; opacity: .55; border-radius: 1px; }
.bubble.voice .wave i:nth-child(3n) { height: 14px; }
.bubble.voice .wave i:nth-child(3n+1) { height: 8px; }
.bubble.voice .wave i:nth-child(3n+2) { height: 11px; }
.bubble.voice .dur { font-size: 12px; opacity: .8; }
.bubble.voice.playing .wave i { animation: wave .6s infinite alternate; }

/* 语音进度条 / 倍速 / 图片 / 表情 */
.bubble.voice { position: relative; padding-bottom: 10px; }
.bubble.voice .pbar { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 2px; width: 0%;
  background: var(--accent); transition: width .15s linear; border-radius: 2px; }
.bubble.voice.fast .dur::after { content: ' 1.5×'; color: var(--accent); }
.bubble.image { padding: 3px; background: transparent; }
.bubble.image img { display: block; max-width: min(220px, 62vw); max-height: 300px;
  border-radius: 10px; cursor: zoom-in; }
.bubble.sticker { background: transparent; font-size: 13px; color: var(--text-dim);
  border: 1px dashed rgba(128,128,140,.45); }

/* 加载更早 */
.loadmore { position: fixed; top: 62px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: var(--text-dim); padding: 4px 0; z-index: 9; pointer-events: none; }

/* 搜索 */
.search-results { max-height: 54vh; overflow-y: auto; margin-top: 10px; }
.search-hit { display: flex; gap: 8px; align-items: baseline; padding: 9px 4px;
  border-bottom: 1px solid rgba(128,128,140,.14); cursor: pointer; font-size: 14px; }
.search-hit:active { background: rgba(128,128,140,.12); }
.sh-time { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.sh-who { font-size: 12px; color: var(--accent); flex-shrink: 0; }
.sh-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { font-size: 13px; color: var(--text-dim); padding: 14px 4px; }
.search-hit.me .sh-who { color: #6fd47a; }

/* 搜索定位高亮 */
.row.flash .bubble { animation: flash 1.4s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes wave { from { opacity: .35; } to { opacity: 1; } }
.voice-text { font-size: 11px; color: var(--text-dim); margin-top: 4px; padding: 0 4px; opacity: .85; }

.busy-dot { display: none !important; }

/* 对方正在输入… */
.typing { margin: 4px 0 6px 46px; font-size: 12px; color: var(--text-dim); }
.busy-dot.show { display: flex; gap: 4px; }
.busy-dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim);
  animation: blink 1.2s infinite; }
.busy-dot i:nth-child(2) { animation-delay: .2s; }
.busy-dot i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

/* ── 输入栏 ── */
.inputbar { position: fixed; bottom: 0; left: 0; right: 0; height: 64px;
  background: var(--topbar); display: flex; align-items: center; gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(128,128,140,.22); z-index: 10; }
#input { flex: 1; resize: none; max-height: 96px; padding: 10px 14px; font-size: 15px;
  background: rgba(128,128,140,.12); color: var(--text); border: 1px solid rgba(128,128,140,.25);
  border-radius: 18px; outline: none; font-family: inherit; }
#send-btn { width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 17px; cursor: pointer; flex-shrink: 0; }
#send-btn:disabled { opacity: .4; }
.mic { width: 36px; height: 36px; border-radius: 50%; border: none; flex-shrink: 0;
  background: rgba(128,128,140,.15); color: var(--text); font-size: 16px; cursor: pointer; }

/* ── 设置面板 ── */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; }
.sheet.hidden { display: none; }
.sheet-card { width: min(100%, 480px); max-height: 86vh; overflow-y: auto;
  background: var(--topbar); border-radius: 16px 16px 0 0; padding: 16px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.35); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head .x { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }
.sheet-body label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.sheet-body input[type="text"], .sheet-body input:not([type]), .sheet-body input[type="password"],
.sheet-body input[type="email"], .sheet-body select {
  width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 15px; font-family: inherit;
  background: rgba(128,128,140,.12); color: var(--text); box-sizing: border-box;
  border: 1px solid rgba(128,128,140,.25); border-radius: 10px; outline: none; display: block; }
.sheet-body input[type="file"] { width: 100%; margin-top: 6px; font-size: 12px; color: var(--text-dim); }
.sheet-body input[type="color"] { width: 100%; height: 38px; margin-top: 6px; background: none;
  border: 1px solid rgba(128,128,140,.25); border-radius: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-tip { font-size: 12px; color: var(--accent); min-height: 18px; margin: 4px 0 10px; }
.sheet-divider { margin: 18px 0 12px; padding-top: 14px; font-size: 12px; color: var(--text-dim);
  border-top: 1px solid rgba(128,128,140,.22); }
.sheet-body label.inline { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--text); }
.sheet-body label.inline input[type="checkbox"] { width: auto; margin: 0; }
.ghost { padding: 10px 12px; font-size: 14px; border-radius: 10px; cursor: pointer;
  background: rgba(128,128,140,.14); color: var(--text); border: 1px solid rgba(128,128,140,.25); }
.primary { width: 100%; padding: 12px; font-size: 15px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; cursor: pointer; }
.primary:disabled { opacity: .5; }

@media (min-width: 640px) {
  .bubble-wrap { max-width: 56%; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 16px; }
}

/* ---- tabs ---- */
.tabbtn { background: none; border: none; color: var(--text-dim); font-size: 13px;
  padding: 5px 7px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.tabbtn.active { color: var(--text); background: rgba(128,128,140,.18); }

/* ---- moments / diary pages ---- */
.page { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; overflow-y: auto;
  padding: 12px 14px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.composer { background: rgba(128,128,140,.10); border-radius: 12px; padding: 10px; margin-bottom: 14px; }
.composer textarea { width: 100%; box-sizing: border-box; background: transparent; border: none;
  color: var(--text); font-size: 15px; font-family: inherit; resize: none; outline: none; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.pickimg { font-size: 13px; color: var(--text-dim); cursor: pointer; }
.hint { flex: 1; font-size: 12px; color: var(--accent); }
.post-btn { margin-left: auto; padding: 7px 16px; border: none; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; font-family: inherit; }
.post-btn:disabled { opacity: .55; }
.date-input { background: rgba(128,128,140,.12); border: 1px solid rgba(128,128,140,.25);
  color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 14px; font-family: inherit; }

.feed { display: flex; flex-direction: column; gap: 12px; }
.card { background: rgba(128,128,140,.09); border-radius: 12px; padding: 12px; }
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.avatar.small { width: 30px; height: 30px; font-size: 14px; border-radius: 6px; }
.card-who { display: flex; flex-direction: column; line-height: 1.3; }
.card-who b { font-size: 14px; }
.card-time { font-size: 11px; color: var(--text-dim); }
.card-text { font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.card-img { display: block; margin-top: 8px; max-width: 100%; max-height: 320px; border-radius: 8px; cursor: zoom-in; }
.card-likes { margin-top: 8px; font-size: 12px; color: #e06a9a; }
.card-comments { margin-top: 6px; }
.cmt-item { font-size: 13px; line-height: 1.5; color: var(--text); opacity: .92; }
.cmt-item b { color: var(--accent); font-weight: 500; }
.card-actions { display: flex; gap: 14px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid rgba(128,128,140,.15); }
.act { background: none; border: none; color: var(--text-dim); font-size: 13px;
  cursor: pointer; font-family: inherit; padding: 2px 0; }
.act.like.on { color: #e06a9a; }
.cmt-bar { margin-top: 8px; }
.cmt-bar input { width: 100%; box-sizing: border-box; background: rgba(128,128,140,.12);
  border: 1px solid rgba(128,128,140,.2); color: var(--text); border-radius: 8px;
  padding: 7px 10px; font-size: 14px; font-family: inherit; outline: none; }
.day-sep { font-size: 12px; color: var(--text-dim); margin: 6px 0 -4px 2px; }
.card.diary .card-who { margin-bottom: 6px; }
.empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 26px 0; }

/* narrow screens: keep header from crowding */
@media (max-width: 520px) {
  .topsub { display: none; }
  .tabbtn { font-size: 12px; padding: 4px 5px; }
  .topname { font-size: 15px; }
  .topbar { gap: 6px; }
}
