/* ============================================================
   口袋48 房间消息 —— 视觉规范
   ------------------------------------------------------------
   冷蓝画布 + 白色纸卡，唯一高饱和蓝做「动作/时间码」，
   琥珀色留给命中高亮与成员强调。克制、左对齐、大点击区、
   无多余动效。复刻「回放弹幕检索」的风格基调。
   ============================================================ */
:root {
  --bg: #e9f0f6;
  --glow: rgba(30, 144, 224, 0.10);
  --card: #ffffff;
  --ink: #14283c;
  --muted: #5e7488;
  --faint: #93a7b8;
  --line: #d6e1eb;
  --line-strong: #c2d2e0;
  --primary: #0b7ec4;
  --primary-deep: #09679f;
  --primary-soft: #e1f0fb;
  --accent: #efa600;
  --mark: #ffe9ab;
  --member-bg: #fff6df;
  --danger: #c23a30;
  --ok: #1f9d55;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(20, 40, 60, 0.03), 0 10px 24px -14px rgba(20, 40, 60, 0.18);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, svg { -webkit-user-drag: none; user-drag: none; }
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 40vh;
  background: radial-gradient(120% 90% at 50% -10%, var(--glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-touch-callout: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(18px + var(--safe-b));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-t)) 16px 10px;
  background: linear-gradient(180deg, rgba(233, 240, 246, 0.96), rgba(233, 240, 246, 0.82));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(194, 210, 224, 0.7);
}
.topbar .brand { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--ink);
}
.topbar .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}
.icon-btn:active { background: var(--primary-soft); }

.view { padding: 14px 16px 0; }

/* ---------- 检索表单卡片 ---------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}
.member-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.member-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--primary-soft);
}
.member-pick .who { flex: 1; min-width: 0; }
.member-pick .who .name { font-size: 16px; font-weight: 800; }
.member-pick .who .team { font-size: 12px; color: var(--muted); }
.member-pick .pick-btn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--primary-deep);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.member-pick .pick-btn:active { background: var(--primary-soft); }

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.search-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 15px;
  background: var(--card);
  color: var(--ink);
}
.search-input::placeholder { color: var(--faint); }
.search-input:focus { border-color: var(--primary); outline: none; }
.search-btn {
  flex: none;
  height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.search-btn:active { background: var(--primary-deep); }

.date-row { display: flex; gap: 8px; margin-bottom: 10px; }
.date-field {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 10px;
  font-size: 14px;
  background: var(--card);
  color: var(--ink);
}
.date-field:focus { border-color: var(--primary); outline: none; }
.date-sep { align-self: center; color: var(--faint); font-size: 13px; }

.tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.sort-seg { display: flex; gap: 6px; }
.sort-seg .seg {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sort-seg .seg.on { background: var(--primary-deep); border-color: var(--primary-deep); color: #fff; }
.hint { font-size: 12px; color: var(--faint); }

/* ---------- 结果统计与列表 ---------- */
.result-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 2px 10px;
  font-size: 12px;
  color: var(--muted);
}
.result-meta .count { font-weight: 700; color: var(--ink); }

.msg-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.msg-card:active { background: #f7fbff; }
.msg-card .head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-card .m-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--primary-soft);
}
.msg-card .m-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.msg-card .m-name .idol-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 11px;
  font-weight: 700;
}
.msg-card .m-time { margin-left: auto; font-size: 12px; color: var(--faint); flex: none; }
.msg-card .body { font-size: 15px; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.msg-card .body mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.msg-card .meta-line { margin-top: 6px; font-size: 13px; color: var(--muted); }
.msg-card .replied {
  margin-top: 6px;
  padding: 6px 9px;
  border-left: 3px solid var(--primary-soft);
  color: var(--muted);
  font-size: 13px;
  background: #f7fafc;
  border-radius: 0 8px 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-card .placeholder { font-size: 14px; color: var(--primary); font-weight: 600; }
.msg-card .media-thumb {
  display: block;
  margin-top: 8px;
  max-width: 160px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* 加载更多 */
.load-more {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 4px 0 10px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--primary-deep);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.load-more:active { background: var(--primary-soft); }
.load-more[disabled] { color: var(--faint); cursor: default; }

/* 空态 / 提示 */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 成员选择浮层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 30, 45, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 84vh;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 30px rgba(20, 40, 60, 0.25);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet-head .search-input { height: 40px; }
.sheet-close {
  flex: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}
.sheet-body { overflow-y: auto; padding: 10px 16px 24px; flex: 1; }
.sheet-group { margin-bottom: 4px; }
.sheet-group .g-title {
  margin: 12px 2px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.4px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.member-item:active { background: var(--primary-soft); }
.member-item .a {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--primary-soft);
}
.member-item .n { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.member-item .t { font-size: 12px; color: var(--faint); flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-item .star { flex: none; color: var(--accent); font-size: 16px; cursor: pointer; }
.member-item.on { background: var(--primary-soft); }

/* ---------- 上下文抽屉 ---------- */
.ctx-drawer {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(15, 30, 45, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.ctx-sheet {
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 30px rgba(20, 40, 60, 0.25);
}
.ctx-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.ctx-head .title { flex: 1; min-width: 0; font-size: 14px; font-weight: 800; }
.ctx-body { overflow-y: auto; padding: 12px 14px 24px; flex: 1; }
.ctx-msg {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.ctx-msg.target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.ctx-msg.is-member { background: var(--member-bg); border-color: #eed9a0; }
.ctx-msg .head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.ctx-msg .who { font-size: 12px; font-weight: 700; }
.ctx-msg .idol-tag {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 10px;
  font-weight: 700;
}
.ctx-msg .tm { margin-left: auto; font-size: 11px; color: var(--faint); flex: none; }
.ctx-msg .body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.ctx-msg .body mark { background: var(--mark); border-radius: 3px; padding: 0 1px; }
.ctx-msg .ph { font-size: 13px; color: var(--primary); font-weight: 600; }

@media (min-width: 720px) {
  .overlay, .ctx-drawer { align-items: center; }
  .sheet, .ctx-sheet { border-radius: 18px; }
}
