:root {
  --bg: #08111d;
  --bg-soft: #0e1b2c;
  --panel: #132238;
  --line: rgba(130, 190, 255, .14);
  --text: #e8f4ff;
  --muted: #8fb0cc;
  --blue: #4aa8ff;
  --blue-deep: #1f6fd0;
  --mine: #1d63b8;
  --danger: #e2564f;
  --radius: 16px;
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(80% 60% at 80% 0%, rgba(60, 140, 230, .18), transparent 60%),
    radial-gradient(70% 50% at 0% 100%, rgba(40, 90, 170, .16), transparent 60%);
  pointer-events: none;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
#login { align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, rgba(20, 38, 62, .96), rgba(10, 22, 38, .98));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 30px 80px rgba(0, 8, 20, .6);
  text-align: center;
}
.logo { font-size: 44px; line-height: 1; }
.login-card h1 { margin: 12px 0 4px; font-size: 22px; letter-spacing: .02em; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 12.5px; letter-spacing: .14em; }
.login-card label { display: block; text-align: left; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
.login-card input:focus { border-color: rgba(110, 190, 255, .6); }
button { font: inherit; cursor: pointer; border: 0; }
.primary {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  color: #03203a;
  background: linear-gradient(180deg, #b9ecff, #5cb2ff 62%, #3f93ea);
  box-shadow: 0 12px 26px rgba(50, 150, 255, .35);
}
.primary:active { transform: scale(.99); }
.err { min-height: 18px; margin: 12px 0 0; color: #ff9d9d; font-size: 12.5px; }

/* ---------- 聊天 ---------- */
#chat { background: transparent; }

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(9, 19, 32, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}
.title { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; }
.title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 8px #3ddc84; flex: 0 0 auto; }
.who { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32%; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: var(--text); font-size: 15px; display: grid; place-items: center;
}
.icon-btn:active { background: rgba(255, 255, 255, .14); }

.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.row { display: flex; align-items: flex-start; gap: 8px; width: 100%; }
.row.mine { flex-direction: row-reverse; }
.stack { display: flex; flex-direction: column; gap: 4px; max-width: min(76%, 560px); min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #062033;
  background: #6fc0ff;
}
.bubble {
  max-width: 100%;
  padding: 10px 13px;
  border-radius: 16px 16px 16px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.row.mine .bubble { background: var(--mine); border-color: rgba(120, 190, 255, .3); border-radius: 16px 16px 6px 16px; }
.bubble img, .bubble video { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; }
.bubble img { cursor: zoom-in; }
.meta { margin-top: 4px; font-size: 10.5px; color: rgba(220, 240, 255, .5); }
.row.mine .meta { text-align: right; }
.empty { margin: 48px auto; color: var(--muted); font-size: 13px; text-align: center; }

.netbar {
  padding: 7px 12px;
  font-size: 12px;
  text-align: center;
  color: #ffd9a8;
  background: rgba(120, 70, 10, .35);
  border-bottom: 1px solid rgba(255, 200, 120, .25);
}

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(9, 19, 32, .9);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.round {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  background: rgba(255, 255, 255, .07); color: var(--text); font-size: 17px;
}
.round:active { background: rgba(255, 255, 255, .16); }
#input {
  flex: 1; min-height: 40px; max-height: 120px;
  padding: 11px 13px; border-radius: 13px; resize: none;
  font: inherit; font-size: 15px; line-height: 1.4;
  color: var(--text); background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); outline: none;
}
#input:focus { border-color: rgba(110, 190, 255, .5); }
.send {
  padding: 0 18px; height: 40px; border-radius: 13px;
  font-weight: 800; color: #04233f;
  background: linear-gradient(180deg, #b9ecff, #5cb2ff 62%, #3f93ea);
}
.send:active { transform: scale(.98); }

.upload {
  position: absolute; left: 12px; right: 12px; bottom: 76px;
  background: rgba(9, 22, 38, .95); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--muted);
}
.upload .bar { flex: 1; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.upload .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4aa8ff, #b9ecff); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 18px;
  background: rgba(2, 8, 16, .72);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: min(360px, 100%);
  background: linear-gradient(180deg, rgba(22, 42, 68, .98), rgba(10, 22, 38, .99));
  border: 1px solid var(--line); border-radius: 20px;
  padding: 22px; text-align: center;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55);
}
.modal-card.wide { width: min(720px, 100%); }
.modal-card h2 { margin: 0 0 6px; font-size: 17px; }
.incoming-text { margin: 8px 0 18px; color: var(--muted); font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: 12px; font-weight: 700; }
.ghost { background: rgba(255, 255, 255, .08); color: var(--text); }
.danger { background: var(--danger); color: #fff; }

.videos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.videos video { width: 100%; aspect-ratio: 3 / 4; background: #000; border-radius: 14px; object-fit: cover; }

.user-list { display: grid; gap: 8px; margin-top: 12px; }
.user-list button {
  padding: 12px; border-radius: 12px; text-align: left;
  background: rgba(255, 255, 255, .06); color: var(--text);
}
.user-list button:active { background: rgba(255, 255, 255, .14); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 30; max-width: 84vw;
  padding: 10px 16px; border-radius: 12px;
  background: rgba(10, 24, 40, .96); border: 1px solid var(--line);
  color: var(--text); font-size: 13px;
}

@media (min-width: 760px) {
  .msgs { padding: 22px max(18px, calc((100% - 760px) / 2)) 10px; }
  .composer { padding-left: max(18px, calc((100% - 760px) / 2)); padding-right: max(18px, calc((100% - 760px) / 2)); }
}
