:root{
  --bg:#0b0c0d;
  --panel:#0f1112;
  --panel-2:#141617;
  --panel-3:#1b1e20;
  --text:#f6f6f6;
  --muted:#8f969d;
  --line:#2a2f33;
  --line-soft:#202428;
  --accent:#ff6a1a;
  --accent-2:#ff7b2f;
  --danger:#ff4b34;
  --radius:22px;
  --radius-sm:15px;
  --shadow:0 16px 50px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:radial-gradient(circle at 40% 0%, #121517 0%, var(--bg) 44%);
  color:var(--text);
  font-family:Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow:hidden;
}
button,input{font:inherit}
button{color:inherit}
svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

.app-shell{
  height:100vh;
  padding:8px;
  display:grid;
  grid-template-columns: 305px minmax(0,1fr) 278px;
  gap:8px;
}
.sidebar,.conversation,.profile-panel{
  background:linear-gradient(180deg,rgba(17,19,20,.96),rgba(10,11,12,.98));
  border:1px solid var(--line);
  border-radius:var(--radius);
  min-height:0;
}
.sidebar{
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.brand-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:20px 18px 14px;
}
.brand{
  font-size:29px;
  line-height:1;
  font-weight:800;
  letter-spacing:-1.5px;
  flex:1;
}
.brand span{color:var(--accent)}
.icon-btn{
  width:42px;height:42px;
  border-radius:14px;
  border:1px solid transparent;
  background:transparent;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:.18s ease;
}
.icon-btn:hover{background:var(--panel-3);border-color:var(--line)}
.icon-btn.accent,.send-btn{
  background:var(--accent);
  color:#121212;
  border:none;
  box-shadow:0 8px 24px rgba(255,106,26,.18);
}
.icon-btn.accent:hover,.send-btn:hover{background:var(--accent-2);transform:translateY(-1px)}

.search-wrap{
  margin:0 16px 12px;
  position:relative;
}
.search-wrap svg{
  position:absolute;left:13px;top:50%;transform:translateY(-50%);
  width:16px;height:16px;color:#666e74;
}
.search-wrap input{
  width:100%;
  border:1px solid var(--line-soft);
  background:#151718;
  color:var(--text);
  padding:12px 13px 12px 40px;
  border-radius:15px;
  outline:none;
  transition:.18s ease;
}
.search-wrap input:focus{border-color:#555d63;box-shadow:0 0 0 3px rgba(255,255,255,.025)}
.chat-list{
  padding:0 10px;
  overflow:auto;
  flex:1;
}
.chat-item{
  width:100%;
  display:grid;
  grid-template-columns:48px minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  text-align:left;
  padding:10px;
  margin:4px 0;
  background:transparent;
  border:1px solid transparent;
  border-radius:17px;
  cursor:pointer;
  transition:.16s ease;
}
.chat-item:hover{background:#151718}
.chat-item.active{
  background:linear-gradient(180deg,#181818,#121212);
  border-color:var(--accent);
  box-shadow:inset 0 0 0 1px rgba(255,106,26,.12),0 8px 28px rgba(0,0,0,.15);
}
.avatar,.profile-avatar{
  border-radius:50%;
  background:var(--avatar,#555);
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
}
.avatar{width:42px;height:42px;font-weight:800}
.avatar::after,.profile-avatar::after{content:attr(data-initials);color:#fff}
.chat-copy{min-width:0}
.chat-title-row{display:flex;align-items:center;gap:6px}
.chat-title{font-weight:700;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.online-mini{width:6px;height:6px;background:var(--accent);border-radius:50%}
.chat-preview{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:4px}
.chat-time{font-size:10px;color:var(--muted);align-self:start;margin-top:3px}

.sidebar-action{
  border:0;border-top:1px solid var(--line-soft);
  background:transparent;
  color:var(--text);
  height:62px;
  display:flex;align-items:center;gap:11px;
  padding:0 18px;
  cursor:pointer;
}
.sidebar-action:hover{background:#131516}
.sidebar-action svg{width:18px}

.conversation{
  display:grid;
  grid-template-rows:68px minmax(0,1fr) 72px;
  overflow:hidden;
}
.conversation-header{
  border-bottom:1px solid var(--line-soft);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
}
.person-block{display:flex;align-items:center;gap:12px}
.person-name,.profile-name{font-weight:800}
.person-status{font-size:12px;color:var(--accent);display:flex;align-items:center;gap:6px;margin-top:2px}
.person-status.centered{justify-content:center}
.dot{width:7px;height:7px;background:var(--accent);border-radius:50%}
.header-actions{display:flex;gap:2px}
.header-actions .icon-btn{width:38px;height:38px;border-radius:12px}

.messages{
  position:relative;
  padding:46px 24px 26px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  scroll-behavior:smooth;
}
.day-pill{
  position:absolute;
  top:18px;left:50%;transform:translateX(-50%);
  background:#1a1d1f;
  border:1px solid var(--line-soft);
  color:#a8afb5;
  font-size:11px;
  padding:6px 10px;
  border-radius:999px;
}
.message-row{display:flex}
.message-row.out{justify-content:flex-end}
.message{
  max-width:min(70%,560px);
  background:#202326;
  border:1px solid #24282b;
  border-radius:18px 18px 18px 6px;
  padding:11px 12px 8px;
  box-shadow:0 5px 18px rgba(0,0,0,.12);
}
.message-row.out .message{
  background:var(--accent);
  color:#fff;
  border-color:transparent;
  border-radius:18px 18px 6px 18px;
}
.message-text{font-size:14px;line-height:1.35;white-space:pre-wrap;word-break:break-word}
.message-meta{
  display:flex;justify-content:flex-end;gap:5px;
  margin-top:4px;
  font-size:9px;
  color:#9ca3a9;
}
.message-row.out .message-meta{color:rgba(255,255,255,.78)}

.composer{
  margin:10px 12px 12px;
  height:50px;
  display:grid;
  grid-template-columns:42px 1fr 42px 46px;
  align-items:center;
  gap:4px;
  padding:0 7px;
  background:#151718;
  border:1px solid var(--line);
  border-radius:18px;
}
.composer input{
  min-width:0;
  border:0;background:transparent;outline:0;
  color:var(--text);
}
.composer input::placeholder{color:#6d747a}
.composer .icon-btn{width:38px;height:38px}
.send-btn{
  width:38px;height:38px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;transition:.18s ease;
}
.send-btn svg{width:18px;height:18px}

.profile-panel{
  position:relative;
  padding:20px 16px;
  overflow:auto;
}
.profile-close{display:none;position:absolute;right:10px;top:10px}
.profile-top{text-align:center;padding:16px 8px 22px}
.profile-avatar{width:98px;height:98px;margin:0 auto 14px;font-size:28px;border:1px solid var(--line)}
.profile-name{font-size:21px}
.profile-section{border-top:1px solid var(--line-soft);padding:17px 4px}
.status-line{font-size:12px;color:#c4c8cb}
.menu-stack{display:flex;flex-direction:column;gap:5px}
.menu-stack button{
  border:0;background:transparent;color:var(--text);
  display:grid;grid-template-columns:26px 1fr auto;align-items:center;
  gap:8px;text-align:left;padding:10px 3px;border-radius:10px;cursor:pointer;
}
.menu-stack button:hover{background:#151718}
.menu-stack b{font-weight:500;font-size:13px}
.menu-stack em{font-style:normal;color:#b4bbc0;font-size:12px}
.switch{
  width:35px;height:20px;border-radius:999px;background:#555;position:relative
}
.switch::after{
  content:"";position:absolute;width:14px;height:14px;border-radius:50%;
  background:#fff;top:3px;left:3px;transition:.18s
}
.switch.on{background:var(--accent)}
.switch.on::after{left:18px}
.danger-zone .danger{color:var(--danger)}

.modal-backdrop{
  position:fixed;inset:0;
  background:rgba(0,0,0,.62);
  display:flex;align-items:center;justify-content:center;
  z-index:40;
  backdrop-filter:blur(6px);
}
.modal-backdrop[hidden]{display:none}
.modal{
  width:min(92vw,480px);
  background:#111314;
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:var(--shadow);
  padding:18px;
}
.modal-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.modal-header h2{margin:0;font-size:20px}
.settings-grid{display:grid;gap:10px}
.setting-card{
  border:1px solid var(--line-soft);background:#151718;border-radius:15px;padding:14px
}
.setting-card strong{display:block;margin-bottom:4px}
.setting-card span{color:var(--muted);font-size:13px}

.empty-state{color:var(--muted);font-size:13px;padding:24px 10px;text-align:center}

@media (max-width:1180px){
  .app-shell{grid-template-columns:280px minmax(0,1fr)}
  .profile-panel{
    position:fixed;
    right:8px;top:8px;bottom:8px;
    width:310px;
    z-index:20;
    transform:translateX(calc(100% + 20px));
    transition:.22s ease;
    box-shadow:var(--shadow);
  }
  .profile-panel.open{transform:translateX(0)}
  .profile-close{display:flex}
}
@media (max-width:760px){
  body{overflow:auto}
  .app-shell{padding:0;display:block;height:100dvh}
  .sidebar,.conversation{border-radius:0;border-width:0}
  .sidebar{
    position:fixed;inset:0;
    z-index:15;
    background:var(--bg);
  }
  .conversation{display:none;height:100dvh}
  body.mobile-chat .sidebar{display:none}
  body.mobile-chat .conversation{display:grid}
  .conversation-header{padding-left:8px}
  .conversation-header::before{
    content:"‹";font-size:34px;line-height:1;cursor:pointer;margin-right:4px
  }
  .messages{padding-left:12px;padding-right:12px}
  .message{max-width:86%}
  .composer{margin-left:8px;margin-right:8px}
  .profile-panel{top:0;right:0;bottom:0;width:min(88vw,340px);border-radius:22px 0 0 22px}
}
