:root {
  /* 只允许浅色：挡住浏览器/系统的强制深色反转 */
  color-scheme: light only;
  /* 简约白 + 磨砂玻璃 */
  --ink: #1d1d1f;
  --muted: #8a8a8e;
  --line: rgba(0, 0, 0, .06);
  --glass: rgba(255, 255, 255, .38);
  --glass-strong: rgba(255, 255, 255, .56);
  --glass-border: rgba(255, 255, 255, .8);
  --glass-border-2: rgba(150, 150, 155, .26);
  --accent: #1d1d1f;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

/* 关键：下面的 display:flex 会盖掉 [hidden] 的默认隐藏，这里兜底 */
[hidden] { display: none !important; }

html { background: #F7F7F8; }

html, body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  background: transparent;
}

/* 背景图：鱼娘女孩，上面盖一层很淡的白纱，保证字和玻璃都清楚 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("/bg.jpg") center 42% / cover no-repeat;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, .30) 0%, rgba(255, 255, 255, .46) 45%, rgba(255, 255, 255, .60) 100%);
}

/* ---------- 登录 ---------- */
.auth {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px 26px;
  border-radius: 30px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: 0 20px 50px rgba(60, 60, 65, .1), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.auth-card h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: 4px; font-weight: 600; }
.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; letter-spacing: .5px; }

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  padding: 4px; border-radius: 16px;
  background: rgba(120, 120, 128, .08);
}
.tab {
  flex: 1; padding: 9px 0;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 14px;
  transition: .2s;
}
.tab.active {
  background: rgba(255, 255, 255, .95);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(60, 60, 65, .1);
}

