/* N Sosyal look: palette sampled from nsosyal.com (dark theme) */
:root {
  --bg: #1b1e26;
  --surface: #232732;
  --surface-2: #252b3c;
  --surface-hover: #2a2f3d;
  --border: #2d3240;
  --border-strong: #40475a;
  --text: #f8fafc;
  --text-2: #c4c6cc;
  --muted: #a7aab3;
  --faint: #555a64;
  --primary: #1890ff;
  --primary-hover: #40a9ff;
  --primary-soft: rgba(50, 75, 255, 0.12);
  --accent: #3b82f6;
  --danger: #f5222d;
  --danger-soft: rgba(245, 34, 45, 0.12);
  --success: #52c41a;
  --warning: #faad14;
  --logo-gradient: linear-gradient(135deg, #22d3ee 0%, #3b82f6 55%, #324bff 100%);
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; } /* the page never shifts sideways when a scrollbar appears */
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-hover); text-decoration: none; }
button { font-family: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--primary-hover); outline-offset: 2px; }
.person:focus-visible { outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 600px) 350px;
  justify-content: center;
  gap: 0 24px;
  min-height: 100vh;
  padding: 0 16px;
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 8px;
}
.logo { display: inline-flex; flex-direction: column; align-items: center; width: 56px; margin: 0 0 18px 8px; }
.logo svg { width: 44px; height: 44px; }
.logo small { font-size: 9px; letter-spacing: 2px; color: var(--muted); margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; border-radius: 999px;
  color: var(--text); font-size: 18px; font-weight: 500;
  cursor: pointer; background: none; border: 0; text-align: left;
}
.nav-item:hover { background: var(--surface); }
.nav-item.active { font-weight: 700; }
.nav-item svg { width: 24px; height: 24px; flex: none; }
.nav-item .badge {
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px; margin-left: -8px;
}
.sidebar .btn-primary { margin-top: 14px; padding: 14px; font-size: 16px; }
.me-card {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 999px; cursor: pointer;
}
.me-card:hover { background: var(--surface); }
.me-card .names { min-width: 0; flex: 1; }
.me-card .names div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Middle column: content on top, the room controls stuck to the bottom of the viewport */
.col {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh; min-width: 0;
  display: flex; flex-direction: column;
}
.main { flex: 1; min-width: 0; }
.aside { padding: 16px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }

