/* 密聊室 —— 界面样式（浅/深色自适应） */
:root {
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-2: #ECF1EF;
  --ink: #1D2B27;
  --ink-soft: #5D706A;
  --line: #D8E2DE;
  --accent: #0E6B5C;
  --accent-hover: #0B5A4D;
  --accent-ink: #FFFFFF;
  --bubble-me: #D9EBE5;
  --bubble-peer: #FFFFFF;
  --err: #B23B2E;
  --shadow: 0 1px 3px rgba(20, 40, 35, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111917;
    --surface: #19241F;
    --surface-2: #20302A;
    --ink: #E2ECE8;
    --ink-soft: #90A69E;
    --line: #2B3A34;
    --accent: #3DB79C;
    --accent-hover: #4FCBAF;
    --accent-ink: #0B1512;
    --bubble-me: #1E3A32;
    --bubble-peer: #19241F;
    --err: #E0796C;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 首页 ---------- */
.home {
  max-width: 26rem;
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.brand { text-align: center; margin-bottom: 0.5rem; }
.brand h1 { margin: 0; font-size: 2rem; letter-spacing: 0.15em; }
.brand p { margin: 0.3rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.25rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.card h2 { margin: 0; font-size: 1.05rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field span { font-size: 0.8rem; color: var(--ink-soft); }
.field input, .field select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
}
.field input::placeholder { color: var(--ink-soft); opacity: 0.7; }

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.5; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  color: var(--ink-soft);
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.ghost.big { font-size: 1.3rem; line-height: 1; padding: 0.35rem 0.75rem; }

.err { color: var(--err); font-size: 0.88rem; text-align: center; margin: 0; }
.tiny { color: var(--ink-soft); font-size: 0.75rem; text-align: center; line-height: 1.6; }

/* ---------- 房间 ---------- */
.room {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 52rem;
  margin: 0 auto;
  width: 100%;
}
.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.room-id-wrap { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.room-label { font-size: 0.78rem; color: var(--ink-soft); }
.room-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}
.room-meta { display: flex; align-items: center; gap: 0.5rem; }
.tag {
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.banner {
  background: var(--err);
  color: #fff;
  text-align: center;
  font-size: 0.82rem;
  padding: 0.3rem;
}

.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sys {
  align-self: center;
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.1rem 0.8rem;
}

.msg { display: flex; flex-direction: column; max-width: 78%; align-self: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .meta { font-size: 0.72rem; color: var(--ink-soft); margin: 0 0.4rem 0.15rem; }
.msg .bubble {
  background: var(--bubble-peer);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
}
.msg.me .bubble { background: var(--bubble-me); }
.msg .bubble img.thumb {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  cursor: pointer;
}
.msg .bubble img.full { display: block; max-width: 100%; border-radius: 8px; }
.msg .bubble video { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; }

.filecard { display: flex; align-items: center; gap: 0.7rem; min-width: 13rem; }
.filecard .ficon { font-size: 1.5rem; }
.filecard .finfo { flex: 1; min-width: 0; }
.filecard .fname { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filecard .fsize { font-size: 0.75rem; color: var(--ink-soft); }
.filecard button { flex-shrink: 0; }
.progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-top: 0.3rem;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s;
}

/* ---------- 输入区 ---------- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer textarea {
  flex: 1;
  resize: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  max-height: 9rem;
}

/* ---------- 遮罩 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.overlay-box p { margin: 0.8rem 0 0; font-size: 0.9rem; color: var(--ink-soft); }
.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

[hidden] { display: none !important; }
