.custom-server-dialog::part(panel) {
  width: min(860px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  border-radius: 28px;
  border: 1px solid rgba(var(--mdui-color-outline-variant), 0.45);
  background:
    linear-gradient(180deg, rgba(var(--mdui-color-surface), 0.96), rgba(var(--mdui-color-surface-container-low), 0.94));
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.custom-server-dialog::part(headline) {
  text-align: center;
}

.custom-server-dialog::part(body) {
  width: 100%;
  box-sizing: border-box;
}

.custom-server-dialog::part(description) {
  display: block;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  text-align: initial;
}

.custom-server-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 700px;
  margin-inline: auto;
  align-items: center;
  padding-top: 8px;
}

.custom-server-sidepanel {
  display: block;
  width: 100%;
  margin-inline: auto;
  padding: 0;
  border-radius: 22px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.custom-server-category-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.custom-server-category-card {
  display: flex;
  align-items: center;
  justify-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 0 18px;
  border: 1px solid rgba(var(--mdui-color-outline-variant), 0.5);
  border-radius: 16px;
  background: rgba(var(--mdui-color-surface), 0.5);
  color: inherit;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.custom-server-category-card:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(var(--mdui-color-primary), 0.32);
  background: rgba(var(--mdui-color-surface), 0.72);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.custom-server-category-card:disabled {
  cursor: default;
  opacity: 0.72;
}

.custom-server-category-card.active {
  border-color: rgba(var(--mdui-color-primary), 0.4);
  background: rgba(var(--mdui-color-primary-container), 0.82);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.custom-server-category-text {
  min-width: 0;
}

.custom-server-category-title {
  font-size: 15px;
  font-weight: 700;
  color: rgb(var(--mdui-color-on-surface));
}

.custom-server-form {
  display: grid;
  align-content: start;
  gap: 14px;
  width: 100%;
  margin-inline: auto;
  min-width: 0;
  padding: 4px 2px 2px;
}

.custom-server-endpoint-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 14px;
}

.custom-server-host-field,
.custom-server-type-field,
.custom-server-port-field {
  width: 100%;
}

.custom-server-type-field::part(menu) {
  max-height: min(360px, calc(100vh - 48px));
  overflow-y: auto;
}

.custom-server-form-error {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(var(--mdui-color-error-container), 0.9);
  color: rgb(var(--mdui-color-on-error-container));
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 680px) {
  .custom-server-dialog::part(panel) {
    width: min(100vw - 24px, 640px);
    max-width: calc(100vw - 24px);
  }

  .custom-server-category-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .custom-server-category-list {
    grid-template-columns: 1fr;
  }

  .custom-server-endpoint-row {
    grid-template-columns: 1fr;
  }
}