#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input {
  padding: 13px 15px;
  border: 1px solid var(--glass-border-2);
  border-radius: 16px;
  background: rgba(255, 255, 255, .6);
  color: var(--ink);
  font: inherit; font-size: 15px;
  outline: none;
  transition: .2s;
}
#auth-form input::placeholder { color: #a8a8ad; }
#auth-form input:focus { border-color: rgba(90, 90, 95, .5); background: rgba(255, 255, 255, .92); }
#auth-submit {
  margin-top: 8px; padding: 13px;
  border: 0; border-radius: 16px;
  background: #1d1d1f; color: #fff;
  font: inherit; font-size: 15px; font-weight: 600; letter-spacing: 1px;
  transition: .18s;
}
#auth-submit:active { transform: scale(.985); opacity: .9; }
.err { color: #d04a37; font-size: 13px; min-height: 18px; margin: 4px 0 0; }

/* ---------- 聊天 ---------- */
.chat {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  background: transparent;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, .5);
  border-bottom: 1px solid rgba(255, 255, 255, .6);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
}
.room { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #c9c9ce; }
.dot.on { background: #34c759; box-shadow: 0 0 8px rgba(52, 199, 89, .6); }
.dot.off { background: #ff9f0a; box-shadow: 0 0 8px rgba(255, 159, 10, .55); }
.who { font-size: 12px; color: var(--muted); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.msg { display: flex; flex-direction: column; max-width: 80%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg .name { font-size: 11px; color: var(--muted); margin: 0 10px 5px; }

.bubble {
  padding: 11px 15px;
  border-radius: 24px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(13px) saturate(1.35);
  -webkit-backdrop-filter: blur(13px) saturate(1.35);
  box-shadow: 0 4px 18px rgba(60, 60, 65, .07), inset 0 1px 0 rgba(255, 255, 255, .85);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.6;
}
/* 自己发的：只描边、几乎透明，跟参考图一致 */
.msg.mine .bubble {
  background: rgba(255, 255, 255, .18);
  border-color: var(--glass-border-2);
  box-shadow: none;
  border-bottom-right-radius: 10px;
}
.msg:not(.mine) .bubble { border-bottom-left-radius: 10px; }

.bubble img {
  display: block;
  max-width: 220px; max-height: 260px;
  border-radius: 16px;
}
.bubble .sticker-img {
  max-width: 120px; max-height: 120px;
  border-radius: 12px;
  border: 0; box-shadow: none;
}
.bubble audio { display: block; width: 200px; }
.voice-wrap { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.voice-bars { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.voice-bars i { display: block; width: 3px; background: currentColor; opacity: .5; border-radius: 2px; }
.time { font-size: 10px; color: #a8a8ad; margin: 5px 10px 0; }

.typing { padding: 0 18px 6px; font-size: 12px; color: var(--muted); }

/* 输入区：一行玻璃条，左箭头展开工具，右边圆形发送 */
.composer {
  position: relative;
  margin: 6px 10px calc(10px + var(--safe-b));
  padding: 6px 8px 6px 6px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border-radius: 24px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 10px 34px rgba(60, 60, 65, .1), inset 0 1px 0 rgba(255, 255, 255, .95);
}
#input {
  flex: 1 1 auto;
  resize: none;
  max-height: 96px;
  height: 34px;
  min-height: 34px;
  padding: 7px 8px 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 20px;
  outline: none;
}
#input::placeholder { color: #a1a1a6; }

/* 左边的展开箭头 */
.more {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--glass-border-2);
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  color: var(--ink);
  padding: 0;
  transition: .2s;
}
.more svg { transition: transform .22s ease; }
.composer.open .more svg { transform: rotate(180deg); }
.more:active { transform: scale(.94); }

/* 三个工具：点箭头才从下方升起（磨砂更重，像一小块毛玻璃） */
.tools {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 8px);
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 22px;
  background: rgba(252, 252, 253, .82);
  border: 1px solid rgba(255, 255, 255, .9);
  backdrop-filter: blur(28px) saturate(1.2);
  -webkit-backdrop-filter: blur(28px) saturate(1.2);
  box-shadow: 0 16px 40px rgba(40, 40, 45, .16), inset 0 1px 0 rgba(255, 255, 255, 1);
  opacity: 0;
  transform: translateY(6px) scale(.96);
  pointer-events: none;
  transition: .2s ease;
}
.composer.open .tools { opacity: 1; transform: none; pointer-events: auto; }

/* 黑白简约风工具按钮 */
.icon {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 50%;
  background: #fff;
  color: #1d1d1f;
  transition: .16s ease;
}
.icon:active,
.icon:hover {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}
.icon:active { transform: scale(.95); }

/* 圆形回车发送 */
.send {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #1d1d1f;
  color: #fff;
  transition: .18s;
}
.send:active { transform: scale(.94); opacity: .92; }
.send:disabled { opacity: .28; }

/* ---------- 录音 ---------- */
/* 不挡点击：只做状态提示，麦克风按钮本身负责开始/发送 */
.recording {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 50;
}
.rec-card {
  min-width: 200px;
  padding: 16px 20px 14px;
  text-align: center;
  border-radius: 22px;
  background: rgba(252, 252, 253, .86);
  border: 1px solid rgba(255, 255, 255, .9);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
  box-shadow: 0 16px 40px rgba(40, 40, 45, .18), inset 0 1px 0 rgba(255, 255, 255, 1);
}
.rec-wave { color: #ff3b30; font-size: 13px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.rec-time { font-size: 22px; font-variant-numeric: tabular-nums; margin: 2px 0 4px; letter-spacing: 1px; }
.rec-card p { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.rec-actions { display: flex; gap: 8px; justify-content: center; pointer-events: auto; }
.rec-btn {
  padding: 7px 16px;
  border-radius: 14px;
  font: inherit;
  font-size: 13px;
  border: 1px solid rgba(0, 0, 0, .14);
  background: #fff;
  color: #1d1d1f;
  transition: .15s;
}
.rec-btn.solid { background: #1d1d1f; border-color: #1d1d1f; color: #fff; }
.rec-btn:active { transform: scale(.96); }

/* ---------- 表情面板 ---------- */
.sticker-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 52vh;
  padding: 14px 14px calc(16px + var(--safe-b));
  z-index: 40;
  overflow-y: auto;
  background: var(--glass-strong);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(26px) saturate(1.6);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -12px 40px rgba(60, 60, 65, .12);
}
.sp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sp-head button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; }
.sp-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sp-list img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--glass-border-2);
  background: rgba(255, 255, 255, .5);
}
.sp-tip { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.lightbox {
  position: fixed; inset: 0;
  background: rgba(20, 20, 22, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 14px; }

/* 语音转写文字 */
.voice-text {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.55;
  opacity: .85;
  max-width: 240px;
  word-break: break-word;
  border-top: 1px solid rgba(0, 0, 0, .08);
  padding-top: 6px;
}

/* 录音中：麦克风按钮反白提示 */
.composer.recording-on #btn-voice {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 8px);
  padding: 9px 16px;
  border-radius: 16px;
  background: rgba(29, 29, 31, .9);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  z-index: 80;
  pointer-events: none;
  transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 语音播放中 */
.bubble.playing .voice-bars i { animation: bar 0.6s infinite alternate; }
.bubble.playing .voice-bars i:nth-child(2) { animation-delay: .1s; }
.bubble.playing .voice-bars i:nth-child(3) { animation-delay: .2s; }
.bubble.playing .voice-bars i:nth-child(4) { animation-delay: .3s; }
.bubble.playing .voice-bars i:nth-child(5) { animation-delay: .4s; }
@keyframes bar { from { transform: scaleY(.55); } to { transform: scaleY(1.15); } }
