:root {
  --bg: #17212b;
  --panel: #212d3b;
  --panel-soft: #182533;
  --panel-hover: #2b3948;
  --line: rgba(255,255,255,.08);
  --text: #f4f7fb;
  --muted: #8b9bad;
  --accent: #2ea6ff;
  --accent-dark: #1987d8;
  --out: #2b5278;
  --in: #263545;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
[hidden], .is-hidden { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top left, #203248 0, #101821 48%, #0d141c 100%);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; }
.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 300px;
  width: min(1480px, 100vw);
  height: min(920px, 100vh);
  margin: auto;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
}
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(33,45,59,.96);
  border-bottom: 1px solid var(--line);
}
.sidebar { min-width: 0; background: var(--panel); border-right: 1px solid var(--line); }
.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 50%;
  font-size: 22px;
  transition: .16s ease;
}
.icon-button:hover { background: var(--panel-hover); color: var(--text); }
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  color: var(--muted);
  background: #172331;
  border-radius: 999px;
}
.search-box input, .composer input, .name-card input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}
.chat-list { height: calc(100% - 56px); overflow: auto; padding: 8px; }
.chat-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  color: inherit;
  transition: .16s ease;
}
.chat-item:hover, .chat-item.selected { background: var(--panel-hover); }
.avatar, .profile-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #32b5ff, #6c5ce7);
  font-weight: 800;
}
.avatar { width: 48px; height: 48px; }
.avatar.active { box-shadow: 0 0 0 3px rgba(46,166,255,.15); }
.chat-meta { min-width: 0; }
.chat-line { display: flex; justify-content: space-between; gap: 12px; }
.chat-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-line time { color: var(--muted); font-size: 12px; }
.chat-preview { margin-top: 4px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-panel { min-width: 0; display: grid; grid-template-rows: 56px 1fr 72px; background: #0f1b26; }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title strong { font-size: 16px; }
.chat-title span { color: var(--muted); font-size: 13px; }
.header-actions { display: flex; }
.name-chip {
  display: block;
  max-width: 110px;
  height: 34px;
  padding: 0 10px;
  color: #dff2ff;
  background: rgba(46,166,255,.16);
  border: 1px solid rgba(46,166,255,.28);
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-space {
  position: relative;
  overflow: auto;
  padding: 22px clamp(14px, 4vw, 72px);
  background:
    linear-gradient(rgba(15,27,38,.82), rgba(15,27,38,.82)),
    radial-gradient(circle at 20% 20%, rgba(46,166,255,.18), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(108,92,231,.18), transparent 20%);
}
.date-pill {
  width: max-content;
  margin: 0 auto 18px;
  padding: 4px 12px;
  color: #d7e6f6;
  background: rgba(36,52,68,.72);
  border-radius: 999px;
  font-size: 12px;
  backdrop-filter: blur(12px);
}
.messages { display: flex; flex-direction: column; gap: 8px; }
.message {
  max-width: min(620px, 82%);
  padding: 8px 11px 6px;
  border-radius: 14px;
  color: #eff7ff;
  background: var(--in);
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.message.mine { align-self: flex-end; background: var(--out); border-bottom-right-radius: 5px; }
.message:not(.mine) { align-self: flex-start; border-bottom-left-radius: 5px; }
.message-author { color: #6ec6ff; font-weight: 700; margin-bottom: 2px; }
.message.mine .message-author { color: #9bd4ff; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.message-time { float: right; margin: 5px 0 0 10px; color: rgba(240,247,255,.58); font-size: 12px; }
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px clamp(12px, 4vw, 72px);
  background: #172331;
  border-top: 1px solid var(--line);
}
.composer input {
  height: 48px;
  padding: 0 16px;
  background: var(--panel);
  border-radius: 999px;
}
.send-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 20px;
  transition: .16s ease;
}
.send-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.profile-panel { background: var(--panel); border-left: 1px solid var(--line); padding: 22px; }
.profile-card { text-align: center; padding: 22px 0 28px; border-bottom: 1px solid var(--line); }
.profile-avatar { width: 96px; height: 96px; margin: 0 auto 16px; font-size: 42px; }
.profile-card h1 { margin: 0; font-size: 22px; }
.profile-card p { margin: 8px 0 0; color: var(--muted); }
.info-list { display: grid; gap: 14px; padding-top: 22px; }
.info-list div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.info-list span { color: var(--muted); }
.info-list button { color: var(--accent); background: transparent; padding: 0; }
.name-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(9,15,22,.74);
  backdrop-filter: blur(10px);
}
.name-card {
  width: min(360px, calc(100vw - 32px));
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.name-card h2 { margin: 0 0 8px; }
.name-card p { color: var(--muted); margin: 0 0 18px; }
.name-card input { height: 46px; padding: 0 14px; background: #172331; border-radius: 12px; }
.name-card button { width: 100%; height: 46px; margin-top: 12px; color: #fff; background: var(--accent); border-radius: 12px; }
.name-card .secondary-button { color: var(--accent); background: rgba(46,166,255,.12); }
@media (max-width: 1100px) { .app-shell { grid-template-columns: 320px 1fr; } .profile-panel { display: none; } }
@media (max-width: 720px) {
  body { overflow: hidden; }
  .app-shell { height: 100vh; grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .message-space { padding: 14px 10px; }
  .composer { padding: 10px; }
  .emoji-button { display: none; }
}
