.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* 侧栏 */
.sidebar {
  width: var(--sidebar-width);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 15.5px;
  color: var(--text);
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(135deg, #2f6bff, #7b5cff);
  box-shadow: 0 6px 16px rgba(47, 107, 255, 0.32);
}

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

.sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 12px 8px;
}

.new-chat {
  margin: 4px 6px 12px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: 0.15s ease;
}

.new-chat:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.conv-search {
  margin: 0 6px 10px;
  position: relative;
}

.conv-search .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.conv-search input {
  width: 100%;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--panel-2);
  padding: 0 10px 0 32px;
  font-size: 13px;
  outline: none;
  color: var(--text);
}

.conv-search input:focus {
  border-color: var(--border-strong);
  background: var(--panel);
}

.conv-groups {
  flex: 1;
  overflow-y: auto;
  padding: 2px 2px 8px;
}

.conv-group-title {
  padding: 10px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.conv-item {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 34px 9px 10px;
  border-radius: 9px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.12s ease;
}

.conv-item:hover {
  background: var(--panel-2);
}

.conv-item.active {
  background: var(--accent-soft);
  color: var(--text);
}

.conv-item .title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .preview {
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .pin-dot {
  position: absolute;
  right: 10px;
  top: 12px;
  color: var(--accent);
  width: 14px;
  height: 14px;
}

.conv-actions {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 1px;
  background: var(--panel-2);
  border-radius: 7px;
  padding: 1px;
}

.conv-item:hover .conv-actions {
  display: flex;
}

.conv-item:hover .pin-dot {
  display: none;
}

.conv-action {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
}

.conv-action:hover {
  background: var(--panel);
  color: var(--text);
}

.conv-action.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.conv-action .icon {
  width: 14px;
  height: 14px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-meta .name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta .role {
  font-size: 11.5px;
  color: var(--muted);
}

.user-actions {
  display: flex;
  gap: 2px;
}

.user-actions .btn-icon {
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.user-actions .btn-icon:hover {
  color: var(--text);
}

/* 主区 */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(8px);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.topbar-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-actions .btn-icon {
  width: 34px;
  height: 34px;
  color: var(--muted);
}

.topbar-actions .btn-icon:hover {
  color: var(--text);
  background: var(--panel-2);
}

.mobile-menu {
  display: none;
}

.view-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view-admin {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.view-chat[hidden],
.view-admin[hidden] {
  display: none;
}

.conv-text {
  min-width: 0;
}

.conv-empty {
  padding: 18px 10px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* 移动端 */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(10, 14, 20, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 0 14px;
  }
}

@media (max-width: 600px) {
  .topbar-badge.desktop-only {
    display: none;
  }
}
