:root {
  color-scheme: dark;
  --bg: #080b16;
  --panel: rgba(18, 24, 44, .82);
  --line: rgba(255, 255, 255, .09);
  --text: #f4f6ff;
  --muted: #929ab2;
  --primary: #7c6cff;
  --mint: #50ddc5;
  --danger: #ff7a90;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.ambient { position: fixed; width: 520px; height: 520px; border-radius: 50%; filter: blur(110px); opacity: .22; pointer-events: none; }
.ambient-one { background: #6445ff; top: -240px; left: -120px; }
.ambient-two { background: #00c8ae; right: -230px; bottom: -280px; }
.shell { width: min(1180px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; display: grid; place-items: center; padding: 32px 0; }
.hidden { display: none !important; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 750; letter-spacing: .06em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #0b1020; background: linear-gradient(135deg, #9d91ff, #5de2d2); border-radius: 11px; box-shadow: 0 0 32px rgba(124,108,255,.4); }
.auth-layout { width: 100%; display: grid; grid-template-columns: 1.25fr .75fr; gap: 80px; align-items: center; }
.intro h1 { margin: 58px 0 24px; font-size: clamp(44px, 6vw, 76px); line-height: 1.06; letter-spacing: -.055em; }
.intro h1 span { color: transparent; background: linear-gradient(100deg, #a69cff, #62e4d5); -webkit-background-clip: text; background-clip: text; }
.intro > p { max-width: 600px; color: var(--muted); font-size: 18px; line-height: 1.8; }
.feature-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 38px; }
.feature-row span { color: #c6cbdb; font-size: 13px; }
.feature-row span::before { content: "✓"; color: var(--mint); margin-right: 7px; }
.auth-card { padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); backdrop-filter: blur(24px); box-shadow: 0 24px 90px rgba(0,0,0,.35); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 28px; background: rgba(255,255,255,.045); border-radius: 13px; }
.tab { border: 0; padding: 11px; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.tab.active { color: white; background: rgba(255,255,255,.09); box-shadow: 0 4px 15px rgba(0,0,0,.16); }
label { display: grid; gap: 9px; margin: 18px 0; color: #cbd0df; font-size: 14px; }
input, textarea { width: 100%; color: var(--text); background: rgba(7,10,20,.68); border: 1px solid rgba(255,255,255,.11); outline: none; transition: .2s ease; }
input { height: 50px; padding: 0 15px; border-radius: 12px; }
input:focus, textarea:focus { border-color: rgba(124,108,255,.85); box-shadow: 0 0 0 3px rgba(124,108,255,.13); }
.primary { width: 100%; min-height: 50px; padding: 0 18px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #7969ff, #5c87f7); font-weight: 700; cursor: pointer; box-shadow: 0 12px 25px rgba(91,93,234,.26); }
.primary:disabled { opacity: .55; cursor: wait; }
.primary.compact { width: auto; }
.hint { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.error { min-height: 18px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.chat-card { width: 100%; height: min(780px, calc(100vh - 64px)); min-height: 600px; display: grid; grid-template-columns: 270px 1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 25px; background: var(--panel); backdrop-filter: blur(24px); box-shadow: 0 30px 100px rgba(0,0,0,.42); }
.sidebar { min-width: 0; display: flex; flex-direction: column; padding: 26px 18px 18px; border-right: 1px solid var(--line); background: rgba(8,11,22,.48); }
.sidebar .brand { padding: 0 10px 30px; }
.rooms-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 9px 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.mini-button { width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); color: #c8ccda; cursor: pointer; }
.room-list { min-height: 0; overflow-y: auto; }
.room { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 5px; border: 0; border-radius: 13px; background: transparent; text-align: left; cursor: pointer; }
.room:hover { background: rgba(255,255,255,.045); }
.active-room { background: rgba(124,108,255,.15) !important; }
.room-icon { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: rgba(124,108,255,.18); color: #b7afff; font-weight: 800; }
.room > span:last-child { min-width: 0; }
.room strong, .room small, .profile strong, .profile small { display: block; }
.room strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.room small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.join-button { width: 100%; margin-top: 8px; padding: 10px; border: 1px dashed rgba(255,255,255,.12); border-radius: 11px; background: transparent; color: #aeb5ca; font-size: 12px; cursor: pointer; }
.join-button:hover { border-color: rgba(124,108,255,.5); color: white; }
.sidebar-bottom { display: grid; grid-template-columns: 40px 1fr 34px; gap: 10px; align-items: center; margin-top: auto; padding: 14px 8px 2px; border-top: 1px solid var(--line); }
.avatar, .message-avatar { display: grid; place-items: center; border-radius: 12px; background: linear-gradient(135deg, #6d5bf4, #34bcb1); color: white; font-weight: 750; }
.avatar { width: 40px; height: 40px; }
.profile { min-width: 0; }
.profile strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.profile small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.profile i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--mint); }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }

.conversation { min-width: 0; display: grid; grid-template-rows: auto 1fr auto auto; }
.conversation header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 28px; border-bottom: 1px solid var(--line); }
.conversation h2 { margin: 0; font-size: 17px; }
.conversation header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.lock { font-size: 10px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.invite-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.045); color: #c9cedd; font-size: 11px; cursor: pointer; }
.connection { padding: 6px 10px; border-radius: 99px; color: #f7c873; background: rgba(247,200,115,.09); font-size: 11px; white-space: nowrap; }
.connection.online { color: #63dfb2; background: rgba(99,223,178,.09); }
.messages { overflow-y: auto; padding: 24px 30px; scrollbar-color: rgba(255,255,255,.13) transparent; }
.message { display: grid; grid-template-columns: 38px 1fr; gap: 12px; margin: 0 0 22px; }
.message-avatar { width: 38px; height: 38px; font-size: 13px; }
.message:nth-child(3n+2) .message-avatar { background: linear-gradient(135deg, #e272aa, #9a6cf3); }
.message:nth-child(3n+3) .message-avatar { background: linear-gradient(135deg, #dd9455, #d46173); }
.message-meta { display: flex; align-items: baseline; gap: 9px; margin-bottom: 6px; }
.message-meta strong { font-size: 13px; }
.message-meta time { color: #6f778e; font-size: 10px; }
.bubble { display: inline-block; max-width: min(680px, 90%); padding: 10px 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: rgba(255,255,255,.055); color: #dfe3f0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.mine .bubble { border-color: rgba(124,108,255,.2); background: rgba(124,108,255,.12); }
.failed .bubble { border-color: rgba(255,122,144,.25); color: #ff9eb0; }
.empty-state { align-self: center; justify-self: center; max-width: 520px; padding: 40px; text-align: center; }
.empty-icon { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 22px; border: 1px solid rgba(124,108,255,.28); border-radius: 24px; background: rgba(124,108,255,.1); font-size: 30px; }
.empty-state h3 { margin: 0 0 12px; font-size: 22px; }
.empty-state p { margin: 0 auto 24px; color: var(--muted); line-height: 1.65; font-size: 14px; }
.composer { display: grid; grid-template-columns: 1fr 44px; gap: 10px; margin: 0 28px 5px; padding: 9px 9px 9px 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(6,9,18,.68); }
.composer textarea { align-self: center; max-height: 130px; padding: 8px 0; resize: none; border: 0; background: transparent; box-shadow: none; }
.composer textarea:disabled { opacity: .45; }
.send { width: 44px; height: 44px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #7d6cff, #4eb8c2); cursor: pointer; }
.send:disabled { opacity: .35; cursor: not-allowed; }
.chat-error { margin: 0 30px 5px; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,4,11,.74); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(520px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.12); border-radius: 23px; background: #12172a; box-shadow: 0 30px 100px rgba(0,0,0,.55); }
.modal-close { position: absolute; right: 16px; top: 14px; width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; }
.modal-lock { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: rgba(80,221,197,.1); font-size: 21px; }
.modal-card h2 { margin: 20px 0 8px; font-size: 21px; }
.modal-card > p { color: var(--muted); line-height: 1.55; font-size: 13px; }
.modal-card textarea { min-height: 92px; padding: 12px; border-radius: 11px; resize: vertical; line-height: 1.45; word-break: break-all; }
.modal-secondary, .modal-danger { width: 100%; min-height: 44px; margin-top: 10px; border-radius: 11px; cursor: pointer; }
.modal-secondary { border: 1px solid var(--line); background: rgba(255,255,255,.045); }
.modal-danger { border: 1px solid rgba(255,122,144,.28); background: rgba(255,122,144,.09); color: #ff9bae; }
.member-list { display: grid; gap: 8px; max-height: 280px; margin: 20px 0; overflow-y: auto; }
.member-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.member-row .avatar { width: 38px; height: 38px; }
.member-row strong, .member-row small { display: block; }
.member-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.owner-badge { color: #8de5d4; }
.kick-button { padding: 7px 10px; border: 1px solid rgba(255,122,144,.25); border-radius: 9px; background: rgba(255,122,144,.08); color: #ff9bae; font-size: 11px; cursor: pointer; }
.security-note { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px !important; }

@media (max-width: 820px) {
  .auth-layout { grid-template-columns: 1fr; gap: 36px; }
  .intro { text-align: center; }
  .intro h1 { margin-top: 35px; }
  .intro > p { margin-inline: auto; }
  .feature-row { justify-content: center; }
  .auth-card { width: min(430px, 100%); margin: auto; }
  .chat-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: grid; grid-template-columns: auto auto 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 8px 14px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0; }
  .rooms-heading { display: flex; margin: 0; }
  .rooms-heading > span { display: none; }
  .room-list { display: flex; gap: 6px; overflow-x: auto; }
  .room { flex: 0 0 auto; width: auto; margin: 0; }
  .room-icon, .room small { display: none; }
  .join-button { width: auto; margin: 0; }
  .sidebar-bottom { grid-column: 1 / -1; margin: 0; padding: 8px 0 0; }
}

@media (max-width: 560px) {
  .shell { width: 100%; padding: 0; }
  .auth-layout { padding: 28px 18px; }
  .intro h1 { font-size: 43px; }
  .feature-row { display: none; }
  .auth-card { padding: 25px; }
  .chat-card { min-height: 100vh; height: 100vh; border: 0; border-radius: 0; }
  .sidebar { grid-template-columns: auto 1fr; }
  .sidebar .brand { display: none; }
  .join-button { font-size: 0; }
  .join-button::after { content: "加入"; font-size: 11px; }
  .conversation header { padding: 16px; }
  .conversation header p { max-width: 180px; }
  .header-actions { gap: 6px; }
  .invite-button { display: inline-flex; align-items: center; font-size: 0; }
  #membersRoom::after { content: "成员"; font-size: 11px; }
  #inviteRoom::after { content: "邀请"; font-size: 11px; }
  .messages { padding: 20px 16px; }
  .composer { margin-inline: 14px; }
  .modal-card { padding: 27px 22px; }
}
