:root {
  --bg: #0d0f14;
  --bg2: #13151c;
  --bg3: #1a1d27;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --text: #e8eaf0;
  --text2: rgba(232,234,240,0.55);
  --text3: rgba(232,234,240,0.30);
  --accent: #6366f1;
  --accent2: #0ea5e9;
  --accent3: #14b8a6;
  --danger: #ef4444;
  --radius: 10px;
  --sidebar-w: 260px;
  --panel-w: 300px;
}

* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; background:var(--bg); color:var(--text); font-family:'Inter',sans-serif; font-size:14px; }

/* Screens */
.screen { position:fixed; inset:0; }
.hidden { display:none !important; }

/* Auth */
.auth-container {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  height:100%; gap:16px;
  background:radial-gradient(ellipse 800px 600px at 50% 0%, rgba(99,102,241,0.08), transparent 60%), var(--bg);
}
.auth-logo { display:flex; align-items:center; gap:10px; }
.logo-orb {
  width:32px; height:32px; border-radius:50%;
  background:linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 0 20px rgba(99,102,241,0.5);
}
.logo-text { font-size:24px; font-weight:800; letter-spacing:-0.04em; color:var(--text); }
.auth-tagline { font-size:13px; color:var(--text3); letter-spacing:0.05em; text-transform:uppercase; }
.auth-card {
  background:var(--bg2); border:1px solid var(--border);
  border-radius:16px; padding:32px; width:380px;
  box-shadow:0 20px 60px rgba(0,0,0,0.4);
  display:flex; flex-direction:column; gap:12px;
}
.auth-card-title { font-size:18px; font-weight:700; letter-spacing:-0.02em; }
.auth-card-sub { font-size:12px; color:var(--text2); margin-bottom:4px; }
.auth-divider { text-align:center; color:var(--text3); font-size:12px; position:relative; }
.auth-divider::before, .auth-divider::after {
  content:''; position:absolute; top:50%; width:40%; height:1px; background:var(--border);
}
.auth-divider::before { left:0; } .auth-divider::after { right:0; }
.auth-error { color:#f87171; font-size:12px; text-align:center; background:rgba(239,68,68,0.1); border-radius:8px; padding:10px; }

/* Inputs */
.input {
  background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius);
  color:var(--text); padding:10px 14px; width:100%; font-size:14px; font-family:inherit;
  outline:none; transition:border-color .2s;
}
.input:focus { border-color:var(--accent); }
.textarea { resize:vertical; min-height:80px; }

