:root {
  font-family: "Segoe UI", Inter, Avenir, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #e8ecf1;
  background-color: #12151c;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.muted {
  color: #7d879c;
  font-size: 0.82rem;
  margin: 0;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 8px;
  background: #0a0d13;
  border-right: 1px solid #1e2431;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
  background: #121824;
  border: 1px solid #1c2433;
  border-radius: 12px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #161d2b;
  border-bottom: 1px solid #1f2838;
}

.panel-head h2 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7b8699;
  margin: 0;
}

.badge {
  background: #1d2534;
  color: #9aa6bd;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.75rem;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #2a3346;
  background: #171d29;
  color: #cfd6e4;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #202a3b;
}

.list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #c3cbda;
  cursor: pointer;
  font-size: 0.9rem;
}

.item:hover {
  background: #1a2130;
}

.item.active {
  background: #24304a;
  color: #fff;
}

.item.self {
  cursor: default;
  color: #8b96aa;
}

.item.self:hover {
  background: transparent;
}

.item .count {
  font-size: 0.75rem;
  color: #7d879c;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid #1e2431;
  background: #141924;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
}

.conn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #9aa6bd;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6b7280;
}

.dot.online {
  background: #35c26b;
  box-shadow: 0 0 8px #35c26b88;
}

.dot.connecting {
  background: #e0b341;
}

.dot.offline {
  background: #d9534f;
}

.ghost-btn {
  border: 1px solid #2a3346;
  background: #171d29;
  color: #cfd6e4;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.82rem;
}

.ghost-btn:hover {
  background: #202a3b;
  border-color: #3f6bd0;
}

.mic-meter {
  display: inline-block;
  width: 70px;
  height: 8px;
  border-radius: 999px;
  background: #1d2534;
  overflow: hidden;
  vertical-align: middle;
}

.mic-level {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #35c26b, #e0b341);
  transition: width 0.08s linear;
}

.hidden {
  display: none !important;
}

.call-btn {
  border: none;
  background: transparent;
  color: #9aa6bd;
  font-size: 0.95rem;
  padding: 2px 4px;
  border-radius: 6px;
  flex: none;
}

.call-btn:hover {
  background: #24304a;
}

.call-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1b2230;
  border: 1px solid #2f3b52;
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 15;
}

.call-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #35c26b;
  box-shadow: 0 0 8px #35c26b88;
  animation: call-pulse 1.4s infinite;
}

@keyframes call-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.call-peer {
  font-weight: 600;
}

.call-status,
.call-timer {
  color: #9aa6bd;
  font-size: 0.82rem;
}

.call-timer {
  font-family: Consolas, "Courier New", monospace;
}

.danger-btn {
  border: none;
  border-radius: 8px;
  background: #c0392b;
  color: #fff;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.danger-btn:hover {
  background: #d9534f;
}

.incoming-card {
  width: 300px;
  background: #161c28;
  border: 1px solid #24304a;
  border-radius: 16px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.incoming-title {
  margin: 0;
  color: #9aa6bd;
  font-size: 0.85rem;
}

.incoming-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.incoming-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

.incoming-actions button {
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.95rem;
}

#call-accept {
  background: #35c26b;
  color: #08210f;
}

#call-accept:hover {
  background: #43d47b;
}

.messages {
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty {
  margin: auto;
  color: #5c6578;
}

.msg {
  max-width: 72%;
  align-self: flex-start;
  background: #1b2230;
  border: 1px solid #232c3d;
  border-radius: 12px;
  padding: 8px 12px;
}

.msg.mine {
  align-self: flex-end;
  background: #23406e;
  border-color: #2c4f88;
}

.msg.dm {
  border-style: dashed;
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.msg-who {
  font-size: 0.8rem;
  font-weight: 600;
  color: #9fb6e0;
}

.msg.mine .msg-who {
  color: #cfe0ff;
}

.msg-time {
  font-size: 0.7rem;
  color: #6d7789;
}

.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-status {
  margin-top: 3px;
  text-align: right;
  font-size: 0.68rem;
  color: #8fa2c4;
}

.msg.mine .msg-status {
  color: #b8cdf0;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid #1e2431;
  background: #141924;
}

.composer input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid #2a3346;
  background: #0f141d;
  color: #e8ecf1;
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
}

.composer input:focus {
  border-color: #3f6bd0;
}

.composer button {
  border: none;
  border-radius: 10px;
  padding: 0 22px;
  background: #3f6bd0;
  color: #fff;
  font-size: 0.95rem;
}

.composer button:hover {
  background: #4c79e0;
}

.composer .attach {
  background: transparent;
  border: 1px solid #2a3346;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 1.05rem;
  color: #9aa6bd;
}

.composer .attach:hover {
  background: #1b2230;
  color: #dfe6f2;
}

.msg-image {
  display: block;
  margin-top: 6px;
  max-width: 280px;
  max-height: 280px;
  border-radius: 8px;
}

.msg-file {
  display: inline-block;
  margin-top: 6px;
  color: #9fc0ff;
  text-decoration: none;
  word-break: break-all;
}

.msg-file:hover {
  text-decoration: underline;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 15, 0.86);
  backdrop-filter: blur(4px);
  z-index: 40;
}

