:root {
  --bg: #0c0e12;
  --panel: #15181e;
  --panel-2: #1d2128;
  --line: #23272f;
  --text: #eceef1;
  --muted: #868d99;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, .12);
  --mine: #3b6fd4;
  --theirs: #20242b;
  --danger: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% -8%, rgba(110, 168, 254, .07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================ 落地页 ============================ */

.landing {
  max-width: 440px;
  margin: 0 auto;
  padding: 96px 24px 64px;
  text-align: center;
}

.mark {
  width: 40px;
  height: 40px;
  margin: 0 auto 22px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--accent), #9b7bff);
  box-shadow: 0 8px 28px rgba(110, 168, 254, .3);
}

.landing h1 {
  font-size: 34px;
  margin: 0 0 10px;
  font-weight: 600;
  letter-spacing: 4px;
}
.tagline {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 2px;
  margin: 0 0 30px;
}

.desc {
  color: var(--muted);
  line-height: 1.9;
  font-size: 14px;
  margin: 0 auto;
  max-width: 380px;
}
.desc strong { color: var(--text); font-weight: 600; }

.primary {
  margin-top: 32px;
  padding: 13px 36px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  box-shadow: 0 6px 22px rgba(110, 168, 254, .28);
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(110, 168, 254, .38); }
.primary:active { transform: translateY(0); }

.once-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.once-pick input { width: 15px; height: 15px; accent-color: var(--accent); }

.result { margin-top: 28px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.linkbox { display: flex; gap: 8px; }
.linkbox input {
  flex: 1;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.linkbox button {
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.linkbox button:hover { border-color: var(--accent); }
.enter {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.notes {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.note {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.75;
  margin: 0 0 6px;
}
.hidden { display: none !important; }

/* 视觉隐藏但仍在渲染树中：iOS 允许对其编程式 .click()（display:none 会被拦截）。 */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================ 聊天室 ============================ */

body.room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 移动端动态视口：键盘/工具栏弹出时布局不破 */
}

/* 口令门 */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, .94);
  backdrop-filter: blur(6px);
}
.gate-card {
  width: min(92%, 380px);
  padding: 32px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
}
.gate-card h2 { margin: 0 0 12px; font-size: 19px; font-weight: 600; letter-spacing: 1px; }
.gate-msg { color: var(--muted); font-size: 13.5px; line-height: 1.7; margin: 0 0 20px; }
.gate-msg.error { color: var(--danger); }
.gate-msg strong { color: var(--text); }
.gate-card input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* ≥16px：避免 iOS 聚焦时自动放大 */
}
.gate-card input:focus { outline: none; border-color: var(--accent); }
.gate-card .primary { width: 100%; margin: 0; }
.gate-hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 16px 0 0; }

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 18px;
  background: rgba(21, 24, 30, .7);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: 1px; }
.peers { color: var(--accent); font-size: 12.5px; }
.status { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.status.error { color: var(--danger); }

.leave {
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.leave:hover { color: var(--danger); border-color: rgba(255,107,107,.4); }

.left-note { margin: auto; text-align: center; color: var(--muted); line-height: 1.8; }

/* 离开确认弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(8,10,14,.72); backdrop-filter: blur(4px);
}
.modal-card {
  width: min(92%, 380px);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
}
.modal-card h3 { margin: 0 0 12px; font-size: 18px; }
.modal-card p { color: var(--muted); line-height: 1.7; font-size: 14px; margin: 0 0 20px; }
.modal-sub { font-size: 12.5px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.modal-actions button { padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; border: 1px solid var(--line); }
.btn-danger { background: rgba(255,107,107,.12); border-color: rgba(255,107,107,.45); color: #ff9a9a; }
.btn-danger:hover { background: rgba(255,107,107,.2); }
.btn-ghost { background: var(--bg); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-text { background: transparent; border: none; color: var(--muted); font-weight: 400; }

.fs-badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
}
.fs-badge.strong { background: var(--accent-soft); color: var(--accent); }

.safety {
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.safety:hover { color: var(--text); border-color: var(--accent); }

.safety-bar {
  flex: 0 0 auto;
  padding: 9px 18px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.safety-code {
  font-family: ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 700;
  user-select: all;
}
.safety-hint { font-size: 12px; }

.burn-pick {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.burn-pick select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 12.5px;
}

/* 消息区 */
.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.msg.theirs { justify-content: flex-start; }

.bubble {
  max-width: min(78%, 560px);
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 14.5px;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.mine .bubble { background: var(--mine); color: #fff; border-bottom-right-radius: 5px; }
.msg.theirs .bubble { background: var(--theirs); color: var(--text); border-bottom-left-radius: 5px; }

.media { max-width: 100%; max-height: 360px; border-radius: 10px; display: block; }
.file-link { color: inherit; text-decoration: underline; }
.recv-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress {
  height: 6px;
  width: 180px;
  background: rgba(255, 255, 255, .12);
  border-radius: 3px;
  overflow: hidden;
}
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .1s; }

.burn-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  opacity: .65;
  vertical-align: middle;
}
.msg.burning { opacity: 0; transform: scale(.96); transition: opacity .3s, transform .3s; }

/* 输入区 */
.compose {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(21, 24, 30, .7);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
}
.attach-wrap { position: relative; flex: 0 0 auto; display: flex; }
.attach {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 24px; line-height: 1;
  color: var(--muted);
  background: var(--panel-2);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.attach:hover { color: var(--accent); }

/* 上传方式弹出菜单 */
.attach-menu {
  position: absolute;
  left: 0;
  bottom: 52px;
  min-width: 168px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 20;
}
.am-item {
  text-align: left;
  padding: 11px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.am-item:hover { background: var(--panel-2); }
.am-item:active { background: var(--accent-soft); }
#text-input {
  flex: 1;
  min-width: 0; /* 允许在窄屏内收缩，不撑破输入栏 */
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* ≥16px：避免 iOS 聚焦时自动放大 */
}
#text-input::placeholder { color: var(--muted); }
#text-input:focus { outline: none; border-color: var(--accent); }
.send {
  padding: 0 22px; height: 42px;
  border: none; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer;
  transition: filter .15s;
}
.send:hover { filter: brightness(1.08); }

/* ============================ 移动端适配 ============================ */

@media (max-width: 600px) {
  /* 落地页：收紧上方留白 */
  .landing { padding: 56px 20px 44px; }
  .landing h1 { font-size: 30px; }
  .desc { font-size: 13.5px; }

  /* 顶栏：允许换行，缩小间距/字号，避免横向溢出 */
  .topbar { flex-wrap: wrap; gap: 7px 9px; padding: 10px 14px; }
  .topbar .status { margin-left: auto; }
  .fs-badge, .peers, .safety, .burn-pick, .burn-pick select { font-size: 11.5px; }

  /* 安全码提示换行显示，避免挤成一长行 */
  .safety-bar { font-size: 12px; line-height: 1.6; }
  .safety-hint { display: block; margin-top: 3px; }

  /* 气泡更宽一点，利用窄屏空间 */
  .bubble { max-width: 86%; }
  .media { max-height: 300px; }

  /* 输入栏更紧凑 */
  .compose { gap: 8px; padding: 10px 12px; }
  .attach { width: 40px; height: 40px; font-size: 20px; }
  .send { padding: 0 16px; }
}

/* 触摸设备：去掉依赖悬停的视觉反馈，避免“悬停态卡住” */
@media (hover: none) {
  .primary:hover { transform: none; }
}
