/* 深色是默认。浅色靠 <html data-theme="light"> 整套换变量 ——
   所有颜色都走变量，所以换主题不需要改任何一条规则。
   data-theme 由 index.html 里那段内联脚本在样式生效前设好，避免先画一帧再跳。 */
:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1d2229;
  --line: #262c35;
  --line-strong: #3a4250;
  --text: #e6e9ee;
  --dim: #98a2b3;
  --dot-off: #4b5563;
  --blue: #1f6feb;
  --green: #2ea043;
  --red: #d9534f;
  --amber: #d29922;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f1f4f9;
  --line: #e2e7ef;
  --line-strong: #c9d2de;
  --text: #141a22;
  --dim: #5c6675;
  --dot-off: #b3bcc9;
  --blue: #1a66d6;
  --green: #1a7f37;
  --red: #cf222e;
  --amber: #9a6700;
  color-scheme: light;
}

/* 浅色下这两处是深色的"设计"，得单独调 */
[data-theme="light"] .setup {
  background: radial-gradient(1200px 600px at 50% -10%, #e3edff 0%, var(--bg) 62%);
}
[data-theme="light"] .notify-icon {
  background: rgba(26, 102, 214, .12);
  color: #1a66d6;
}
[data-theme="light"] .msg.out { color: #fff; }
* { box-sizing: border-box; }
/* hidden 属性必须真的能藏住元素。
   浏览器给 [hidden] 的默认样式是 display:none，但它的优先级**低于**类选择器 ——
   于是 `.setup { display:flex }` 会把 hidden 顶掉：JS 里设了 .hidden = true，
   DOM 上属性也在，界面却一点没变。
   这个 bug 骗过了自动化测试（脚本直接点 DOM，穿透遮罩照样点得动），
   是截图时才看出来的 —— 拍出来的"聊天界面"上盖着引导页。
   所以这里用 !important 把这条底线钉死。 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 20px; margin: 0 0 6px; }
.hint { color: var(--dim); font-size: 12px; margin: 8px 0 0; }
.muted { color: var(--dim); font-size: 12px; font-weight: 400; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.input:focus { outline: 2px solid rgba(31, 111, 235, .35); border-color: var(--blue); }
.label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; }

.btn {
  padding: 9px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 首次使用 ── */
.setup {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #16233a 0%, var(--bg) 60%);
}
.setup-card {
  width: 100%; max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.setup-sub { color: var(--dim); margin: 0 0 20px; font-size: 13px; }
.step { border-top: 1px solid var(--line); padding-top: 18px; }
.notify-box { display: flex; gap: 14px; align-items: flex-start; }
.notify-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
  background: rgba(31, 111, 235, .14); color: #6ea8fe;
  display: flex; align-items: center; justify-content: center;
}
.notify-box p { margin: 6px 0 0; }

/* ── 主界面 ── */
.app { display: flex; height: 100vh; }
.side {
  width: 264px; flex: 0 0 264px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.me { padding: 16px; border-bottom: 1px solid var(--line); }
.me-name { font-weight: 650; }
.me-sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.newconv {
  display: flex; gap: 6px; padding: 10px 10px 0;
}
.newconv .input { padding: 7px 10px; font-size: 13px; }
.side-title {
  padding: 12px 16px 6px;
  font-size: 12px; color: var(--dim); text-transform: none;
  display: flex; justify-content: space-between;
}
.peers { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.peer {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
}
.peer:hover { background: var(--panel-2); }
.peer.active { background: var(--panel-2); border-color: var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot-off); flex: 0 0 auto; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(46, 160, 67, .18); }
.peer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer .tag { font-size: 11px; color: var(--dim); }
.side-foot { padding: 10px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--dim); font-size: 12.5px; padding: 14px 10px; line-height: 1.7; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.chat-title { font-weight: 650; }
.chat-sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.chat-actions { display: flex; gap: 6px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(680px, 78%); padding: 9px 13px; border-radius: 13px; word-break: break-word; white-space: pre-wrap; }
.msg.out { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.in { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--dim); margin-top: 3px; }
.msg.out .msg-meta { color: rgba(255, 255, 255, .75); }
.sys { align-self: center; color: var(--dim); font-size: 12px; padding: 2px 0; }
.composer { display: flex; gap: 10px; padding: 12px 18px 18px; align-items: flex-end; }
.composer .input { min-height: 46px; max-height: 180px; }
.composer-hint { padding: 16px 18px 20px; color: var(--dim); font-size: 12.5px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  background: #111827; border: 1px solid #2b3444; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .18s;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .side { width: 100%; flex: 0 0 auto; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--line); }
  .msg { max-width: 88%; }
}

/* ── 通知面板 ── */
.notify-panel {
  margin: 8px 10px 12px; padding: 10px 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-size: 12px; line-height: 1.65;
}
.notify-panel .np-title { font-weight: 600; margin-bottom: 6px; }
.notify-panel .hint { margin: 6px 0; }
.notify-panel .row { display: flex; gap: 6px; margin-top: 9px; }
.np-check { display: flex; gap: 6px; align-items: center; margin-top: 9px; cursor: pointer; }

/* ── 页内提醒条：系统通知被挡时也能看见 ── */
.banner {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  font-size: 13px; line-height: 1.5;
}
.banner .b-who { font-weight: 600; margin-bottom: 3px; }
.banner .b-text { color: var(--muted); word-break: break-word; }
.banner .b-hint { color: var(--muted); font-size: 11px; margin-top: 6px; opacity: .8; }