/* ---------------------------------------------------------------- header + tabs */
.header {
  position: sticky; top: 0; z-index: 5;
  background: rgba(27, 30, 38, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-title { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 0 16px; font-size: 20px; font-weight: 700; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 999px; border: 0; background: none; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn svg { width: 20px; height: 20px; }
.tabs { display: flex; }
.tab {
  flex: 1; background: none; border: 0; color: var(--muted); font-size: 15px; font-weight: 500;
  padding: 16px 0 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.tab::after { content: ""; height: 4px; width: 56px; border-radius: 999px; background: transparent; }
.tab:hover { background: var(--surface); }
.tab.active { color: var(--primary); font-weight: 700; }
.tab.active::after { background: var(--primary); }

.chips { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.chip {
  flex: none; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip:hover { background: var(--surface); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------------------------------------------------------------- buttons */
.btn {
  border: 0; border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--surface-hover); }
.btn-danger { background: var(--danger-soft); color: #ff7875; }
.btn-danger:hover:not(:disabled) { background: rgba(245, 34, 45, 0.2); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- avatars */
.avatar {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 15px;
  position: relative;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; border: 2px solid var(--surface); }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.verified { width: 16px; height: 16px; color: var(--primary); vertical-align: -3px; }
.name { font-weight: 700; }
.handle { color: var(--muted); }

/* ---------------------------------------------------------------- space cards */
.feed-empty { padding: 48px 32px; text-align: center; color: var(--muted); }
.feed-empty h3 { color: var(--text); font-size: 22px; margin: 0 0 8px; }
.space-card {
  margin: 12px 16px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, #2b3a8c 0%, #1f4fd1 45%, #1890ff 100%);
  cursor: pointer; position: relative; overflow: hidden;
  transition: box-shadow .12s, border-color .12s;
}
.space-card:hover { box-shadow: 0 8px 24px rgba(24, 144, 255, .18); }
.space-card.scheduled { background: var(--surface); border: 1px solid var(--border); }
.space-card .live-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
}
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.space-card h3 { margin: 10px 0 12px; font-size: 20px; line-height: 1.25; }
.space-card .meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,.85); }
.space-card.scheduled .meta { color: var(--muted); }
.space-card .topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.space-card .topic { background: rgba(255,255,255,.16); padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.space-card.scheduled .topic { background: var(--primary-soft); color: var(--primary-hover); }
.space-card .here { margin-top: 10px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.space-card .footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ---------------------------------------------------------------- aside widgets */
.widget { background: var(--surface); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.widget h4 { margin: 0; padding: 14px 16px; font-size: 19px; font-weight: 800; }
.widget-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.widget-row:hover { background: var(--surface-hover); }
.widget-row .grow { flex: 1; min-width: 0; }
.widget-row .sub { color: var(--muted); font-size: 13px; }
.widget .empty { padding: 4px 16px 16px; color: var(--muted); font-size: 14px; }
.search {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 999px;
  padding: 10px 16px; margin-bottom: 16px; color: var(--muted); border: 1px solid transparent;
}
.search:focus-within { border-color: var(--primary); }
.search input { background: none; border: 0; outline: 0; color: var(--text); flex: 1; font-size: 15px; font-family: inherit; }

/* ---------------------------------------------------------------- room */
.room { padding: 0 0 16px; }
.room-head { padding: 16px; border-bottom: 1px solid var(--border); }
.room-head .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-head h2 { margin: 8px 0 6px; font-size: 22px; line-height: 1.25; }
.room-head .live-pill { color: var(--primary-hover); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.room-head .live-dot { background: var(--primary-hover); }
.room-head .sub { color: var(--muted); font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.rec-badge { color: #ff7875; font-weight: 600; }

.section-title { padding: 16px 16px 4px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: flex; justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 8px; padding: 12px 16px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer; position: relative; border-radius: 12px; padding: 6px 2px; }
.person:hover { background: var(--surface); }
.person .avatar { transition: box-shadow .15s; }
.person.speaking .avatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--primary); }
.person .pname { font-size: 13px; font-weight: 600; max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .role { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.person .role.host { color: var(--primary-hover); }
.person .mic-state {
  position: absolute; top: 44px; right: calc(50% - 34px);
  width: 22px; height: 22px; border-radius: 999px; background: var(--surface-2);
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.person .mic-state svg { width: 12px; height: 12px; }
.person .mic-state.off { color: var(--danger); }
.person .hand { position: absolute; top: 0; right: calc(50% - 36px); font-size: 16px; }

/* Sits in the middle column, so it lines up with the content by construction */
#dock-slot { position: sticky; bottom: 0; z-index: 20; }
.dock {
  background: rgba(35, 39, 50, 0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; min-height: 76px;
}
.dock .grow { flex: 1; min-width: 0; }
.dock-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock .round {
  width: 48px; height: 48px; border-radius: 999px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text);
}
.dock .round { flex: none; }
.dock .round:hover { background: var(--surface-hover); }
.dock .round.on { background: var(--primary); color: #fff; }
.dock .round.muted { color: var(--danger); }
.dock .round svg { width: 22px; height: 22px; }
.dock .status { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- chat */
.chat { display: flex; flex-direction: column; }
.chat[hidden] { display: none; }
/* Inline under the room (not a pop-up), collapsed until the viewer opens it */
.room-chat {
  margin: 0 16px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
#aside-chat .room-chat { margin: 16px 16px 0; }
#aside-chat .chat-list { max-height: calc(100vh - 320px); min-height: 200px; }
.delay-chip { background: var(--primary-soft); color: var(--primary-hover); padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 20px; }
.room-actions { display: flex; gap: 6px; align-items: center; }
body.has-dock .mobile-fab { display: none !important; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 8px 16px; }
.chat-head h4 { margin: 0; font-size: 17px; font-weight: 800; }
.chat-head-actions { display: flex; align-items: center; gap: 6px; }
.chat-list { display: flex; flex-direction: column; gap: 2px; max-height: min(420px, 50vh); min-height: 120px; overflow-y: auto; padding: 0 8px 8px; }
.dock .round { position: relative; }
.dock-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface);
}
.chat-empty, .chat-dropped { color: var(--muted); font-size: 13px; padding: 12px 8px; text-align: center; }
.chat-dropped { padding: 4px 8px; font-style: italic; }
.chat-msg { display: flex; gap: 10px; padding: 6px 8px; border-radius: 10px; position: relative; }
.chat-msg:hover { background: var(--surface-hover); }
.chat-body { min-width: 0; flex: 1; }
.chat-meta { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.chat-meta .name { font-size: 13px; }
.chat-time { color: var(--muted); font-size: 12px; margin-left: auto; }
.chat-text { font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-role { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-hover); }
.chat-role.host { background: var(--primary); color: #fff; }
.chat-role.speaker { background: rgba(82, 196, 26, .15); color: #73d13d; }
.chat-actions { display: none; position: absolute; right: 6px; top: 4px; background: var(--surface-2); border-radius: 999px; }
.chat-msg:hover .chat-actions, .chat-msg:focus-within .chat-actions { display: flex; }
.chat-actions .icon-btn { width: 28px; height: 28px; font-size: 13px; }
.chat-form { display: flex; gap: 8px; padding: 8px 12px 4px; border-top: 1px solid var(--border); }
.chat-form .input { padding: 9px 12px; font-size: 14px; border-radius: 999px; }
.chat-form .input:disabled { opacity: .55; }
.chat-status { font-size: 12px; color: var(--muted); padding: 2px 16px 12px; min-height: 18px; }

/* ---------------------------------------------------------------- mod panel */
.panel-list .widget-row { align-items: center; }
.panel-list .actions { display: flex; gap: 6px; }
.count-pill { background: var(--primary); color: #fff; font-size: 12px; border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }

/* ---------------------------------------------------------------- menus, modals, toasts */
.menu {
  position: fixed; z-index: 60; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); min-width: 220px; padding: 6px 0;
}
.menu button {
  display: flex; width: 100%; gap: 10px; align-items: center; background: none; border: 0;
  color: var(--text); padding: 11px 16px; font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--surface); }
.menu button.danger { color: #ff7875; }
.menu .menu-head { padding: 10px 16px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; gap: 10px; align-items: center; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(91, 112, 131, 0.4); z-index: 50;
  display: grid; place-items: start center; padding-top: 6vh;
}
.modal { width: min(600px, calc(100% - 32px)); background: var(--bg); border-radius: var(--radius); padding: 0 0 20px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; gap: 16px; padding: 12px 16px; font-weight: 700; font-size: 18px; }
.modal-body { padding: 4px 24px; display: flex; flex-direction: column; gap: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; background: transparent; border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--text); padding: 12px; font-size: 16px; font-family: inherit; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
select.input option { background: var(--surface); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { width: 42px; height: 24px; accent-color: var(--primary); }
.hint { font-size: 13px; color: var(--muted); }
.char-count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

.toasts { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,.35); animation: fade .2s ease-out; }
.toast.error { background: #a8071a; }
.toast.action { background: var(--surface-2); border: 1px solid var(--border-strong); display: flex; align-items: center; gap: 12px; }
@keyframes fade { from { opacity: 0; } }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
@media (max-width: 900px) {
  .login { grid-template-columns: minmax(0, 1fr); align-content: center; }
  .login .brand svg { width: 120px; height: 120px; }
  .login h1 { font-size: 40px; }
}
.login .brand { display: grid; place-items: center; }
.login .brand svg { width: 280px; height: 280px; filter: drop-shadow(0 10px 60px rgba(59,130,246,.35)); }
.login .panel { padding: 32px; max-width: 520px; }
.login h1 { font-size: 56px; line-height: 1.05; margin: 0 0 32px; font-weight: 800; letter-spacing: -1px; }
.login h2 { font-size: 26px; margin: 0 0 16px; }
.user-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; max-height: 50vh; overflow-y: auto; }
.user-pick button {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); cursor: pointer; text-align: left;
}
.user-pick button:hover { border-color: var(--primary); }
.user-pick .n { font-weight: 600; font-size: 14px; }
.user-pick .h { font-size: 12px; color: var(--muted); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 999px; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 88px minmax(0, 600px); }
  .aside { display: none; }
  .nav-item span, .sidebar .btn-primary span, .me-card .names { display: none; }
  .sidebar .btn-primary { width: 52px; height: 52px; padding: 0; }
}
@media (max-width: 640px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .sidebar { display: none; }
  .main { border: 0; }
  .login { grid-template-columns: 1fr; }
  .login .brand svg { width: 120px; height: 120px; }
  .login h1 { font-size: 36px; }
  .mobile-fab { display: grid !important; }
  .icon-btn { width: 44px; height: 44px; }
  .dock { padding: 10px 12px; gap: 8px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); padding: 12px; }
  .col { border: 0; }
}
.mobile-fab {
  display: none; position: fixed; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 999px;
  background: var(--primary); color: #fff; border: 0; place-items: center; z-index: 30; box-shadow: 0 6px 20px rgba(24,144,255,.4);
}
.mobile-fab svg { width: 24px; height: 24px; }
