:root {
  --bg-deep: #0d0f14;
  --panel: #151822;
  --panel-alt: #1b1f2b;
  --border: #262b3a;
  --text: #e7e9ee;
  --muted: #8891a7;
  --accent: #3ddc97;
  --accent-dim: #2a9d6f;
  --accent-alt: #5b8def;
  --danger: #e0605d;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 700;
  font-size: 20px;
  background: rgba(61, 220, 151, 0.08);
  border: 1px solid var(--accent-dim);
  padding: 2px 8px;
  border-radius: 6px;
  animation: blink-cursor 2.4s steps(1) infinite;
}
@keyframes blink-cursor {
  0%, 60% { opacity: 1; }
  80% { opacity: 0.35; }
  100% { opacity: 1; }
}
.brand-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.02em;
}

/* ---------- Auth screen ---------- */
.auth-screen {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(61,220,151,0.06), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(91,141,239,0.06), transparent 40%),
    var(--bg-deep);
}
.auth-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
}
.auth-tagline {
  color: var(--muted);
  font-size: 13.5px;
  margin: 14px 0 24px;
  line-height: 1.5;
}
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.auth-tab {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px 0; font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none;
}
.auth-form input:focus { border-color: var(--accent-dim); }
.btn-primary {
  margin-top: 6px;
  background: var(--accent); color: #06120c; border: none;
  font-weight: 700; font-size: 14px; padding: 11px; border-radius: 8px;
}
.btn-primary:hover { background: #4ee8a7; }
.auth-error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 0; }

/* ---------- App layout ---------- */
.app-screen { display: flex; height: 100%; }
.sidebar {
  width: 240px; background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-section { padding: 14px 12px; border-bottom: 1px solid var(--border); overflow-y: auto; }
.sidebar-section:nth-child(2) { flex: 1; }
.sidebar-section-title {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 6px 8px;
}
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 22px; height: 22px; border-radius: 6px; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-dim); }

.channel-list, .presence-list { list-style: none; margin: 0; padding: 0; }
.channel-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: 6px; color: var(--muted);
  font-size: 14px; font-family: var(--font-mono);
}
.channel-item:hover { background: var(--panel-alt); color: var(--text); }
.channel-item.active { background: rgba(61,220,151,0.1); color: var(--accent); }

.presence-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13.5px; }
.presence-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(61,220,151,0.5);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(61,220,151,0.45); }
  70% { box-shadow: 0 0 0 6px rgba(61,220,151,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); }
}

.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: #06120c;
}
.me-name { font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-header {
  height: 56px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  flex-shrink: 0;
}
.channel-title { font-family: var(--font-mono); font-size: 15px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
.hash { color: var(--muted); }
.channel-topic { font-family: var(--font-body); font-weight: 400; font-size: 12.5px; color: var(--muted); }
.btn-call {
  background: var(--panel-alt); border: 1px solid var(--accent-dim); color: var(--accent);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.btn-call:hover { background: rgba(61,220,151,0.12); }

.messages { flex: 1; overflow-y: auto; padding: 18px 24px; }
.msg { display: flex; gap: 12px; padding: 8px 0; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: #06120c;
}
.msg-body { min-width: 0; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.msg-author { font-weight: 600; font-size: 14px; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-text { font-size: 14.5px; line-height: 1.5; word-wrap: break-word; }
.msg-file {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-alt); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 8px; font-size: 13px; color: var(--accent-alt);
  text-decoration: none;
}
.msg-file:hover { border-color: var(--accent-alt); }

.typing-indicator { min-height: 20px; padding: 0 24px; font-size: 12px; color: var(--muted); font-style: italic; }

.message-form {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.message-form input[type="text"] {
  flex: 1; background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 11px 14px; font-size: 14px; outline: none;
}
.message-form input[type="text"]:focus { border-color: var(--accent-dim); }
.btn-send {
  background: var(--accent); color: #06120c; border: none; font-weight: 700;
  padding: 10px 18px; border-radius: 8px; font-size: 13.5px;
}

/* ---------- Video stage ---------- */
.video-stage {
  border-bottom: 1px solid var(--border);
  background: #090a0e;
  padding: 16px;
}
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px; max-height: 320px;
}
.video-tile {
  position: relative; background: #000; border-radius: 10px; overflow: hidden;
  aspect-ratio: 16/9; border: 1px solid var(--border);
}
.video-tile video { width: 100%; height: 100%; object-fit: cover; }
.video-tile-label {
  position: absolute; bottom: 6px; left: 8px; font-size: 11.5px;
  background: rgba(0,0,0,0.55); padding: 2px 8px; border-radius: 5px;
  font-family: var(--font-mono);
}
.video-toolbar { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.tool-btn {
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
}
.tool-btn:hover { border-color: var(--accent-dim); }
.tool-btn-danger { border-color: var(--danger); color: var(--danger); }
.tool-btn-danger:hover { background: rgba(224,96,93,0.12); }
.tool-btn.active { background: rgba(61,220,151,0.14); border-color: var(--accent); color: var(--accent); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
  .sidebar { width: 76px; }
  .sidebar-header .brand-name, .sidebar-section-title span:first-child,
  .channel-item span.channel-name-text, .presence-item span, .me-name { display: none; }
}
