/* ============ 基础 ============ */
:root {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --bg-3: #161b27;
  --line: #232a3a;
  --text: #e6e9f2;
  --muted: #8b93a7;
  --accent: #6ea8fe;
  --accent-2: #8b7bff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --gold: #f0c674;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 80% -10%, #1b2440 0%, transparent 60%),
              radial-gradient(900px 700px at -10% 110%, #241b3a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font: 15px/1.6 "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .2px; }
a { color: var(--accent); text-decoration: none; }

/* ============ 按钮 / 输入 ============ */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-3);
  color: var(--text); padding: 10px 16px; border-radius: 10px; cursor: pointer;
  font-size: 14px; transition: .15s ease; font-family: inherit;
}
.btn:hover { border-color: #33405a; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #0a0d14; font-weight: 700;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: var(--danger); border-color: #4a2530; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.input, textarea, input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 10px 12px;
  font: inherit; outline: none; transition: .15s;
}
.input.small, input.small { padding: 7px 10px; font-size: 13px; }
input:focus, textarea:focus, .input:focus { border-color: #3a4a6b; box-shadow: 0 0 0 3px rgba(110,168,254,.12); }
textarea { resize: vertical; }

.icon-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  font-size: 17px; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

/* ============ 登录 ============ */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(440px, 100%); background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  border: 1px solid var(--line); border-radius: 20px; padding: 30px 28px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.brand { font-size: 24px; display: flex; align-items: baseline; gap: 10px; }
.brand-sub { font-size: 13px; color: var(--muted); font-weight: 400; }
.tabs { display: flex; gap: 6px; margin: 22px 0 18px; background: var(--bg-3); padding: 4px; border-radius: 12px; }
.tab {
  flex: 1; background: transparent; border: 0; color: var(--muted);
  padding: 9px; border-radius: 9px; cursor: pointer; font: inherit;
}
.tab.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 7px; font-size: 13px; color: var(--muted); }
.hint { min-height: 18px; font-size: 13px; color: var(--warn); margin: 0; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--ok); }