.login-card {
  width: 340px;
  background: #161c28;
  border: 1px solid #24304a;
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
  margin: 0;
  font-size: 1.3rem;
}

.login-card input {
  border-radius: 10px;
  border: 1px solid #2a3346;
  background: #0f141d;
  color: #e8ecf1;
  padding: 11px 14px;
  font-size: 1rem;
  outline: none;
}

.login-card input:focus {
  border-color: #3f6bd0;
}

.login-card button {
  border: none;
  border-radius: 10px;
  padding: 11px;
  background: #3f6bd0;
  color: #fff;
  font-size: 1rem;
}

.login-card button:hover {
  background: #4c79e0;
}

.error {
  color: #ff8080;
  min-height: 1.2em;
  margin: 0;
  font-size: 0.85rem;
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: #222b3d;
  border: 1px solid #33405c;
  color: #dfe6f2;
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 300px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 10px 2px;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-me {
  font-size: 0.78rem;
  color: #7d879c;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.brand-me:hover {
  color: #cfd6e4;
}

.item-main {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-side {
  display: flex;
  align-items: center;
  flex: none;
}

.item .count {
  margin-left: 6px;
}

.lock {
  font-size: 0.72rem;
}

.badge-unread {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 0.72rem;
  line-height: 18px;
  text-align: center;
}

.bell {
  position: relative;
  padding: 5px 10px;
  font-size: 1rem;
}

.bell .badge-unread {
  position: absolute;
  top: -6px;
  right: -6px;
}

.system-panel {
  position: fixed;
  top: 60px;
  right: 14px;
  width: 300px;
  max-height: 60vh;
  background: #161c28;
  border: 1px solid #24304a;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.system-head {
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #9aa6bd;
  background: #161d2b;
  border-bottom: 1px solid #1f2838;
}

.system-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}

.system-list li {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #c3cbda;
}

.system-list li + li {
  border-top: 1px solid #1a2130;
}

.system-time {
  display: block;
  font-size: 0.7rem;
  color: #6d7789;
  margin-top: 3px;
}

.system-empty {
  padding: 14px;
  color: #5c6578;
  font-size: 0.82rem;
}

.empty-tip {
  padding: 8px 14px;
  color: #5c6578;
  font-size: 0.82rem;
}

.view-head {
  flex: 1;
  min-width: 0;
}

.menu-btn {
  display: none;
  font-size: 1.1rem;
  padding: 4px 10px;
}

.modal-card {
  width: 320px;
  max-width: 90vw;
  background: #161c28;
  border: 1px solid #24304a;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-card h3 {
  margin: 0;
}

.modal-card input {
  border-radius: 10px;
  border: 1px solid #2a3346;
  background: #0f141d;
  color: #e8ecf1;
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
}

.modal-card input:focus {
  border-color: #3f6bd0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.modal-actions button[type="submit"] {
  border: none;
  border-radius: 10px;
  padding: 9px 20px;
  background: #3f6bd0;
  color: #fff;
}

.modal-actions button[type="submit"]:hover {
  background: #4c79e0;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 36;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
  }

  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 1rem;
  }

  .conn-text {
    display: none;
  }

  .messages {
    padding: 14px;
  }

  .msg {
    max-width: 88%;
  }

  .composer {
    padding: 10px 12px;
    gap: 8px;
  }

  .composer input {
    padding: 10px 12px;
  }

  .send-btn {
    padding: 0 14px;
  }

  .msg-image {
    max-width: 70vw;
    max-height: 320px;
  }

  .toasts {
    left: 12px;
    right: 12px;
    bottom: 84px;
  }

  .toast {
    max-width: none;
  }

  .call-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
  }

  .system-panel {
    left: 12px;
    right: 12px;
    width: auto;
  }
}