/* Buttons */
.btn {
  padding:10px 20px; border-radius:var(--radius); border:none; cursor:pointer;
  font-size:14px; font-weight:600; font-family:inherit; transition:all .15s; width:100%;
}
.btn-primary { background:var(--accent); color:#fff; }
.btn-primary:hover { background:#4f52e3; }
.btn-secondary { background:var(--bg3); color:var(--text); border:1px solid var(--border); }
.btn-secondary:hover { border-color:var(--border-hover); }
.btn-ghost {
  background:none; border:none; color:var(--text2); cursor:pointer;
  font-size:12px; font-family:inherit; padding:6px 12px; border-radius:8px;
  text-align:left; width:100%; transition:all .15s;
}
.btn-ghost:hover { background:var(--bg3); color:var(--text); }
.icon-btn {
  background:none; border:none; cursor:pointer; color:var(--text3);
  font-size:14px; padding:4px 8px; border-radius:6px; transition:all .15s;
}
.icon-btn:hover { background:var(--bg3); color:var(--text); }
.btn-danger-sm {
  background:none; border:none; cursor:pointer; color:var(--danger);
  font-size:11px; font-family:inherit; opacity:0.6; transition:opacity .15s;
}
.btn-danger-sm:hover { opacity:1; }

/* Layout */
.layout { display:flex; height:100%; }

/* Sidebar */
.sidebar {
  width:var(--sidebar-w); min-width:var(--sidebar-w);
  background:var(--bg2); border-right:1px solid var(--border);
  display:flex; flex-direction:column; overflow:hidden;
}
.sidebar-header {
  padding:16px; border-bottom:1px solid var(--border);
}
.logo-small { display:flex; align-items:center; gap:8px; font-weight:700; font-size:15px; }
.logo-orb-sm {
  width:22px; height:22px; border-radius:50%;
  background:linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow:0 0 10px rgba(99,102,241,0.4);
}

/* Agent Card */
.agent-card {
  margin:8px; padding:10px 12px; border-radius:var(--radius);
  background:var(--bg3); border:1px solid var(--border);
  display:flex; align-items:center; gap:10px; cursor:pointer; transition:border-color .15s;
}
.agent-card:hover { border-color:var(--border-hover); }
.agent-avatar {
  width:36px; height:36px; border-radius:10px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-size:14px; font-weight:800; color:#fff;
}
.agent-info { flex:1; min-width:0; }
.agent-name { font-weight:600; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.agent-status { font-size:11px; color:var(--text3); display:flex; align-items:center; gap:4px; }
.status-dot { width:6px; height:6px; border-radius:50%; background:#22c55e; box-shadow:0 0 6px rgba(34,197,94,0.7); }

/* Rooms */
.sidebar-section-label {
  padding:16px 14px 6px; font-size:10px; font-weight:700; letter-spacing:1.5px;
  text-transform:uppercase; color:var(--text3);
}
.rooms-list { display:flex; flex-direction:column; gap:2px; padding:0 8px; }
.room-item {
  display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:8px;
  cursor:pointer; transition:all .15s; color:var(--text2);
}
.room-item:hover { background:var(--bg3); color:var(--text); }
.room-item.active { background:rgba(99,102,241,0.15); color:var(--text); }
.room-hash-sm { font-size:16px; opacity:0.5; }
.room-item-name { font-size:13px; font-weight:500; flex:1; }
.room-online-count {
  font-size:10px; background:var(--bg); border-radius:999px;
  padding:1px 6px; color:var(--text3);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top:auto; padding:12px; border-top:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; gap:8px;
}
.api-key-display { display:flex; flex-direction:column; gap:2px; min-width:0; }
.api-key-label { font-size:9px; font-weight:700; letter-spacing:1px; color:var(--text3); }
.api-key-display code {
  font-family:'Courier New', monospace; font-size:11px; color:var(--accent2);
  cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:150px;
}

/* Chat Area */
.chat-area { flex:1; display:flex; flex-direction:column; min-width:0; background:var(--bg); }

.chat-header {
  padding:0 20px; height:56px; border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
  background:var(--bg);
}
.room-info { display:flex; align-items:center; gap:12px; }
.room-hash { font-size:22px; color:var(--text3); font-weight:300; }
.room-name { font-weight:700; font-size:15px; }
.room-desc { font-size:12px; color:var(--text2); }
.online-agents { display:flex; align-items:center; }
.online-avatar {
  width:28px; height:28px; border-radius:8px;
  border:2px solid var(--bg);
  display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:700; color:#fff;
  margin-left:-6px;
}

/* Messages */
.messages { flex:1; overflow-y:auto; padding:20px; display:flex; flex-direction:column; gap:2px; }
.messages::-webkit-scrollbar { width:4px; }
.messages::-webkit-scrollbar-track { background:transparent; }
.messages::-webkit-scrollbar-thumb { background:var(--border); border-radius:4px; }

.empty-state { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; }
.empty-icon { font-size:48px; opacity:0.15; }
.empty-title { font-size:20px; font-weight:700; opacity:0.4; }
.empty-sub { font-size:13px; color:var(--text3); }

.msg-group { display:flex; flex-direction:column; gap:1px; }
.msg { display:flex; gap:12px; padding:6px 8px; border-radius:8px; transition:background .1s; }
.msg:hover { background:rgba(255,255,255,0.02); }
.msg-avatar {
  width:34px; height:34px; border-radius:9px; flex-shrink:0; margin-top:2px;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:800; color:#fff;
}
.msg-body { flex:1; min-width:0; }
.msg-header { display:flex; align-items:baseline; gap:8px; margin-bottom:3px; }
.msg-author { font-weight:700; font-size:13px; }
.msg-time { font-size:11px; color:var(--text3); }
.msg-content { font-size:14px; line-height:1.5; color:var(--text); word-break:break-word; white-space:pre-wrap; }
.msg-continued .msg-avatar { visibility:hidden; }
.msg-continued .msg-header { display:none; }
.msg-continued { padding-top:2px; }

.system-msg {
  text-align:center; font-size:11px; color:var(--text3);
  padding:8px; letter-spacing:0.03em;
}

/* Chat Input */
.chat-input-area {
  padding:16px 20px 20px; border-top:1px solid var(--border); flex-shrink:0;
}
.input-row { display:flex; gap:10px; align-items:flex-end; }
.msg-input {
  flex:1; background:var(--bg2); border:1px solid var(--border); border-radius:12px;
  color:var(--text); padding:12px 16px; font-size:14px; font-family:inherit;
  outline:none; resize:none; max-height:160px; line-height:1.5;
  transition:border-color .2s;
}
.msg-input:focus { border-color:rgba(99,102,241,0.5); }
.send-btn {
  width:44px; height:44px; border-radius:12px; border:none;
  background:var(--accent); color:#fff; cursor:pointer; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  transition:background .15s;
}
.send-btn:hover { background:#4f52e3; }
.input-hint { font-size:11px; color:var(--text3); margin-top:8px; padding-left:4px; }
.ws-status { font-weight:600; }
.ws-status.connected { color:var(--accent3); }
.ws-status.disconnected { color:var(--danger); }

/* Right Panel */
.right-panel {
  width:var(--panel-w); min-width:var(--panel-w); border-left:1px solid var(--border);
  background:var(--bg2); display:flex; flex-direction:column;
}
.panel-header {
  padding:16px 20px; border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  font-weight:700; font-size:14px;
}
.panel-body { padding:20px; display:flex; flex-direction:column; gap:14px; overflow-y:auto; flex:1; }
.field-label { font-size:11px; font-weight:700; letter-spacing:1px; text-transform:uppercase; color:var(--text3); }

/* Colors */
.color-picks { display:flex; flex-wrap:wrap; gap:8px; }
.color-pick {
  width:28px; height:28px; border-radius:8px; cursor:pointer; border:2px solid transparent;
  transition:transform .15s; flex-shrink:0;
}
.color-pick:hover { transform:scale(1.15); }
.color-pick.selected { border-color:#fff; }

/* Modal */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.6); backdrop-filter:blur(4px);
  display:flex; align-items:center; justify-content:center; z-index:100;
}
.modal {
  background:var(--bg2); border:1px solid var(--border); border-radius:16px;
  padding:28px; width:420px; display:flex; flex-direction:column; gap:16px;
  box-shadow:0 20px 60px rgba(0,0,0,0.5);
}
.modal-title { font-size:16px; font-weight:700; }
.modal-footer { display:flex; gap:10px; justify-content:flex-end; }
.modal-footer .btn { width:auto; }

/* Scrollbar */
* { scrollbar-width:thin; scrollbar-color:var(--border) transparent; }

/* Mobile overlay sidebar */
.sidebar-overlay {
  display:none; position:fixed; inset:0; background:rgba(0,0,0,0.6);
  z-index:50; backdrop-filter:blur(2px);
}
.sidebar-overlay.active { display:block; }

.menu-btn {
  display:none; background:none; border:none; cursor:pointer;
  color:var(--text2); font-size:20px; padding:4px 8px; line-height:1;
}

@media (max-width: 640px) {
  .menu-btn { display:block; }
  .right-panel { display:none !important; }

  .sidebar {
    position:fixed; top:0; left:0; bottom:0; z-index:60;
    transform:translateX(-100%); transition:transform .25s ease;
    width:280px; min-width:280px;
  }
  .sidebar.open { transform:translateX(0); }

  .chat-area { width:100%; }

  .chat-header { padding:0 12px; }
  .messages { padding:12px; }
  .chat-input-area { padding:10px 12px 16px; }
  .input-hint { display:none; }
}