/* ============ 主界面 ============ */
.app { display: grid; grid-template-columns: 288px 1fr; height: 100vh; overflow: hidden; }
.sidebar {
  display: flex; flex-direction: column; border-right: 1px solid var(--line);
  background: rgba(12, 16, 24, .72); backdrop-filter: blur(8px); min-width: 0;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.logo { font-weight: 800; letter-spacing: .5px; background: linear-gradient(120deg, #9db8ff, #c3a6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.side-tabs { display: flex; gap: 6px; padding: 0 16px 10px; }
.mini-tab {
  flex: 1; background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 10px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px;
}
.mini-tab.active { background: var(--bg-3); color: var(--text); border-color: var(--line); }
.side-pane { flex: 1; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 10px 4px 2px; }

.item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer; transition: .12s; min-width: 0;
}
.item:hover { background: var(--bg-3); border-color: var(--line); }
.item.active { background: linear-gradient(90deg, rgba(110,168,254,.16), transparent); border-color: #2b3857; }
.item-main { min-width: 0; flex: 1; }
.item-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--bg-3);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.owner { color: var(--gold); border-color: #4a3f22; }
.badge.admin { color: var(--accent); border-color: #26405f; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #3b4256; flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 8px rgba(74,222,128,.7); }
.side-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; }

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.empty { margin: auto; text-align: center; padding: 40px; max-width: 520px; }
.empty h2 { font-size: 20px; margin-bottom: 8px; }

/* ============ 房间 ============ */
.room { display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.room-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(12,16,24,.6); backdrop-filter: blur(6px);
}
.room-title-wrap { min-width: 0; }
.room-head h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-head .muted { font-size: 12px; }
.room-actions { display: flex; gap: 6px; flex: none; }

.messages { flex: 1; overflow-y: auto; padding: 22px 22px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }

/* 普通消息 */
.msg { display: flex; gap: 10px; max-width: 860px; }
.msg .avatar {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: linear-gradient(135deg, #2b3857, #3a2b57); color: #cfd8f5;
}
.msg .bubble-wrap { min-width: 0; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 8px; align-items: center; }
.msg .bubble {
  background: var(--bg-3); border: 1px solid var(--line); padding: 9px 13px;
  border-radius: 4px 13px 13px 13px; white-space: pre-wrap; word-break: break-word;
}
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { background: linear-gradient(135deg, rgba(110,168,254,.22), rgba(139,123,255,.18)); border-color: #2f4370; border-radius: 13px 4px 13px 13px; }
.msg.mine .who { justify-content: flex-end; }

/* 系统信息：四种语气，样式明显不同 */
.sys { align-self: center; max-width: 720px; width: 100%; text-align: center; }
.sys .sys-inner {
  display: inline-block; padding: 7px 16px; border-radius: 999px; font-size: 13px;
  border: 1px dashed var(--line); color: var(--muted); background: rgba(255,255,255,.02);
}
.sys.narration .sys-inner {
  border: 0; background: transparent; font-style: italic; letter-spacing: .5px;
  color: #a9b3cc; font-size: 14px; border-radius: 0; padding: 4px 8px;
}
.sys.alert .sys-inner { border: 1px solid #4a2530; background: rgba(248,113,113,.08); color: #ffb4b4; }
.sys.event { text-align: center; }
.sys.event .sys-inner {
  display: block; border: 0; background: linear-gradient(90deg, transparent, rgba(240,198,116,.10), transparent);
  color: var(--gold); font-size: 13px; letter-spacing: 2px; padding: 10px 16px; border-radius: 8px;
  position: relative;
}
.sys.event .sys-inner::before, .sys.event .sys-inner::after {
  content: "◆"; color: rgba(240,198,116,.5); margin: 0 10px; font-size: 9px; vertical-align: middle;
}

/* 需要确认的按钮 */
.card {
  max-width: 720px; width: 100%; background: linear-gradient(180deg, rgba(139,123,255,.10), rgba(110,168,254,.05));
  border: 1px solid #2f3d63; border-radius: 14px; padding: 14px 16px;
}
.card .card-label { font-size: 11px; letter-spacing: 1.5px; color: var(--accent); text-transform: uppercase; }
.card .card-q { font-size: 15px; margin: 6px 0 12px; white-space: pre-wrap; }
.prompt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.prompt-actions .btn.yes { background: rgba(74,222,128,.14); border-color: #2f5a41; color: #9df3bb; }
.prompt-actions .btn.no { background: rgba(248,113,113,.12); border-color: #53282f; color: #ffb0b0; }
.prompt-actions .btn.chosen { outline: 2px solid var(--accent); }
.answers { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.answers b { color: var(--text); font-weight: 600; }

/* 选项 */
.opt-list { display: grid; gap: 8px; margin-top: 4px; }
.opt {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px;
  padding: 10px 13px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg-3); cursor: pointer; transition: .15s;
}
.opt:hover { border-color: #3a4a6b; }
.opt.picked { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110,168,254,.15); }
.opt .bar { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, rgba(110,168,254,.22), rgba(139,123,255,.10)); width: 0; transition: width .4s ease; }
.opt .opt-label { position: relative; flex: 1; font-size: 14px; }
.opt .opt-count { position: relative; font-size: 12px; color: var(--muted); }
.voters { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* 发送区 */
.composer { border-top: 1px solid var(--line); padding: 10px 18px 14px; background: rgba(12,16,24,.7); backdrop-filter: blur(8px); }
.owner-bar { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.chip {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12.5px;
}
.chip:hover { color: var(--text); border-color: #3a4a6b; }
.send-row { display: flex; gap: 10px; align-items: flex-end; }
.send-row textarea { max-height: 168px; min-height: 44px; }

/* ============ 弹窗 ============ */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 6, 10, .66); backdrop-filter: blur(3px); }
.modal {
  position: relative; width: min(520px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.modal h3 { font-size: 17px; margin-bottom: 14px; }
.modal .form { gap: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row .m-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .m-actions { display: flex; gap: 6px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.switch input { width: auto; }

/* ============ 提示 ============ */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow);
  animation: toastIn .18s ease both;
}
.toast.err { border-color: #53282f; color: #ffb0b0; background: #241419; }
.toast.ok { border-color: #2f5a41; color: #9df3bb; background: #12211a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ============ 滚动条 / 响应式 ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232a3a; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #33405a; background-clip: content-box; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84%; max-width: 320px; z-index: 40; transform: translateX(-102%); transition: transform .22s ease; }
  .app.side-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .messages { padding: 16px 14px 6px; }
  .room-head { padding: 12px 14px; }
  .composer { padding: 8px 12px 12px; }
}
